Feature Flags, also known as feature toggles, switches, flippers, gates, or conditional features, are software switches that control the visibility of a feature in real-time, without needing to release a new version of the software. They are used to turn on or off a feature, usually in real-time.
For instance, if you are shipping a new feature and you want to control who gets to see your new feature and who shouldn’t, then you use Feature Flags to accomplish that. They are also known by many names such as Feature toggle, switch, flipper, conditional feature, and more.
A feature flag evaluation involves checking a user against the Feature Gate created. This evaluates a predefined set of rules and conditions, ultimately passing if those are met, or failing if not.
For example, a Feature Gate named is_statsig_employee
could have a single rule. The rule should be evaluated as follows: if the condition (as defined by: targetValue “email” matches the contains operator with input “@statsig.com”) passes, then the rule (and hence the gate) will pass 100% of the time and return true. Otherwise, the evaluation fails, and the check returns false.
Feature flags can be categorized into two types:
Permanent Gates: These are expected to live in your codebase for an extended period of time, beyond a feature release, usually for operations or infrastructure control. Common examples include user permissions (e.g. premium features based on subscription level) or circuit breakers/kill switches (e.g. terminating a connection to prevent negative customer impact) or even supporting legacy features in old app versions.
Temporary Gates: All newly created feature gates are marked as Temporary, unless marked otherwise (i.e. Permanent). Therefore, Statsig will not display the phrase Temporary in the console.
A feature can go through different phases throughout its lifecycle - maybe it’s still being tested out by a few users, or only recently fully rolled out to the world, or maybe it’s been tried and true and you no longer need the feature behind a toggle. Statsig makes it easy for your feature gates to reflect the phase your feature is in by using status. A gate can be in one of four statuses:
In Progress: This feature is in the process of being rolled out and tested.
Launched: This feature has been rolled out to everyone
Disabled: This feature has been rolled back from everyone
Archived: This feature is no longer in use
In this modern, continuous deployment style, Feature flags are useful in a variety of scenarios. They can be used for A/B testing, canary releases, kill switches, and more. They allow developers to separate code deployment from feature release, test in production, and do gradual rollouts. They also help in reducing the risk of feature releases and help in easy rollback of features.