No results for ""
EXPAND ALL
  • Home
  • API docs

Context attributes

Read time: 3 minutes
Last edited: Aug 28, 2024

Overview

This topic explains what context attributes are, how to configure them, and how LaunchDarkly uses them to evaluate flags and display flag variations to your customers.

Some SDKs still use user attributes

Some LaunchDarkly SDKs do not yet support context-based feature flagging. Instead, they rely on legacy user objects.

To learn which SDKs are available to use with contexts, read SDKs. To learn more about upgrading to contexts, read Best practices for upgrading users to contexts.

About context attributes

Contexts are people, services, machines, or other resources that encounter feature flags in your product.

Each context has a context kind that you can use to categorize context instances for targeting and Experimentation. For example, you may know:

  • the username, first name, last name, and email address of a person. You might include these context attributes in contexts with a "user" context kind.
  • the size, region, and location of an office. You might include these context attributes in contexts with an "organization" context kind.
  • the configuration details of an environment. You might include these attributes in contexts with a "device" context kind.

To learn more, read Context kinds.

A more precise way to refer to a context when you are using it to evaluate a feature flag is an "evaluation context." An evaluation context is the object that the SDK uses to evaluate a feature flag. It can contain a single context or a multi-context. It includes all of the information about a context that LaunchDarkly can use for a feature flag evaluation. To learn more, read Contexts.

By default, the Contexts list displays a context's attribute values. If you mark a context attribute as private within your SDK, it will not display in the LaunchDarkly user interface (UI) but you can still use it in flag evaluations. To learn more, read Using private context attributes.

Target based on context attributes

You can use context attributes in targeting rules for flags and segments. For example, imagine you want a flag to serve the Enabled variation to user contexts that have a plan type of Beta tester and are in the segment example segment.

Here is an example of that rule:

A rule with two conditions.
A rule with two conditions.

After you have set up the conditions for your rule, you can decide to roll out one variation to all your contexts, or do a percentage rollout across several variations. To learn more, read Target with flags.

View and manage context attributes

By default, SDKs send all of a context's attributes to LaunchDarkly. This data lets LaunchDarkly determine the expected flag variations for contexts and powers the autocomplete functionality throughout the LaunchDarkly UI. You can change the value of an attribute for a context at any time by sending new attributes values to LaunchDarkly from your SDK.

You can access context detail pages from the Contexts list. To learn how, read The Contexts list.

Here is a context details page in the LaunchDarkly UI:

A context's details page.
A context's details page.
The SDK does not use the attributes in the Contexts list to evaluate flags

The SDK only evaluates flags based on the evaluation context you provide in the evaluation call. The SDK does not use the attributes shown on the Contexts list, and context attributes are not synchronized across SDK instances. You must provide all applicable context attributes for your targeting rules to apply correctly. To learn more, read Evaluating flags.