You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/targeting/feature-flag-evaluation.mdx
+31-27Lines changed: 31 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ description: This document offers an in-depth explanation of how the ConfigCat S
6
6
7
7
# Feature Flag Evaluation
8
8
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).
10
10
11
11
The feature flag's value is determined by:
12
12
@@ -48,22 +48,22 @@ In case the prerequisite flag is missing or there is a type mismatch between the
48
48
49
49
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`.
50
50
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.
52
52
53
53
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.)
54
54
55
55
## Evaluation of Percentage Options
56
56
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.
58
58
59
59
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.
61
61
- The hashing algorithm assigns the user a number between 0 and 99.
62
62
- The assigned number determines which group the user falls into, i.e. which Percentage Option applies to the user.
63
63
64
64
The fact that the above algorithm is implemented across all SDKs guarantees [stickiness](../percentage-options#stickiness) and [consistency](../percentage-options#consistency).
65
65
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.
67
67
68
68
:::info
69
69
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
73
73
74
74
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.
75
75
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:
| 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**|
82
84
83
-
1.**Initial Setup: 0% ON / 100% OFF**
85
+
1\.**Initial Setup: 0% ON / 100% OFF**
84
86
85
87
|| isTwitterSharingEnabled <br/> 0% ON / 100% OFF | isFacebookSharingEnabled <br/> 0% ON / 100% OFF |
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.
100
102
:::
101
103
102
-
3.**Increasing `isTwitterSharingEnabled` to 40% ON / 60% OFF**
104
+
3\.**Increasing `isTwitterSharingEnabled` to 40% ON / 60% OFF**
103
105
104
106
|| isTwitterSharingEnabled <br/> 40% ON / 60% OFF | isFacebookSharingEnabled <br/> 10% ON / 90% OFF |
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.
112
116
113
117
|| isTwitterSharingEnabled <br/> 10% ON / 90% OFF | isFacebookSharingEnabled <br/> 10% ON / 90% OFF |
0 commit comments