Skip to content

Commit cba8592

Browse files
authored
docs: document feature flag env vars and experiments config (#8)
Documents the build-time config injection mechanism and the experiments/feature-flag system added in SableClient/Sable#572. ## Changes - **Installation guide**: new "Injecting config at build time" section covering the `CLIENT_CONFIG_OVERRIDES_JSON` env var and the optional `CLIENT_CONFIG_OVERRIDES_STRICT` build-fail flag; new "Feature flag and experiment configuration" subsection with the full `experiments` config schema and field descriptions. - **Developer Tools**: new "Features & Experiments" section describing the panel in Settings → Developer Tools that shows each experiment's current variant assignment. ## Related - Feature PR: SableClient/Sable#572 > ⚠️ This docs PR should be merged when (or after) SableClient/Sable#572 merges.
1 parent 727e4f4 commit cba8592

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

content/features/developer-tools.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,21 @@ See [Privacy & Crash Reporting](../privacy) for information on enabling or disab
5252
# In-App Bug Report
5353

5454
Type `/bugreport` in any room's compose box to open the bug report form. This prefills a GitHub issue template with your description and optionally attaches your recent debug log export.
55+
56+
# Features & Experiments
57+
58+
The **Features & Experiments** panel (Settings → Developer Tools → Features & Experiments) shows
59+
the feature flags and A/B experiments defined in your deployment's `config.json`.
60+
61+
For each configured experiment you can see:
62+
63+
- **Enabled** — whether the experiment is active for any users
64+
- **Rollout** — the percentage of users enrolled
65+
- **Your Variant** — the variant you have been assigned, and whether you are in the
66+
experiment group or the control group
67+
68+
This is useful for verifying that a flag was deployed correctly, or for confirming which arm
69+
of an experiment you are currently in. Variant assignment is deterministic: the same account
70+
always receives the same variant for a given experiment key, across devices and sessions.
71+
72+
See [Installation → Feature flag and experiment configuration](../installation/#feature-flag-and-experiment-configuration) for how operators define experiments.

content/installation/_index.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,48 @@ After that, you can copy the dist/ directory to your server and serve it.
6161

6262
* To deploy on subdirectory, you need to rebuild the app youself after updating the `base` path in [`build.config.ts`](build.config.ts).
6363
* For example, if you want to deploy on `https://sable.moe/app`, then set `base: '/app'`.
64+
65+
## Injecting config at build time
66+
67+
If you build Sable in a CI/CD pipeline, you can inject `config.json` overrides without
68+
editing the file directly. Set the `CLIENT_CONFIG_OVERRIDES_JSON` environment variable to
69+
a JSON object before running `pnpm run build`; the build script will deep-merge it into the
70+
bundled `config.json`.
71+
72+
```sh
73+
export CLIENT_CONFIG_OVERRIDES_JSON='{"defaultHomeServer": "matrix.example.com"}'
74+
pnpm run build
75+
```
76+
77+
Set `CLIENT_CONFIG_OVERRIDES_STRICT=true` to make the build fail hard if the JSON is
78+
malformed (useful in CI where silent failures are dangerous).
79+
80+
### Feature flag and experiment configuration
81+
82+
The `experiments` block in `config.json` lets server operators define feature flags with
83+
optional percentage-based rollout. Each key is a free-form experiment name; the value
84+
controls who gets it.
85+
86+
```json
87+
{
88+
"experiments": {
89+
"myFeature": {
90+
"enabled": true,
91+
"rolloutPercentage": 50,
92+
"variants": ["treatment-a", "treatment-b"],
93+
"controlVariant": "control"
94+
}
95+
}
96+
}
97+
```
98+
99+
| Field | Type | Description |
100+
|---|---|---|
101+
| `enabled` | boolean | Master switch; `false` means no users receive the experiment |
102+
| `rolloutPercentage` | number (0–100) | Percentage of users bucketed into the experiment |
103+
| `variants` | string[] | Names for each treatment arm |
104+
| `controlVariant` | string | The variant name given to users outside the rollout |
105+
106+
Bucketing is deterministic and stable: the same user always receives the same variant for
107+
a given experiment key. You can see your current variant assignments in
108+
**Settings → Developer Tools → Features & Experiments**.

0 commit comments

Comments
 (0)