Chapter 2 · Model your release
Contexts
You declare the facts a rule can use, country and user_tier, and see how your app sends them at evaluation time.
Before you start
- The environments Development, Staging and Production and the pipeline
checkout-releaseexist. See Environments and pipelines. - Sign in as
priyaRequester. Creating a context needs no special role. - Select the team Checkout in Select team.
What a context is
FluxGate cannot know a user's country or plan. Your app knows, and it sends those facts with every evaluation. A context declares one such fact: a key, such as country, and the values your app is expected to send, such as US, CA and UK.
Contexts help in two places:
- The rule editor suggests context keys, so you pick
countryinstead of typing it again. - The In List operator can use a whole context as its list of values.
A context does not restrict anything. A rule can still use a key that you never declared, and your app can send values that are not in the list.
Create the contexts
- Click Contexts under Build to open
/contexts. The page reads "Define context variables for targeting rules". - Click Create New Context. The page Create Context opens.
- In Context Key, type
country. Use exactly the spelling your app sends. - Under Context Values, type
USin the empty field. Click Add Value, click the new field below it, and typeCA. Do the same forUK. - Click Save Context. The toast "Context created" appears and the list at
/contextsshowscountry. - Repeat for the key
user_tierwith the valuesfreeandplus.
The list shows only the Key column. Open a context to see its values again.
What your app sends
When your app asks for a flag, it sends an evaluation context. Its keys match the contexts you declared, plus a bucketing key:
{
"bucketingKey": "user-42",
"country": "CA",
"user_tier": "plus"
}Clients and edge server sends this context to the edge server for real.
The bucketing key
The bucketing key is a stable identifier for the user. For a percentage split, FluxGate hashes the flag key together with the bucketing key to choose a bucket:
bucket = SHA-256("<flag key>:<bucketing key>")The same user lands in the same bucket every time, so nobody switches between checkout versions when they reload the page.
Good to know
- Any signed-in user can create a context. Editing an existing context needs a system admin or a Team Admin.
- The value fields have no labels, only the placeholder "e.g., admin, US, mobile". A remove button appears when you point at a value.
- Add contexts when a rule needs a new fact, for example
app_versionordevice_type.
Next
Create the express-checkout flag, its variants and its pipeline in Create your first feature.