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

GIVE DOCS FEEDBACK

Built-in attributes

Read time: 2 minutes
Last edited: Jun 07, 2024

Overview

This topic explains what LaunchDarkly's built-in attributes are and how to configure them.

LaunchDarkly allows you to target contexts based on built-in attributes. To learn more, read Target with flags.

Use built-in attributes

The built-in attributes are kind, key, name, and anonymous. Kind, key, and name attributes must be strings, and anonymous attributes must be booleans. You can define additional attributes for a context by passing in a name and value for each.

The context kind and key are the only mandatory attributes. All other attributes are optional.

Some SDKs will automatically set the kind to "user" if you do not provide a value. Some client-side SDKs will automatically generate the key if the anonymous attribute is set to true.

Here is a table explaining LaunchDarkly's built-in attributes:

Attribute nameAttribute example valueNotes
kind"user"The context kind. Required for evaluation. The combination of kind and key must be unique for each context.
key"context-key-123abc"Required for evaluation. The combination of kind and key must be unique for each context. Some client-side SDKs will generate this for you if anonymous is set to true.
name"Sandy Smith"This attribute is optional, but we recommend including it if you need to target flags to individual contexts.
anonymoustrueThis attribute is optional. If set, this boolean attribute prevents the context from appearing in the Contexts list. If the anonymous attribute is set to true, LaunchDarkly treats the context as anonymous.

Here is an example of a context with built-in attribute values:

"context": {
"kind": "user",
"key": "user-key-123abc",
"name": "Sandy"
}
Creating searchable context keys

You can structure your context keys so they are both searchable and unique. To do this, we suggest adding a searchable term to the beginning of the key, followed by a unique ID. For example, if you wanted to easily search users that encountered a specific service, you could structure the key as follows: service_name:uuid.

Alternatively, you can set unique identifiers for contexts in your SDK configuration. To learn more, read Application metadata configuration.

You can view a context's attributes by clicking on the individual context from the Contexts list.