Skip to content

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.

2:25 videoBuilds on:Environments and pipelines

Before you start

  • The environments Development, Staging and Production and the pipeline checkout-release exist. See Environments and pipelines.
  • Sign in as priya Requester. 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 country instead 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

  1. Click Contexts under Build to open /contexts. The page reads "Define context variables for targeting rules".
  2. Click Create New Context. The page Create Context opens.
  3. In Context Key, type country. Use exactly the spelling your app sends.
  4. Under Context Values, type US in the empty field. Click Add Value, click the new field below it, and type CA. Do the same for UK.
  5. Click Save Context. The toast "Context created" appears and the list at /contexts shows country.
  6. Repeat for the key user_tier with the values free and plus.

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:

Evaluation context
{
  "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:

How a bucket is chosen
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_version or device_type.

Next

Create the express-checkout flag, its variants and its pipeline in Create your first feature.