Options
All
  • Public
  • Public/Protected
  • All
Menu

LaunchDarkly Client-Side SDK for React Native (7.0.0)

This is the API reference for the LaunchDarkly Client-Side SDK for React Native.

In typical usage, you will instantiate LDClient and then call configure once at startup time to set up your connection to LaunchDarkly.

For more information, see the SDK reference guide.

Index

Type aliases

LDConfig: { allAttributesPrivate?: boolean; application?: { id?: string; name?: string; version?: string; versionName?: string }; backgroundPollingInterval?: number; connectionTimeout?: number; debugMode?: boolean; diagnosticOptOut?: boolean; diagnosticRecordingInterval?: number; disableBackgroundUpdating?: boolean; enableAutoEnvAttributes?: boolean; evaluationReasons?: boolean; eventCapacity?: number; eventsUrl?: string; flushInterval?: number; generateAnonymousKeysAndroid?: boolean; maxCachedContexts?: number; mobileKey: string; offline?: boolean; pollUrl?: string; pollingInterval?: number; privateAttributes?: string[]; secondaryMobileKeys?: Record<string, string>; stream?: boolean; streamUrl?: string; useReport?: boolean }

Configuration options for the LaunchDarkly React Native SDK.

Type declaration

  • Optional allAttributesPrivate?: boolean

    Whether to treat all context attributes as private for event reporting for all contexts. The SDK will not include private attribute values in analytics events, but private attribute names will be sent. The default is false.

  • Optional application?: { id?: string; name?: string; version?: string; versionName?: string }

    Information about the application where the LaunchDarkly SDK is running.

    • Optional id?: string

      A unique identifier representing the application where the LaunchDarkly SDK is running.

      This can be specified as any string value as long as it only uses the following characters: ASCII letters, ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.

      Example: authentication-service

    • Optional name?: string

      Sets a human friendly name for the application in which the LaunchDarkly SDK is running.

    • Optional version?: string

      A unique identifier representing the version of the application where the LaunchDarkly SDK is running.

      This can be specified as any string value as long as it only uses the following characters: ASCII letters, ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.

      Example: 1.0.0 (standard version string) or abcdef (sha prefix)

    • Optional versionName?: string

      Sets a human friendly name for the version of the application in which the LaunchDarkly SDK is running.

  • Optional backgroundPollingInterval?: number

    The interval by which the SDK polls for flag updates when the application is in the background.

    The default value is 3600000ms (1 hour).

  • Optional connectionTimeout?: number

    The timeout interval for connecting to LaunchDarkly for flag requests and event reports.

    The default value is 10000ms (10 seconds).

  • Optional debugMode?: boolean

    Controls information logged to the console, and modifying some setting ranges to facilitate debugging.

    This setting is only used when running in iOS. In Android this setting is ignored.

    The default value is false.

  • Optional diagnosticOptOut?: boolean

    Setting for whether sending diagnostic data about the SDK is disabled. The default is false.

  • Optional diagnosticRecordingInterval?: number

    The time interval between sending periodic diagnostic data. The default is 900000ms (15 minutes).

  • Optional disableBackgroundUpdating?: boolean

    Whether or not the SDK should attempt to check for flag updates while the application runs in the background.

    If this is true, the client will periodically poll for updates while in the background; if false, the SDK will not attempt to receive updates while the app is backgrounded.

    The default value is false.

  • Optional enableAutoEnvAttributes?: boolean

    When enabled the SDK will automatically send data about the mobile environment to LaunchDarkly.

    The default value is false (the SDK will not send mobile environment data).

  • Optional evaluationReasons?: boolean

    Whether LaunchDarkly should provide additional information about how flag values were calculated.

    The additional information will then be available through the client's LDClient.*VariationDetail methods. Since this increases the size of network requests, such information is not sent unless you set this option to true.

  • Optional eventCapacity?: number

    The capacity of the analytics events queue.

    The client buffers up to this many events in memory before flushing. If the capacity is exceeded before the queue is flushed, events will be discarded. Increasing the capacity means that events are less likely to be discarded, at the cost of consuming more memory. Note that in regular usage flag evaluations do not produce individual events, only summary counts, so you only need a large capacity if you are generating a large number of click, pageview, or identify events (or if you are using the event debugger).

    The default value is 100.

  • Optional eventsUrl?: string

    The base URI for the LaunchDarkly events server.

    Most customers should use the default value.

  • Optional flushInterval?: number

    The interval in between flushes of the analytics events queue, in milliseconds.

    The default value is 30000ms (30 seconds).

  • Optional generateAnonymousKeysAndroid?: boolean

    Android only.

    Set to true to make the SDK provide unique keys for anonymous contexts. Read more at https://launchdarkly.github.io/android-client-sdk/com/launchdarkly/sdk/android/LDConfig.Builder.html#generateAnonymousKeys(boolean).

    The default is true.

  • Optional maxCachedContexts?: number

    Setting for the maximum number of locally cached contexts. Default is 5 contexts.

  • mobileKey: string

    The mobile SDK key associated with your LaunchDarkly environment.

    This field is required as the React Native SDK will use this value to uniquely identify your LaunchDarkly account.

  • Optional offline?: boolean

    Disables all network calls from the LaunchDarkly SDK.

    This can also be specified after the client has been created, using LDClient.setOffline().

    The default value is false (the client will make network calls).

  • Optional pollUrl?: string

    The base URI for the LaunchDarkly polling server.

    Most customers should use the default value.

  • Optional pollingInterval?: number

    The interval by which the SDK polls for flag updates when the application is in the foreground. This property is only used if is the streaming connection is disabled.

    The default value is 300000ms (5 min).

  • Optional privateAttributes?: string[]

    The names of context attributes that should be marked as private, and not sent to LaunchDarkly in analytics events.

    You can also specify this on a per-context basis with {@link LDContextMeta.privateAttributes}

  • Optional secondaryMobileKeys?: Record<string, string>

    The mapping of environment names as keys to mobile keys for each environment as values.

  • Optional stream?: boolean

    Whether or not to open a streaming connection to LaunchDarkly for live flag updates.

    If this is true, the client will always attempt to maintain a streaming connection; if false, it never will.

    The default value is true.

  • Optional streamUrl?: string

    The base URI for the LaunchDarkly streaming server.

    Most customers should use the default value.

  • Optional useReport?: boolean

    Whether or not to use the REPORT verb to fetch flag settings.

    If this is true, flag settings will be fetched with a REPORT request including a JSON entity body with the context.

    Otherwise (by default) a GET request will be issued with the context passed as a base64 URL-encoded path parameter.

    Do not use unless advised by LaunchDarkly.

