Files
trezor-suite/docs/features/feature-flags.md
Jan Bouchner 23a8ae6a09 chore: suite utils (wallet and few others from suite) and types to common package (#5874)
* chore(wallet-utils): Moving wallet utils to common package

* chore(suite-common) Device types moved to common package

* chore(suite-common): Moving tests from suite to common package

* chore(test): wallet utils tests moved to common suite package

* chore: replace message system types from suite-types from common package

* chore: import global JestMocks in suite and wallet-utils

* chore: decrease jest global coverage thresholds for suite tests

* chore: fix import for suite-config

* chore: update refactored build paths and pckg for web and web-landing
2022-08-01 19:08:06 +02:00

1.4 KiB

Feature Flags

Feature flags allow us to enable and disable certain features at build time, helping us to produce specific builds for specific environments.

Work flow

All feature flags are located in suite-common/suite-config/src/features.ts. To add a new flag, start by doing the following:

  1. Add your flag to the FLAGS constant and set its defautl value. When naming your flag, bear in mind the following conventions:
    1. Always explain what the flag is about using a comment next to it.
    2. The name of the flag should always be in capitals.
    3. The name of the flag should never contain the world enable or disable because the name should always towards an enabled state. Its value should reflect whether the feature is enabled or not.
    4. The name of the flag should never contain the word flag because it's inferred.
  2. (optional) You can override the flag for each environment (web, desktop, landing) using their specific constants.
  3. Use the isEnabled function from @suite-utils/features to check if the flag is enabled or not.
  4. Wrap the code you wish to control in a condition checking for your flag being enabled or not.

Example

import { isEnabled } from '@suite-utils/features';

const main = () => {
    alwaysRunning();

    if (isEnabled('LABELING')) {
        myLabelingFeature();
    }
};

Future evolutions

  • Control feature flags at runtime.