/// import { AsyncMap } from '@eppo/js-client-sdk-common'; import { Attributes } from '@eppo/js-client-sdk-common'; import { AttributeType } from '@eppo/js-client-sdk-common'; import { BanditActions } from '@eppo/js-client-sdk-common'; import { BanditSubjectAttributes } from '@eppo/js-client-sdk-common'; import { ContextAttributes } from '@eppo/js-client-sdk-common'; import { EppoAssignmentLogger } from '@eppo/js-client-sdk-common'; import { EppoClient } from '@eppo/js-client-sdk-common'; import { EppoPrecomputedClient } from '@eppo/js-client-sdk-common'; import { EventDispatcher } from '@eppo/js-client-sdk-common'; import { Flag } from '@eppo/js-client-sdk-common'; import { FlagKey } from '@eppo/js-client-sdk-common'; import { IAssignmentDetails } from '@eppo/js-client-sdk-common'; import { IAssignmentEvent } from '@eppo/js-client-sdk-common'; import { IAssignmentLogger } from '@eppo/js-client-sdk-common'; import { IAsyncStore } from '@eppo/js-client-sdk-common'; import { IBanditEvent } from '@eppo/js-client-sdk-common'; import { IBanditLogger } from '@eppo/js-client-sdk-common'; import { IContainerExperiment } from '@eppo/js-client-sdk-common'; import { ObfuscatedFlag } from '@eppo/js-client-sdk-common'; export { Attributes } export { AttributeType } export { BanditActions } export { BanditSubjectAttributes } /** * Builds a storage key suffix from an API key. * @param apiKey - The API key to build the suffix from * @returns A string suffix for storage keys * @public */ export declare function buildStorageKeySuffix(apiKey: string): string; /** Chrome storage-backed {@link AsyncMap}. */ declare class ChromeStorageAsyncMap implements AsyncMap { private readonly storage; constructor(storage: chrome.storage.StorageArea); has(key: string): Promise; get(key: string): Promise; entries(): Promise<{ [p: string]: T; }>; set(key: string, value: T): Promise; } /** * Chrome storage implementation of a string-valued store for storing a configuration and its metadata. * * This serializes the entire configuration object into a string and then stores it to a single key * within the object for another single top-level key. * Same with metadata about the store (e.g., when it was last updated). * * Note: this behaves a bit differently than local storage as the chrome storage API gets and sets * subsets of key-value pairs, so we have to dereference or re-specify the key. * @public */ export declare class ChromeStorageEngine implements IStringStorageEngine { private storageMap; private readonly contentsKey; private readonly metaKey; constructor(storageMap: ChromeStorageAsyncMap, storageKeySuffix: string); getContentsJsonString: () => Promise; getMetaJsonString: () => Promise; setContentsJsonString: (configurationJsonString: string) => Promise; setMetaJsonString: (metaJsonString: string) => Promise; } export { ContextAttributes } export { EppoAssignmentLogger } /** * Client for assigning experiment variations. * @public */ export declare class EppoJSClient extends EppoClient { /** * @deprecated Use `getInstance()` instead. */ static instance: EppoJSClient; static initialized: boolean; private initialized; getStringAssignment(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: string): string; getStringAssignmentDetails(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: string): IAssignmentDetails; /** * @deprecated Use getBooleanAssignment instead */ getBoolAssignment(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: boolean): boolean; getBooleanAssignment(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: boolean): boolean; getBooleanAssignmentDetails(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: boolean): IAssignmentDetails; getIntegerAssignment(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: number): number; getIntegerAssignmentDetails(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: number): IAssignmentDetails; getNumericAssignment(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: number): number; getNumericAssignmentDetails(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: number): IAssignmentDetails; getJSONAssignment(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: object): object; getJSONAssignmentDetails(flagKey: string, subjectKey: string, subjectAttributes: Record, defaultValue: object): IAssignmentDetails; getBanditAction(flagKey: string, subjectKey: string, subjectAttributes: BanditSubjectAttributes, actions: BanditActions, defaultValue: string): Omit, 'evaluationDetails'>; getBanditActionDetails(flagKey: string, subjectKey: string, subjectAttributes: BanditSubjectAttributes, actions: BanditActions, defaultValue: string): IAssignmentDetails; getExperimentContainerEntry(flagExperiment: IContainerExperiment, subjectKey: string, subjectAttributes: Record): T; private ensureInitialized; /** * @internal */ init(config: Omit): Promise; /** * @internal */ offlineInit(config: IClientConfigSync): void; } /** * Client for assigning precomputed experiment variations. * @public */ export declare class EppoPrecomputedJSClient extends EppoPrecomputedClient { static instance: EppoPrecomputedJSClient; static initialized: boolean; getStringAssignment(flagKey: string, defaultValue: string): string; getBooleanAssignment(flagKey: string, defaultValue: boolean): boolean; getIntegerAssignment(flagKey: string, defaultValue: number): number; getNumericAssignment(flagKey: string, defaultValue: number): number; getJSONAssignment(flagKey: string, defaultValue: object): object; getBanditAction(flagKey: string, defaultValue: string): Omit, 'evaluationDetails'>; private static getAssignmentInitializationCheck; } export { Flag } /** * Used to build the URL for fetching the flag configuration. * @returns a URL string * @public */ export declare function getConfigUrl(apiKey: string, baseUrl?: string): string; /** * Used to access a singleton SDK client instance. * Use the method after calling init() to initialize the client. * @returns a singleton client instance * @public */ export declare function getInstance(): EppoJSClient; /** * Used to access a singleton SDK precomputed client instance. * Use the method after calling precomputedInit() to initialize the client. * @returns a singleton precomputed client instance * @public */ export declare function getPrecomputedInstance(): EppoPrecomputedClient; export { IAssignmentDetails } export { IAssignmentEvent } export { IAssignmentLogger } export { IAsyncStore } export { IBanditEvent } export { IBanditLogger } /** * Base configuration for API requests and polling behavior */ declare interface IBaseRequestConfig { /** * Eppo API key */ apiKey: string; /** * Base URL of the Eppo API. * Clients should use the default setting in most cases. */ baseUrl?: string; /** * Pass a logging implementation to send variation assignments to your data warehouse. */ assignmentLogger: IAssignmentLogger; /** * Pass a logging implementation to send bandit assignments to your data warehouse. */ banditLogger?: IBanditLogger; /** * Timeout in milliseconds for the HTTPS request for the experiment configuration. (Default: 5000) */ requestTimeoutMs?: number; /** * Number of additional times the initial configuration request will be attempted if it fails. * This is the request typically synchronously waited (via await) for completion. A small wait will be * done between requests. (Default: 1) */ numInitialRequestRetries?: number; /** * Poll for new configurations even if the initial configuration request failed. (default: false) */ pollAfterFailedInitialization?: boolean; /** * Poll for new configurations (every `pollingIntervalMs`) after successfully requesting the initial configuration. (default: false) */ pollAfterSuccessfulInitialization?: boolean; /** * Amount of time to wait between API calls to refresh configuration data. Default of 30_000 (30 seconds). */ pollingIntervalMs?: number; /** * Number of additional times polling for updated configurations will be attempted before giving up. * Polling is done after a successful initial request. Subsequent attempts are done using an exponential * backoff. (Default: 7) */ numPollRequestRetries?: number; /** * Skip the request for new configurations during initialization. (default: false) */ skipInitialRequest?: boolean; } /** * Configuration for regular client initialization * @public */ export declare interface IClientConfig extends IBaseRequestConfig { /** * Throw an error if unable to fetch an initial configuration during initialization. (default: true) */ throwOnFailedInitialization?: boolean; /** * Maximum age, in seconds, previously cached values are considered valid until new values will be * fetched (default: 0) */ maxCacheAgeSeconds?: number; /** * Whether initialization will be considered successfully complete if expired cache values are * loaded. If false, initialization will always wait for a fetch if cached values are expired. * (default: false) */ useExpiredCache?: boolean; /** * Sets how the configuration is updated after a successful fetch * - always: immediately start using the new configuration * - expired: immediately start using the new configuration only if the current one has expired * - empty: only use the new configuration if the current one is both expired and uninitialized/empty */ updateOnFetch?: ServingStoreUpdateStrategy; /** * A custom class to use for storing flag configurations. * This is useful for cases where you want to use a different storage mechanism * than the default storage provided by the SDK. */ persistentStore?: IAsyncStore; /** * Force reinitialize the SDK if it is already initialized. */ forceReinitialize?: boolean; /** Configuration settings for the event dispatcher */ eventTracking?: { /** Maximum number of events to send per delivery request. Defaults to 1000 events. */ batchSize?: number; /** Number of milliseconds to wait between each batch delivery. Defaults to 10 seconds. */ deliveryIntervalMs?: number; /** Whether to enable event ingestion. Defaults to false. */ enabled?: boolean; /** * Maximum number of events to queue in memory before starting to drop events. * Note: This is only used if localStorage is not available. * Defaults to 10000 events. */ maxQueueSize?: number; /** Maximum number of retry attempts before giving up on a batch delivery. Defaults to 3 retries. */ maxRetries?: number; /** Maximum amount of milliseconds to wait before retrying a failed delivery. Defaults to 30 seconds. */ maxRetryDelayMs?: number; /** Minimum amount of milliseconds to wait before retrying a failed delivery. Defaults to 5 seconds */ retryIntervalMs?: number; }; /** * Enable the Overrides Store for local flag overrides. * (default: false) */ enableOverrides?: boolean; /** * The key to use for the overrides store. */ overridesStorageKey?: string; } /** * Configuration interface for synchronous client initialization. * @public */ export declare interface IClientConfigSync { flagsConfiguration: Record; assignmentLogger?: IAssignmentLogger; banditLogger?: IBanditLogger; isObfuscated?: boolean; throwOnFailedInitialization?: boolean; enableOverrides?: boolean; overridesStorageKey?: string; configPublishedAt?: string; configFetchedAt?: string; } /** * Initializes the Eppo client with configuration parameters. * This method should be called once on application startup. * @param config - client configuration * @public */ export declare function init(config: IClientConfig): Promise; /** * Configuration for precomputed flag assignments */ declare interface IPrecompute { /** * Subject key to use for precomputed flag assignments. */ subjectKey: string; /** * Subject attributes to use for precomputed flag assignments. */ subjectAttributes?: BanditSubjectAttributes; /** * Bandit actions to use for precomputed flag assignments. */ banditActions?: Record>; } /** * Configuration for Eppo precomputed client initialization * @public */ export declare interface IPrecomputedClientConfig extends IBaseRequestConfig { precompute: IPrecompute; /** * Enable the Overrides Store for local flag overrides. * (default: false) */ enableOverrides?: boolean; /** * The key to use for the overrides store. */ overridesStorageKey?: string; } /** * Configuration parameters for initializing the Eppo precomputed client. * * This interface is used for cases where precomputed assignments are available * from an external process that can bootstrap the SDK client. * * @param precomputedConfiguration - The configuration as a string to bootstrap the client. * @param assignmentLogger - Optional logger for assignment events. * @param banditLogger - Optional logger for bandit events. * @param throwOnFailedInitialization - Optional flag to throw an error if initialization fails. * @public */ export declare interface IPrecomputedClientConfigSync { precomputedConfiguration: string; assignmentLogger?: IAssignmentLogger; banditLogger?: IBanditLogger; throwOnFailedInitialization?: boolean; enableOverrides?: boolean; overridesStorageKey?: string; } /** * Interface for a string-based storage engine which stores string contents as well as metadata * about those contents (e.g., when it was last updated) */ declare interface IStringStorageEngine { getContentsJsonString: () => Promise; getMetaJsonString: () => Promise; setContentsJsonString: (configurationJsonString: string) => Promise; setMetaJsonString: (metaJsonString: string) => Promise; } /** * Valid log levels for the Eppo SDK logger. * @public */ export declare type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent'; /** * @internal */ export declare const NO_OP_EVENT_DISPATCHER: EventDispatcher; export { ObfuscatedFlag } /** * Initializes the Eppo client with configuration parameters. * * The purpose is for use-cases where the configuration is available from an external process * that can bootstrap the SDK. * * This method should be called once on application startup. * * @param config - client configuration * @returns a singleton client instance * @public */ export declare function offlineInit(config: IClientConfigSync): EppoClient; /** * Initializes the Eppo precomputed client with configuration parameters. * * The purpose is for use-cases where the precomputed assignments are available from an external process * that can bootstrap the SDK. * * This method should be called once on application startup. * * @param config - precomputed client configuration * @returns a singleton precomputed client instance * @public */ export declare function offlinePrecomputedInit(config: IPrecomputedClientConfigSync): EppoPrecomputedClient; /** * Initializes the Eppo precomputed client with configuration parameters. * This method should be called once on application startup. * @param config - client configuration * @public */ export declare function precomputedInit(config: IPrecomputedClientConfig): Promise; declare type ServingStoreUpdateStrategy = 'always' | 'expired' | 'empty'; /** * Sets the log level for the Eppo SDK logger globally. * This affects all logging across the entire SDK, including both * EppoJSClient and EppoPrecomputedJSClient instances. * * @param level - The log level to set: * - 'trace': Most verbose, logs everything * - 'debug': Detailed debugging information * - 'info': General informational messages * - 'warn': Warning messages (default in production) * - 'error': Error messages only * - 'silent': Disable all logging * * @public */ export declare function setLogLevel(level: LogLevel): void; export { }