import { DownloadConfigSpecsResponse } from './DownloadConfigSpecsResponse'; import { ErrorBoundary } from './ErrorBoundary'; import { DynamicConfigEvaluationOptions, ExperimentEvaluationOptions, FeatureGateEvaluationOptions, LayerEvaluationOptions, ParameterStoreEvaluationOptions } from './EvaluationOptions'; import { AnyInitializeResponse, ClientInitializeResponseOptions } from './InitializeResponse'; import { StatsigSession, StatsigSession as StatsigSessionType } from './SessionID'; import { StatsigClientEventEmitterInterface } from './StatsigClientEventEmitter'; import { EvaluationsDataAdapter, SpecsDataAdapter } from './StatsigDataAdapter'; import { StatsigEvent } from './StatsigEvent'; import { AnyStatsigOptions, StatsigRuntimeMutableOptions } from './StatsigOptionsCommon'; import { DynamicConfig, Experiment, FeatureGate, Layer, ParameterStore } from './StatsigTypes'; import { StatsigUpdateDetails } from './StatsigUpdateDetails'; import { StatsigUser } from './StatsigUser'; import { Flatten } from './TypingUtils'; export interface StatsigClientCommonInterface extends StatsigClientEventEmitterInterface { initializeSync(): StatsigUpdateDetails; initializeAsync(): Promise; shutdown(): Promise; flush(): Promise; updateRuntimeOptions(options: StatsigRuntimeMutableOptions): void; } export type CommonContext = { sdkKey: string; options: AnyStatsigOptions; errorBoundary: ErrorBoundary; session: StatsigSession; stableID: string | null; sdkInstanceID: string; }; export type OnDeviceEvaluationsContext = CommonContext & { values: DownloadConfigSpecsResponse | null; }; export interface OnDeviceEvaluationsInterface extends StatsigClientCommonInterface { readonly dataAdapter: SpecsDataAdapter; getContext(): OnDeviceEvaluationsContext; checkGate(name: string, user: StatsigUser, options?: FeatureGateEvaluationOptions): boolean; getFeatureGate(name: string, user: StatsigUser, options?: FeatureGateEvaluationOptions): FeatureGate; getDynamicConfig(name: string, user: StatsigUser, options?: DynamicConfigEvaluationOptions): DynamicConfig; getExperiment(name: string, user: StatsigUser, options?: ExperimentEvaluationOptions): Experiment; getLayer(name: string, user: StatsigUser, options?: LayerEvaluationOptions): Layer; logEvent(event: StatsigEvent, user: StatsigUser): void; logEvent(eventName: string, user: StatsigUser, value?: string | number, metadata?: Record): void; getClientInitializeResponse(user: StatsigUser, options?: ClientInitializeResponseOptions): AnyInitializeResponse | null; } export type PrecomputedEvaluationsContext = Flatten; export interface PrecomputedEvaluationsInterface extends StatsigClientCommonInterface { readonly dataAdapter: EvaluationsDataAdapter; getContext(): PrecomputedEvaluationsContext; getContextHandle(): PrecomputedEvaluationsContextHandle; updateUserSync(user: StatsigUser): StatsigUpdateDetails; updateUserAsync(user: StatsigUser): Promise; checkGate(name: string, options?: FeatureGateEvaluationOptions): boolean; getFeatureGate(name: string, options?: FeatureGateEvaluationOptions): FeatureGate; getDynamicConfig(name: string, options?: DynamicConfigEvaluationOptions): DynamicConfig; getExperiment(name: string, options?: ExperimentEvaluationOptions): Experiment; getLayer(name: string, options?: LayerEvaluationOptions): Layer; getParameterStore(name: string, options?: ParameterStoreEvaluationOptions): ParameterStore; logEvent(event: StatsigEvent): void; logEvent(eventName: string, value?: string | number, metadata?: Record): void; } export type StatsigClientInterface = OnDeviceEvaluationsInterface | PrecomputedEvaluationsInterface; /** * A handle to the PrecomputedEvaluationsContext that computes fields lazily on access. * This avoids unnecessary computation (e.g., cloning the user) when only certain fields are needed. * The handle is created once and reused; individual getters fetch current values on each access. */ export declare class PrecomputedEvaluationsContextHandle { private _sdkKey; private _getOptions; private _getErrorBoundary; private _getValues; private _getUser; private _getSdkInstanceID; constructor(sdkKey: string, getOptions: () => AnyStatsigOptions, getErrorBoundary: () => ErrorBoundary, getValues: () => AnyInitializeResponse | null, getUser: () => StatsigUser, getSdkInstanceID: () => string); get sdkKey(): string; get options(): AnyStatsigOptions; get errorBoundary(): ErrorBoundary; get values(): AnyInitializeResponse | null; get user(): StatsigUser; /** * Gets the current session. * @param {boolean} [bumpSession=true] - Whether to bump/update the session timing. Set to false to read without affecting session state. */ getSession(bumpSession?: boolean): StatsigSessionType; get stableID(): string | null; get sdkInstanceID(): string; /** * Returns the full PrecomputedEvaluationsContext object. * Use this when you need all fields at once. * @param {boolean} [bumpSession=true] - Whether to bump the session when building the context. */ toContext(bumpSession?: boolean): PrecomputedEvaluationsContext; }