From 275d0b2dbd54caa3fbc5d2267611567c69be39ed Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Wed, 20 Mar 2024 12:55:47 -0400 Subject: [PATCH 1/3] Describe advanced local feature flag configuration --- docs/contributing/feature-flags.md | 104 +++++++++++++++++++++++++++-- 1 file changed, 99 insertions(+), 5 deletions(-) diff --git a/docs/contributing/feature-flags.md b/docs/contributing/feature-flags.md index d38919b2..4c794ecf 100644 --- a/docs/contributing/feature-flags.md +++ b/docs/contributing/feature-flags.md @@ -1,8 +1,3 @@ ---- -sidebar_custom_props: - access: bitwarden ---- - # Feature Flags ## Background @@ -97,6 +92,105 @@ configuration setting can be used to override it. The file must be present befor solution, but once there you can change the file contents and see immediate results in running / debugging code. +
+ Context-aware feature flag JSON +
+
+ The `flags.json` file can also define flags which respond to user context. Currently, only `UserId`and the `OrganizationId` of all organizations a user belongs to are included in our feature flagging context. The syntax for defining context-aware flags amounts to defining a `flag` object which specifies `variations` values and `rules` which are evaluated against the user context. A `fallthrough` object is also available to specify a default variation. Rules are represented by `segments`, which are defined in the same file. + + a Feature flag may not appear in both the `flags` object and in the `flagValues` object. +
+
+
+ + JSON example + +
+ +```json +{ + "flagValues": { + "example-single-boolean-key": true, + }, + "flags": { + "example-advanced-configuration": { + "key": "example-advanced-configuration", + "on": true, + "variations": [ + false, + true + ], + "fallthrough": { + "variation": 0 + }, + "rules": [ + { + "variation": 1, + "clauses": [ + { + "contextKind": "user", + "attribute": "segmentMatch", + "op": "segmentMatch", + "values": [ + "user-segment" + ] + } + ] + } + ], + "version": 1 + } + }, + "segments": { + "user-segment": { + "key": "user-segment", + "rules": [ + { + "clauses": [ + { + "contextKind": "user", + "attribute": "key", + "op": "in", + "values": [ + "<>", + "<>" + ... + ] + } + ] + } + ], + "version": 1 + }, + "organization-segment": { + "key": "organization-segment", + "rules": [ + { + "clauses": [ + { + "contextKind": "user", + "attribute": "organizations", + "op": "in", + "values": [ + "<>", + "<>" + ... + ] + } + ] + } + ] + } + } +} +``` + +
+
+ +
+
+ ### Local configuration: code modification In some situations there may be a need to change a feature flag value to be something other than its From c910e542b9f626b4cc0eaaa5f0e60e10743fd59c Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Wed, 20 Mar 2024 12:59:17 -0400 Subject: [PATCH 2/3] Clarify UserId property in context --- docs/contributing/feature-flags.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/contributing/feature-flags.md b/docs/contributing/feature-flags.md index 4c794ecf..143716bc 100644 --- a/docs/contributing/feature-flags.md +++ b/docs/contributing/feature-flags.md @@ -98,7 +98,9 @@ debugging code.
The `flags.json` file can also define flags which respond to user context. Currently, only `UserId`and the `OrganizationId` of all organizations a user belongs to are included in our feature flagging context. The syntax for defining context-aware flags amounts to defining a `flag` object which specifies `variations` values and `rules` which are evaluated against the user context. A `fallthrough` object is also available to specify a default variation. Rules are represented by `segments`, which are defined in the same file. - a Feature flag may not appear in both the `flags` object and in the `flagValues` object. + A Feature flag may not appear in both the `flags` object and in the `flagValues` object. + + Note that UserId is referred to as `key` in the `clauses` object while defining a segment.

From 5d663fd60bf9c850b29863b9b1d0f47ba9a5dc45 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Wed, 20 Mar 2024 18:45:14 -0400 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Matt Bishop --- docs/contributing/feature-flags.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contributing/feature-flags.md b/docs/contributing/feature-flags.md index 143716bc..e0a5e7cd 100644 --- a/docs/contributing/feature-flags.md +++ b/docs/contributing/feature-flags.md @@ -98,9 +98,9 @@ debugging code.
The `flags.json` file can also define flags which respond to user context. Currently, only `UserId`and the `OrganizationId` of all organizations a user belongs to are included in our feature flagging context. The syntax for defining context-aware flags amounts to defining a `flag` object which specifies `variations` values and `rules` which are evaluated against the user context. A `fallthrough` object is also available to specify a default variation. Rules are represented by `segments`, which are defined in the same file. - A Feature flag may not appear in both the `flags` object and in the `flagValues` object. + A feature flag may not appear in both the `flags` object and in the `flagValues` object. - Note that UserId is referred to as `key` in the `clauses` object while defining a segment. + Note that `UserId` is referred to as `key` in the `clauses` object while defining a segment.