C Server-Side SDK
LaunchDarkly SDK
client.h File Reference

Public API for Client operations. More...

Include dependency graph for client.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct LDClientLDClientInit (struct LDConfig *const config, const unsigned int maxwaitmilli)
 Initialize a new client, and connect to LaunchDarkly. It's important to make LDClient a singleton. The client instance maintains internal state that allows LaunchDarkly to serve feature flags without making any remote requests. Do not instantiate a new client with every request. More...
 
LDBoolean LDClientClose (struct LDClient *const client)
 Shuts down the LaunchDarkly client. This will block until all resources have been freed. It is not safe to use the client during or after this operation. It is safe to initialize another client after this operation is completed. More...
 
LDBoolean LDClientIsInitialized (struct LDClient *const client)
 Check if a client has been fully initialized. This may be useful if the initialization timeout was reached in LDClientInit. More...
 
LDBoolean LDClientTrack (struct LDClient *const client, const char *const key, const struct LDUser *const user, struct LDJSON *const data)
 Reports that a user has performed an event. Custom data can be attached to the event as JSON. More...
 
LDBoolean LDClientTrackMetric (struct LDClient *const client, const char *const key, const struct LDUser *const user, struct LDJSON *const data, const double metric)
 Reports that a user has performed an event. Custom data, and a metric can be attached to the event as JSON. More...
 
LDBoolean LDClientAlias (struct LDClient *const client, const struct LDUser *const currentUser, const struct LDUser *const previousUser)
 Record a alias event. More...
 
LDBoolean LDClientIdentify (struct LDClient *const client, const struct LDUser *const user)
 Generates an identify event for a user, if the user's key is non-empty. More...
 
LDBoolean LDClientIsOffline (struct LDClient *const client)
 Whether the LaunchDarkly client is in offline mode. More...
 
LDBoolean LDClientFlush (struct LDClient *const client)
 Immediately flushes queued events. More...
 

Detailed Description

Public API for Client operations.

Function Documentation

◆ LDClientAlias()

LDBoolean LDClientAlias ( struct LDClient *const  client,
const struct LDUser *const  currentUser,
const struct LDUser *const  previousUser 
)

Record a alias event.

Parameters
[in]clientThe client to use. May not be NULL.
[in]currentUserThe new version of a user. Ownership is not transferred. May not be NULL.
[in]previousUserThe previous version of a user. Ownership is not transferred. May not be NULL.
Returns
True if the event was queued successfully, or if analytics events are disabled. False on error.

◆ LDClientClose()

LDBoolean LDClientClose ( struct LDClient *const  client)

Shuts down the LaunchDarkly client. This will block until all resources have been freed. It is not safe to use the client during or after this operation. It is safe to initialize another client after this operation is completed.

Parameters
[in]clientThe client to use. May be NULL.
Returns
True on success, False on failure.

◆ LDClientFlush()

LDBoolean LDClientFlush ( struct LDClient *const  client)

Immediately flushes queued events.

Parameters
[in]clientThe client to use. May not be NULL.
Returns
True if signalled, False on error.

◆ LDClientIdentify()

LDBoolean LDClientIdentify ( struct LDClient *const  client,
const struct LDUser *const  user 
)

Generates an identify event for a user, if the user's key is non-empty.

Parameters
[in]clientThe client to use. May not be NULL.
[in]userThe user to generate the event for. Ownership is not transferred. May not be NULL.
Returns
True if the event was queued successfully, or if analytics events are disabled. False on error.

◆ LDClientInit()

struct LDClient* LDClientInit ( struct LDConfig *const  config,
const unsigned int  maxwaitmilli 
)

Initialize a new client, and connect to LaunchDarkly. It's important to make LDClient a singleton. The client instance maintains internal state that allows LaunchDarkly to serve feature flags without making any remote requests. Do not instantiate a new client with every request.

Parameters
[in]configThe client configuration. Ownership of config is transferred.
[in]maxwaitmilliHow long to wait for flags to download. If the timeout is reached a non fully initialized client will be returned.
Returns
A fresh client.

◆ LDClientIsInitialized()

LDBoolean LDClientIsInitialized ( struct LDClient *const  client)

Check if a client has been fully initialized. This may be useful if the initialization timeout was reached in LDClientInit.

Parameters
[in]clientThe client to use. May not be NULL.
Returns
True if fully initialized, False if not or on error.

◆ LDClientIsOffline()

LDBoolean LDClientIsOffline ( struct LDClient *const  client)

Whether the LaunchDarkly client is in offline mode.

Parameters
[in]clientThe client to use. May not be NULL.
Returns
True if offline, False if not or on error.

◆ LDClientTrack()

LDBoolean LDClientTrack ( struct LDClient *const  client,
const char *const  key,
const struct LDUser *const  user,
struct LDJSON *const  data 
)

Reports that a user has performed an event. Custom data can be attached to the event as JSON.

Parameters
[in]clientThe client to use. May not be NULL.
[in]keyThe name of the event. May not be NULL.
[in]userThe user to generate the event for. Ownership is not transferred. May not be NULL.
[in]dataThe JSON to attach to the event. Ownership of data is transferred only if True is returned. May be NULL.
Returns
True if the event was queued successfully, or if analytics events are disabled. False on error.

◆ LDClientTrackMetric()

LDBoolean LDClientTrackMetric ( struct LDClient *const  client,
const char *const  key,
const struct LDUser *const  user,
struct LDJSON *const  data,
const double  metric 
)

Reports that a user has performed an event. Custom data, and a metric can be attached to the event as JSON.

Parameters
[in]clientThe client to use. May not be NULL.
[in]keyThe name of the event. May not be NULL.
[in]userThe user to generate the event for. Ownership is not transferred. May not be NULL.
[in]dataThe JSON to attach to the event. Ownership of data is transferred. May be NULL.
[in]metricA metric to be associated with the event.
Returns
True if the event was queued successfully, or if analytics events are disabled. False on error.