@launchdarkly/js-client-sdk-common - v1.35.0
    Preparing search index...

    Interface LDOptions

    interface LDOptions {
        allAttributesPrivate?: boolean;
        applicationInfo?: {
            id?: string;
            name?: string;
            version?: string;
            versionName?: string;
        };
        baseUri?: string;
        capacity?: number;
        cleanOldPersistentData?: boolean;
        dataSystem?: LDClientDataSystemOptions;
        debug?: boolean;
        diagnosticOptOut?: boolean;
        diagnosticRecordingInterval?: number;
        disableCache?: boolean;
        eventsUri?: string;
        flushInterval?: number;
        hooks?: Hook[];
        inspectors?: LDInspection[];
        logger?: LDLogger;
        maxCachedContexts?: number;
        payloadFilterKey?: string;
        pollInterval?: number;
        privateAttributes?: string[];
        sendEvents?: boolean;
        streamInitialReconnectDelay?: number;
        streamUri?: string;
        usePost?: boolean;
        useReport?: boolean;
        withReasons?: boolean;
        wrapperName?: string;
        wrapperVersion?: string;
    }
    Index
    allAttributesPrivate?: boolean

    Whether all context attributes (except the context key) should be marked as private, and not sent to LaunchDarkly in analytics events.

    false.
    
    applicationInfo?: {
        id?: string;
        name?: string;
        version?: string;
        versionName?: string;
    }

    Information about the application the LaunchDarkly SDK is running in.

    These properties are optional and informational. They may be used in LaunchDarkly analytics or other product features.

    Type Declaration

    • Optionalid?: 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

    • Optionalname?: string

      A human-friendly application name 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.

    • Optionalversion?: 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)

    • OptionalversionName?: string

      A human-friendly name 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.

    baseUri?: string

    The base uri for the LaunchDarkly server. Most users should use the default value.

    https://clientsdk.launchdarkly.com.
    
    capacity?: 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).

    100.
    
    cleanOldPersistentData?: boolean

    Whether to clean old persistent data. If set to true, the SDK will check to see if old there are any persistent data that is generated by an older version and remove it.

    false.
    

    Configuration for the FDv2 data system. When present, the SDK uses the FDv2 protocol for flag delivery instead of the default FDv1 protocol.

    This option is not stable, and not subject to any backwards compatibility guarantees or semantic versioning. It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode

    debug?: boolean

    Enables debug logging.

    false.
    
    diagnosticOptOut?: boolean

    Set to true to opt out of sending diagnostics data.

    Unless diagnosticOptOut is set to true, the client will send some diagnostics data to the LaunchDarkly servers in order to assist in the development of future SDK improvements. These diagnostics consist of an initial payload containing some details of SDK in use, the SDK's configuration, and the platform the SDK is being run on, as well as payloads sent periodically with information on irregular occurrences such as dropped events.

    false.
    
    diagnosticRecordingInterval?: number

    The interval at which periodic diagnostic data is sent, in seconds.

    The default is 900 (every 15 minutes) and the minimum value is 6. See diagnosticOptOut for more information on the diagnostics data being sent.

    900s.
    
    disableCache?: boolean

    Set to true to suppress all reads and writes to the persistent flag cache in local storage.

    Unlike setting LDOptions.maxCachedContexts to 0, this does not remove previously cached data. Existing entries are left intact. This takes precedence over maxCachedContexts.

    false
    
    eventsUri?: string

    The base uri for the LaunchDarkly events server. Most users should use the default value.

    https://events.launchdarkly.com.
    
    flushInterval?: number

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

    2s for browser implementations 30s for others.
    
    hooks?: Hook[]

    Initial set of hooks for the client.

    Hooks provide entrypoints which allow for observation of SDK functions.

    LaunchDarkly provides integration packages, and most applications will not need to implement their own hooks. Refer to the @launchdarkly/node-server-sdk-otel for instrumentation for the @launchdarkly/node-server-sdk.

    Example:

    import { init } from '@launchdarkly/node-server-sdk';
    import { TheHook } from '@launchdarkly/some-hook';

    const client = init('my-sdk-key', { hooks: [new TheHook()] });
    inspectors?: LDInspection[]

    Inspectors can be used for collecting information for monitoring, analytics, and debugging.

    Hooks should be used instead of inspectors and inspectors will be removed in a future version. If you need functionality that is not exposed using hooks, then please let us know through a github issue or support.

    logger?: LDLogger

    An object that will perform logging for the client.

    Set a custom LDLogger if you want full control of logging behavior.

    The default logging implementation will vary based on platform. For the browser the default logger will log "info" level and higher priority messages and it will log messages to console.info, console.warn, and console.error. Other platforms may use a BasicLogger instance also defaulted to the "info" level.

    maxCachedContexts?: number

    The maximum number of locally cached contexts. The cache is used to decrease initialization latency and to provide fallback flag values when the SDK cannot reach LaunchDarkly services.

    Setting this to 0 disables caching entirely: the SDK will not read from or write to the cache, and any previously cached entries will be pruned from local storage.

    To suppress cache read/writes without removing existing cached data, use LDOptions.disableCache instead.

    5
    
    payloadFilterKey?: string

    LaunchDarkly Server SDKs historically downloaded all flag configuration and segments for a particular environment during initialization.

    For some customers, this is an unacceptably large amount of data, and has contributed to performance issues within their products.

    Filtered environments aim to solve this problem. By allowing customers to specify subsets of an environment's flags using a filter key, SDKs will initialize faster and use less memory.

    This payload filter key only applies to the default streaming and polling data sources. It will not affect TestData or FileData data sources, nor will it be applied to any data source provided through the featureStore config property.

    Payload filtering is not supported with the FDv2 data system, so this key has no effect on requests made by FDv2 data sources.

    pollInterval?: number

    The time between polling requests, in seconds. Ignored in streaming mode.

    The minimum polling interval is 30 seconds.

    privateAttributes?: string[]

    Specifies a list of attribute names (either built-in or custom) which should be marked as private, and not sent to LaunchDarkly in analytics events. You can also specify this on a per-context basis with LDContextMeta.privateAttributes.

    Any contexts sent to LaunchDarkly with this configuration active will have attributes with these names removed in analytic events. This is in addition to any attributes that were marked as private for an individual context with LDContextMeta.privateAttributes. Setting LDOptions.allAttributesPrivate to true overrides this.

    If and only if a parameter starts with a slash, it is interpreted as a slash-delimited path that can denote a nested property within a JSON object. For instance, "/address/street" means that if there is an attribute called "address" that is a JSON object, and one of the object's properties is "street", the "street" property will be redacted from the analytics data but other properties within "address" will still be sent. This syntax also uses the JSON Pointer convention of escaping a literal slash character as "~1" and a tilde as "~0".

    sendEvents?: boolean

    Whether to send analytics events back to LaunchDarkly.

    true.
    
    streamInitialReconnectDelay?: number

    Sets the initial reconnect delay for the streaming connection, in seconds.

    The streaming service uses a backoff algorithm (with jitter) every time the connection needs to be reestablished. The delay for the first reconnection will start near this value, and then increase exponentially for any subsequent connection failures.

    1s.
    
    streamUri?: string

    The base uri for the LaunchDarkly streaming server. Most users should use the default value.

    https://clientstream.launchdarkly.com.
    
    usePost?: boolean

    Directs the SDK to use the POST method, with the evaluation context in the request body, for polling and streaming requests instead of GET with the context encoded in the URL path.

    false

    This option only takes effect when the dataSystem option is also configured.

    For streaming specifically, this also requires an EventSource implementation that supports a custom HTTP method (the customMethod capability). Without that capability, streaming requests use GET, polling requests still use POST, and the SDK logs a warning.

    If the data system falls back to the legacy polling endpoints, this option directs those requests to use the REPORT method, so the context stays in the request body instead of the URL.

    This is not stable, and not subject to any backwards compatibility guarantees or semantic versioning. It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode

    useReport?: boolean

    Directs the SDK to use the REPORT method for HTTP requests instead of GET. (Default: false)

    This setting applies both to requests to the streaming service, as well as flag requests when the SDK is in polling mode.

    This option only applies to the legacy (non-dataSystem) data source. If the dataSystem option is also configured, this option has no effect and a warning is logged -- use usePost instead.

    withReasons?: 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 method. Since this increases the size of network requests, such information is not sent unless you set this option to true.

    false.
    
    wrapperName?: string

    For use by wrapper libraries to set an identifying name for the wrapper being used.

    This will be sent as diagnostic information to the LaunchDarkly servers to allow recording metrics on the usage of these wrapper libraries.

    wrapperVersion?: string

    For use by wrapper libraries to set version to be included alongside wrapperName.

    If wrapperName is unset, this field will be ignored.