Context kinds
A context kind is the type of a thing your code passes to the SDK as a context. The built-in kind is user. You can declare custom kinds (organization, device, tenant, session) per project.
Why declare a kind
Section titled “Why declare a kind”A context kind is the bridge between two views of the same thing:
- The SDK side: the field name your code uses in the context payload.
- The dashboard side: a typed entity you can target on, percentage-roll on, and read attributes from.
When you create a context kind called organization, the dashboard knows that targeting rules can read organization.region, organization.plan, and so on. The rule editor offers them as autocomplete options.
Anatomy
Section titled “Anatomy”key: organizationname: Organizationdescription: The B2B customer the request is attributed to.- Key. The string used in code (
organizationshows up ascontext.organization.region). Immutable after creation. - Name and description. For humans.
The user kind exists in every project automatically. You cannot delete it; it is what flags evaluate against by default.
When to add a new kind
Section titled “When to add a new kind”Add a kind when you have something other than a user that you want to target on, bucket on, or carry attributes for. The common ones:
organization(oraccount,tenant): for B2B products where features roll out per customer, not per individual.device: when targeting depends on the device (mobile OS version, screen size).session: when you want a bucket that resets across logins.
If a value is just an attribute of a user, do not give it its own kind. country does not need to be a kind; it is user.country.
Choosing a bucketing kind
Section titled “Choosing a bucketing kind”Every percentage rollout and every targeting rule that ends in a rollout needs to know which context kind to hash on. The choice determines who flips together:
- Bucket by
userto give 10% of users the new variation. Two users in the same organization can land in different buckets. - Bucket by
organizationto give 10% of organizations the new variation. Everyone in a bucketed organization flips together.
Pick one per rollout. The dashboard surfaces the choice at the rule and at the environment default rule. See Percentage rollouts.
Related
Section titled “Related”- Contexts for the runtime side.
- Targeting rules for how rules reference kinds.
- Percentage rollouts for bucketing.