Featurevisor

Types of evaluation

Feature variables

Feature variables are key/value pairs owned by a feature and evaluated through Featurevisor SDKs.

This page covers variables defined under a feature's variablesSchema. Featurevisor also supports global variables with their own targeting, requirements, and lifecycle.

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 evaluated 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.

Override keys

Granular variableOverrides inside rules and variations can define a stable key:

features/my_feature.yml
rules:
production:
- key: everyone
segments: '*'
percentage: 100
variableOverrides:
my_variable:
- key: netherlands
conditions:
attribute: country
operator: equals
value: nl
value: Waarde voor Nederland

The key appears as variableOverrideKey in detailed SDK evaluations and lets an individual override participate safely in promotions. Keys remain optional for backwards compatibility, but they are recommended for new definitions. Set requireOverrideKeysInFeatures to true when every feature variable override in the project should require one.

Further overrides

Learn about more advanced use cases of overriding variable values here.

Feature variable override lists remain flat. If a broad match should supply a value that more specific matches refine in stages, use nested global variable overrides.

Usage of SDK

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

your-app/index.js
import { createFeaturevisor } from '@featurevisor/sdk'
// create Featurevisor SDK instance
const f = createFeaturevisor({
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.

Further reading

Previous
Variations