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
feat!: allow custom seed when using targetingKey override for fractional op (#1266)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->
## This PR
<!-- add the description of the PR here -->
- no longer injects flagKey as seed for fractional op when user has
provided custom targeting
- updates schema to allow `cat` and other operations so that custom
targeting can be properly seeded
### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->
#1264
### Notes
<!-- any additional notes for this PR -->
### Follow-up Tasks
<!-- anything that is related to this PR but not done here should be
noted under this section -->
<!-- if there is a need for a new issue, please link it here -->
### How to test
<!-- if applicable, add testing instructions under this section -->
```bash
# unit tests
make test
# gherkin tests
./bin/flagd start -f file:test-harness/flags/testing-flags.json -f file:test-harness/flags/custom-ops.json -f file:test-harness/flags/evaluator-refs.json -f file:test-harness/flags/zero-flags.json
make flagd-integration-test
```
---------
Signed-off-by: Cole Bailey <[email protected]>
Signed-off-by: Cole Bailey <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Co-authored-by: Michael Beemer <[email protected]>
Co-authored-by: Kavindu Dodanduwa <[email protected]>
Copy file name to clipboardexpand all lines: docs/reference/custom-operations/fractional-operation.md
+17-4
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,13 @@ OpenFeature allows clients to pass contextual information which can then be used
10
10
// Factional evaluation property name used in a targeting rule
11
11
"fractional": [
12
12
// Evaluation context property used to determine the split
13
-
{ "var":"email" },
13
+
// Note using `cat` and `$flagd.flagKey` is the suggested default to seed your hash value and prevent bucketing collisions
14
+
{
15
+
"cat": [
16
+
{ "var":"$flagd.flagKey" },
17
+
{ "var":"email" }
18
+
]
19
+
},
14
20
// Split definitions contain an array with a variant and percentage
15
21
// Percentages must add up to 100
16
22
[
@@ -33,7 +39,7 @@ The `defaultVariant` is `red`, but it contains a [targeting rule](../flag-defini
33
39
34
40
In this case, `25%` of the evaluations will receive `red`, `25%` will receive `blue`, and so on.
35
41
36
-
Assignment is deterministic (sticky) based on the expression supplied as the first parameter (`{ "var": "email" }`, in this case).
42
+
Assignment is deterministic (sticky) based on the expression supplied as the first parameter (`{ "cat": [{ "var": "$flagd.flagKey" }, { "var": "email" }]}`, in this case).
37
43
The value retrieved by this expression is referred to as the "bucketing value".
38
44
The bucketing value expression can be omitted, in which case a concatenation of the `targetingKey` and the `flagKey` will be used.
39
45
@@ -46,8 +52,10 @@ is selected.
46
52
As hashing is deterministic we can be sure to get the same result every time for the same data point.
47
53
48
54
The `fractional` operation can be added as part of a targeting definition.
49
-
The value is an array and the first element is the name of the property to use from the evaluation context.
55
+
The value is an array and the first element is a nested JsonLogic rule which resolves to the hash key.
56
+
This rule should typically consist of a seed concatenated with a session variable to use from the evaluation context.
50
57
This value should typically be something that remains consistent for the duration of a users session (e.g. email or session ID).
58
+
The seed is typically the flagKey so that experiments running across different flags are statistically independent, however, you can also specify another seed to either align or further decouple your allocations across different feature flags or use-cases.
51
59
The other elements in the array are nested arrays with the first element representing a variant and the second being the percentage that this option is selected.
52
60
There is no limit to the number of elements but the configured percentages must add up to 100.
0 commit comments