ldclient
module.
ldclient
module
Acts as an interface to most common SDK functions: starting and stopping client instances, and evaluating feature flags for contexts.
Most use cases only need a single client instance for the lifetime of their application. Consider using multiple instances only if you need to simultaneously access more than one environment. Do not start an instance every time you need to make a variation or other SDK call.all_flags_state/1 | Evaluate all flags for a given context and return their values. |
all_flags_state/2 | Evaluate all flags for a given context and given client instance. |
all_flags_state/3 | Returns an object that encapsulates the state of all feature flags for a given context. |
identify/1 | Identify reports details about a context. |
identify/2 | Identify reports details about a context. |
initialized/1 | Returns whether the LaunchDarkly client has initialized. |
is_offline/1 | Returns whether the LaunchDarkly client is in offline mode. |
start_instance/1 | Start client with default options. |
start_instance/2 | Start client with custom name or options. |
start_instance/3 | Start client with custom name and options. |
stop_all_instances/0 | Stop all client instances. |
stop_instance/0 | Stop client instance. |
stop_instance/1 | Stop client with the custom name. |
track/3 | Track reports that a context has performed an event. |
track/4 | Track reports that a context has performed an event. |
track_metric/4 | Reports that a context has performed an event, and associates it with a numeric value. |
track_metric/5 | Reports that a context has performed an event, and associates it with a numeric value. |
variation/3 | Evaluate given flag key for given context. |
variation/4 | Evaluate given flag key for given context and given client instance. |
variation_detail/3 | Evaluate given flag key for given context. |
variation_detail/4 | Evaluate given flag key for given context and given client instance. |
all_flags_state(Context::ldclient_user:user() | ldclient_context:context()) -> ldclient_eval:feature_flags_state()
Evaluate all flags for a given context and return their values
Evaluates all existing flags, but does not create any events as a side effect of the evaluation. It returns a map of flag keys to evaluated values.all_flags_state(Context::ldclient_user:user() | ldclient_context:context(), Tag::atom()) -> ldclient_eval:feature_flags_state()
Evaluate all flags for a given context and given client instance
Evaluates all existing flags, but does not create any events as a side effect of the evaluation. It returns a map of flag keys to evaluated values.all_flags_state(Context::ldclient_user:user() | ldclient_context:context(), Options::ldclient_eval:all_flags_state_options(), Tag::atom()) -> ldclient_eval:feature_flags_state()
Returns an object that encapsulates the state of all feature flags for a given context.
This includes the flag values, and also metadata that can be used on the front end. The most common use case for this method is to bootstrap a set of client-side feature flags from a back-end service.
If you are not using this to boostrap a client, then you likely want all_flags_state/1 or all_flags_state/2.identify(Context::ldclient_user:user() | ldclient_context:context()) -> ok
Identify reports details about a context
This function uses the default client instance.identify(Context::ldclient_user:user() | ldclient_context:context(), Tag::atom()) -> ok
Identify reports details about a context
This is useful to report context to a specific client instance.initialized(Tag::atom()) -> boolean()
Returns whether the LaunchDarkly client has initialized.
If this value is true, it means the client has succeeded at some point in connecting to LaunchDarkly and has received feature flag data. It could still have encountered a connection problem after that point, so this does not guarantee that the flags are up to date. Alternatively, it could also mean that the client is in offline mode.
If this value is false, it means the client has not yet connected to LaunchDarkly, or has permanently failed. In this state, feature flag evaluations will always return default values.is_offline(Tag::atom()) -> boolean()
Returns whether the LaunchDarkly client is in offline mode.
In some situations, you might want to stop making remote calls to LaunchDarkly and fall back to default values for your feature flags, this tells you whether only default values will be returned.start_instance(SdkKey::string()) -> ok | {error, atom(), term()}
Start client with default options
The SDK key is required to connect. Default streamer URL, storage backend and instance namedefault
will be used.
start_instance(SdkKey::string(), TagOrOptions::atom() | map()) -> ok | {error, atom(), term()}
Start client with custom name or options
WhenTagOrOptions
is an atom, the instance is started with that name. When
it's a map, it can be used to start with custom options.
start_instance(SdkKey::string(), Tag::atom(), Options::map()) -> ok | {error, atom(), term()}
Start client with custom name and options
Specify both custom client name and options when starting the client.stop_all_instances() -> ok
Stop all client instances
stop_instance() -> ok | {error, not_found, term()}
Stop client instance
Stops the default client instance.stop_instance(Tag::atom()) -> ok | {error, not_found, term()}
Stop client with the custom name
This is useful if a client instance was started with a custom name.track(Key::binary(), Context::ldclient_user:user() | ldclient_context:context(), Data::ldclient_event:event_data()) -> ok
Track reports that a context has performed an event
Custom data can be attached to the event.track(Key::binary(), Context::ldclient_user:user() | ldclient_context:context(), Data::ldclient_event:event_data(), Tag::atom()) -> ok
Track reports that a context has performed an event
This is useful for specifying a specific client instance.track_metric(Key::binary(), Context::ldclient_user:user() | ldclient_context:context(), Data::ldclient_event:event_data(), Metric::number()) -> ok
Reports that a context has performed an event, and associates it with a numeric value.
This value is used by the LaunchDarkly experimentation feature in numeric custom metrics, and will also be returned as part of the custom event for Data Export.
Custom data can also be attached to the event.track_metric(Key::binary(), Context::ldclient_user:user() | ldclient_context:context(), Data::ldclient_event:event_data(), Metric::number(), Tag::atom()) -> ok
Reports that a context has performed an event, and associates it with a numeric value.
This value is used by the LaunchDarkly experimentation feature in numeric custom metrics, and will also be returned as part of the custom event for Data Export.
Custom data can also be attached to the event.variation(FlagKey::binary(), Context::ldclient_user:user() | ldclient_context:context(), DefaultValue::ldclient_eval:result_value()) -> ldclient_eval:result_value()
Evaluate given flag key for given context
Evaluates the flag and returns the resulting variation value. The default value will be returned in case of any errors.variation(FlagKey::binary(), Context::ldclient_user:user() | ldclient_context:context(), DefaultValue::ldclient_eval:result_value(), Tag::atom()) -> ldclient_eval:result_value()
Evaluate given flag key for given context and given client instance
Evaluates the flag and returns the resulting variation value. The default value will be returned in case of any errors.variation_detail(FlagKey::binary(), Context::ldclient_user:user() | ldclient_context:context(), DefaultValue::ldclient_eval:result_value()) -> ldclient_eval:detail()
Evaluate given flag key for given context
Evaluates the flag and returns the result detail containing the variation index, value, and reason why the specific result was chosen. The default value will be returned in case of any errors.variation_detail(FlagKey::binary(), Context::ldclient_user:user() | ldclient_context:context(), DefaultValue::ldclient_eval:result_value(), Tag::atom()) -> ldclient_eval:detail()
Evaluate given flag key for given context and given client instance
Evaluates the flag and returns the result detail containing the variation index, value, and reason why the specific result was chosen. The default value will be returned in case of any errors.Generated by EDoc