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

Contexts

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

Overview

This category has documentation topics about LaunchDarkly contexts. Contexts are people, services, machines, or other resources that encounter feature flags in your product.

Most, but not all, LaunchDarkly SDKs support contexts. Instead, some rely on legacy user objects. To learn which SDKs are available to use with contexts, read SDKs.

About contexts

Contexts let you create targeting rules for feature flags based on a variety of different information, including attributes pertaining to users, organizations, devices, and more. You can be as specific as targeting a flag to a single end user, or as broad as targeting your entire customer base.

You can manage the way contexts interact with flags by targeting flags to specific contexts. You can even choose which contexts to include or exclude in the data you collect. When a flag evaluation occurs, the feature flag uses the evaluation context to understand what variation to serve. The evaluation context is an object including one or more contexts and its attributes that you pass to the SDK's variation method when you evaluate flags.

Only the context attributes you provide are available for targeting

The SDK only evaluates flags based on the context you provide in the evaluation call. You must provide all applicable attributes for each evaluation in the SDK for your targeting rules to apply correctly. To learn more, read Evaluating flags.

Example context: Anna at Global Health Services

As an example, let's assume Anna is one of your end users. She is a doctor who works for a hospital chain called Global Health Services. Anna has two mobile devices, an Android phone and an iPad tablet. Anna uses your application on both devices as part of her work.

Given this information, you may know the following things about Anna:

  • her name, email, and job function ("doctor"),
  • her organization's name ("Global Health Services") and address,
  • her device's type, operating system, and device ID, for each mobile device.

You may want to customize Anna's experience in your application based on:

  • her job function, as part of a feature that allows all doctors to access patient records.
  • her devices as part of a feature that provides different styling for Android and iPad devices.
  • her organization, ensuring everyone at her location receives the same variation as part of an experiment testing out a new feature

You can do this using context kinds.

Context kinds

You can organize information about the different entities that encounter feature flags in your product based on context kinds. Each context has one kind with a unique set of corresponding attributes that you can use for targeting and Experimentation. To learn more, read Context kinds.

Here are the topics in this category:

  • The Contexts list
  • Context kinds
  • Context attributes
  • Multi-contexts
  • Anonymous contexts