Featurevisor

Advanced

Environments

Featurevisor is highly configurable and allows us to have any number of custom environments (like development, staging, and production). We can also choose to have no environments at all.

There are 3 ways to to configure environments in Featurevisor:

  • environment specific data in individual self-contained feature definitions
  • feature definitions + separate environment specific files for rules, force, and/or expose
  • no environments at all

Custom environments

It is recommended that we have at least staging and production environments in our project.

Adding environments

We can add more environments as needed:

featurevisor.config.js
module.exports = {
tags: [
'web',
'mobile'
],
environments: [
'staging',
'production',
// add more environments here...
],
}

Above configuration will help us define our features and their rules against each environment as follows:

Environment specific rules

features/my_feature.yml
description: My feature
tags:
- web
bucketBy: userId
# rules per each environment
rules:
staging:
- key: everyone
segments: '*'
percentage: 100
production:
- key: everyone
segments: '*'
percentage: 0

See also force and expose for more information.

Generated datafiles

And the datafiles will be built per each environment in datafiles directory:

Command
$ tree datafiles
.
├── staging/
│ ├── featurevisor-tag-web.json
│ └── featurevisor-tag-mobile.json
├── production/
│ ├── featurevisor-tag-web.json
│ └── featurevisor-tag-mobile.json

Split by environment

If we prefer to keep environment specific rollout settings in separate files, enable splitByEnvironment in featurevisor.config.js:

featurevisor.config.js
module.exports = {
environments: ['staging', 'production'],
splitByEnvironment: true,
}

Directory structure

Directory structure
features/
└── my_feature.yml # base feature definition
environments/
├── staging/
│ └── my_feature.yml # environment specific files
└── production/
└── my_feature.yml

Base feature definition

Then our base feature keeps common feature-level data only:

features/my_feature.yml
description: My feature
tags:
- web
bucketBy: userId
# variablesSchema: ...
# variations: ...

We can also define variables and variations in the base feature definition here.

Environment specific files

And each environment file defines rules, force, and/or expose data directly:

environments/staging/my_feature.yml
rules:
- key: everyone
segments: '*'
percentage: 100
environments/production/my_feature.yml
rules:
- key: everyone
segments: '*'
percentage: 0

This kind of splitting is useful when we have a lot of environment specific data and we want to:

  • keep the base feature definition clean and simple
  • maintain different levels of access control and ownership for different environments (like via CODEOWNERS file for example)

No environments

We can also choose to have no environments at all:

featurevisor.config.js
module.exports = {
tags: [
'web',
'mobile'
],
environments: false,
}

This will allow us to define our rollout rules directly without needing any environment specific keys:

features/my_feature.yml
description: My feature
tags:
- web
bucketBy: userId
# rules without needing environment specific keys
rules:
- key: everyone
segments: '*'
percentage: 100

The datafiles will be built without any environment:

$ tree datafiles
.
├── featurevisor-tag-web.json
├── featurevisor-tag-mobile.json
Previous
CLI usage
Next
Tags