Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "launchdarkly-js-client-sdk"

This is the API reference for the LaunchDarkly SDK for browser JavaScript.

In typical usage, you will call initialize once at startup time to obtain an instance of LDClient, which provides access to all of the SDK's functionality.

For more information, see the SDK reference guide.

Index

Type aliases

LDFlagValue

LDFlagValue: any

The types of values a feature flag can have.

Flags can have any JSON-serializable value.

Variables

Const version

version: string

The current version string of the SDK.

Functions

createConsoleLogger

  • createConsoleLogger(minimumLevel: string, prefix?: undefined | string): LDLogger
  • A basic implementation of logging that uses the global console object. This is used by default in the browser SDK. It sends messages of "debug", "info", "warn", or "error" level (if enable) to console.log(), console.info(), console.warn(), and console.error() respectively.

    To make LDClient use this logger, put it in the logger property of LDOptions.

    Parameters

    • minimumLevel: string

      The minimum log level to be displayed: 'debug', 'info', 'warn', or 'error'. For instance, if it is 'warn', then 'debug' and 'info' messages will be suppressed. The default is 'debug'.

    • Optional prefix: undefined | string

      A string to prepend to each log line. The default is 'LD:'.

    Returns LDLogger

initialize

  • Creates an instance of the LaunchDarkly client.

    The client will begin attempting to connect to LaunchDarkly as soon as it is created. To determine when it is ready to use, call LDClient.waitForInitialization, or register an event listener for the "ready" event using LDClient.on.

    Note that you can either import this as a named export or as part of the default exports, although the latter is deprecated:

    // Preferred usage:
    import { initialize } from 'launchdarkly-js-client-sdk';
    const client = initialize(envKey, user, options);
    
    // Deprecated usage:
    import LaunchDarkly from 'launchdarkly-js-client-sdk';
    const client = LaunchDarkly.initialize(envKey, user, options);

    Parameters

    • envKey: string

      The environment ID.

    • user: LDUser

      The initial user properties. These can be changed later with LDClient.identify.

    • Optional options: LDOptions

      Optional configuration settings.

    Returns LDClient

    The new client instance.

Generated using TypeDoc