Feature Flags
Feature flags allow us to enable and disable certain features at build time, helping us to produce specific builds for specific environments.
Workflow
All feature flags are located in suite-common/suite-config/src/features.ts. To add a new flag, start by doing the following:
- Add your flag to the
FLAGSconstant and set its default value. When naming your flag, bear in mind the following conventions:- Always explain what the flag is about using a comment next to it.
- The name of the flag should always be in capitals.
- The name of the flag should never contain the world
enableordisablebecause the name should always towards an enabled state. Its value should reflect whether the feature is enabled or not. - The name of the flag should never contain the word
flagbecause it's inferred.
- (optional) You can override the flag for each environment (web, desktop) using their specific constants.
- Use the
isFeatureFlagEnabledfunction from@suite-utils/featuresto check if the flag is enabled or not. - Wrap the code you wish to control in a condition checking for your flag being enabled or not.
Example
import { isFeatureFlagEnabled } from '@suite-utils/features';
const main = () => {
alwaysRunning();
if (isFeatureFlagEnabled('LABELING')) {
myLabelingFeature();
}
};
Future evolutions
- Control feature flags at runtime.