Skip to content

Features

A. Malthe Henriksen edited this page Jul 9, 2024 · 6 revisions

What are features?

Features are settings located in features.json. These settings are used by build variants to check for feature toggles and certain variables such as the document.title text in the application.

Adding a feature

To add a feature, create a new entry into features.json (including all build variants). This means we add a new entry into all variants of features.json in folders ./src/__viteBuildVariants__/[variant].

Then to be able to reference the feature in the Feature enum in file FeatureToggles.ts. The name should string variant should reflect the name in features.json.

Using features

We can use features specified in features.json by using the utility file FeatureToggles.ts

  document.title = getFeature(Feature.TITLE);
  // Or
  console.log(hasFeature(Feature.KNN_MODEL);

Feature flags

Feature flags are strings that can be placed in the browser's cookies to change how the system behaves. To enable features that are behind feature flags, create a cookie on the domain you wish to test on, named fflags. Then create a comma-separated list of the features you wish to enable.

Feature flags are used for in-development feature testing in production. This means it is subject to frequent change and undefined behaviours.

List of feature flags

  • FEATURE-TOGGLE-ALWAYS-TRUE - Forcefully set features in features.json to true at runtime. Features toggles in the features.json, such as KNN_MODEL will now always be set to true, despite it's configuration value.

example value of fflags FEATURE-TOGGLE-ALWAYS-TRUE

Setting fflags

Using chromium-based browsers,

  • Open the developer tools
  • Navigate to Application tab

image

  • Open the cookies expandable menu under storage

image

  • Create a cookie named fflags
  • Assign the feature flag values you want, comma-separated

image

  • (optionally) It is recommended to set an expiration date as it will default to the current session.
Clone this wiki locally