Multi-contexts
Overview
This topic includes information about multi-contexts. Contexts are people, services, machines, or other resources that encounter feature flags in your product. Multi-contexts are combinations of several context kinds into one context. Multi-contexts allow your feature flags to target entities based on data from multiple contexts. For multi-contexts, the context kind
is set to multi
.
This is a representation of what two multi-contexts might look like:
View multi-contexts
Multi-contexts appear individually in the Contexts list.
For example, your application may send a multi-context that contains the “user,” “organization,” and “device” context kinds, all in one evaluation call in the LaunchDarkly SDK. When this happens, all three individual contexts appear separately in your Contexts list. You can use the context kind filters to search for them separately.
If an individual context has an instance count higher than one, that means it is part of a multi-context. You can view the instance count for a context in the “Instances” column. Here, we know that the user context “Sandy Smith” is part of a multi-context because it has an instance count of 2:
To learn more, read The Contexts list.
Example multi-context: Anna at Global Health Services
Imagine Anna is a doctor who works for a hospital chain called Global Health Services. Anna works at two different locations, Springfield and Midway. Jesse is a nurse who works with Anna at the Springfield location.
Maybe you want to serve one variation of a flag to doctors working at the Global Health Services Springfield location, and a different variation to nurses at the Springfield location, and you want to serve a third variation to doctors at the Midway location. In this situation, you can have the LaunchDarkly SDK send multiple contexts at once during the flag evaluation, so that LaunchDarkly can evaluate targeting rules using data from both the “user” and “organization” contexts at the same time.
In this example, the multi-contexts contain two associated contexts: one for user, and one for organization.
Here is an example of what the data structure might look like for these two multi-contexts, though each SDK sends context data to LaunchDarkly in a slightly different format:
This configuration allows you to target the user and organization together to ensure you serve the correct variation. This helps eliminate risk and ensure accuracy in complex deliveries.
The multiple contexts that appear in a multi-context are called “associated contexts.” For example, the Anna
user context and the Global Health Services
organization context are associated contexts.