Skip to content

Commit eb9ce2e

Browse files
committed
Revise Feature Flag Evaluation
1 parent 8775001 commit eb9ce2e

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

website/docs/targeting/feature-flag-evaluation.mdx

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: This document offers an in-depth explanation of how the ConfigCat S
66

77
# Feature Flag Evaluation
88

9-
This document offers an in-depth explanation of how the SDK determines the value of a feature flag when executing the `GetValue` function. Understanding this process requires prior knowledge of targeting concepts.
9+
This document offers an in-depth explanation of how the SDK determines the value of a feature flag when executing the `GetValue` function. Understanding this process requires prior knowledge of [targeting concepts](../targeting-overview).
1010

1111
The feature flag's value is determined by:
1212

@@ -48,22 +48,22 @@ In case the prerequisite flag is missing or there is a type mismatch between the
4848

4949
The SDK looks up the segment referenced by the condition and evaluates the condition described by the segment similarly to [User Conditions](../targeting-rule/user-condition). Then, the result is checked against the comparator. In the case of `IS IN SEGMENT` the result of the Segment Condition will be the same as the result of the segment. The result will be negated in the case of `IS NOT IN SEGMENT`.
5050

51-
If the segment evaluates to `cannot evaluate`, so is the Segment Condition.
51+
If the segment evaluates to `cannot evaluate`, so does the Segment Condition.
5252

