Experiment client for evaluating variants for a user locally.

Hierarchy

  • LocalEvaluationClient

Constructors

Properties

Methods

Constructors

Properties

Directly access the client's flag config cache.

Used for directly manipulating the flag configs used for evaluation.

cohortStorage: InMemoryCohortStorage

Methods

  • Locally evaluates flag variants for a user.

    This function will only evaluate flags for the keys specified in the flagKeys argument. If flagKeys is missing, all flags in the FlagConfigCache will be evaluated.

    Returns

    The evaluated variants

    Deprecated

    use evaluateV2 instead

    Parameters

    • user: ExperimentUser

      The user to evaluate

    • Optional flagKeys: string[]

      The flags to evaluate with the user. If empty, all flags from the flag cache are evaluated.

    Returns Promise<Variants>

  • Locally evaluate varints for a user.

    This function will only evaluate flags for the keys specified in the flagKeys argument. If flagKeys is missing, all flags in the FlagConfigCache will be evaluated.

    Unlike evaluate, this function returns a default variant object if the flag or experiment was evaluated, but the user was not assigned a variant (i.e. 'off').

    Returns

    The evaluated variants

    Parameters

    • user: ExperimentUser

      The user to evaluate

    • Optional flagKeys: string[]

      The flags to evaluate with the user. If empty, all flags from the flag cache are evaluated.

    Returns Record<string, Variant>

  • Fetch initial flag configurations and start polling for updates.

    You must call this function to begin polling for flag config updates. The promise returned by this function is resolved when the initial call to fetch the flag configuration completes.

    Calling this function while the poller is already running does nothing.

    Returns Promise<void>

  • Stop polling for flag configurations.

    Calling this function while the poller is not running will do nothing.

    Returns void