Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface LDElectronNodeAdapterClient

Interface for the Node SDK compatibility wrapper returned by createNodeSdkAdapter.

Keep in mind that the underlying implementation is still the client-side SDK, which has a single-current-user model. Therefore, when you call variation(flagKey, user, defaultValue), it is really calling identify(user) first, obtaining flag values for that user, and then evaluating the flag. This will perform poorly if you attempt to evaluate flags for a variety of different users in rapid succession.

Hierarchy

  • LDElectronNodeAdapterClient

Index

Methods

alias

  • Associates two users for analytics purposes.

    This can be helpful in the situation where a person is represented by multiple LaunchDarkly users. This may happen, for example, when a person initially logs into an application-- the person might be represented by an anonymous user prior to logging in and a different user after logging in, as denoted by a different user key.

    Parameters

    • user: LDUser

      The newly identified user.

    • previousUser: LDUser

      The previously identified user.

    Returns void

allFlags

  • Retrieves the set of all flag values for a user.

    Deprecated: use allFlagsState instead. Current versions of the client-side SDK will not generate analytics events correctly if you pass the result of allFlags().

    Parameters

    • user: LDUser

      The end user requesting the feature flags.

    • Optional callback: undefined | ((err: any, res: LDFlagSet) => void)

      A Node-style callback to receive the result (as an LDFlagSet). If omitted, you will receive a Promise instead.

    Returns Promise<LDFlagSet>

    If you provided a callback, then nothing. Otherwise, a Promise which will be resolved with the result as an LDFlagSet.

allFlagsState

  • Builds an object that encapsulates the state of all feature flags for a given user. This includes the flag values and also metadata that can be used on the front end. This method does not send analytics events back to LaunchDarkly.

    The most common use case for this method is to bootstrap a set of client-side feature flags from a back-end service. Call the toJSON() method of the returned object to convert it to the data structure used by the client-side SDK.

    Parameters

    • user: LDUser

      The end user requesting the feature flags.

    • Optional options: undefined | object

      Optional [[LDFlagsStateOptions]] to determine how the state is computed.

    • Optional callback: undefined | ((err: any, res: LDFlagsState) => void)

      A Node-style callback to receive the result (as an LDFlagsState). If omitted, you will receive a Promise instead.

    Returns Promise<LDFlagsState>

    If you provided a callback, then nothing. Otherwise, a Promise which will be resolved with the result as an LDFlagsState.

close

  • close(): void
  • Discards all network connections, background tasks, and other resources held by the client.

    Do not attempt to use the client after calling this method.

    Returns void

flush

  • flush(callback?: undefined | ((err: any, res: boolean) => void)): Promise<void>
  • Flushes all pending analytics events.

    Normally, batches of events are delivered in the background at intervals determined by the flushInterval property of LDOptions. Calling flush() triggers an immediate delivery.

    Parameters

    • Optional callback: undefined | ((err: any, res: boolean) => void)

      A function which will be called when the flush completes. If omitted, you will receive a Promise instead.

    Returns Promise<void>

    If you provided a callback, then nothing. Otherwise, a Promise which resolves once flushing is finished. Note that the Promise will be rejected if the HTTP request fails, so be sure to attach a rejection handler to it.

identify

  • identify(user: LDUser): void
  • Identifies a user to LaunchDarkly.

    This simply creates an analytics event that will transmit the given user properties to LaunchDarkly, so that the user will be visible on your dashboard even if you have not evaluated any flags for that user. It has no other effect.

    Parameters

    • user: LDUser

      The user properties. Must contain at least the key property.

    Returns void

initialized

  • initialized(): boolean
  • Tests whether the client has completed initialization.

    If this returns false, it means that the client has not yet successfully connected to LaunchDarkly. It might still be in the process of starting up, or it might be attempting to reconnect after an unsuccessful attempt, or it might have received an unrecoverable error (such as an invalid SDK key) and given up.

    Returns boolean

    True if the client has successfully initialized.

isOffline

  • isOffline(): boolean
  • Tests whether the client is configured in offline mode.

    Returns boolean

    True if the offline property is true in your LDOptions.

secureModeHash

  • secureModeHash(user: LDUser): string
  • In the Node SDK, secureModeHash computes an HMAC signature of a user signed with the client's SDK key. This is not possible in Electron because the SDK key is not available, so secureModeHash will always return an empty string.

    Parameters

    Returns string

    An empty string.

track

  • track(key: string, user: LDUser, data?: any): void
  • Tracks that a user performed an event.

    LaunchDarkly automatically tracks pageviews and clicks that are specified in the Goals section of the dashboard. This can be used to track custom goals or other events that do not currently have goals.

    Parameters

    • key: string

      The name of the event, which may correspond to a goal in A/B tests.

    • user: LDUser

      The user to track.

    • Optional data: any

      Optional additional information to associate with the event.

    Returns void

variation

  • Determines the variation of a feature flag for a user.

    Parameters

    • key: string

      The unique key of the feature flag.

    • user: LDUser

      The end user requesting the flag. The client will generate an analytics event to register this user with LaunchDarkly if the user does not already exist.

    • defaultValue: LDFlagValue

      The default value of the flag, to be used if the value is not available from LaunchDarkly.

    • Optional callback: undefined | ((err: any, res: LDFlagValue) => void)

      A Node-style callback to receive the result value. If omitted, you will receive a Promise instead.

    Returns Promise<LDFlagValue>

    If you provided a callback, then nothing. Otherwise, a Promise which will be resolved with the result value.

variationDetail

  • Determines the variation of a feature flag for a user, along with information about how it was calculated.

    The reason property of the result will also be included in analytics events, if you are capturing detailed event data for this flag.

    For more information, see the SDK reference guide.

    Parameters

    • key: string

      The unique key of the feature flag.

    • user: LDUser

      The end user requesting the flag. The client will generate an analytics event to register this user with LaunchDarkly if the user does not already exist.

    • defaultValue: LDFlagValue

      The default value of the flag, to be used if the value is not available from LaunchDarkly.

    • Optional callback: undefined | ((err: any, res: LDEvaluationDetail) => void)

      A Node-style callback to receive the result (as an LDEvaluationDetail). If omitted, you will receive a Promise instead.

    Returns Promise<LDEvaluationDetail>

    If you provided a callback, then nothing. Otherwise, a Promise which will be resolved with the result (as an LDEvaluationDetail).

waitForInitialization

  • Returns a Promise that tracks the client's initialization state.

    The Promise will be resolved if the client successfully initializes, or rejected if client initialization has irrevocably failed (for instance, if it detects that the SDK key is invalid).

    Note that you can also use event listeners (on) for the same purpose: the event "ready" indicates success, and "failed" indicates failure.

    Returns Promise<LDElectronNodeAdapterClient>

    A Promise that will be resolved if the client initializes successfully, or rejected if it fails. If successful, the result is the same client object.

waitUntilReady

  • Returns a Promise that tracks the client's initialization state.

    Deprecated: please use waitForInitialization instead. The difference between that method and this one is that waitUntilReady never rejects the Promise, even if initialization fails.

    Returns Promise<void>

    A Promise that will be resolved if the client initializes successfully.

Generated using TypeDoc