import DynamicConfig from './DynamicConfig'; import ErrorBoundary from './ErrorBoundary'; import Layer from './Layer'; import StatsigIdentity from './StatsigIdentity'; import StatsigLogger from './StatsigLogger'; import StatsigNetwork from './StatsigNetwork'; import StatsigSDKOptions, { StatsigOptions } from './StatsigSDKOptions'; import { EvaluationDetails } from './EvaluationMetadata'; import { StatsigUser } from './StatsigUser'; import Evaluator from './Evaluator'; import { UserPersistedValues } from './utils/StickyValuesStorage'; export type CheckGateOptions = { disableExposureLogging: boolean; }; export type GetExperimentOptions = { disableExposureLogging?: boolean; userPersistedValues?: UserPersistedValues | null; }; export type GetLayerOptions = { disableExposureLogging?: boolean; userPersistedValues?: UserPersistedValues | null; }; export type InitializeResult = { success: boolean; message?: string; }; export default class StatsigClient { private _ready; private _initCalled; private _pendingInitPromise; readonly _identity: StatsigIdentity; readonly _errorBoundary: ErrorBoundary; readonly _network: StatsigNetwork; readonly _evaluator: Evaluator; readonly _logger: StatsigLogger; readonly _options: StatsigSDKOptions; constructor(sdkKey: string, options?: StatsigOptions | null); initializeAsync(): Promise; initialize(initializeValues: Record): InitializeResult; getEvaluationDetails(): EvaluationDetails; /** * Checks the value of a gate for the current user * @param {string} gateName - the name of the gate to check * @returns {boolean} - value of a gate for the user. Gates are "off" (return false) by default */ checkGate(user: StatsigUser, gateName: string, options?: CheckGateOptions): boolean; getFeatureGateEvaluation(user: StatsigUser, gateName: string): boolean; logGateExposure(user: StatsigUser, gateName: string): void; /** * Checks the value of a config for the current user * @param {string} configName - the name of the config to get * @returns {DynamicConfig} - value of a config for the user */ getConfig(user: StatsigUser, configName: string): DynamicConfig; logConfigExposure(user: StatsigUser, configName: string): void; getExperiment(user: StatsigUser, experimentName: string, options?: GetExperimentOptions): DynamicConfig; logExperimentExposure(user: StatsigUser, experimentName: string): void; getLayer(user: StatsigUser, layerName: string, options?: GetLayerOptions): Layer; logLayerParameterExposure(user: StatsigUser, layerName: string, parameterName: string): void; logEvent(user: StatsigUser, eventName: string, value?: string | number | null, metadata?: Record | null): void; loadUserPersistedValues(user: StatsigUser, idType: string): UserPersistedValues | null; loadUserPersistedValuesAsync(user: StatsigUser, idType: string): Promise; /** * Informs the statsig SDK that the client is closing or shutting down * so the SDK can clean up internal state */ shutdown(): void; /** * @returns The Statsig stable ID used for device level experiments */ getStableID(): string; initializeCalled(): boolean; private _delayedSetup; private _normalizeUser; private _getEvaluationDetailsForError; private _fetchAndSaveValues; private _checkGateImpl; private _getGateEvaluation; private _logGateExposureImpl; private _getConfigImpl; private _getConfigEvaluation; private _logConfigExposureImpl; private _makeOnConfigDefaultValueFallback; private _getLayerImpl; private _getLayerEvaluation; private _logLayerParameterExposureForLayer; private _getEmptyConfig; }