Featurevisor

Use cases

Environment variables and remote configuration

Environment variables configure a process when it starts. Featurevisor global variables are typed settings that your application evaluates for each context, and they change when it loads a new datafile. This page shows which settings belong where, and how to move one across.

Choose where each setting belongs

SettingTypical home
Database credentials or signing keysYour secret management system
Service address needed before configuration can loadDeployment or process configuration
Support email that varies by countryA Featurevisor global variable
Payment methods selected for a customer contextA Featurevisor global variable
A label that changes with an experiment variationA variable inside a Featurevisor feature

Anyone can read a datafile sent to a browser or a phone, so keep secrets out of them. A flag does not authorize anything either, so check permissions on your server.

Move one setting at a time

A process setting might currently look like this in Node.js:

const supportEmail = process.env.SUPPORT_EMAIL || '[email protected]'

Define the configuration value in a Featurevisor project:

variables/supportEmail.yml
description: Support email shown in checkout
type: string
defaultValue: [email protected]

After loading a datafile, evaluate it through an instance named f:

const context = {
country: 'nl',
}
const supportEmail =
f.getVariable('supportEmail', context) ??
process.env.SUPPORT_EMAIL ??

The environment variable stays as a fallback while you move over. Once the value is in Featurevisor, overrides can give different users different addresses, which an environment variable cannot.

supportEmail gives Dutch users support-nl@example.com and everyone else support@example.com.

Moving a setting also changes who can change it. An environment variable usually needs whoever deploys the service and a restart. A global variable changes through a reviewed pull request that anyone on the team can open, and reaches running applications with the next datafile.

Understand when values change

Changing the definition, publishing the datafile, loading it in the application and evaluating the setting are separate steps. If your application reads a value once at startup, a new datafile does not change the copy it already holds.

Evaluate where the value is needed, or evaluate again on the SDK's datafile_set event. React's hooks do this for you.

Previous
Remote configuration