OptionalallWhether all context attributes (except the context key) should be marked as private, and not sent to LaunchDarkly in analytics events.
By default, this is false.
OptionalapplicationInformation about the application where the LaunchDarkly SDK is running.
Optionalid?: stringA 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
Optionalversion?: stringA 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)
OptionalbaseThe base URL for the LaunchDarkly server.
Most users should use the default value.
OptionalbootstrapThe initial set of flags to use until the remote set is retrieved.
If "localStorage" is specified, the flags will be saved and retrieved from browser local
storage. Alternatively, an LDFlagSet can be specified which will be used as the initial
source of flag values. In the latter case, the flag values will be available via LDClient.variation
immediately after calling initialize() (normally they would not be available until the
client signals that it is ready).
For more information, see the SDK Reference Guide.
OptionaldiagnosticSet 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.
OptionaldiagnosticThe interval at which periodic diagnostic data is sent, in milliseconds.
The default is 900000 (every 15 minutes) and the minimum value is 6000. See diagnosticOptOut for more information on the diagnostics data being sent.
OptionaldisableIf set to true, this prevents the SDK from trying to use a synchronous HTTP request to deliver analytics events if the page is being closed. Not all browsers allow such requests; the SDK normally tries to avoid making them if not allowed, by using browser detection, but sometimes browser detection may not work so if you are seeing errors like "synchronous XHR request during page dismissal", you may want to set this option. Since currently the SDK does not have a better way to deliver events in this scenario, some events may be lost.
OptionalevaluationWhether 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.
OptionaleventThe 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.
OptionaleventsThe base URL for the LaunchDarkly events server.
Most users should use the default value.
OptionaleventA function which, if present, can change the URL in analytics events to something other
than the actual browser URL. It will be called with the current browser URL as a parameter,
and returns the value that should be stored in the event's url property.
OptionalfetchWhether the client should make a request to LaunchDarkly for Experimentation metrics (goals).
This is true by default, meaning that this request will be made on every page load. Set it to false if you are not using Experimentation and want to skip the request.
OptionalflushThe interval in between flushes of the analytics events queue, in milliseconds.
The default value is 2000ms.
OptionalhashThe signed context key for Secure Mode.
For more information, see the JavaScript SDK Reference Guide on Secure mode.
OptionalhooksInitial 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 { initialize } from 'launchdarkly-js-client-sdk';
import { TheHook } from '@launchdarkly/some-hook';
const client = init('my-sdk-key', { hooks: [new TheHook()] });
OptionalinspectorsInspectors can be used for collecting information for monitoring, analytics, and debugging.
OptionalloggerAn object that will perform logging for the client.
If not specified, the default is to use basicLogger.
OptionalpluginsA list of plugins to be used with the SDK.
Plugin support is currently experimental and subject to change.
OptionalprivateSpecifies 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".
OptionalrequestA transform function for dynamic configuration of HTTP headers.
This method will run last in the header generation sequence, so the function should have all system generated headers in case those also need to be modified.
OptionalsendWhether to send analytics events back to LaunchDarkly. By default, this is true.
OptionalsendWhether analytics events should be sent only when you call variation (true), or also when you call allFlags (false).
By default, this is false (events will be sent in both cases).
OptionalsendLDHeadersWhether or not to include custom HTTP headers when requesting flags from LaunchDarkly.
These are used to send metadata about the SDK (such as the version). They are also used to send the application.id and application.version set in the options.
This defaults to true (custom headers will be sent). One reason you might want to set it to false is that the presence of custom headers causes browsers to make an extra OPTIONS request (a CORS preflight check) before each flag request, which could affect performance.
OptionalstreamingWhether 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. If you leave the value undefined (the default), the client will open a streaming
connection if you subscribe to "change" or "change:flag-key" events (see LDClient.on).
This is equivalent to calling client.setStreaming() with the same value.
OptionalstreamHow long (in milliseconds) to wait after a failure of the stream connection before trying to reconnect.
This only applies if streaming has been enabled by setting streaming to true or
subscribing to "change" events. The default is 1000ms.
OptionalstreamThe base URL for the LaunchDarkly streaming server.
Most users should use the default value.
OptionaluseWhether 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 object.
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.
OptionalwrapperFor 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.
OptionalwrapperFor use by wrapper libraries to set version to be included alongside wrapperName.
If wrapperName is unset, this field will be ignored.
Initialization options for the LaunchDarkly browser SDK.