Skip to content

Commit 2db876d

Browse files
authored
Merge pull request element-hq#11341 from vector-im/jryans/feature-flag-process
Document feature flag process
2 parents ceacf3b + d373e28 commit 2db876d

2 files changed

Lines changed: 116 additions & 3 deletions

File tree

‎docs/config.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ For a good example, see https://riot.im/develop/config.json.
2222
`default_hs_url` is specified. When multiple sources are specified, it is unclear
2323
which should take priority and therefore the application cannot continue.
2424
* As of Riot 1.4.0, identity servers are optional. See [Identity servers](#identity-servers) below.
25-
1. `features`: Lookup of optional features that may be `enable`d, `disable`d, or exposed to the user
26-
in the `labs` section of settings. The available optional experimental features vary from
27-
release to release. The available features are described in [labs.md](labs.md).
25+
1. `features`: Lookup of optional features that may be `enable`d, `disable`d, or
26+
exposed to the user in the `labs` section of settings. The available
27+
optional experimental features vary from release to release and are [documented](labs.md). The feature flag process is
28+
[documented](feature-flags.md) as well.
2829
1. `showLabsSettings`: Shows the "labs" tab of user settings even when no `features` are enabled
2930
or present. Useful for getting at settings which may be otherwise hidden.
3031
1. `brand`: String to pass to your homeserver when configuring email notifications, to let the

‎docs/feature-flags.md‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Feature flags
2+
3+
When developing new features for Riot, we use feature flags to give us more
4+
flexibility and control over when and where those features are enabled.
5+
6+
For example, flags make the following things possible:
7+
8+
* Extended testing of a feature via labs on develop
9+
* Enabling features when ready instead of the first moment the code is released
10+
* Testing a feature with a specific set of users (by enabling only on a specific
11+
Riot instance)
12+
13+
The size of the feature controlled by a feature flag may vary widely: it could
14+
be a large project like reactions or a smaller change to an existing algorithm.
15+
A large project might use several feature flags if it's useful to control the
16+
deployment of different portions independently.
17+
18+
Everyone involved in a feature (engineering, design, product, reviewers) should
19+
think about its deployment plan up front as best as possible so we can have the
20+
right feature flags in place from the start.
21+
22+
## Interaction with spec process
23+
24+
Historically, we have often used feature flags to guard client features that
25+
depend on unstable spec features. Unfortunately, there was never clear agreement
26+
about how long such a flag should live for, when it should be removed, etc.
27+
28+
Under the [new spec
29+
process](https://github.com/matrix-org/matrix-doc/pull/2324), server-side
30+
unstable features can be used by clients and enabled by default as long as
31+
clients commit to doing the associated clean up work once a feature stabilises.
32+
33+
## Starting work on a feature
34+
35+
When starting work on a feature, we should create a matching feature flag:
36+
37+
1. Add a new
38+
[setting](https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/settings/Settings.js)
39+
of the form:
40+
```js
41+
"feature_cats": {
42+
isFeature: true,
43+
displayName: _td("Adds cats everywhere"),
44+
supportedLevels: LEVELS_FEATURE,
45+
default: false,
46+
},
47+
```
48+
2. Check whether the feature is enabled as appropriate:
49+
```js
50+
SettingsStore.isFeatureEnabled("feature_cats")
51+
```
52+
3. Add the feature to the [set of labs on develop](https://github.com/vector-im/riot-web/blob/develop/riot.im/develop/config.json):
53+
```json
54+
"features": {
55+
"feature_cats": "labs"
56+
},
57+
```
58+
4. Document the feature in the [labs documentation](https://github.com/vector-im/riot-web/blob/develop/docs/labs.md)
59+
60+
With these steps completed, the feature is disabled by default, but can be
61+
enabled on develop by interested users for testing.
62+
63+
Different features may have different deployment plans for when to enable where.
64+
The following lists a few common options.
65+
66+
## Enabling by default on develop
67+
68+
Set the feature to `enable` in the [develop config](https://github.com/vector-im/riot-web/blob/develop/riot.im/develop/config.json):
69+
70+
```json
71+
"features": {
72+
"feature_cats": "enable"
73+
},
74+
```
75+
76+
## Enabling by default on staging and app
77+
78+
Set the feature to `enable` in the [app
79+
config](https://github.com/vector-im/riot-web/blob/develop/riot.im/app/config.json).
80+
81+
## Feature deployed successfully
82+
83+
Once we're confident that a feature is working well, we should remove the flag:
84+
85+
1. Remove the [setting](https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/settings/Settings.js)
86+
2. Remove all `isFeatureEnabled` lines that test for the feature's setting
87+
3. Remove the feature from the [labs documentation](https://github.com/vector-im/riot-web/blob/develop/docs/labs.md)
88+
4. Remove feature state from
89+
[develop](https://github.com/vector-im/riot-web/blob/develop/riot.im/develop/config.json)
90+
and [app](https://github.com/vector-im/riot-web/blob/develop/riot.im/app/config.json)
91+
configs
92+
5. Celebrate! 🥳
93+
94+
## Convert to a regular setting (optional)
95+
96+
Sometimes we decide a feature should always be user-controllable as a setting
97+
even after it has been fully deployed. In that case, we would craft a new,
98+
regular setting:
99+
100+
1. Remove the feature flag from
101+
[settings](https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/settings/Settings.js)
102+
and add a regular setting with the appropriate levels for your feature
103+
2. Replace the `isFeatureEnabled` lines with `getValue` or similar calls
104+
according to the [settings
105+
docs](https://github.com/matrix-org/matrix-react-sdk/blob/develop/docs/settings.md)
106+
(checking carefully, as we may want a different mix of code paths when the
107+
feature is always present but gated by a setting)
108+
3. Remove the feature from the [labs documentation](https://github.com/vector-im/riot-web/blob/develop/docs/labs.md)
109+
4. Remove feature state from
110+
[develop](https://github.com/vector-im/riot-web/blob/develop/riot.im/develop/config.json)
111+
and [app](https://github.com/vector-im/riot-web/blob/develop/riot.im/app/config.json)
112+
configs

0 commit comments

Comments
 (0)