🪣 Custom Bucketing
Overview
When it comes to splitting the affectation of a flag, the targetingKey
is usually given a user ID. This key ensures that a user will always be in the same group for each flag.
But sometimes we want to be sure that a group of users will always be in the same group for each flag.
The bucketingKey
field in the flag configuration allows you to define a different identifier to be used instead of the targetingKey
.
This enables you to split users based on a custom identifier, such as a team ID, a company ID, or any other attribute that is common to multiple users.
How it works
When evaluating flags, the targetingKey
is used to build the hash that will allow GO Feature Flag to affect the user to a variation, if a bucketingKey
is defined, it will be used instead of the targetingKey
.
Since we are using an attribute that is common to multiple users at the same time, we can ensure that all users with the same attribute will always be in the same group.
- If a value in the corresponding
bucketingKey
is not found in the evaluation context, the flag rules will not be evaluated, and the SDK will return the default value. - Since the
bucketingKey
is not unique to a user, you can end up with a not uniform distribution of users in the variations depending on the repartition of thebucketingKey
values.