Module launchdarkly-server-sdk

Server-side SDK for LaunchDarkly.

Functions

makeUser (fields) Create a new opaque user object.
clientInit (config, timeoutMilliseconds) Initialize a new client, and connect to LaunchDarkly.

Tables

Details Details associated with an evaluation

Class Client

Client:isInitialized () Check if a client has been fully initialized.
Client:identify (user) Generates an identify event for a user.
Client:isOffline () Whether the LaunchDarkly client is in offline mode.
Client:flush () Immediately flushes queued events.
Client:track (key, user[, data[, metric]]) Reports that a user has performed an event.
Client:allFlags (user) Returns a map from feature flag keys to values for a given user.
Client:boolVariation (user, key, fallback) Evaluate a boolean flag
Client:boolVariationDetail (user, key, fallback) Evaluate a boolean flag and return an explanation
Client:intVariation (user, key, fallback) Evaluate an integer flag
Client:intVariationDetail (user, key, fallback) Evaluate an integer flag and return an explanation
Client:doubleVariation (user, key, fallback) Evaluate a double flag
Client:doubleVariationDetail (user, key, fallback) Evaluate a double flag and return an explanation
Client:stringVariation (user, key, fallback) Evaluate a string flag
Client:stringVariationDetail (user, key, fallback) Evaluate a string flag and return an explanation
Client:jsonVariation (user, key, fallback) Evaluate a json flag
Client:jsonVariationDetail (user, key, fallback) Evaluate a json flag and return an explanation


Functions

makeUser (fields)
Create a new opaque user object.

Parameters:

  • fields list of user fields.
    • key string The user's key
    • anonymous boolean Mark the user as anonymous (optional)
    • ip string Set the user's IP (optional)
    • firstName string Set the user's first name (optional)
    • lastName string Set the user's last name (optional)
    • email string Set the user's email (optional)
    • name string Set the user's name (optional)
    • avatar string Set the user's avatar (optional)
    • country string Set the user's country (optional)
    • secondary string Set the user's secondary key (optional)
    • privateAttributeNames table A list of attributes to redact (optional)
    • custom table Set the user's custom JSON (optional)

Returns:

    an opaque user object
clientInit (config, timeoutMilliseconds)
Initialize a new client, and connect to LaunchDarkly.

Parameters:

  • config list of configuration options
    • key string Environment SDK key
    • baseURI string Set the base URI for connecting to LaunchDarkly. You probably don't need to set this unless instructed by LaunchDarkly. (optional)
    • streamURI string Set the streaming URI for connecting to LaunchDarkly. You probably don't need to set this unless instructed by LaunchDarkly. (optional)
    • eventsURI string Set the events URI for connecting to LaunchDarkly. You probably don't need to set this unless instructed by LaunchDarkly. (optional)
    • stream boolean Enables or disables real-time streaming flag updates. When set to false, an efficient caching polling mechanism is used. We do not recommend disabling streaming unless you have been instructed to do so by LaunchDarkly support. Defaults to true. (optional)
    • sendEvents string Sets whether to send analytics events back to LaunchDarkly. By default, the client will send events. This differs from Offline in that it only affects sending events, not streaming or polling. (optional)
    • eventsCapacity int The capacity of the events buffer. The client buffers up to this many events in memory before flushing. If the capacity is exceeded before the buffer is flushed, events will be discarded. (optional)
    • timeout int The connection timeout to use when making requests to LaunchDarkly. (optional)
    • flushInterval int he time between flushes of the event buffer. Decreasing the flush interval means that the event buffer is less likely to reach capacity. (optional)
    • pollInterval int The polling interval (when streaming is disabled) in milliseconds. (optional)
    • offline boolean Sets whether this client is offline. An offline client will not make any network connections to LaunchDarkly, and will return default values for all feature flags. (optional)
    • allAttributesPrivate boolean Sets whether or not all user attributes (other than the key) should be hidden from LaunchDarkly. If this is true, all user attribute values will be private, not just the attributes specified in PrivateAttributeNames. (optional)
    • inlineUsersInEvents boolean Set to true if you need to see the full user details in every analytics event. (optional)
    • userKeysCapacity int The number of user keys that the event processor can remember at an one time, so that duplicate user details will not be sent in analytics. (optional)
    • userKeysFlushInterval int The interval at which the event processor will reset its set of known user keys, in milliseconds. (optional)
    • privateAttributeNames table Marks a set of user attribute names private. Any users sent to LaunchDarkly with this configuration active will have attributes with these names removed. (optional)
  • timeoutMilliseconds int How long to wait for flags to download. If the timeout is reached a non fully initialized client will be returned.

