Featurevisor

Types of evaluation

Variables

Variables are key/value pairs of data that we evaluate against features using Featurevisor SDKs in our applications.

They are one of the 3 different types of values that we can evaluate against features, including:

Visual explanation

Variables illustration

Default variable values

When defining a feature, we can set a default value for each variable:

features/my_feature.yml
description: My feature here...
tags:
- web
- ios
- android
bucketBy: userId
variablesSchema:
my_variable:
type: string
defaultValue: default value
rules:
production:
- key: nl
segments: netherlands
percentage: 0
- key: de
segments: germany
percentage: 80
- key: us
segments: usa
percentage: 100

Whenever the variable is evaluated, if the feature itself is evaluated as enabled, the default value will be served.

Disabled variable values

The feature itself will not always be evaulated as enabled, given it is being rolled out gradually targeting specific segments.

If we wish to serve a variable value when the feature is disabled, we can make use of the disabledValue property:

features/my_feature.yml
# ...
variablesSchema:
my_variable:
type: string
defaultValue: default value
disabledValue: different value for disabled feature

Overrides at rule level

There are times when we want to override the default value for a variable for a specific rule alone. In that case, we can make use of the variables property at individual rule level:

features/my_feature.yml
# ...
rules:
production:
- key: nl
segments: netherlands
percentage: 0
- key: de
segments: germany
percentage: 80
- key: us
segments: usa
percentage: 100
variables:
my_variable: different value for USA

Overrides at variation level

It's very much possible that we are running experiments, and want to override the variable value depending on the variation that the user is bucketed into.

Variables illustration

We can achieve that by expressing the variations property as follows:

features/my_feature.yml
# ...
variations:
- value: A
weight: 50
# default variable values will be served for this variation
# if no `variables` property is defined here
- value: B
weight: 50
variables:
my_variable: different value for B variation
# ...

This approach basically makes it a multivariate test experiment, which you can read more about here.

Usage of SDK

If we take JavaScript SDK as an example, variable values can be evaluated as follows:

your-app/index.js
import { createInstance } from '@featurevisor/sdk'
// create Featurevisor SDK instance
const f = createInstance({
datafile: { ... }
});
// set some common context to evaluate values against
f.setContext({
userId: '123',
});
const myVariableValue = f.getVariable('my_feature', 'my_variable');
const anotherVariableValue = f.getVariable('another_feature', 'another_variable');

Learn about more advanced use cases for evaluations here.

Previous
Variations