Targeting and rollouts
Model context attributes, ordered rules, and stable percentage rollout keys.
Targeting rules are evaluated in order. The first matching rule wins. If no rule matches, FeatureGate returns the environment default for the flag.
Rule groups
Match allrequires every condition in the rule group to match.Match anyrequires at least one condition in the group to match.- Missing context attributes are treated as condition misses, never as errors.
targeting.ts
ts
featuregate.getBoolean("new-checkout", {
defaultValue: false,
attributes: {
user: { id: "user_123" },
account: { plan: "enterprise", region: "au" },
},
});Percentage rollouts
Percentage rollouts hash the configured attribute path as the stable rollout key, so the same subject lands in the same bucket on every evaluation, across processes and across restarts.
Pick an attribute that is stable for the unit you are rolling out to, typically a user or account id.
Pick a stable rollout key
Hash on a value that stays constant for the unit you roll out to — usually a user or account id. A key that changes between requests reshuffles buckets, so users flip in and out of the rollout.