Returns:

    A fresh client.

Tables

Details
Details associated with an evaluation

Fields:

  • variationIndex int The index of the returned value within the flag's list of variations. (optional)
  • value The resulting value of an evaluation
  • reason The reason a specific value was returned
    • kind string The kind of reason
    • errorKind string If the kind is LD_ERROR, this contains the error string. (optional)
    • ruleId string If the kind is LD_RULE_MATCH this contains the id of the rule. (optional)
    • ruleIndex int If the kind is LD_RULE_MATCH this contains the index of the rule. (optional)
    • prerequisiteKey string If the kind is LD_PREREQUISITE_FAILED this contains the key of the failed prerequisite. (optional)

Class Client

An opaque client object
Client:isInitialized ()
Check if a client has been fully initialized. This may be useful if the initialization timeout was reached.

Returns:

    boolean true if fully initialized
Client:identify (user)
Generates an identify event for a user.

Parameters:

  • user user An opaque user object from makeUser

Returns:

    nil
Client:isOffline ()
Whether the LaunchDarkly client is in offline mode.

Returns:

    boolean true if offline
Client:flush ()
Immediately flushes queued events.

Returns:

    nil
Client:track (key, user[, data[, metric]])
Reports that a user has performed an event. Custom data, and a metric can be attached to the event as JSON.

Parameters:

  • key string The name of the event
  • user user An opaque user object from makeUser
  • data table A value to be associated with an event (optional)
  • metric number A value to be associated with an event (optional)

Returns:

    nil
Client:allFlags (user)
Returns a map from feature flag keys to values for a given user. This does not send analytics events back to LaunchDarkly.

Parameters:

  • user user An opaque user object from makeUser

Returns:

    table
Client:boolVariation (user, key, fallback)
Evaluate a boolean flag

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback boolean The value to return on error

Returns:

    boolean The evaluation result, or the fallback value
Client:boolVariationDetail (user, key, fallback)
Evaluate a boolean flag and return an explanation

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback boolean The value to return on error

Returns:

    table The evaluation explanation
Client:intVariation (user, key, fallback)
Evaluate an integer flag

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback int The value to return on error

Returns:

    int The evaluation result, or the fallback value
Client:intVariationDetail (user, key, fallback)
Evaluate an integer flag and return an explanation

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback int The value to return on error

Returns:

    table The evaluation explanation
Client:doubleVariation (user, key, fallback)
Evaluate a double flag

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback number The value to return on error

Returns:

    double The evaluation result, or the fallback value
Client:doubleVariationDetail (user, key, fallback)
Evaluate a double flag and return an explanation

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback number The value to return on error

Returns:

    table The evaluation explanation
Client:stringVariation (user, key, fallback)
Evaluate a string flag

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback string The value to return on error

Returns:

    string The evaluation result, or the fallback value
Client:stringVariationDetail (user, key, fallback)
Evaluate a string flag and return an explanation

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback string The value to return on error

Returns:

    table The evaluation explanation
Client:jsonVariation (user, key, fallback)
Evaluate a json flag

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback table The value to return on error

Returns:

    table The evaluation result, or the fallback value
Client:jsonVariationDetail (user, key, fallback)
Evaluate a json flag and return an explanation

Parameters:

  • user user An opaque user object from makeUser
  • key string The key of the flag to evaluate.
  • fallback table The value to return on error

Returns:

    table The evaluation explanation
generated by LDoc 1.4.6 Last updated 2020-03-25 02:24:34