C++ Client-Side SDK
LaunchDarkly SDK
Public Types | Public Member Functions | Static Public Member Functions | List of all members
launchdarkly::client_side::Client Class Reference
Inheritance diagram for launchdarkly::client_side::Client:
Inheritance graph
[legend]
Collaboration diagram for launchdarkly::client_side::Client:
Collaboration graph
[legend]

Public Types

using FlagKey = std::string
 
- Public Types inherited from launchdarkly::client_side::IClient
using FlagKey = std::string
 

Public Member Functions

 Client (Config config, Context context)
 
 Client (Client &&)=delete
 
 Client (Client const &)=delete
 
Clientoperator= (Client)=delete
 
Clientoperator= (Client &&other)=delete
 
std::future< bool > StartAsync () override
 
bool Initialized () const override
 
std::unordered_map< FlagKey, ValueAllFlags () const override
 
void Track (std::string event_name, Value data, double metric_value) override
 
void Track (std::string event_name, Value data) override
 
void Track (std::string event_name) override
 
void FlushAsync () override
 
std::future< bool > IdentifyAsync (Context context) override
 
bool BoolVariation (FlagKey const &key, bool default_value) override
 
EvaluationDetail< bool > BoolVariationDetail (FlagKey const &key, bool default_value) override
 
std::string StringVariation (FlagKey const &key, std::string default_value) override
 
EvaluationDetail< std::string > StringVariationDetail (FlagKey const &key, std::string default_value) override
 
double DoubleVariation (FlagKey const &key, double default_value) override
 
EvaluationDetail< double > DoubleVariationDetail (FlagKey const &key, double default_value) override
 
int IntVariation (FlagKey const &key, int default_value) override
 
EvaluationDetail< int > IntVariationDetail (FlagKey const &key, int default_value) override
 
Value JsonVariation (FlagKey const &key, Value default_value) override
 
EvaluationDetail< ValueJsonVariationDetail (FlagKey const &key, Value default_value) override
 
data_sources::IDataSourceStatusProviderDataSourceStatus () override
 
flag_manager::IFlagNotifierFlagNotifier () override
 
- Public Member Functions inherited from launchdarkly::client_side::IClient
 IClient (IClient const &item)=delete
 
 IClient (IClient &&item)=delete
 
IClientoperator= (IClient const &)=delete
 
IClientoperator= (IClient &&)=delete
 

Static Public Member Functions

static char const * Version ()
 

Member Function Documentation

◆ AllFlags()

std::unordered_map< FlagKey, Value > launchdarkly::client_side::Client::AllFlags ( ) const
overridevirtual

Returns a map from feature flag keys to feature flag values for the current context.

This method will not send analytics events back to LaunchDarkly.

Returns
A map from feature flag keys to values for the current context.

Implements launchdarkly::client_side::IClient.

◆ BoolVariation()

bool launchdarkly::client_side::Client::BoolVariation ( FlagKey const &  key,
bool  default_value 
)
overridevirtual

Returns the boolean value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implements launchdarkly::client_side::IClient.

◆ BoolVariationDetail()

EvaluationDetail< bool > launchdarkly::client_side::Client::BoolVariationDetail ( FlagKey const &  key,
bool  default_value 
)
overridevirtual

Returns the boolean value of a feature flag for a given flag key, in an object that also describes the way the value was determined.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implements launchdarkly::client_side::IClient.

◆ DataSourceStatus()

data_sources::IDataSourceStatusProvider & launchdarkly::client_side::Client::DataSourceStatus ( )
overridevirtual

Returns an interface which provides methods for subscribing to data source status.

Returns
A data source status provider.

Implements launchdarkly::client_side::IClient.

◆ DoubleVariation()

double launchdarkly::client_side::Client::DoubleVariation ( FlagKey const &  key,
double  default_value 
)
overridevirtual

Returns the double value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implements launchdarkly::client_side::IClient.

◆ DoubleVariationDetail()

EvaluationDetail< double > launchdarkly::client_side::Client::DoubleVariationDetail ( FlagKey const &  key,
double  default_value 
)
overridevirtual

Returns the double value of a feature flag for a given flag key, in an object that also describes the way the value was determined.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implements launchdarkly::client_side::IClient.

◆ FlagNotifier()

flag_manager::IFlagNotifier & launchdarkly::client_side::Client::FlagNotifier ( )
overridevirtual

Returns an interface which provides methods for subscribing to data flag changes.

Returns
A flag notifier.

Implements launchdarkly::client_side::IClient.

◆ FlushAsync()

void launchdarkly::client_side::Client::FlushAsync ( )
overridevirtual

Tells the client that all pending analytics events (if any) should be delivered as soon as possible.

Implements launchdarkly::client_side::IClient.

