Documentation Index
Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This topic explains how LaunchDarkly automatically provides data about the environment where the application is running. Some LaunchDarkly mobile SDKs support automatically providing data about the environment where the application is running. This data makes it simpler to target your mobile customers based on application name or version, or on device characteristics including manufacturer, model, operating system, locale, and so on. When you configure your SDK, you must explicitly decide whether or not LaunchDarkly should collect and return this data. We recommend enabling this feature when you configure the SDK. After you enable this option, the SDKs automatically add this data to each evaluation context you provide. The data is provided in two new context kinds:ld_application and ld_device. If the data is not available, it is omitted.
Customers who are billed by MAU may be charged based on the ld_device context kind if it becomes the context kind with the highest volume of monthly activity in their account. This feature does not affect customers on other billing models. To learn more, read Account usage metrics.
To use this feature, you must:
- Use a supported client-side SDK
- Configure your SDK to enable collection of these environment attributes
About the automatically added environment attributes
If you enable automatic environment attributes in the SDK client configuration, the SDK automatically adds additional contexts to each context that you evaluate. You can use attributes from these contexts in your targeting rules. These automatically added contexts include the following attributes: | Context kind | Context attribute | Description| Examples |
|---|
ld_application
| key
| Unique for this context kind. Automatically generated by the SDK. One of LaunchDarkly’s standard built-in attributes .
| randomly generated |
| id
| Unique identifier of the application.
| com.launchdarkly.example |
| locale
| Locale of the device, in IETF BCP 47 Language Tag format.
| en-US |
| name
| Human-friendly name of the application. One of LaunchDarkly’s standard built-in attributes .
| Example Mobile App |
| version
| Version of the application used for update comparison.
| 5 , 1.2.3 |
| versionName
| Human-friendly name of the version. May or may not be a semantic version.
| 5 , 1.2 |
| envAttributesVersion
| Version of the environment attributes schema being used. This may change in later versions of the SDK.
| 1.0 |
| ld_device
| key
| Unique for this context kind. Automatically generated by the SDK. May be regenerated in some cases, for example, if a customer uninstalls and then re-installs the application, or if a customer purchases a new device and doesn’t restore the device from their prior device’s backup. One of LaunchDarkly’s standard built-in attributes .
| randomly generated |
| manufacturer
| Manufacturer of the device.
| Google , Apple |
| model
| Model of the device.
| Pixel 6 Pro , iPhone , iPhone10,3 , iPad |
| os
| Operating system of the device. Includes properties for family , name , and version .
|
family:Android,Appleversion:13,16.2name:Android,Android33,iOS
envAttributesVersion
| Version of the environment attributes schema being used. This may change in later versions of the SDK.
| 1.0 |
If the SDK cannot determine the information for a particular attribute, it will not include that attribute. For example, if the SDK cannot determine the device’s model, it will not include the model attribute.
If the SDK can determine none of the information for an entire context, it will not include that context. For example, if you run the .NET (client-side) SDK on a desktop environment, the SDK cannot reliably get the device information. In this case the ld_device context is omitted.
Automatic environment attributes and application metadata configuration
If you are already setting application metadata as part of your SDK configuration, you can still use the environment attributes feature. Any application metadata that you set will override the automatically collected environment attributes. Specifically, if you enable automatic environment attributes, then theld_application context attributes are set based on the following priority order:
- If you set values for application id, name, version, or version name using application metadata configuration in the SDK, then the
ld_applicationcontext will reflect those values. - Otherwise, if you have set values for the application id, name, version, or version name within your mobile app, the
ld_applicationcontext will reflect those values. - Otherwise, the
ld_applicationcontext will use the LaunchDarkly SDK name and version.
Client-side SDKs
This feature is available in the following client-side SDKs:.NET (client-side)
Expand .NET (client-side) code sample
Expand .NET (client-side) code sample
This feature is available in v4 and later of the .NET (client-side) SDK.This code sample shows you how to configure the SDK to record environment attributes from an end user’s mobile device:To disable this option, pass in
After you upgrade from version 4 to version 5 of the LaunchDarkly .NET (client-side) SDK, the SDK returns different values for some of the environment attributes:
- For Android, the
ld_deviceattributeos/namenow returns only the name. For example, the version 5 SDK returnsAndroid, while the version 4 SDK returnsAndroid28or similar. Use theld_deviceattributeos/versionto access the version information. - For iOS, the
ld_deviceattributemodelnow returns model numbers in some cases. For example, the version 5 SDK returnsiPad5,2oriPhone10,3, while the version 4 SDK returnsiPadoriPhone. - For iOS, the
ld_applicationattributenameis populated as follows:ld_application.namereturns thenamethat you set using application metadata configuration in the SDK, if any.- If that is not set, then the version 5 SDK returns the
CFBundleDisplayNameif defined. Otherwise, it returns theCFBundleName. This is a change in behavior. The version 4 SDK always returns theCFBundleName. - If that is not set,
ld_application.namereturns the LaunchDarkly SDK name and version.
AutoEnvAttributes.Disabled instead.To learn more, read Configuration.Android
Expand Android code sample
Expand Android code sample
This feature is available in v5 and later of the Android SDK.This code sample shows you how to configure the SDK to record environment attributes from an end user’s mobile device:To learn more, read
LDConfig.Builder.Flutter
Expand Flutter code sample
Expand Flutter code sample
This feature is available in version 3 and later of the Flutter SDK.This code sample shows you how to configure the SDK to record environment attributes from an end user’s device:To learn more, read
LDConfig.iOS
Expand iOS code sample
Expand iOS code sample
This feature is available in v9 and later of the iOS SDK.This code sample shows you how to configure the SDK to record environment attributes from an end user’s mobile device:To learn more, read
LDConfig.React Native
Expand React Native code sample
Expand React Native code sample
This feature is available in v8 and later of the React Native SDK.This code sample shows you how to configure the SDK to record environment attributes from an end user’s mobile device:To learn more, read
ReactNativeLDClient.