Docs How to integrate Feature flags

Feature flags

One of the simplest and most powerful use cases of Mantle is the ability to control which features are available to which users. This is done through the use of feature flags, which are managed from Plans page of your app, and can be accessed from the app’s sub-navigation on the left side of the Mantle Admin.

Feature flags can currently be used in a number of ways to control access to your app’s features:

  • All users: by using the default value property on your created app features. This will be the value that is used for all users who are not assigned to a plan, or who are assigned to a plan that does not have a value set for the feature.
  • Users subscribed to plans: based on which plan they are subscribed to, feature availability can be controlled for groups of users. This is done by setting the default value of a feature for a specific plan, which will override the app-level default value for users who are subscribed to that plan.

In the very near future, Mantle will also support the ability to control feature availability using:

  • Beta groups: will enable you to expose groups of users to beta features based on specific controls that you set. This is done by creating a beta group, and then assigning users to it. Beta groups can be used to control access to features in a number of ways, including:
    • Percentage of users: expose a percentage of users to a feature.
    • Specific users: expose specific users to a feature.
    • Specific plans: expose users subscribed to specific plans to a feature.
    • Specific countries: expose users from specific countries to a feature.

Creating a feature

For each feature you want to leverage Mantle for, you will need to add a new feature at the app level. Each feature has a number of properties that can be set, including:

  • Feature name: the name of the feature, which will be used to identify it in the Mantle Admin and to expose to customers in your app
  • Key: the key of the feature, which can be used to reference the feature in the Mantle API and to do things like feature gating
  • Type: the type of the feature, which determines what sort of value the feature will have. Currently, Mantle supports the following feature types:
    • Boolean: a feature is enabled or disabled, such as a feature that enables a new UI
    • Limit: a feature has an upper limit on some entity, such as the number of users or the number of products
    • Usage: a feature has a usage maximum, such as the number of times an SMS has been sent
  • Default value: the default value of the feature, which will be used for all users who are not assigned to a plan, or who are assigned to a plan that does not have a value set for the feature
  • Description: the description of the feature, which can be used to explain the feature to customers in something like a plan table or help popover

Assigning features to plans

Each new plan that you create will automatically inherit all of the features that you have created at the app level and their default values. When dealing with adding/removing plan features, there will be two common scenarios:

  • Existing plans: if a plan already exists, they will automatically inherit the default value of any newly added features, while retaining custom values for any existing plan features. Any plan-level feature can then be modified by editing the plan in the Mantle Admin.
  • New plans: if a plan is created after a feature has been created, it will automatically inherit the default value of all existing app features. Plan features can then be configured during plan creation.