• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
    No results for ""
    EXPAND ALL

    EDIT ON GITHUB

    Application metadata configuration

    Read time: 3 minutes
    Last edited: Mar 16, 2023

    Overview

    This topic explains how to configure LaunchDarkly SDKs to send application metadata to LaunchDarkly. This feature is available for both client-side and server-side SDKs.

    Newer versions of LaunchDarkly SDKs replace users with contexts

    A context is a generalized way of referring to the people, services, machines, or other resources that encounter feature flags in your product. Contexts replace another data object in LaunchDarkly: "users." To learn more, read Contexts and segments.

    Creating contexts and evaluating flags based on them is supported in the latest major versions of most of our SDKs. For these SDKs, the code samples on this page include the two most recent versions.

    Customizing application identifiers and application versions

    Some LaunchDarkly SDKs support application identifier and application version configuration options. These options allow you to send this application metadata to LaunchDarkly. The metadata will appear in the "From source" field on Context details pages. To learn more, read The context details page.

    You can also use this metadata for configuring the Accelerate product offering. To learn more, read Getting started with Accelerate.

    For the SDKs that support this feature, you can send the following metadata:

    • Application identifier (string): A unique identifier representing the application where the LaunchDarkly SDK is running. The value can use only alphanumeric characters and hyphens -, periods ., and underscores _. For example, authentication-service.
    • Application version (string): A unique identifier representing the version of the application where the LaunchDarkly SDK is running. The value can use only alphanumeric characters and hyphens -, periods ., and underscores _. For example, you could set this to the semantic version of your application, such as 1.0.0. If you are using Accelerate, we recommend setting the application version to the full secure hash algorithm (SHA) of the GitHub commit for this deployment, such as a12bcde3f45ab6c789123456d78efabcde91234f, or to the tag associated with the GitHub commit for this deployment.

    You can set these values when you configure the SDK. All connections to LaunchDarkly from a client will send the same value to LaunchDarkly, whether the connection is through streaming, polling, or events. You cannot change the value after you configure the client.

    Configuring application metadata for Accelerate

    Accelerate is for Early Access Program customers only

    Accelerate is only available to members of LaunchDarkly's Early Access Program (EAP). If you want access to this feature, join the EAP.

    Configuring your application metadata to send deployment information lets Accelerate track the frequency and timing of your deployments. If you set the application version to a deployment SHA or tag from GitHub, Accelerate will also track which commits and pull requests are in your deployment.

    To learn how to retrieve the SHA for your deployment, read Configure your application to send deployment information.

    Details about each SDK's configuration are available in the SDK-specific sections below:

    Client-side SDKs

    This feature is available in the following client-side SDKs:

    Android

    Expand Android code sample

    This code sample shows you how to configure the application identifier and application version:

    LDConfig config = new LDConfig.Builder()
    .applicationInfo(
    Components.applicationInfo()
    .applicationId("authentication-service")
    .applicationVersion("1.0.0")
    )
    .build();

    To learn more, read ApplicationInfoBuilder.

    iOS

    Expand iOS code sample

    This code sample shows you how to configure the application identifier and application version:

    var applicationInfo = ApplicationInfo()
    applicationInfo.applicationIdentifier("authentication-service")
    applicationInfo.applicationVersion("1.0.0")
    var config = LDConfig(mobileKey: mobileKey)
    config.applicationInfo = applicationInfo

    To learn more about the specific configuration options that are available in this SDK, read the SDK's API docs.

    JavaScript

    Expand JavaScript code sample

    This code sample shows you how to configure the application identifier and application version:

    const options = {
    application: {
    id: 'authentication-service',
    version: '1.0.0',
    },
    };
    const client = LDClient.initialize('client-side-id-123abc', context, options);

    To learn more about the specific configuration options that are available in this SDK, read the LDOptions.

    Node.js (client-side)

    Expand Node.js (client-side) code sample

    This code sample shows you how to configure the application identifier and application version:

    const options = {
    application: {
    id: "authentication-service",
    version: "1.0.0"
    }
    };
    const client = LDClient.initialize('client-side-id-123abc', context, options);

    To learn more, read application.

    React Native

    Expand React Native code sample

    This code sample shows you how to configure the application identifier and application version:

    let client = new LDClient();
    let config = {
    mobileKey: 'mobile-key-123abc',
    application: {
    id: 'authentication-service',
    version: '1.0.0',
    },
    };
    let context = { key: 'user-key-123abc', 'kind': 'user' };
    await ldClient.configure(config, context);

    To learn more about the specific configuration options that are available in this SDK, read the LDConfig.

    Server-side SDKs

    This feature is available for the following server-side SDKs:

    Erlang

    Expand Erlang code sample

    This code sample shows you how to configure the application identifier and application version:

    ldclient:start_instance("sdk-key-123abc", #{
    application => #{
    id => <<"authentication-service">>,
    version => <<"1.0.0">>
    }
    })

    For a complete list of configuration options, read the documentation for the ldclient_config module.

    Go

    Expand Go code sample

    The code in this sample configures the application identifier and application version:

    var config ld.Config
    config.ApplicationInfo.ApplicationID = "authentication-service"
    config.ApplicationInfo.ApplicationVersion = "1.0.0"

    To learn more about the configuration options, read Config.

    Java

    Expand Java code sample

    This code sample shows you how to configure the application identifier and application version:

    LDConfig config = new LDConfig.Builder()
    .applicationInfo(
    Components.applicationInfo()
    .applicationId("authentication-service")
    .applicationVersion("1.0.0")
    ).build();

    For a complete list of configuration options for the client, including proxy settings, timeouts, and streaming/polling options, read the Javadoc for LDConfig.Builder.

    Haskell

    Expand Haskell code sample

    This code sample shows you how to pass custom parameters to the client by creating a custom configuration object.

    The code in this sample configures the application identifier and application version:

    {-# LANGUAGE OverloadedStrings #-}
    import LaunchDarkly.Server.Config
    import Data.Function ((&))
    config :: Config
    config = makeConfig "sdk-key-123abc" & configSetApplicationInfo appInfo
    where appInfo = makeApplicationInfo
    & withApplicationValue "id" "authentication-service"
    & withApplicationValue "version" "1.0.0"

    Node.js (server-side)

    Expand Node.js (server-side) code sample

    This code sample shows you how to configure the application identifier and application version:

    var options = {
    application: {
    id: 'authentication-service',
    version: '1.0.0'
    }
    };
    client = ld.init('sdk-key-123abc', options);

    To learn more about the specific configuration options that are available in this SDK, read the SDK's API docs.

    PHP

    Expand PHP code sample

    This code sample shows you how to configure the application identifier and application version:

    $appInfo = (new ApplicationInfo())->withId('authentication-service')->withVersion('1.0.0');
    $config = [
    "application_info" => $appInfo
    ];
    $client = new LaunchDarkly\LDClient("sdk-key-123abc", $config);

    To learn more, read ApplicationInfo. For a complete list of configuration options, read the documentation for the LDClient constructor.

    Python

    Expand Python code sample

    This code sample shows you how to configure the application identifier and application version:

    config = Config(sdk_key='sdk-key-123abc',
    application = {"id": "authentication-service", "version": "1.0.0"})
    ldclient.set_config(config)

    To learn more, read application. For a complete list of configuration options, read the documentation for the ldclient.config module.

    Ruby

    Expand Ruby code sample

    This code sample shows you how to configure the application identifier and application version:

    LaunchDarkly::Config.new({
    application: {
    id: "authentication-service",
    version: "abc123def456"
    }
    })

    To learn more about the specific configuration options that are available in this SDK, read the SDK's API docs.

    Rust

    Expand Rust code sample

    This code sample shows you how to configure the application identifier and application version:

    let mut application_info = ApplicationInfo::new();
    application_info
    .application_identifier("authentication-service")
    .application_version("1.0.0");
    let config = ConfigBuilder::new(&sdk_key)
    .application_info(application_info)
    .build();

    The Config type lets you specify a variety of options. To learn more about the specific configuration options that are available in this SDK, read the SDK's API docs.