@statsig/client-core
Advanced tools
Comparing version 1.2.0 to 1.3.0
{ | ||
"name": "@statsig/client-core", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"dependencies": {}, | ||
@@ -5,0 +5,0 @@ "type": "commonjs", |
import { DownloadConfigSpecsResponse } from './DownloadConfigSpecsResponse'; | ||
import { ErrorBoundary } from './ErrorBoundary'; | ||
import { DynamicConfigEvaluationOptions, ExperimentEvaluationOptions, FeatureGateEvaluationOptions, LayerEvaluationOptions } from './EvaluationOptions'; | ||
import { DynamicConfigEvaluationOptions, ExperimentEvaluationOptions, FeatureGateEvaluationOptions, LayerEvaluationOptions, ParameterStoreEvaluationOptions } from './EvaluationOptions'; | ||
import { InitializeResponseWithUpdates } from './InitializeResponse'; | ||
@@ -10,3 +10,3 @@ import { StatsigSession } from './SessionID'; | ||
import { AnyStatsigOptions, StatsigRuntimeMutableOptions } from './StatsigOptionsCommon'; | ||
import { DynamicConfig, Experiment, FeatureGate, Layer } from './StatsigTypes'; | ||
import { DynamicConfig, Experiment, FeatureGate, Layer, ParameterStore } from './StatsigTypes'; | ||
import { StatsigUser } from './StatsigUser'; | ||
@@ -62,2 +62,3 @@ import { Flatten } from './UtitlityTypes'; | ||
getLayer(name: string, options?: LayerEvaluationOptions): Layer; | ||
getParameterStore(name: string, options?: ParameterStoreEvaluationOptions): ParameterStore; | ||
logEvent(event: StatsigEvent): void; | ||
@@ -64,0 +65,0 @@ logEvent(eventName: string, value?: string | number, metadata?: Record<string, string>): void; |
@@ -21,1 +21,2 @@ export type EvaluationOptionsCommon = { | ||
export type LayerEvaluationOptions = EvaluationOptionsCommon & {}; | ||
export type ParameterStoreEvaluationOptions = EvaluationOptionsCommon & {}; |
@@ -0,1 +1,2 @@ | ||
import { ParamStoreConfig } from './ParamStoreTypes'; | ||
import { Flatten } from './UtitlityTypes'; | ||
@@ -35,6 +36,6 @@ type EvaluationBase<T> = { | ||
}; | ||
export type DetailedEvaluation<T extends AnyEvaluation> = { | ||
evaluation: T | null; | ||
export type DetailedStoreResult<T extends AnyEvaluation | ParamStoreConfig> = { | ||
result: T | null; | ||
details: EvaluationDetails; | ||
}; | ||
export {}; |
@@ -20,2 +20,3 @@ /** Statsig Global should go first */ | ||
export * from './OverrideAdapter'; | ||
export * from './ParamStoreTypes'; | ||
export * from './SafeJs'; | ||
@@ -22,0 +23,0 @@ export * from './SDKType'; |
@@ -41,2 +41,3 @@ "use strict"; | ||
__exportStar(require("./OverrideAdapter"), exports); | ||
__exportStar(require("./ParamStoreTypes"), exports); | ||
__exportStar(require("./SafeJs"), exports); | ||
@@ -43,0 +44,0 @@ __exportStar(require("./SDKType"), exports); |
import { DynamicConfigEvaluation, GateEvaluation, LayerEvaluation } from './EvaluationTypes'; | ||
import { ParamStoreConfig } from './ParamStoreTypes'; | ||
import { StatsigUser } from './StatsigUser'; | ||
@@ -11,2 +12,3 @@ type SessionReplayFields = { | ||
layer_configs: Record<string, LayerEvaluation>; | ||
param_stores?: Record<string, ParamStoreConfig>; | ||
time: number; | ||
@@ -13,0 +15,0 @@ has_updates: true; |
@@ -18,3 +18,4 @@ type SessionTimeoutID = ReturnType<typeof setTimeout>; | ||
get: (sdkKey: string) => Promise<StatsigSession>; | ||
overrideInitialSessionID: (override: string, sdkKey: string) => void; | ||
}; | ||
export {}; |
@@ -33,2 +33,5 @@ "use strict"; | ||
}), | ||
overrideInitialSessionID: (override, sdkKey) => { | ||
PROMISE_MAP[sdkKey] = _overrideSessionId(override, sdkKey); | ||
}, | ||
}; | ||
@@ -52,2 +55,13 @@ function _loadSession(sdkKey) { | ||
} | ||
function _overrideSessionId(override, sdkKey) { | ||
const now = Date.now(); | ||
return Promise.resolve({ | ||
data: { | ||
sessionID: override, | ||
startTime: now, | ||
lastUpdate: now, | ||
}, | ||
sdkKey, | ||
}); | ||
} | ||
function _bumpSession(session) { | ||
@@ -54,0 +68,0 @@ const now = Date.now(); |
@@ -19,2 +19,3 @@ "use strict"; | ||
const SafeJs_1 = require("./SafeJs"); | ||
const SessionID_1 = require("./SessionID"); | ||
const StorageProvider_1 = require("./StorageProvider"); | ||
@@ -29,2 +30,4 @@ class StatsigClientBase { | ||
(options === null || options === void 0 ? void 0 : options.disableStorage) && StorageProvider_1.Storage._setDisabled(true); | ||
(options === null || options === void 0 ? void 0 : options.initialSessionID) && | ||
SessionID_1.StatsigSession.overrideInitialSessionID(options.initialSessionID, sdkKey); | ||
this._sdkKey = sdkKey; | ||
@@ -31,0 +34,0 @@ this._options = options !== null && options !== void 0 ? options : {}; |
@@ -8,3 +8,3 @@ import { SecondaryExposure } from './EvaluationTypes'; | ||
metadata?: { | ||
[key: string]: string; | ||
[key: string]: string | undefined; | ||
} | null; | ||
@@ -11,0 +11,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "1.2.0"; | ||
export declare const SDK_VERSION = "1.3.0"; | ||
export type StatsigMetadata = { | ||
@@ -3,0 +3,0 @@ readonly [key: string]: string | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0; | ||
exports.SDK_VERSION = '1.2.0'; | ||
exports.SDK_VERSION = '1.3.0'; | ||
let metadata = { | ||
@@ -6,0 +6,0 @@ sdkVersion: exports.SDK_VERSION, |
@@ -107,2 +107,8 @@ import { LogLevel } from './Log'; | ||
overrideAdapter?: OverrideAdapter; | ||
/** | ||
* Overrides the auto-generated SessionID with the provided string. | ||
* | ||
* Note: Sessions still expire and will be replaced with an auto-generated SessionID. | ||
*/ | ||
initialSessionID?: string; | ||
}; | ||
@@ -109,0 +115,0 @@ export type AnyStatsigOptions = StatsigOptionsCommon<NetworkConfigCommon>; |
import { DynamicConfigEvaluation, EvaluationDetails, GateEvaluation, LayerEvaluation } from './EvaluationTypes'; | ||
import { AnyConfigBasedStatsigType, DynamicConfig, FeatureGate, Layer } from './StatsigTypes'; | ||
import { AnyConfigBasedStatsigType, DynamicConfig, Experiment, FeatureGate, Layer, TypedGet } from './StatsigTypes'; | ||
type Primitive = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function'; | ||
export declare function _makeFeatureGate(name: string, details: EvaluationDetails, evaluation: GateEvaluation | null): FeatureGate; | ||
export declare function _makeDynamicConfig(name: string, details: EvaluationDetails, evaluation: DynamicConfigEvaluation | null): DynamicConfig; | ||
export declare function _makeExperiment(name: string, details: EvaluationDetails, evaluation: DynamicConfigEvaluation | null): Experiment; | ||
export declare function _makeLayer(name: string, details: EvaluationDetails, evaluation: LayerEvaluation | null, exposeFunc?: (param: string) => void): Layer; | ||
export declare function _mergeOverride<T extends AnyConfigBasedStatsigType>(original: T, overridden: T | null | undefined, value: Record<string, unknown>, exposeFunc?: (param: string) => void): T; | ||
export declare function _typeOf(input: unknown): Primitive | 'array'; | ||
export declare function _isTypeMatch<T>(a: unknown, b: unknown): a is T; | ||
export declare function _makeTypedGet(value: Record<string, unknown> | undefined, exposeFunc?: (param: string) => void): TypedGet; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._mergeOverride = exports._makeLayer = exports._makeDynamicConfig = exports._makeFeatureGate = void 0; | ||
exports._makeTypedGet = exports._isTypeMatch = exports._typeOf = exports._mergeOverride = exports._makeLayer = exports._makeExperiment = exports._makeDynamicConfig = exports._makeFeatureGate = void 0; | ||
const DEFAULT_RULE = 'default'; | ||
@@ -21,5 +21,12 @@ function _makeEvaluation(name, details, evaluation, value) { | ||
var _a; | ||
return Object.assign(Object.assign({}, _makeEvaluation(name, details, evaluation, (_a = evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) !== null && _a !== void 0 ? _a : {})), { groupName: null, get: _makeTypedGet(evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) }); | ||
const value = (_a = evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) !== null && _a !== void 0 ? _a : {}; | ||
return Object.assign(Object.assign({}, _makeEvaluation(name, details, evaluation, value)), { get: _makeTypedGet(evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) }); | ||
} | ||
exports._makeDynamicConfig = _makeDynamicConfig; | ||
function _makeExperiment(name, details, evaluation) { | ||
var _a; | ||
const result = _makeDynamicConfig(name, details, evaluation); | ||
return Object.assign(Object.assign({}, result), { groupName: (_a = evaluation === null || evaluation === void 0 ? void 0 : evaluation.group_name) !== null && _a !== void 0 ? _a : null }); | ||
} | ||
exports._makeExperiment = _makeExperiment; | ||
function _makeLayer(name, details, evaluation, exposeFunc) { | ||
@@ -34,2 +41,6 @@ var _a, _b; | ||
exports._mergeOverride = _mergeOverride; | ||
function _typeOf(input) { | ||
return Array.isArray(input) ? 'array' : typeof input; | ||
} | ||
exports._typeOf = _typeOf; | ||
function _isTypeMatch(a, b) { | ||
@@ -39,2 +50,3 @@ const typeOf = (x) => (Array.isArray(x) ? 'array' : typeof x); | ||
} | ||
exports._isTypeMatch = _isTypeMatch; | ||
function _makeTypedGet(value, exposeFunc) { | ||
@@ -54,1 +66,2 @@ return (param, fallback) => { | ||
} | ||
exports._makeTypedGet = _makeTypedGet; |
import { EvaluationDetails, ExperimentEvaluation, GateEvaluation, LayerEvaluation } from './EvaluationTypes'; | ||
import { ParamStoreConfig } from './ParamStoreTypes'; | ||
import { Flatten } from './UtitlityTypes'; | ||
export type TypedGet = <T = unknown>(key: string, fallback?: T) => TypedReturn<T>; | ||
export type ParamStoreTypedGet = <T = unknown>(key: string, fallback: T) => T; | ||
export type TypedReturn<T = unknown> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends Array<unknown> ? Array<unknown> : T extends object ? object : unknown; | ||
@@ -22,3 +24,3 @@ export type SpecType = 'gate' | 'dynamic_config' | 'experiment' | 'layer'; | ||
}>; | ||
export type DynamicConfig = Flatten<Experiment>; | ||
export type DynamicConfig = Flatten<Omit<Experiment, 'groupName'>>; | ||
export type Layer = Flatten<{ | ||
@@ -33,3 +35,9 @@ readonly name: string; | ||
}>; | ||
export type ParameterStore = Flatten<{ | ||
readonly name: string; | ||
readonly details: EvaluationDetails; | ||
readonly get: TypedGet; | ||
readonly __configuration: ParamStoreConfig | null; | ||
}>; | ||
export type AnyConfigBasedStatsigType = DynamicConfig | Experiment | Layer; | ||
export type AnyStatsigType = FeatureGate | AnyConfigBasedStatsigType; |
119278
75
2829