Hierarchy (view full)

Implements

Properties

_apiEmitter: OpenFeatureEventEmitter = ...
_clientEvents: Map<undefined | string, GenericEventEmitter<AnyProviderEvent, Record<string, unknown>>> = ...
_context: EvaluationContext = {}
_defaultProvider: ProviderWrapper<Provider, ProviderStatus> = ...
_domainScopedContext: Map<string, EvaluationContext> = ...
_domainScopedProviders: Map<string, ProviderWrapper<Provider, ProviderStatus>> = ...
_hooks: Hook[] = []
_logger: Logger = ...
_runsOn: Paradigm
_statusEnumType: typeof ProviderStatus = ProviderStatus

Accessors

Methods

  • Adds hooks that will run during flag evaluations on this receiver. Hooks are executed in the order they were registered. Adding additional hooks will not remove existing hooks. Hooks registered on the global API object run with all evaluations. Hooks registered on the client run with all evaluations on that client.

    Parameters

    • Rest...hooks: Hook[]

      A list of hooks that should always run

    Returns this

    The receiver (this object)

  • A factory function for creating new domainless OpenFeature clients. Clients can contain their own state (e.g. logger, hook, context). Multiple clients can be used to segment feature flag configuration.

    All domainless or unbound clients use the default provider set via this.setProvider setProvider.

    Parameters

    • Optionalcontext: EvaluationContext

      Evaluation context that should be set on the client to used during flag evaluations

    Returns Client

    OpenFeature Client

  • A factory function for creating new domain scoped OpenFeature clients. Clients can contain their own state (e.g. logger, hook, context). Multiple clients can be used to segment feature flag configuration.

    If there is already a provider bound to this domain via this.setProvider setProvider, this provider will be used. Otherwise, the default provider is used until a provider is assigned to that domain.

    Parameters

    • domain: string

      An identifier which logically binds clients with providers

    • Optionalcontext: EvaluationContext

      Evaluation context that should be set on the client to used during flag evaluations

    Returns Client

    OpenFeature Client

  • A factory function for creating new domain scoped OpenFeature clients. Clients can contain their own state (e.g. logger, hook, context). Multiple clients can be used to segment feature flag configuration.

    If there is already a provider bound to this domain via this.setProvider setProvider, this provider will be used. Otherwise, the default provider is used until a provider is assigned to that domain.

    Parameters

    • domain: string

      An identifier which logically binds clients with providers

    • version: string

      The version of the client (only used for metadata)

    • Optionalcontext: EvaluationContext

      Evaluation context that should be set on the client to used during flag evaluations

    Returns Client

    OpenFeature Client

  • Sets a logger on this receiver. This logger supersedes to the global logger and is passed to various components in the SDK. The logger configured on the global API object will be used for all evaluations, unless overridden in a particular client.

    Parameters

    • logger: Logger

      The logger to be used

    Returns this

    The receiver (this object)

  • Sets the default provider for flag evaluations. This provider will be used by domainless clients and clients associated with domains to which no provider is bound. Setting a provider supersedes the current provider used in new and existing unbound clients.

    Parameters

    • provider: Provider

      The provider responsible for flag evaluations.

    Returns this

    OpenFeature API

  • Sets the provider for flag evaluations of providers with the given name. Setting a provider supersedes the current provider used in new and existing clients bound to the same domain.

    Parameters

    • domain: string

      The name to identify the client

    • provider: Provider

      The provider responsible for flag evaluations.

    Returns this

    OpenFeature API

  • Sets the default provider for flag evaluations and returns a promise that resolves when the provider is ready. This provider will be used by domainless clients and clients associated with domains to which no provider is bound. Setting a provider supersedes the current provider used in new and existing unbound clients.

    Parameters

    • provider: Provider

      The provider responsible for flag evaluations.

    Returns Promise<void>

    Uncaught exceptions thrown by the provider during initialization.

  • Sets the provider that OpenFeature will use for flag evaluations on clients bound to the same domain. A promise is returned that resolves when the provider is ready. Setting a provider supersedes the current provider used in new and existing clients bound to the same domain.

    Parameters

    • domain: string

      The name to identify the client

    • provider: Provider

      The provider responsible for flag evaluations.

    Returns Promise<void>

    Uncaught exceptions thrown by the provider during initialization.

  • Sets the transaction context using the registered transaction context propagator. Runs the callback function, in which the transactionContext will be available by calling this#getTransactionContext.

    The TransactionContextPropagator must persist the transactionContext and make it available to callback via this#getTransactionContext.

    The precedence of merging context can be seen in the specification.

    Example:

    app.use((req: Request, res: Response, next: NextFunction) => {
    const ip = res.headers.get("X-Forwarded-For")
    OpenFeature.setTransactionContext({ targetingKey: req.user.id, ipAddress: ip }, () => {
    // The transaction context is used in any flag evaluation throughout the whole call chain of next
    next();
    });
    })

    Type Parameters

    • TArgs extends unknown[]

      The optional args passed to the callback function

    • R

      The return value of the callback

    Parameters

    • transactionContext: EvaluationContext

      The transaction specific context

    • callback: ((...args: TArgs) => R)

      Callback function to run

        • (...args): R
        • Parameters

          Returns R

    • Rest...args: TArgs

      Optional arguments that are passed to the callback function

    Returns void