# Create a feature toggle

The process of creating a new feature toggle involves 3 steps:

  1. Declare the new feature toggle in the toggles json schema (opens new window)
  2. Define the default value of the new feature
  3. Wrap your code within the feature toggles

# Feature Toggle json schema

All feature toggles are defined in features json schema (opens new window). The schema includes information about the type, title, description and the owner team of a feature toggle. Here's an example:

{
  "fooFeature": {
    "$id": "/properties/fooFeature",
    "type": "boolean",
    "title": "Foo feature",
    "description": "The foo feature does something super",
    "owner": "Team owner of the feature, (e.g., TEN)"
  },
}

TIP

The features json schema (opens new window) is used at compile time to validate tenant specific features.json files. If a given tenant uses an invalid or deprecated toggle the build will fail preventing the code to land in production.

To create a new feature toggle you have to:

  1. Declare the feature toggle in features json schema (opens new window)
  2. Merge the PR, build MarfeelSchemas (opens new window) and shuttle (opens new window).
  3. The new schema will be accessible through Alexandria (opens new window), Insight will show the new toggle and at compile time it will be available both client and server-side.
  4. Update CLI's dependency (package.json (opens new window) and package-lock.json (opens new window)) to use the last json-lint version published after merging the MarfeelSchemas changes.
  5. Update MarfeelXP's package.json (opens new window) to use the CLI version (opens new window) generated with the recent json-lint changes.

WARNING

For Java SDK and JSP SDK, the feature has to be added as java enum in FeatureToggle.java.

# Default values: features.json

The default values across Marfeel for every feature toggle are defined in the MarfeelTenant features.json file (opens new window). When Tenant specific values are not defined, these default values will be used throughout the intrinsic inheritance mechanism.

This is an example of the MarfeelTenant features.json file:

{
  "features" : {
    "fooFeature" : true,
    "barFeature" : true,
    "bazFreature" : false
  }
}

Adding a default value for your feature toggle in MarfeelTenant features.json file (opens new window) is mandatory.

# Wrap your code

Once you've declared a new feature toggle you can start toggling your code.