@statsig/client-core
Advanced tools
Comparing version 1.4.0 to 1.5.0-beta.1
{ | ||
"name": "@statsig/client-core", | ||
"version": "1.4.0", | ||
"version": "1.5.0-beta.1", | ||
"dependencies": {}, | ||
@@ -5,0 +5,0 @@ "type": "commonjs", |
import { DataAdapterAsyncOptions, DataAdapterResult } from './StatsigDataAdapter'; | ||
import { AnyStatsigOptions } from './StatsigOptionsCommon'; | ||
import { StatsigUser } from './StatsigUser'; | ||
import { StatsigUser, StatsigUserInternal } from './StatsigUser'; | ||
export declare abstract class DataAdapterCore { | ||
@@ -21,6 +21,6 @@ private _adapterName; | ||
__primeInMemoryCache(cache: Record<string, DataAdapterResult>): void; | ||
protected _getDataAsyncImpl(current: DataAdapterResult | null, user?: StatsigUser, options?: DataAdapterAsyncOptions): Promise<DataAdapterResult | null>; | ||
protected _getDataAsyncImpl(current: DataAdapterResult | null, user?: StatsigUserInternal, options?: DataAdapterAsyncOptions): Promise<DataAdapterResult | null>; | ||
protected _prefetchDataImpl(user?: StatsigUser, options?: DataAdapterAsyncOptions): Promise<void>; | ||
protected abstract _fetchFromNetwork(current: string | null, user?: StatsigUser, options?: DataAdapterAsyncOptions): Promise<string | null>; | ||
protected abstract _getCacheKey(user?: StatsigUser): string; | ||
protected abstract _getCacheKey(user?: StatsigUserInternal): string; | ||
protected abstract _isCachedResultValidFor204(result: DataAdapterResult, user: StatsigUser | undefined): boolean; | ||
@@ -27,0 +27,0 @@ private _fetchAndPrepFromNetwork; |
@@ -33,4 +33,5 @@ "use strict"; | ||
getDataSync(user) { | ||
const cacheKey = this._getCacheKey(user); | ||
const inMem = this._inMemoryCache.get(cacheKey, user); | ||
const normalized = user && (0, StatsigUser_1._normalizeUser)(user, this._options); | ||
const cacheKey = this._getCacheKey(normalized); | ||
const inMem = this._inMemoryCache.get(cacheKey, normalized); | ||
if (inMem) { | ||
@@ -42,3 +43,3 @@ return inMem; | ||
this._inMemoryCache.add(cacheKey, cache); | ||
return this._inMemoryCache.get(cacheKey, user); | ||
return this._inMemoryCache.get(cacheKey, normalized); | ||
} | ||
@@ -48,4 +49,3 @@ return null; | ||
setData(data, user) { | ||
var _a; | ||
const normalized = user && (0, StatsigUser_1._normalizeUser)(user, (_a = this._options) === null || _a === void 0 ? void 0 : _a.environment); | ||
const normalized = user && (0, StatsigUser_1._normalizeUser)(user, this._options); | ||
const cacheKey = this._getCacheKey(normalized); | ||
@@ -77,4 +77,5 @@ this._inMemoryCache.add(cacheKey, _makeDataAdapterResult('Bootstrap', data, null, normalized)); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const cacheKey = this._getCacheKey(user); | ||
const result = yield this._getDataAsyncImpl(null, user, options); | ||
const normalized = user && (0, StatsigUser_1._normalizeUser)(user, this._options); | ||
const cacheKey = this._getCacheKey(normalized); | ||
const result = yield this._getDataAsyncImpl(null, normalized, options); | ||
if (result) { | ||
@@ -81,0 +82,0 @@ this._inMemoryCache.add(cacheKey, Object.assign(Object.assign({}, result), { source: 'Prefetch' })); |
@@ -56,4 +56,4 @@ "use strict"; | ||
}); | ||
this._retryFailedLogs(); | ||
this._startBackgroundFlushInterval(); | ||
// this._retryFailedLogs(); | ||
// this._startBackgroundFlushInterval(); | ||
} | ||
@@ -113,3 +113,3 @@ setLoggingDisabled(isDisabled) { | ||
} | ||
setTimeout(() => _safeFlushAndForget(this._sdkKey), QUICK_FLUSH_WINDOW_MS); | ||
// setTimeout(() => _safeFlushAndForget(this._sdkKey), QUICK_FLUSH_WINDOW_MS); | ||
} | ||
@@ -120,3 +120,3 @@ _shouldLogEvent(event) { | ||
} | ||
const user = event.user ? event.user : {}; | ||
const user = event.user ? event.user : { statsigEnvironment: undefined }; | ||
const metadata = event.metadata ? event.metadata : {}; | ||
@@ -123,0 +123,0 @@ const key = [ |
import { SecondaryExposure } from './EvaluationTypes'; | ||
import { DynamicConfig, FeatureGate, Layer } from './StatsigTypes'; | ||
import { StatsigUser } from './StatsigUser'; | ||
import { StatsigUserInternal } from './StatsigUser'; | ||
export type StatsigEvent = { | ||
@@ -12,3 +12,3 @@ eventName: string; | ||
export type StatsigEventInternal = Omit<StatsigEvent, 'metadata'> & { | ||
user: StatsigUser | null; | ||
user: StatsigUserInternal | null; | ||
time: number; | ||
@@ -21,4 +21,4 @@ metadata?: { | ||
export declare const _isExposureEvent: ({ eventName, }: StatsigEventInternal) => boolean; | ||
export declare const _createGateExposure: (user: StatsigUser, gate: FeatureGate) => StatsigEventInternal; | ||
export declare const _createConfigExposure: (user: StatsigUser, config: DynamicConfig) => StatsigEventInternal; | ||
export declare const _createLayerParameterExposure: (user: StatsigUser, layer: Layer, parameterName: string) => StatsigEventInternal; | ||
export declare const _createGateExposure: (user: StatsigUserInternal, gate: FeatureGate) => StatsigEventInternal; | ||
export declare const _createConfigExposure: (user: StatsigUserInternal, config: DynamicConfig) => StatsigEventInternal; | ||
export declare const _createLayerParameterExposure: (user: StatsigUserInternal, layer: Layer, parameterName: string) => StatsigEventInternal; |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "1.4.0"; | ||
export declare const SDK_VERSION = "1.5.0-beta.1"; | ||
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.4.0'; | ||
exports.SDK_VERSION = '1.5.0-beta.1'; | ||
let metadata = { | ||
@@ -6,0 +6,0 @@ sdkVersion: exports.SDK_VERSION, |
@@ -1,2 +0,2 @@ | ||
import type { StatsigEnvironment } from './StatsigOptionsCommon'; | ||
import type { AnyStatsigOptions, StatsigEnvironment } from './StatsigOptionsCommon'; | ||
type StatsigUserPrimitives = string | number | boolean | Array<string> | undefined; | ||
@@ -19,6 +19,6 @@ export type StatsigUser = { | ||
export type StatsigUserInternal = StatsigUser & { | ||
statsigEnvironment?: StatsigEnvironment; | ||
statsigEnvironment: StatsigEnvironment | undefined; | ||
}; | ||
export declare function _normalizeUser(original: StatsigUser, environment?: StatsigEnvironment): StatsigUser; | ||
export declare function _normalizeUser(original: StatsigUser, options?: AnyStatsigOptions | null): StatsigUserInternal; | ||
export declare function _getFullUserHash(user: StatsigUser | undefined): string | null; | ||
export {}; |
@@ -6,7 +6,7 @@ "use strict"; | ||
const Log_1 = require("./Log"); | ||
function _normalizeUser(original, environment) { | ||
function _normalizeUser(original, options) { | ||
try { | ||
const copy = JSON.parse(JSON.stringify(original)); | ||
if (environment != null) { | ||
copy.statsigEnvironment = environment; | ||
if (options != null && options.environment != null) { | ||
copy.statsigEnvironment = options.environment; | ||
} | ||
@@ -17,3 +17,3 @@ return copy; | ||
Log_1.Log.error('Failed to JSON.stringify user'); | ||
return {}; | ||
return { statsigEnvironment: undefined }; | ||
} | ||
@@ -20,0 +20,0 @@ } |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
120390
2843
2