'true' or 'false'. You change the
value in the dashboard, and every client reads the new value at its next refresh. Feature flags
use Analytics Web (@grainql/analytics-web). Grain Tag has no remote configuration. Read
Remote configuration for the cache-first flow and the methods.
The pattern
Read the flag, compare it with the string'true', and show one of two branches. Every
configuration value is a string, so enabled === true is always false.
new_ui_enabled to true to turn the feature on and to false to turn
it off.
A kill switch
A kill switch is a flag that is on by default and that you turn off when a feature fails in production. Compare with'false', so that a missing value keeps the feature on.
chat_enabled to false in the dashboard. Every client hides the
widget at its next refresh. The default refresh interval is 300000 ms. Read
Remote configuration to change it.
A gradual rollout
The code of a gradual rollout is the pattern above. The rollout happens in the dashboard, where a rule returns'true' for a percentage of users.
A user-specific flag
Pass user properties with the read. A rule in the dashboard evaluates the properties and returns the value for this user. Every property value is a string.premium_feature: if plan equals premium, return
true. Every other user receives the default value. Read Personalization
for rules on more than one property.
Defaults
Set a default for every flag indefaultConfigurations. A client reads the default before the
first response from the API. It also reads the default when the API is not reachable.
- A new feature defaults to
'false'. - A kill switch defaults to
'true'. - Name a flag after the feature and its state:
new_dashboard_enabled, notfeature1. - Write in the dashboard what the flag controls and when to delete it.
Testing
Both branches of a flag run in production, so both need a test. Pass a client with the flag indefaultConfigurations to the provider, one test per value.