5353
The evaluation process stops if the referenced segment is missing, and the SDK will return the [default value](../targeting-overview#default-value). (Though this can happen only when using the [flag overrides](../../sdk-reference/js#flag-overrides) feature with invalid data.)
5454

5555
## Evaluation of Percentage Options
5656

57-
[Percentage Options](../percentage-options) are designed to be consistent and sticky across all SDKs, which means that users with the same attributes fall in the same group and get the same feature flag value across the supported platforms.
57+
[Percentage Options](../percentage-options) are designed to be consistent and sticky across all SDKs, which means that users with the same attributes fall in the same group and get the same feature flag value across the supported platforms as long as the percentage values stay the same.
5858

5959
The SDK looks up the [Percentage Evaluation Attribute](../percentage-options#percentage-evaluation-attribute) in the [User Object](../user-object), then:
60-
- The SDK creates a hash from the combination of the Percentage Evaluation Attribute's value and the specific feature flag's key.
60+
- The SDK creates a hash from the combination of the specific feature flag's key and the Percentage Evaluation Attribute's value.
6161
- The hashing algorithm assigns the user a number between 0 and 99.
6262
- The assigned number determines which group the user falls into, i.e. which Percentage Option applies to the user.
6363

6464
The fact that the above algorithm is implemented across all SDKs guarantees [stickiness](../percentage-options#stickiness) and [consistency](../percentage-options#consistency).
6565

66-
By hashing the combination of the user attribute and the feature flag's key, we ensure diverse user groups for different feature flags. In other words, the algorithm prevents the same users from being assigned to the same Percentage Options for different feature flags.
66+
By hashing the combination of the feature flag's key and the user attribute, we ensure diverse user groups for different feature flags. In other words, the algorithm prevents the same users from being assigned to the same Percentage Options for different feature flags.
6767

6868
:::info
6969
The evaluation process is entirely implemented within the SDKs, meaning your users' sensitive data never leaves your system. The data flow is one-way – from ConfigCat CDN servers to your SDKs – and ConfigCat does not receive or store any attributes of the [User Object](../user-object) passed to the SDKs. This design prioritizes the privacy and security of user data.
@@ -73,53 +73,57 @@ The evaluation process is entirely implemented within the SDKs, meaning your use
7373

7474
Imagine you have two users, Jane and Joe, and you're experimenting with two different feature flags (`isTwitterSharingEnabled` and `isFacebookSharingEnabled`) that use percentage-based targeting. In these scenarios, we see how Percentage Options allow for a controlled and gradual rollout of features, ensuring a smooth transition for users like Jane and Joe.
7575

76-
First, the users are assigned a number between 0-99 based on the hash of their identifier and the feature flag's key. This number determines their eligibility for a feature based on the Percentage Options set on the Dashboard.
76+
First, the users are assigned a number between 0 and 99 based on the hash of the feature flag's key and their identifier. According to the Percentage Options specified on the Dashboard, this number determines which group they are assigned to, i.e. whether or not the feature is enabled for them.
77+
78+
Let's assume the hash algorithm produces the following numbers:
7779

7880
| | isTwitterSharingEnabled | isFacebookSharingEnabled |
7981
| ---- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
80-
| Jane | `hash('Jane' + 'isTwitterSharingEnabled') mod 100` <br/> Results in **8** | `hash('Jane' + 'isFacebookSharingEnabled') mod 100` <br/> Results in **64** |
81-
| Joe | `hash('Joe' + 'isTwitterSharingEnabled') mod 100` <br/> Results in **32** | `hash('Joe' + 'isFacebookSharingEnabled') mod 100` <br/> Results in **12** |
82+
| Jane | `hash('isTwitterSharingEnabled' + 'Jane') mod 100` <br/> results in **8** | `hash('isFacebookSharingEnabled' + 'Jane') mod 100` <br/> results in **64** |
83+
| Joe | `hash('isTwitterSharingEnabled' + 'Joe') mod 100` <br/> results in **32** | `hash(isFacebookSharingEnabled' + 'Joe') mod 100` <br/> results in **12** |
8284

83-
1. **Initial Setup: 0% ON / 100% OFF**
85+
1\. **Initial Setup: 0% ON / 100% OFF**
8486

8587
| | isTwitterSharingEnabled <br/> 0% ON / 100% OFF | isFacebookSharingEnabled <br/> 0% ON / 100% OFF |
8688
| ---- | ---------------------------------------------- | ----------------------------------------------- |
87-
| Jane | 8 >= 0 <br/>-> **OFF** | 64 >= 0 <br/>-> **OFF** |
88-
| Joe | 32 >= 0 <br/>-> **OFF** | 12 >= 0 <br/>-> **OFF** |
89+
| Jane | 8 >= 0 <br/> **OFF** | 64 >= 0 <br/> **OFF** |
90+
| Joe | 32 >= 0 <br/> **OFF** | 12 >= 0 <br/> **OFF** |
8991

90-
2. **Adjustment to 10% ON / 90% OFF**
92+
2\. **Adjustment to 10% ON / 90% OFF**
9193
In this case both feature flags are enabled for only 10% of users.
9294

9395
| | isTwitterSharingEnabled <br/> 10% ON / 90% OFF | isFacebookSharingEnabled <br/> 10% ON / 90% OFF |
9496
| ---- | ---------------------------------------------- | ----------------------------------------------- |
95-
| Jane | 8 < 10 <br/>-> **ON** | 64 >= 10 <br/>-> **OFF** |
96-
| Joe | 32 >= 10 <br/>-> **OFF** | 12 >= 10 <br/>-> **OFF** |
97+
| Jane | 8 < 10 <br/> **ON** | 64 >= 10 <br/> **OFF** |
98+
| Joe | 32 >= 10 <br/> **OFF** | 12 >= 10 <br/> **OFF** |
9799

98100
:::info
99-
Despite both feature flags being set to 10% ON / 90% OFF, the `isTwitterSharingEnabled` feature flag is only enabled for Jane. Because Jane and Joe have different identifiers, they're assigned different numbers, determining their eligibility for each feature.
101+
Despite both feature flags being set to 10% ON / 90% OFF, the `isTwitterSharingEnabled` feature flag is only enabled for Jane, while `isFacebookSharingEnabled` is disabled for both of them. This happens because the feature flag key is also involved in computing the hash.
100102
:::
101103

102-
3. **Increasing `isTwitterSharingEnabled` to 40% ON / 60% OFF**
104+
3\. **Increasing `isTwitterSharingEnabled` to 40% ON / 60% OFF**
103105

104106
| | isTwitterSharingEnabled <br/> 40% ON / 60% OFF | isFacebookSharingEnabled <br/> 10% ON / 90% OFF |
105107
| ---- | ---------------------------------------------- | ----------------------------------------------- |
106-
| Jane | 8 < 40 <br/>-> **ON** | 64 >= 10 <br/>-> **OFF** |
107-
| Joe | 32 < 40 <br/>-> **ON** | 12 >= 10 <br/>-> **OFF** |
108+
| Jane | 8 < 40 <br/>→ **ON** | 64 >= 10 <br/>→ **OFF** |
109+
| Joe | 32 < 40 <br/>→ **ON** | 12 >= 10 <br/>→ **OFF** |
110+
111+
4\. **Rolling Back to a Safer 10% ON / 90% OFF**
112+
113+
Same setup as in Step 2.
108114

109-
4. **Rolling Back to a Safer 10% ON / 90% OFF**
110-
> Same setup as in Step 2.
111-
There are cases when you want to roll back a feature flag to a safer state. In this case, you can change the Percentage Options to 10% ON / 90% OFF. The sticky nature of percentage-based targeting ensures that the same user base is served **ON** as in Step 2, not another random 10% of users.
115+
There are cases when you want to roll back a feature flag to a safer state. In this case, you can change the Percentage Options to 10% ON / 90% OFF again. The sticky nature of percentage-based targeting ensures that the same user base is served **ON** as in Step 2, not another random 10% of users.
112116

113117
| | isTwitterSharingEnabled <br/> 10% ON / 90% OFF | isFacebookSharingEnabled <br/> 10% ON / 90% OFF |
114118
| ---- | ---------------------------------------------- | ----------------------------------------------- |
115-
| Jane | 8 < 10 <br/>-> **ON** | 64 >= 10 <br/>-> **OFF** |
116-
| Joe | 32 >= 10 <br/>-> **OFF** | 12 >= 10 <br/>-> **OFF** |
119+
| Jane | 8 < 10 <br/> **ON** | 64 >= 10 <br/> **OFF** |
120+
| Joe | 32 >= 10 <br/> **OFF** | 12 >= 10 <br/> **OFF** |
117121

118-
5. **Final Step: Moving to 100% ON / 0% OFF**
122+
5\. **Final Step: Moving to 100% ON / 0% OFF**
119123

120-
After testing the feature flags, you can safely move them to 100% ON. This ensures that all users are receiving the features.
124+
After testing the feature flags, you can safely move them to 100% ON. This will enable the features for all users.
121125

122126
| | isTwitterSharingEnabled <br/> 100% ON / 0% OFF | isFacebookSharingEnabled <br/> 100% ON / 0% OFF |
123127
| ---- | ---------------------------------------------- | ----------------------------------------------- |
124-
| Jane | 8 < 100 <br/>-> **ON** | 64 < 100 <br/>-> **ON** |
125-
| Joe | 32 < 100 <br/>-> **ON** | 12 < 100 <br/>-> **ON** |
128+
| Jane | 8 < 100 <br/> **ON** | 64 < 100 <br/> **ON** |
129+
| Joe | 32 < 100 <br/> **ON** | 12 < 100 <br/> **ON** |

0 commit comments

Comments
 (0)