LDEvaluationDetail<T>: { reason: LDEvaluationReason; value: T; variationIndex?: number }

An object that combines the result of a feature flag evaluation with information about how it was calculated.

This is the result of calling one of the LDClient.*VariationDetail methods.

For more information, see the documentation.

Type parameters

  • T

    The type of flag being evaluated.

Type declaration

  • reason: LDEvaluationReason

    An object describing the main factor that influenced the flag evaluation value.

  • value: T

    The result of the flag evaluation. This will be either one of the flag's variations or the default value that was passed to the variation detail function.

  • Optional variationIndex?: number

    The index of the returned value within the flag's list of variations, e.g. 0 for the first variation-- or null if the default value was returned.

Describes the reason that a flag evaluation produced a particular value. This is part of the LDEvaluationDetail object returned by the variation detail methods.

LDEvaluationReasonError: { errorKind: LDEvaluationReasonErrorKind; kind: "ERROR" }

The flag could not be evaluated, so the default value was returned.

Type declaration

  • errorKind: LDEvaluationReasonErrorKind

    The kind of error which occurred.

    Kinds of errors include:

    • 'CLIENT_NOT_READY': The client is not able to establish a connection to LaunchDarkly yet. If there is a persistent feature store, the store does not yet contain flag data.
    • 'FLAG_NOT_FOUND': The flag key did not match any known flag.
    • 'USER_NOT_SPECIFIED': The user object or user key was not provided.
    • 'MALFORMED_FLAG': There was an internal inconsistency in the flag data. For example, a rule specified a nonexistent variation. This is an unusual condition that might require assistance from LaunchDarkly's Support team.
    • 'WRONG_TYPE': The application code requested the flag value with a different data type than it actually is. For example, the code asked for a boolean when the flag type is actually a string.
    • 'EXCEPTION': An unexpected error stopped flag evaluation. This could happen if you are using a persistent feature store and the database stops working. When this happens, the SDK always prints the specific error to the log.
  • kind: "ERROR"
LDEvaluationReasonFallthrough: { kind: "FALLTHROUGH" }

The flag is on, but the context did not match any targets or rules, so it returned the value that appears on the dashboard under "Default rule."

Type declaration

  • kind: "FALLTHROUGH"
LDEvaluationReasonOff: { kind: "OFF" }

The flag is off and therefore returned its configured off value.

Type declaration

  • kind: "OFF"
LDEvaluationReasonPrerequisiteFailed: { kind: "PREREQUISITE_FAILED"; prerequisiteKey: string }

The flag had at least one prerequisite flag that either was off or did not return the desired variation. Because of this, the flag returned its "off" value.

Type declaration

  • kind: "PREREQUISITE_FAILED"
  • prerequisiteKey: string

    The key of the prerequisite flag that failed.

LDEvaluationReasonRuleMatch: { kind: "RULE_MATCH"; ruleId: string; ruleIndex: number }

The context who encountered the flag matched one of the flag's rules.

Type declaration

  • kind: "RULE_MATCH"
  • ruleId: string

    The rule's unique identifier, which stays the same even if you rearrange the order of the rules.

  • ruleIndex: number

    The positional index of the matched rule (0 for the first rule).

LDEvaluationReasonTargetMatch: { kind: "TARGET_MATCH" }

The context key was specifically targeted for this flag in the "Target individual contexts" section.

Type declaration

  • kind: "TARGET_MATCH"

Generated using TypeDoc