Returns a map of all available flags to the current context's values.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing an object in which each key is a feature flag key and each value is the flag value.
Note that there is no way to specify a default value for each flag as there is with the
*Variation
methods, so any flag that cannot be evaluated will have a null value.
Determines the variation of a boolean feature flag for the current context.
The unique key of the feature flag.
The default value of the flag, to be used if the value is not available from LaunchDarkly.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing the flag's value.
Determines the variation of a boolean feature flag for a context, along with information about how it was calculated.
Note that this will only work if you have set evaluationReasons
to true in LDConfig.
Otherwise, the reason
property of the result will be null.
For more information, see the SDK reference guide.
The unique key of the feature flag.
The default value of the flag, to be used if the value is not available from LaunchDarkly.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing an LDEvaluationDetail object containing the value and explanation.
Shuts down the client and releases its resources, after delivering any pending analytics
events. After the client is closed, all calls to the *Variation
methods will return default values,
and it will not make any requests to LaunchDarkly.
Initialize the SDK to work with the specified client configuration options and on behalf of the specified context. Will block for a number of seconds represented until flags are received from LaunchDarkly if the timeout parameter is passed.
This should only be called once at application start time.
the client configuration options
the LDContext object
(Optional) A number representing how long to wait for flags
Flushes all pending analytics events.
Normally, batches of events are delivered in the background at intervals determined by the
flushInterval
property of LDConfig. Calling flush
triggers an
immediate delivery.
Returns the current state of the connection to LaunchDarkly.
States include:
'STREAMING'
: The SDK is either connected to the flag stream, or is actively attempting to acquire a connection.'POLLING'
: The SDK was configured with streaming disabled, and is in foreground polling mode.'BACKGROUND_POLLING'
: (Android specific enum value) The SDK has detected the application is in the background and has transitioned to battery conscious background polling.'BACKGROUND_DISABLED'
: (Android specific enum value) The SDK was configured with background polling disabled. The SDK has detected the application is in the background and is not attempting to update the flag cache.'OFFLINE'
: The SDK has detected that the mobile device does not have an active network connection so has ceased flag update attempts until the network status changes.'SET_OFFLINE'
: (Android specific enum value) The SDK has been explicitly set offline, either in the initial configuration, by setOffline(), or as a result of failed authentication to LaunchDarkly. The SDK will stay offline unless setOnline() is called.'SHUTDOWN'
: (Android specific enum value) The shutdown state indicates the SDK has been permanently shutdown as a result of a call to close().'ESTABLISHING_STREAMING_CONNECTION'
: (iOS specific enum value) The SDK is attempting to connect to LaunchDarkly by streaming.Optional string to execute the function in a different environment than the default.
A promise containing a LDConnectionMode enum value representing the status of the connection to LaunchDarkly.
Most recent unsuccessful flag cache update attempt in millis from the epoch or null if flag update has never been attempted.
Optional string to execute the function in a different environment than the default.
A promise containing a number representing the status of the connection to LaunchDarkly, or null if a failed connection has yet to occur.
Returns the most recent connection failure reason or null.
Reasons include:
'NONE'
: This indicates when no error has been recorded.'UNKNOWN_ERROR'
: This indicates when there is an internal error in the stream request.'UNAUTHORIZED'
: (iOS specific enum value) This indicates when an incorrect mobile key is provided.'HTTP_ERROR'
: (iOS specific enum value) This indicates when an error with an HTTP error code is present.'UNEXPECTED_RESPONSE_CODE'
: (Android specific enum value) This indicates the LDFailure is an instance of LDInvalidResponseCodeFailure. See Android documentation for more details.'UNEXPECTED_STREAM_ELEMENT_TYPE'
: (Android specific enum value) An event was received through the stream was had an unknown event name. This could indicate a newer SDK is available if new event types have become available through the flag stream since the SDKs release.'NETWORK_FAILURE'
: (Android specific enum value) A network request for polling, or the EventSource stream reported a failure.'INVALID_RESPONSE_BODY'
: (Android specific enum value) A response body received either through polling or streaming was unable to be parsed.Optional string to execute the function in a different environment than the default.
A promise containing a LDFailureReason enum value representing the reason for the most recently failed connection to LaunchDarkly, or null if a failed connection has yet to occur.
Returns the most recent successful flag cache update in millis from the epoch or null if flags have never been retrieved.
Optional string to execute the function in a different environment than the default.
A promise containing a number representing the status of the connection to LaunchDarkly, or null if a successful connection has yet to be established.
Returns the SDK version.
A string containing the SDK version.
Sets the current context, retrieves flags for that context, then sends an Identify Event to LaunchDarkly.
The LDContext for evaluation and event reporting
A promise indicating when this operation is complete (meaning that flags are ready for evaluation).
Checks whether the client is ready to return feature flag values. This is true if either the client has successfully connected to LaunchDarkly and received feature flags, or the client has been put into offline mode (in which case it will return only default flag values).
This function will return a rejected promise in case the client has not been initialized.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing true if the client is initialized or offline, otherwise a rejected promise
Checks whether the client has been put into offline mode. This is true only if setOffline was called, or if the configuration had [[LDConfig.offline]] set to true, not if the client is simply offline due to a loss of network connectivity.
A promise containing true if the client is in offline mode
Determines the variation of a JSON feature flag for the current context.
The unique key of the feature flag.
The default value of the flag, to be used if the value is not available from LaunchDarkly.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing the flag's value.
Determines the variation of a JSON feature flag for a context, along with information about how it was calculated.
Note that this will only work if you have set evaluationReasons
to true in LDConfig.
Otherwise, the reason
property of the result will be null.
For more information, see the SDK reference guide.
The unique key of the feature flag.
The default value of the flag, to be used if the value is not available from LaunchDarkly.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing an LDEvaluationDetail object containing the value and explanation.
Determines the variation of a numeric feature flag for the current context.
The unique key of the feature flag.
The default value of the flag, to be used if the value is not available from LaunchDarkly.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing the flag's value.
Determines the variation of a numeric feature flag for a context, along with information about how it was calculated.
Note that this will only work if you have set evaluationReasons
to true in LDConfig.
Otherwise, the reason
property of the result will be null.
For more information, see the SDK reference guide.
The unique key of the feature flag.
The default value of the flag, to be used if the value is not available from LaunchDarkly.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing an LDEvaluationDetail object containing the value and explanation.
Registers a callback to be called when a flag update is processed by the SDK.
The listener to be called when a flag update is processed
The callback to attach to the flag update
Optional string to execute the function in a different environment than the default.
Registers a callback to be called on connection status updates.
The listener to be called on a connection status update
The callback to attach to the connection status update
Optional string to execute the function in a different environment than the default.
Registers a callback to be called when the flag with key flagKey
changes from its current value.
The flag key to attach the callback to
The callback to attach to the flag key
Optional string to execute the function in a different environment than the default.
Shuts down any network connections maintained by the client and puts the client in offline mode, preventing the client from opening new network connections until setOnline is called.
Note: The client automatically monitors the device's network connectivity and app foreground status, so calling setOffline or setOnline is normally unnecessary in most situations.
A promise containing true if the change was made successfully
Restores network connectivity for the client, if the client was previously in offline mode. This operation may be throttled if it is called too frequently.
Note: The client automatically monitors the device's network connectivity and app foreground status, so calling setOffline or setOnline is normally unnecessary in most situations.
A promise containing true if the change was made successfully
Determines the variation of a string feature flag for the current context.
The unique key of the feature flag.
The default value of the flag, to be used if the value is not available from LaunchDarkly.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing the flag's value.
Determines the variation of a string feature flag for a context, along with information about how it was calculated.
Note that this will only work if you have set evaluationReasons
to true in LDConfig.
Otherwise, the reason
property of the result will be null.
For more information, see the SDK reference guide.
The unique key of the feature flag.
The default value of the flag, to be used if the value is not available from LaunchDarkly.
Optional environment name to obtain the result from the corresponding secondary environment
A promise containing an LDEvaluationDetail object containing the value and explanation.
Track events to use in metrics or Experimentation.
The name of the event, which may correspond to a metric in experiments.
Optional additional information to associate with the event.
Optional numeric value to attach to the tracked event
Optional string to execute the function in a different environment than the default.
Unregisters a callback so it will no longer be called on flag updates.
The listener to be removed
Optional string to execute the function in a different environment than the default.
Unregisters a callback so that it will no longer be called on connection status updates.
The listener to remove the callback from
Optional string to execute the function in a different environment than the default.
Unregisters a callback for the flag with key flagKey
.
The flag key to remove the callback from
The callback to remove from the flag key
Optional string to execute the function in a different environment than the default.
Generated using TypeDoc
The LaunchDarkly SDK client object.
Applications should configure the client at application startup time and reuse the same instance.
For more information, see the SDK Reference Guide.