Segments allow you to group your users based on a set of rules, and then control Feature Flags and Remote Config for those groups. You can create a Segment and then override a Feature Flag state or Remote Config value for that segment of users.
Example - Beta Users
You create a new Segment, call it
Beta Users, and define a single rule:
Once the Segment has been defined, you can then associate that Segment with a specific Feature Flag. To do this, edit the Feature Flag that you want to connect our Segment to. You then have the option of connecting a Segment to the Feature. If the Identified user is a member of that Segment, the flag will be overridden.
For all the Feature Flags that relate to Beta features, you can associate this
Beta Users segment with each Flag, and set the Flag value to
true for that Segment. To do this, edit the Feature Flag and select the segment in the 'Segment Overrides' drop down.
At this point, all users who log in with an email address that contains
@bullet-train.io will have all Beta features enabled.
Let's say that you then partner with another company who need access to all Beta features. You can then simply modify the Segment rules:
Now all users who log in with a
@solidstategroup.com email address are automatically included in beta features.
Feature Flag and Remote Config Precedence
Feature Flag states and Remote Config values can be defined in 3 different places:
- The default Flag/Config value itself
- The Segment associated with the Flag/Config
- Overridden at an Identity level
For example, a Feature Flag
Show Paypal Checkout could be set to
false on the Flag itself,
true in the Beta Users segment, and then overridden as
false for a specific Identity.
In order to deal with this situation, there is an order of priority:
- If the Identity has an override value, this is returned ahead of Segments and Flags/Config
- If there's no Identity override, the Segment is checked and returned if valid
- If no Identity or Segment overrides the value, the default Flag/Config value is used
More simply, the order of precendence is: