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 StatsigStore, { EvaluationDetails } from './StatsigStore'; import { StatsigUser } from './StatsigUser'; import { LocalOverrides } from './LocalOverrides'; export default class StatsigClient { private _ready; private _initCalled; private _pendingInitPromise; private _startTime; private _overrides; readonly _identity: StatsigIdentity; readonly _errorBoundary: ErrorBoundary; readonly _network: StatsigNetwork; readonly _store: StatsigStore; readonly _logger: StatsigLogger; readonly _options: StatsigSDKOptions; readonly _sdkKey: string | null; constructor(sdkKey: string, user?: StatsigUser | null, options?: StatsigOptions | null); setInitializeValues(initializeValues: Record): void; initializeAsync(): Promise; 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 * @throws Error if initialize() is not called first, or gateName is not a string */ checkGate(gateName: string): boolean; checkGateWithExposureLoggingDisabled(gateName: string): boolean; logGateExposure(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 * @throws Error if initialize() is not called first, or configName is not a string */ getConfig(configName: string): DynamicConfig; getConfigWithExposureLoggingDisabled(configName: string): DynamicConfig; logConfigExposure(configName: string): void; getExperiment(experimentName: string): DynamicConfig; getExperimentWithExposureLoggingDisabled(experimentName: string): DynamicConfig; logExperimentExposure(experimentName: string): void; getLayer(layerName: string): Layer; getLayerWithExposureLoggingDisabled(layerName: string): Layer; logLayerParameterExposure(layerName: string, parameterName: string): void; logEvent(eventName: string, value?: string | number | null, metadata?: Record | null): void; updateUserWithValues(user: StatsigUser | null, values: Record): boolean; updateUser(user: StatsigUser | null): 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; overrideGate(gate: string, result: boolean | null): void; overrideConfig(config: string, result: Record | null): void; overrideLayer(layer: string, result: Record | null): void; setOverrides(overrides: LocalOverrides | null): void; getOverrides(): LocalOverrides; private _delayedSetup; private _normalizeUser; private _ensureStoreLoaded; private _getEvaluationDetailsForError; private _fetchAndSaveValues; private _checkGateImpl; private _getGateFromStore; private _logGateExposureImpl; private _getConfigImpl; private _getConfigFromStore; private _logConfigExposureImpl; private _getLayerImpl; private _getLayerFromStore; private _logLayerParameterExposureForLayer; private _getEmptyConfig; private _setOverride; }