import DynamicConfig from './DynamicConfig'; import { ClientInitializeResponse } from './Evaluator'; import { FeatureGate } from './FeatureGate'; import { AdapterResponse, IDataAdapter } from './interfaces/IDataAdapter'; import Layer from './Layer'; import { RulesUpdatedCallback, StatsigEnvironment, InitStrategy, StatsigOptions } from './StatsigOptions'; import StatsigServer, { ClientInitializeResponseOptions, LogEventObject } from './StatsigServer'; import { StatsigUser } from './StatsigUser'; export { DynamicConfig, Layer, LogEventObject, RulesUpdatedCallback, StatsigUser, StatsigOptions, StatsigEnvironment, InitStrategy, IDataAdapter, AdapterResponse, StatsigServer, }; export declare const Statsig: { DynamicConfig: typeof DynamicConfig; Layer: typeof Layer; StatsigServer: typeof StatsigServer; /** * 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 * @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 * @throws Error if the gateName is not provided or not a non-empty string */ checkGateSync(user: StatsigUser, gateName: string): boolean; getFeatureGateSync(user: StatsigUser, gateName: string): FeatureGate; /** * Gets the boolean result of a gate, evaluated against the given user. * No exposure event will be logged. * * @param {StatsigUser} user - the user to check this gate value for * @param {string} gateName - the name of the gate to check * @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 * @throws Error if the gateName is not provided or not a non-empty string */ checkGateWithExposureLoggingDisabledSync(user: StatsigUser, gateName: string): boolean; getFeatureGateWithExposureLoggingDisabledSync(user: StatsigUser, gateName: string): 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 * @returns {DynamicConfig} - the config for the user * @throws Error if initialize() was not called first * @throws Error if the configName is not provided or not a non-empty string */ getConfigSync(user: StatsigUser, configName: string): DynamicConfig; /** * Get the values of a dynamic config, evaluated against the given user. * No exposure event will be logged. * * @param {StatsigUser} user - the user to evaluate for the dyamic config * @param {string} configName - the name of the dynamic config to get * @returns {DynamicConfig} - the config for the user * @throws Error if initialize() was not called first */ getConfigWithExposureLoggingDisabledSync(user: StatsigUser, configName: string): 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 * @returns {DynamicConfig} - the experiment for the user, represented by a Dynamic Config object * @throws Error if initialize() was not called first */ getExperimentSync(user: StatsigUser, experimentName: string): DynamicConfig; /** * Get the values of an experiment, evaluated against the given user. * No exposure event will be logged. * * @param {StatsigUser} user - the user to evaluate for the experiment * @param {string} experimentName - the name of the experiment to get * @returns {DynamicConfig} - the experiment for the user, represented by a Dynamic Config object * @throws Error if initialize() was not called first */ getExperimentWithExposureLoggingDisabledSync(user: StatsigUser, experimentName: string): DynamicConfig; /** * 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 * @returns {Layer} - the layer for the user, represented by a Layer * @throws Error if initialize() was not called first */ getLayerSync(user: StatsigUser, layerName: string): Layer; /** * Get the values of a layer, evaluated against the given user. * No exposure events will be logged from the resulting Layer class. * * @param {StatsigUser} user - the user to evaluate for the layer * @param {string} layerName - the name of the layer to get * @returns {Layer} - the layer for the user, represented by a Layer * @throws Error if initialize() was not called first * @throws Error if the layerName is not provided or not a non-empty string */ getLayerWithExposureLoggingDisabledSync(user: StatsigUser, layerName: string): 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; /** * 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 state */ shutdown(): void; /** * 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 */ getClientInitializeResponse(user: StatsigUser, 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(): 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 */ checkGate(user: StatsigUser, gateName: string): Promise; /** * @deprecated Please use getFeatureGateSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ getFeatureGate(user: StatsigUser, gateName: string): Promise; /** * @deprecated Please use checkGateWithExposureLoggingDisabledSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ checkGateWithExposureLoggingDisabled(user: StatsigUser, gateName: string): Promise; /** * @deprecated Please use getFeatureGateWithExposureLoggingDisabledSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ getFeatureGateWithExposureLoggingDisabled(user: StatsigUser, gateName: string): Promise; /** * @deprecated Please use getConfigSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ getConfig(user: StatsigUser, configName: string): Promise; /** * @deprecated Please use getConfigWithExposureLoggingDisabledSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ getConfigWithExposureLoggingDisabled(user: StatsigUser, configName: string): Promise; /** * @deprecated Please use getExperimentSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ getExperiment(user: StatsigUser, experimentName: string): Promise; /** * @deprecated Please use getExperimentWithExposureLoggingDisabledSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ getExperimentWithExposureLoggingDisabled(user: StatsigUser, experimentName: string): Promise; /** * @deprecated Please use getLayerSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ getLayer(user: StatsigUser, layerName: string): Promise; /** * @deprecated Please use getLayerWithExposureLoggingDisabledSync instead. * @see https://docs.statsig.com/server/deprecation-notices */ getLayerWithExposureLoggingDisabled(user: StatsigUser, layerName: string): Promise; _enforceServer(): StatsigServer; }; type Statsig = Omit; declare const _default: Statsig; export default _default;