| Modifier and Type | Method and Description |
|---|---|
FeatureFlagsState |
allFlagsState(LDUser user,
FlagsStateOption... options)
Returns an object that encapsulates the state of all feature flags for a given user, including the flag
values and also metadata that can be used on the front end.
|
boolean |
boolVariation(java.lang.String featureKey,
LDUser user,
boolean defaultValue)
Calculates the value of a feature flag for a given user.
|
EvaluationDetail<java.lang.Boolean> |
boolVariationDetail(java.lang.String featureKey,
LDUser user,
boolean defaultValue)
Calculates the value of a feature flag for a given user, and returns an object that describes the
way the value was determined.
|
void |
close()
Closes the LaunchDarkly client event processing thread.
|
java.lang.Double |
doubleVariation(java.lang.String featureKey,
LDUser user,
java.lang.Double defaultValue)
Calculates the floating point numeric value of a feature flag for a given user.
|
EvaluationDetail<java.lang.Double> |
doubleVariationDetail(java.lang.String featureKey,
LDUser user,
double defaultValue)
Calculates the value of a feature flag for a given user, and returns an object that describes the
way the value was determined.
|
void |
flush()
Flushes all pending events.
|
DataSourceStatusProvider |
getDataSourceStatusProvider()
Returns an interface for tracking the status of the data source.
|
DataStoreStatusProvider |
getDataStoreStatusProvider()
Returns an interface for tracking the status of a persistent data store.
|
void |
identify(LDUser user)
Registers the user.
|
boolean |
initialized()
Tests whether the client is ready to be used.
|
java.lang.Integer |
intVariation(java.lang.String featureKey,
LDUser user,
int defaultValue)
Calculates the integer value of a feature flag for a given user.
|
EvaluationDetail<java.lang.Integer> |
intVariationDetail(java.lang.String featureKey,
LDUser user,
int defaultValue)
Calculates the value of a feature flag for a given user, and returns an object that describes the
way the value was determined.
|
boolean |
isFlagKnown(java.lang.String featureKey)
Returns true if the specified feature flag currently exists.
|
boolean |
isOffline()
Returns true if the client is in offline mode.
|
LDValue |
jsonValueVariation(java.lang.String featureKey,
LDUser user,
LDValue defaultValue)
Calculates the
LDValue value of a feature flag for a given user. |
EvaluationDetail<LDValue> |
jsonValueVariationDetail(java.lang.String featureKey,
LDUser user,
LDValue defaultValue)
Calculates the
LDValue value of a feature flag for a given user. |
void |
registerFlagChangeListener(FlagChangeListener listener)
Registers a listener to be notified of feature flag changes.
|
java.lang.String |
secureModeHash(LDUser user)
For more info: https://github.com/launchdarkly/js-client#secure-mode
|
java.lang.String |
stringVariation(java.lang.String featureKey,
LDUser user,
java.lang.String defaultValue)
Calculates the String value of a feature flag for a given user.
|
EvaluationDetail<java.lang.String> |
stringVariationDetail(java.lang.String featureKey,
LDUser user,
java.lang.String defaultValue)
Calculates the value of a feature flag for a given user, and returns an object that describes the
way the value was determined.
|
void |
track(java.lang.String eventName,
LDUser user)
Tracks that a user performed an event.
|
void |
trackData(java.lang.String eventName,
LDUser user,
LDValue data)
Tracks that a user performed an event, and provides additional custom data.
|
void |
trackMetric(java.lang.String eventName,
LDUser user,
LDValue data,
double metricValue)
Tracks that a user performed an event, and provides an additional numeric value for custom metrics.
|
void |
unregisterFlagChangeListener(FlagChangeListener listener)
Unregisters a listener so that it will no longer be notified of feature flag changes.
|
java.lang.String |
version()
The current version string of the SDK.
|
boolean initialized()
void track(java.lang.String eventName,
LDUser user)
To add custom data to the event, use trackData(String, LDUser, LDValue).
eventName - the name of the eventuser - the user that performed the eventvoid trackData(java.lang.String eventName,
LDUser user,
LDValue data)
eventName - the name of the eventuser - the user that performed the eventdata - an LDValue containing additional data associated with the eventvoid trackMetric(java.lang.String eventName,
LDUser user,
LDValue data,
double metricValue)
As of this version’s release date, the LaunchDarkly service does not support the metricValue
parameter. As a result, calling this overload of track will not yet produce any different
behavior from calling trackData(String, LDUser, LDValue) without a metricValue.
Refer to the SDK reference guide for the latest status.
eventName - the name of the eventuser - the user that performed the eventdata - an LDValue containing additional data associated with the event; if not applicable,
you may pass either null or LDValue.ofNull()metricValue - a numeric value used by the LaunchDarkly experimentation feature in numeric custom
metrics. Can be omitted if this event is used by only non-numeric metrics. This field will also be
returned as part of the custom event for Data Export.void identify(LDUser user)
user - the user to registerFeatureFlagsState allFlagsState(LDUser user, FlagsStateOption... options)
The most common use case for this method is to bootstrap a set of client-side feature flags from a back-end service.
user - the end user requesting the feature flagsoptions - optional FlagsStateOption values affecting how the state is computed - for
instance, to filter the set of flags to only include the client-side-enabled onesFeatureFlagsState object (will never be null; see FeatureFlagsState.isValid()boolean boolVariation(java.lang.String featureKey,
LDUser user,
boolean defaultValue)
featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagdefaultValue if the flag is disabled in the LaunchDarkly control paneljava.lang.Integer intVariation(java.lang.String featureKey,
LDUser user,
int defaultValue)
If the flag variation has a numeric value that is not an integer, it is rounded toward zero (truncated).
featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagdefaultValue if the flag is disabled in the LaunchDarkly control paneljava.lang.Double doubleVariation(java.lang.String featureKey,
LDUser user,
java.lang.Double defaultValue)
featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagdefaultValue if the flag is disabled in the LaunchDarkly control paneljava.lang.String stringVariation(java.lang.String featureKey,
LDUser user,
java.lang.String defaultValue)
featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagdefaultValue if the flag is disabled in the LaunchDarkly control panelLDValue jsonValueVariation(java.lang.String featureKey, LDUser user, LDValue defaultValue)
LDValue value of a feature flag for a given user.featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagdefaultValue if the flag is disabled in the LaunchDarkly control panel;
will never be a null reference, but may be LDValue.ofNull()EvaluationDetail<java.lang.Boolean> boolVariationDetail(java.lang.String featureKey, LDUser user, boolean defaultValue)
reason property in the result will also be included in
analytics events, if you are capturing detailed event data for this flag.featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagEvaluationDetail objectEvaluationDetail<java.lang.Integer> intVariationDetail(java.lang.String featureKey, LDUser user, int defaultValue)
reason property in the result will also be included in
analytics events, if you are capturing detailed event data for this flag.
If the flag variation has a numeric value that is not an integer, it is rounded toward zero (truncated).
featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagEvaluationDetail objectEvaluationDetail<java.lang.Double> doubleVariationDetail(java.lang.String featureKey, LDUser user, double defaultValue)
reason property in the result will also be included in
analytics events, if you are capturing detailed event data for this flag.featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagEvaluationDetail objectEvaluationDetail<java.lang.String> stringVariationDetail(java.lang.String featureKey, LDUser user, java.lang.String defaultValue)
reason property in the result will also be included in
analytics events, if you are capturing detailed event data for this flag.featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagEvaluationDetail objectEvaluationDetail<LDValue> jsonValueVariationDetail(java.lang.String featureKey, LDUser user, LDValue defaultValue)
LDValue value of a feature flag for a given user.featureKey - the unique key for the feature flaguser - the end user requesting the flagdefaultValue - the default value of the flagEvaluationDetail objectboolean isFlagKnown(java.lang.String featureKey)
featureKey - the unique key for the feature flagvoid close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOException - if an exception is thrown by one of the underlying network servicesvoid flush()
boolean isOffline()
void registerFlagChangeListener(FlagChangeListener listener)
The listener will be notified whenever the SDK receives any change to any feature flag's configuration, or to a user segment that is referenced by a feature flag. If the updated flag is used as a prerequisite for other flags, the SDK assumes that those flags may now behave differently and sends events for them as well.
Note that this does not necessarily mean the flag's value has changed for any particular user, only that some part of the flag configuration was changed so that it may return a different value than it previously returned for some user.
Change events only work if the SDK is actually connecting to LaunchDarkly (or using the file data source).
If the SDK is only reading flags from a database (Components.externalUpdatesOnly()) then it cannot
know when there is a change, because flags are read on an as-needed basis.
The listener will be called from a worker thread.
Calling this method for an already-registered listener has no effect.
listener - the event listener to registerunregisterFlagChangeListener(FlagChangeListener),
FlagChangeListenervoid unregisterFlagChangeListener(FlagChangeListener listener)
Calling this method for a listener that was not previously registered has no effect.
listener - the event listener to unregisterregisterFlagChangeListener(FlagChangeListener),
FlagChangeListenerDataSourceStatusProvider getDataSourceStatusProvider()
The data source is the mechanism that the SDK uses to get feature flag configurations, such as a
streaming connection (the default) or poll requests. The DataSourceStatusProvider has methods
for checking whether the data source is (as far as the SDK knows) currently operational and tracking
changes in this status.
DataSourceStatusProviderDataStoreStatusProvider getDataStoreStatusProvider()
The DataStoreStatusProvider has methods for checking whether the data store is (as far as the
SDK knows) currently operational, tracking changes in this status, and getting cache statistics. These
are only relevant for a persistent data store; if you are using an in-memory data store, then this
method will return a stub object that provides no information.
DataStoreStatusProviderjava.lang.String secureModeHash(LDUser user)
user - the user to be hashed along with the SDK keyjava.lang.String version()