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/orexpose - 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:
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#
description: My featuretags: - webbucketBy: userId# rules per each environmentrules: staging: - key: everyone segments: '*' percentage: 100 production: - key: everyone segments: '*' percentage: 0See also force and expose for more information.
Generated datafiles#
And the datafiles will be built per each environment in datafiles directory:
$ tree datafiles.├── staging/│ ├── featurevisor-tag-web.json│ └── featurevisor-tag-mobile.json├── production/│ ├── featurevisor-tag-web.json│ └── featurevisor-tag-mobile.jsonSplit by environment#
If we prefer to keep environment specific rollout settings in separate files, enable splitByEnvironment in featurevisor.config.js:
module.exports = { environments: ['staging', 'production'], splitByEnvironment: true,}Directory structure#
features/ └── my_feature.yml # base feature definitionenvironments/ ├── staging/ │ └── my_feature.yml # environment specific files └── production/ └── my_feature.ymlBase feature definition#
Then our base feature keeps common feature-level data only:
description: My featuretags: - webbucketBy: 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:
rules: - key: everyone segments: '*' percentage: 100rules: - key: everyone segments: '*' percentage: 0This 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
CODEOWNERSfile for example)
No environments#
We can also choose to have no environments at all:
module.exports = { tags: [ 'web', 'mobile' ], environments: false,}This will allow us to define our rollout rules directly without needing any environment specific keys:
description: My featuretags: - webbucketBy: userId# rules without needing environment specific keysrules: - key: everyone segments: '*' percentage: 100The datafiles will be built without any environment:
$ tree datafiles.├── featurevisor-tag-web.json├── featurevisor-tag-mobile.json
