Class BaseOpenFeatureProvider<TClient>Abstract

Base OpenFeature provider for LaunchDarkly server-side SDKs.

Subclasses must:

  1. Construct or receive an LDClient and pass it to setClient in their constructor.
  2. Optionally wire SDK-specific events by calling emitConfigurationChanged.

Type Parameters

Hierarchy

  • BaseOpenFeatureProvider

Implements

  • Provider

Constructors

Properties

_client?: TClient
_clientConstructionError?: unknown
_initTimeoutSeconds: number
_logger: LDLogger
events: OpenFeatureEventEmitter = ...
metadata: ProviderMetadata
runsOn: Paradigm = 'server'

Accessors

  • get hooks(): Hook[]
  • Returns the OpenFeature hooks registered for this provider. The LaunchDarkly provider does not currently register any provider-level hooks, so this always returns an empty array.

    Returns Hook[]

Methods

  • Emit an OpenFeature ConfigurationChanged event for the given flag key. Per-SDK providers call this from their event wiring.

    Parameters

    • flagKey: string

    Returns void

  • Get the LDClient instance used by this provider.

    Returns TClient

    The client for this provider.

  • Parameters

    • Optional context: EvaluationContext
      Optional

    Returns Promise<void>

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

    If the flag does not evaluate to a boolean value, then the defaultValue will be returned.

    Parameters

    • flagKey: string

      The unique key of the feature flag.

    • defaultValue: boolean

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

    • context: EvaluationContext

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

    Returns Promise<ResolutionDetails<boolean>>

    A promise which will resolve to a ResolutionDetails.

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

    If the flag does not evaluate to a numeric value, then the defaultValue will be returned.

    Parameters

    • flagKey: string

      The unique key of the feature flag.

    • defaultValue: number

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

    • context: EvaluationContext

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

    Returns Promise<ResolutionDetails<number>>

    A promise which will resolve to a ResolutionDetails.

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

    If the flag does not evaluate to a JSON object value, then the defaultValue will be returned.

    Type Parameters

    • U extends JsonValue

    Parameters

    • flagKey: string

      The unique key of the feature flag.

    • defaultValue: U

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

    • context: EvaluationContext

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

    Returns Promise<ResolutionDetails<U>>

    A promise which will resolve to a ResolutionDetails.

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

    If the flag does not evaluate to a string value, then the defaultValue will be returned.

    Parameters

    • flagKey: string

      The unique key of the feature flag.

    • defaultValue: string

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

    • context: EvaluationContext

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

    Returns Promise<ResolutionDetails<string>>

    A promise which will resolve to a ResolutionDetails.

  • Called by subclass constructors to register the LDClient instance.

    Parameters

    • client: TClient

    Returns void

  • Called by subclass constructors when client construction throws. The error will be re-thrown from initialize.

    Parameters

    • error: unknown

    Returns void

  • Parameters

    • trackingEventName: string
    • context: EvaluationContext
    • Optional trackingEventDetails: TrackingEventDetails
      Optional

    Returns void

Generated using TypeDoc