import DynamicConfig from './DynamicConfig'; import { StatsigInvalidArgumentError, StatsigLocalModeNetworkError, StatsigTooManyRequestsError, StatsigUninitializedError } from './Errors'; import { ClientInitializeResponse } from './Evaluator'; import { FeatureGate } from './FeatureGate'; import { InitializationDetails } from './InitializationDetails'; import { AdapterResponse, DataAdapterKeyPath, IDataAdapter } from './interfaces/IDataAdapter'; import { UserPersistedValues } from './interfaces/IUserPersistentStorage'; import Layer from './Layer'; import { CheckGateOptions, ClientInitializeResponseExperimentOverride, ClientInitializeResponseOptions, ClientInitializeResponseValueOverride, CoreApiOptions, EvaluationCallbacks, ExplicitStatsigOptions, GetConfigOptions, GetExperimentOptions, GetLayerOptions, InitStrategy, LoggerInterface, NetworkOverrideFunc, PersistentAssignmentOptions, RetryBackoffFunc, RulesUpdatedCallback, StatsigEnvironment, StatsigOptions } from './StatsigOptions'; import StatsigServer, { LogEventObject } from './StatsigServer'; import { StatsigUser } from './StatsigUser'; export type { AdapterResponse, LogEventObject, StatsigUser, InitializationDetails, FeatureGate, RulesUpdatedCallback, StatsigOptions, GetExperimentOptions, GetLayerOptions, StatsigEnvironment, InitStrategy, CoreApiOptions, EvaluationCallbacks, ExplicitStatsigOptions, LoggerInterface, NetworkOverrideFunc, PersistentAssignmentOptions, RetryBackoffFunc, ClientInitializeResponseOptions, ClientInitializeResponseExperimentOverride, ClientInitializeResponseValueOverride, }; export * from './StatsigOptions'; export { DynamicConfig, IDataAdapter, DataAdapterKeyPath, Layer, StatsigServer, }; export declare const Statsig: { /** * Initializes the statsig server SDK. * This must be called before checking gates/configs or logging events. * * @param {string} secretKey - The secret key for this project from the statsig console. Secret keys should be kept secure on the server side, and not used for client-side integrations * @param {?StatsigOptions} [options={}] - manual sdk configuration for advanced setup * @returns {Promise} - a promise which rejects only if you fail to provide a proper SDK Key * @throws Error if a Server Secret Key is not provided */ initialize(secretKey: string, options?: StatsigOptions): Promise; /** * Gets the boolean result of a gate, evaluated against the given user. * An exposure event will automatically be logged for the gate. * * @param {StatsigUser} user - the user to check this gate value for * @param {string} gateName - the name of the gate to check * @param {CheckGateOptions} options - the options on how gate should be checkced * @returns {boolean} - The value of the gate for the user. Gates are off (return false) by default * @throws Error if initialize() was not called first */ checkGate(user: StatsigUser, gateName: string, options?: CheckGateOptions): boolean; getFeatureGate(user: StatsigUser, gateName: string, options?: CheckGateOptions): FeatureGate; /** * Logs an exposure event for the gate * * @param {StatsigUser} user - the user to log the exposure against * @param {string} gateName - the name of the gate to expose */ manuallyLogGateExposure(user: StatsigUser, gateName: string): void; /** * Get the values of a dynamic config, evaluated against the given user. * An exposure event will automatically be logged for the dynamic config. * * @param {StatsigUser} user - the user to evaluate for the dyamic config * @param {string} configName - the name of the dynamic config to get * @param {GetConfigOptions} options - options for config evaluation * @returns {DynamicConfig} - the config for the user * @throws Error if initialize() was not called first */ getConfig(user: StatsigUser, configName: string, options?: GetConfigOptions): DynamicConfig; /** * Logs an exposure event for the dynamic config * * @param {StatsigUser} user - the user to log the exposure against * @param {string} configName - the name of the dynamic config to expose */ manuallyLogConfigExposure(user: StatsigUser, configName: string): void; /** * Get the values of an experiment, evaluated against the given user. * An exposure event will automatically be logged for the experiment. * * @param {StatsigUser} user - the user to evaluate for the experiment * @param {string} experimentName - the name of the experiment to get * @param {GetExperimentOptions} options - options for experiment evaluation * @returns {DynamicConfig} - the experiment for the user, represented by a Dynamic Config object * @throws Error if initialize() was not called first */ getExperiment(user: StatsigUser, experimentName: string, options?: GetExperimentOptions): DynamicConfig; /** * Get the name of an layer an experiment is in * No exposure event will be logged. * * @param {string} experimentName - the name of the experiment to get * @returns {string} - the layer name the experiment belongs to * @throws Error if initialize() was not called first */ getExperimentLayer(experimentName: string): string | null; /** * Logs an exposure event for the experiment. * * @param {StatsigUser} user - the user to log the exposure against * @param {string} experimentName - the name of the experiment to expose */ manuallyLogExperimentExposure(user: StatsigUser, experimentName: string): void; /** * Get the values of a layer, evaluated against the given user. * Exposure events will be fired when get or getValue is called on the resulting Layer class. * * @param {StatsigUser} user - the user to evaluate for the layer * @param {string} layerName - the name of the layer to get * @param {GetLayerOptions} options - options for layer evaluation * @returns {Layer} - the layer for the user, represented by a Layer * @throws Error if initialize() was not called first */ getLayer(user: StatsigUser, layerName: string, options?: GetLayerOptions): Layer; /** * Logs an exposure event for the parameter in the given layer * * @param {StatsigUser} user - the user to log the exposure against * @param {string} layerName - the name of the layer * @param {string} parameterName - the name of the parameter in the layer */ manuallyLogLayerParameterExposure(user: StatsigUser, layerName: string, parameterName: string): void; getUserPersistedValues(user: StatsigUser, idType: string): UserPersistedValues; getPromptSet(aiConfigName: string): Record[] | null; /** * Log an event for data analysis and alerting or to measure the impact of an experiment * * @param {StatsigUser} user - the user associated with this event * @param {string} eventName - the name of the event (name = Purchase) * @param {string | number | null} value - the value associated with the event (value = 10) * @param {Record | null} metadata - other attributes associated with this event (metadata = {item_name: 'banana', currency: 'USD'}) * @throws Error if initialize() was not called first */ logEvent(user: StatsigUser, eventName: string, value?: string | number | null, metadata?: Record | null): void; /** * Log an event for data analysis and alerting or to measure the impact of an experiment * * @param {LogEventObject} eventObject - an object containing the event data */ logEventObject(eventObject: LogEventObject): void; /** * Informs the statsig SDK that the client is closing or shutting down * so the SDK can clean up internal stat * @param timeout the timeout in milliseconds to wait for pending promises to resolve */ shutdown(timeout?: number): void; /** * Informs the statsig SDK that the server is closing or shutting down * so the SDK can clean up internal state * Ensures any pending promises are resolved and remaining events are flushed. * @param timeout the timeout in milliseconds to wait for pending promises to resolve */ shutdownAsync(timeout?: number): Promise; /** * Returns the initialize values for the given user * Can be used to bootstrap a client SDK with up to date values * @param user the user to evaluate configurations for * @param clientSDKKey the client SDK key to use for fetching configs */ getClientInitializeResponse(user: StatsigUser, clientSDKKey?: string, options?: ClientInitializeResponseOptions): ClientInitializeResponse | null; /** * Overrides the given gate with the provided value * If no userID is provided, it will override for all users * If a userID is provided, it will override the gate with the given value for that user only */ overrideGate(gateName: string, value: boolean, userID?: string): void; /** * Overrides the given config or experiment with the provided value * If no userID is provided, it will override for all users * If a userID is provided, it will override the config/experiment with the given value for that user only */ overrideConfig(configName: string, value: Record, userID?: string): void; /** * Overrides the given layer with the provided value * If no userID is provided, it will override for all users * If a userID is provided, it will override the layer with the given value for that user only */ overrideLayer(layerName: string, value: Record, userID?: string): void; /** * Flushes all the events that are currently in the queue to Statsig. */ flush(timeout?: number): Promise; /** * Clears all gate overrides */ clearAllGateOverrides(): void; /** * Clears all config overrides */ clearAllConfigOverrides(): void; /** * Clears all layer overrides */ clearAllLayerOverrides(): void; /** * Gets all Feature Gate names * * @returns {string[]} */ getFeatureGateList(): string[]; /** * Gets all Dynamic Config names * * @returns {string[]} */ getDynamicConfigList(): string[]; /** * Gets all Experiment names * * @returns {string[]} */ getExperimentList(): string[]; /** * Gets all Autotune names * * @returns {string[]} */ getAutotuneList(): string[]; /** * Gets all Layer names * * @returns {string[]} */ getLayerList(): string[]; syncConfigSpecs(): Promise; syncIdLists(): Promise; /** * @deprecated Please use checkGateSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ checkGateSync(user: StatsigUser, gateName: string): boolean; /** * @deprecated Please use getFeatureGate instead. * @see https://docs.statsig.com/server/deprecation-notices */ getFeatureGateSync(user: StatsigUser, gateName: string): FeatureGate; /** * @deprecated Please use checkGate() with CheckGateOptions instead. * @see https://docs.statsig.com/server/deprecation-notices */ checkGateWithExposureLoggingDisabledSync(user: StatsigUser, gateName: string): boolean; /** * @deprecated Please use getConfig instead. * @see https://docs.statsig.com/server/deprecation-notices */ getConfigSync(user: StatsigUser, configName: string): DynamicConfig; /** * @deprecated Please use getConfig() with GetConfigOptions instead. * @see https://docs.statsig.com/server/deprecation-notices */ getConfigWithExposureLoggingDisabledSync(user: StatsigUser, configName: string): DynamicConfig; /** * @deprecated Please use getExperiment instead. * @see https://docs.statsig.com/server/deprecation-notices */ getExperimentSync(user: StatsigUser, experimentName: string, options?: GetExperimentOptions): DynamicConfig; /** * @deprecated Please use getExperiment() with GetExperimentOptions instead. * @see https://docs.statsig.com/server/deprecation-notices */ getExperimentWithExposureLoggingDisabledSync(user: StatsigUser, experimentName: string, options?: GetExperimentOptions): DynamicConfig; /** * @deprecated Please use getLayer instead. * @see https://docs.statsig.com/server/deprecation-notices */ getLayerSync(user: StatsigUser, layerName: string, options?: GetLayerOptions): Layer; /** * @deprecated Please use getLayer with GetLayerOptions instead. * @see https://docs.statsig.com/server/deprecation-notices */ getLayerWithExposureLoggingDisabledSync(user: StatsigUser, layerName: string, options?: GetLayerOptions): Layer; /** * @deprecated Please use checkGate with CheckGateOptions instead. * @see https://docs.statsig.com/server/deprecation-notices */ checkGateWithExposureLoggingDisabled(user: StatsigUser, gateName: string): boolean; /** * @deprecated Please use getFeatureGate with CheckGateOptions instead. * @see https://docs.statsig.com/server/deprecation-notices */ getFeatureGateWithExposureLoggingDisabled(user: StatsigUser, gateName: string): FeatureGate; /** * @deprecated Please use getExperiment with GetExperimentOptions instead. * @see https://docs.statsig.com/server/deprecation-notices */ getExperimentWithExposureLoggingDisabled(user: StatsigUser, experimentName: string, options?: GetExperimentOptions): DynamicConfig; /** * @deprecated Please use getConfig with GetConfigOptions instead. * @see https://docs.statsig.com/server/deprecation-notices */ getConfigWithExposureLoggingDisabled(user: StatsigUser, configName: string): DynamicConfig; /** * @deprecated Please use getLayer with GetLayerOptions instead. * @see https://docs.statsig.com/server/deprecation-notices */ getLayerWithExposureLoggingDisabled(user: StatsigUser, layerName: string, options?: GetLayerOptions): Layer; _enforceServer(): StatsigServer; StatsigServer: typeof StatsigServer; DataAdapterKeyPath: typeof DataAdapterKeyPath; DynamicConfig: typeof DynamicConfig; Layer: typeof Layer; StatsigInvalidArgumentError: typeof StatsigInvalidArgumentError; StatsigLocalModeNetworkError: typeof StatsigLocalModeNetworkError; StatsigTooManyRequestsError: typeof StatsigTooManyRequestsError; StatsigUninitializedError: typeof StatsigUninitializedError; }; type Statsig = Omit; declare const _default: Statsig; export default _default;