Skip to content

Commit 02ad7ac

Browse files
committed
Add version based FF examples into contributor docs
1 parent f8fa16a commit 02ad7ac

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

docs/remote-feature-flags.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,79 @@ Choose the appropriate feature flag type based on your needs:
8585

8686
The distribution is deterministic based on the user's `metametricsId`, ensuring consistent group assignment across sessions.
8787

88+
**3. Object flag with version-based scope**: Use for:
89+
90+
- Rolling out features progressively across app versions
91+
- Providing different feature configurations per version
92+
- Maintaining backward compatibility while introducing new features
93+
94+
In this example: users get different UI configurations based on their app version, with the system selecting the closest lower or equal version match.
95+
96+
```json
97+
{
98+
"newConfirmationsFeature": {
99+
"versions": {
100+
"13.0.0": { "ui": "legacy" },
101+
"13.1.0": { "ui": "improved" },
102+
"13.2.0": { "ui": "modern", "animations": true }
103+
}
104+
}
105+
}
106+
```
107+
108+
- v13.0.5 → `{ "ui": "legacy" }` (closest lower or equal version)
109+
- v13.1.8 → `{ "ui": "improved" }`
110+
- v13.2.1 → `{ "ui": "modern", "animations": true }`
111+
- v12.9.0 → Feature excluded (no matching versions)
112+
113+
The version matching is deterministic and uses semantic version comparison to find the highest version that is less than or equal to the current app version.
114+
115+
**4. Composing version-based scope with threshold scope**: Use when you need to control both version targeting and user percentage rollout simultaneously.
116+
117+
In this example: the feature is rolled out to 30% of users on v13.0.0+, and 100% of users on v13.2.0+.
118+
119+
```json
120+
{
121+
"newFeature": {
122+
"versions": {
123+
"13.0.0": [
124+
{
125+
"name": "gradual rollout",
126+
"scope": {
127+
"type": "threshold",
128+
"value": 0.3
129+
},
130+
"value": { "enabled": true }
131+
},
132+
{
133+
"name": "disabled",
134+
"scope": {
135+
"type": "threshold",
136+
"value": 1
137+
},
138+
"value": { "enabled": false }
139+
}
140+
],
141+
"13.2.0": [
142+
{
143+
"name": "full rollout",
144+
"scope": {
145+
"type": "threshold",
146+
"value": 1
147+
},
148+
"value": { "enabled": true }
149+
}
150+
]
151+
}
152+
}
153+
}
154+
```
155+
156+
- v13.0.5 user in 30% bucket → `{ "enabled": true }`
157+
- v13.0.5 user in 70% bucket → `{ "enabled": false }`
158+
- v13.2.1 user (any bucket) → `{ "enabled": true }` (100% rollout)
159+
- v12.9.0 user → Feature excluded (no matching versions)
160+
88161
## Implementation Guide
89162

90163
### 1. Creating feature flag in LaunchDarkly.

0 commit comments

Comments
 (0)