◆ IdentifyAsync()

std::future< bool > launchdarkly::client_side::Client::IdentifyAsync ( Context  context)
overridevirtual

Changes the current evaluation context, requests flags for that context from LaunchDarkly if online, and generates an analytics event to tell LaunchDarkly about the context.

Only one IdentifyAsync can be in progress at once; calling it concurrently invokes undefined behavior.

To block until the identify operation is complete, call wait() on the returned future.

The returned future will resolve to true or false based on the logic outlined on Initialized.

Parameters
contextThe new evaluation context.

Implements launchdarkly::client_side::IClient.

◆ Initialized()

bool launchdarkly::client_side::Client::Initialized ( ) const
overridevirtual

Returns a boolean value indicating LaunchDarkly connection and flag state within the client.

When you first start the client, once StartAsync has completed, Initialized should return true if and only if either 1. it connected to LaunchDarkly and successfully retrieved flags, or 2. it started in offline mode so there's no need to connect to LaunchDarkly. If the client timed out trying to connect to LD, then Initialized returns false (even if we do have cached flags). If the client connected and got a 401 error, Initialized is will return false. This serves the purpose of letting the app know that there was a problem of some kind.

Returns
True if the client is initialized.

Implements launchdarkly::client_side::IClient.

◆ IntVariation()

int launchdarkly::client_side::Client::IntVariation ( FlagKey const &  key,
int  default_value 
)
overridevirtual

Returns the int value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implements launchdarkly::client_side::IClient.

◆ IntVariationDetail()

EvaluationDetail< int > launchdarkly::client_side::Client::IntVariationDetail ( FlagKey const &  key,
int  default_value 
)
overridevirtual

Returns the int value of a feature flag for a given flag key, in an object that also describes the way the value was determined.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implements launchdarkly::client_side::IClient.

◆ JsonVariation()

Value launchdarkly::client_side::Client::JsonVariation ( FlagKey const &  key,
Value  default_value 
)
overridevirtual

Returns the JSON value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implements launchdarkly::client_side::IClient.

◆ JsonVariationDetail()

EvaluationDetail< Value > launchdarkly::client_side::Client::JsonVariationDetail ( FlagKey const &  key,
Value  default_value 
)
overridevirtual

Returns the JSON value of a feature flag for a given flag key, in an object that also describes the way the value was determined.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implements launchdarkly::client_side::IClient.

◆ StartAsync()

std::future< bool > launchdarkly::client_side::Client::StartAsync ( )
overridevirtual

Connects the client to LaunchDarkly's flag delivery endpoints.

If StartAsync isn't called, the client is able to post events but is unable to obtain flag data.

The returned future will resolve to true or false based on the logic outlined on Initialized.

Implements launchdarkly::client_side::IClient.

◆ StringVariation()

std::string launchdarkly::client_side::Client::StringVariation ( FlagKey const &  key,
std::string  default_value 
)
overridevirtual

Returns the string value of a feature flag for a given flag key.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
The variation for the selected context, or default_value if the flag is disabled in the LaunchDarkly control panel

Implements launchdarkly::client_side::IClient.

◆ StringVariationDetail()

EvaluationDetail< std::string > launchdarkly::client_side::Client::StringVariationDetail ( FlagKey const &  key,
std::string  default_value 
)
overridevirtual

Returns the string value of a feature flag for a given flag key, in an object that also describes the way the value was determined.

Parameters
keyThe unique feature key for the feature flag.
default_valueThe default value of the flag.
Returns
An evaluation detail object.

Implements launchdarkly::client_side::IClient.

◆ Track() [1/3]

void launchdarkly::client_side::Client::Track ( std::string  event_name)
overridevirtual

Tracks that the current context performed an event for the given event name.

Parameters
event_nameThe name of the event.

Implements launchdarkly::client_side::IClient.

◆ Track() [2/3]

void launchdarkly::client_side::Client::Track ( std::string  event_name,
Value  data 
)
overridevirtual

Tracks that the current context performed an event for the given event name, with additional JSON data.

Parameters
event_nameThe name of the event.
dataA JSON value containing additional data associated with the event.

Implements launchdarkly::client_side::IClient.

◆ Track() [3/3]

void launchdarkly::client_side::Client::Track ( std::string  event_name,
Value  data,
double  metric_value 
)
overridevirtual

Tracks that the current context performed an event for the given event name, and associates it with a numeric metric value.

Parameters
event_nameThe name of the event.
dataA JSON value containing additional data associated with the event.
metric_valuethis 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

Implements launchdarkly::client_side::IClient.

◆ Version()

char const * launchdarkly::client_side::Client::Version ( )
static

Returns the version of the SDK.

Returns
String representing version of the SDK.

The documentation for this class was generated from the following files: