statsig-js
Version:
Statsig JavaScript client SDK for single user environments.
115 lines (114 loc) • 5.78 kB
TypeScript
import DynamicConfig from './DynamicConfig';
import Layer from './Layer';
import { StatsigOverrides } from './StatsigClient';
import { StatsigOptions } from './StatsigSDKOptions';
import { EvaluationDetails } from './StatsigStore';
import { StatsigUser } from './StatsigUser';
export { default as DynamicConfig } from './DynamicConfig';
export { default as Layer } from './Layer';
export { default as StatsigClient, IStatsig, StatsigOverrides, } from './StatsigClient';
export type { AppState, AppStateEvent, AppStateStatus, _SDKPackageInfo as _SDKPackageInfo, } from './StatsigClient';
export type { DeviceInfo, ExpoConstants, ExpoDevice, NativeModules, Platform, UUID, } from './StatsigIdentity';
export { StatsigEnvironment, StatsigOptions } from './StatsigSDKOptions';
export type { InitCompletionCallback, UpdateUserCompletionCallback, GateEvaluationCallback, } from './StatsigSDKOptions';
export { EvaluationReason } from './utils/EvaluationReason';
export type { EvaluationDetails } from './StatsigStore';
export { StatsigUser } from './StatsigUser';
export { default as StatsigAsyncStorage } from './utils/StatsigAsyncStorage';
export type { AsyncStorage } from './utils/StatsigAsyncStorage';
export default class Statsig {
private static instance;
static get encodeIntializeCall(): boolean;
static set encodeIntializeCall(value: boolean);
static initialize(sdkKey: string, user?: StatsigUser | null, options?: StatsigOptions | null): Promise<void>;
static prefetchUsers(users: StatsigUser[]): Promise<void>;
static setInitializeValues(initializeValues: Record<string, unknown>): void;
static checkGate(gateName: string, ignoreOverrides?: boolean): boolean;
static checkGateWithExposureLoggingDisabled(gateName: string, ignoreOverrides?: boolean): boolean;
static manuallyLogGateExposure(gateName: string): void;
static getConfig(configName: string, ignoreOverrides?: boolean): DynamicConfig;
static getConfigWithExposureLoggingDisabled(configName: string, ignoreOverrides?: boolean): DynamicConfig;
static manuallyLogConfigExposure(configName: string): void;
static getExperiment(experimentName: string, keepDeviceValue?: boolean, ignoreOverrides?: boolean): DynamicConfig;
static getExperimentWithExposureLoggingDisabled(experimentName: string, keepDeviceValue?: boolean, ignoreOverrides?: boolean): DynamicConfig;
static manuallyLogExperimentExposure(configName: string, keepDeviceValue?: boolean): void;
static getLayer(layerName: string, keepDeviceValue?: boolean): Layer;
static getLayerWithExposureLoggingDisabled(layerName: string, keepDeviceValue?: boolean): Layer;
static manuallyLogLayerParameterExposure(layerName: string, parameterName: string, keepDeviceValue?: boolean): void;
static logEvent(eventName: string, value?: string | number | null, metadata?: Record<string, string> | null): void;
static updateUser(user: StatsigUser | null): Promise<boolean>;
static updateUserWithValues(user: StatsigUser | null, values: Record<string, unknown>): boolean;
static shutdown(): void;
/**
* Overrides the given gate locally with the given value
* @param gateName - name of the gate to override
* @param value - value to assign to the gate
*/
static overrideGate(gateName: string, value: boolean): void;
/**
* Overrides the given config locally with the given value
* @param configName - name of the config to override
* @param value - value to assign to the config
*/
static overrideConfig(configName: string, value: Record<string, unknown>): void;
/**
* Overrides the given layer locally with the given value
* @param layerName - name of the layer to override
* @param value - value to assign to the layer
*/
static overrideLayer(layerName: string, value: Record<string, unknown>): void;
/**
* @param name the gate override to remove. Leave this parameter empty to remove all gate overrides.
*/
static removeGateOverride(name?: string): void;
/**
* @param name the config override to remove. Leave this parameter empty to remove all config overrides.
*/
static removeConfigOverride(name?: string): void;
/**
* @param name the layer override to remove. Leave this parameter empty to remove all layer overrides.
*/
static removeLayerOverride(name?: string): void;
/**
* @returns The local gate and config overrides
*/
static getAllOverrides(): StatsigOverrides;
/**
* @returns The Statsig stable ID used for device level experiments
*/
static getStableID(): string;
/**
*
* @returns The reason and time associated with the evaluation for the current set
* of gates and configs
*/
static getEvaluationDetails(): EvaluationDetails;
static getInitializeResponseJson(): {
values: string;
evaluationDetails: EvaluationDetails;
};
/**
* @deprecated use removeGateOverride or removeConfigOverride
* @param name the gate override to remove
*/
static removeOverride(name?: string): void;
/**
* @deprecated use getAllOverrides
* @returns the gate overrides
*/
static getOverrides(): Record<string, unknown>;
/**
* @returns true if initialize has already been called, false otherwise
*/
static initializeCalled(): boolean;
/**
* Send any currently queued events to Statsig
*/
static flushEvents(): void;
/**
* Intended to be used in conjunction with StatsigOptions.disableAllLogging.
* This will set StatsigOptions.disableAllLogging to false, thereby enabling logs to function normally.
*/
static reenableAllLogging(): void;
private static getClientX;
}