@statsig/client-core
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "@statsig/client-core", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"dependencies": {}, | ||
@@ -8,2 +8,2 @@ "type": "commonjs", | ||
"typings": "./src/index.d.ts" | ||
} | ||
} |
@@ -12,3 +12,3 @@ import { DownloadConfigSpecsResponse } from './DownloadConfigSpecsResponse'; | ||
import { StatsigUser } from './StatsigUser'; | ||
import { Flatten } from './UtitlityTypes'; | ||
import { Flatten } from './TypingUtils'; | ||
export interface StatsigClientCommonInterface extends StatsigClientEventEmitterInterface { | ||
@@ -15,0 +15,0 @@ initializeSync(): void; |
import { ParamStoreConfig } from './ParamStoreTypes'; | ||
import { Flatten } from './UtitlityTypes'; | ||
import { Flatten } from './TypingUtils'; | ||
type EvaluationBase<T> = { | ||
@@ -4,0 +4,0 @@ id_type: string; |
@@ -259,3 +259,3 @@ "use strict"; | ||
var _a, _b; | ||
if (!(0, SafeJs_1._isBrowserEnv)()) { | ||
if ((0, SafeJs_1._isServerEnv)()) { | ||
return; // do not run in server environments | ||
@@ -262,0 +262,0 @@ } |
export declare const _DJB2: (value: string) => string; | ||
export declare const _DJB2Object: (value: Record<string, unknown> | null) => string; | ||
export declare const _DJB2Object: (value: Record<string, unknown> | null, maxLevels?: number) => string; | ||
export declare const _getSortedObject: (object: Record<string, unknown> | null, maxDepth: number | undefined) => Record<string, unknown> | null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._DJB2Object = exports._DJB2 = void 0; | ||
exports._getSortedObject = exports._DJB2Object = exports._DJB2 = void 0; | ||
const TypingUtils_1 = require("./TypingUtils"); | ||
const _DJB2 = (value) => { | ||
@@ -14,7 +15,7 @@ let hash = 0; | ||
exports._DJB2 = _DJB2; | ||
const _DJB2Object = (value) => { | ||
return (0, exports._DJB2)(JSON.stringify(_getSortedObject(value))); | ||
const _DJB2Object = (value, maxLevels) => { | ||
return (0, exports._DJB2)(JSON.stringify((0, exports._getSortedObject)(value, maxLevels))); | ||
}; | ||
exports._DJB2Object = _DJB2Object; | ||
const _getSortedObject = (object) => { | ||
const _getSortedObject = (object, maxDepth) => { | ||
if (object == null) { | ||
@@ -26,9 +27,11 @@ return null; | ||
keys.forEach((key) => { | ||
let value = object[key]; | ||
if (!Array.isArray(value) && value instanceof Object) { | ||
value = _getSortedObject(value); | ||
const value = object[key]; | ||
if (maxDepth === 0 || (0, TypingUtils_1._typeOf)(value) !== 'object') { | ||
sortedObject[key] = value; | ||
return; | ||
} | ||
sortedObject[key] = value; | ||
sortedObject[key] = (0, exports._getSortedObject)(value, maxDepth != null ? maxDepth - 1 : maxDepth); | ||
}); | ||
return sortedObject; | ||
}; | ||
exports._getSortedObject = _getSortedObject; |
@@ -36,6 +36,6 @@ /** Statsig Global should go first */ | ||
export * from './TypedJsonParse'; | ||
export * from './TypingUtils'; | ||
export * from './UrlOverrides'; | ||
export * from './UtitlityTypes'; | ||
export * from './UUID'; | ||
export * from './VisibilityObserving'; | ||
export { EventLogger, Storage, Log }; |
@@ -57,4 +57,4 @@ "use strict"; | ||
__exportStar(require("./TypedJsonParse"), exports); | ||
__exportStar(require("./TypingUtils"), exports); | ||
__exportStar(require("./UrlOverrides"), exports); | ||
__exportStar(require("./UtitlityTypes"), exports); | ||
__exportStar(require("./UUID"), exports); | ||
@@ -61,0 +61,0 @@ __exportStar(require("./VisibilityObserving"), exports); |
@@ -5,3 +5,3 @@ import './$_StatsigGlobal'; | ||
import { AnyStatsigOptions } from './StatsigOptionsCommon'; | ||
import { Flatten } from './UtitlityTypes'; | ||
import { Flatten } from './TypingUtils'; | ||
type RequestArgs = { | ||
@@ -8,0 +8,0 @@ sdkKey: string; |
export declare const _getWindowSafe: () => Window | null; | ||
export declare const _getDocumentSafe: () => Document | null; | ||
export declare const _isBrowserEnv: () => boolean; | ||
export declare const _isServerEnv: () => boolean; | ||
export declare const _addWindowEventListenerSafe: (key: string, listener: () => void) => void; | ||
export declare const _addDocumentEventListenerSafe: (key: string, listener: () => void) => void; | ||
export declare const _getCurrentPageUrlSafe: () => string | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._getCurrentPageUrlSafe = exports._addDocumentEventListenerSafe = exports._addWindowEventListenerSafe = exports._isBrowserEnv = exports._getDocumentSafe = exports._getWindowSafe = void 0; | ||
exports._getCurrentPageUrlSafe = exports._addDocumentEventListenerSafe = exports._addWindowEventListenerSafe = exports._isServerEnv = exports._getDocumentSafe = exports._getWindowSafe = void 0; | ||
const _getWindowSafe = () => { | ||
@@ -14,6 +14,13 @@ return typeof window !== 'undefined' ? window : null; | ||
exports._getDocumentSafe = _getDocumentSafe; | ||
const _isBrowserEnv = () => { | ||
return (0, exports._getDocumentSafe)() != null; | ||
const _isServerEnv = () => { | ||
if ((0, exports._getDocumentSafe)() !== null) { | ||
return false; | ||
} | ||
const isNode = typeof process !== 'undefined' && | ||
process.versions != null && | ||
process.versions.node != null; | ||
const isVercel = typeof EdgeRuntime === 'string'; | ||
return isVercel || isNode; | ||
}; | ||
exports._isBrowserEnv = _isBrowserEnv; | ||
exports._isServerEnv = _isServerEnv; | ||
const _addWindowEventListenerSafe = (key, listener) => { | ||
@@ -20,0 +27,0 @@ const win = (0, exports._getWindowSafe)(); |
@@ -40,3 +40,3 @@ "use strict"; | ||
this._errorBoundary.wrap(this._logger); | ||
if ((0, SafeJs_1._isBrowserEnv)()) { | ||
if (!(0, SafeJs_1._isServerEnv)()) { | ||
const statsigGlobal = (0, __StatsigGlobal_1._getStatsigGlobal)(); | ||
@@ -43,0 +43,0 @@ const instances = (_b = statsigGlobal.instances) !== null && _b !== void 0 ? _b : {}; |
import { DataAdapterResult } from './StatsigDataAdapter'; | ||
import { DynamicConfig, Experiment, FeatureGate, Layer } from './StatsigTypes'; | ||
import { Flatten } from './UtitlityTypes'; | ||
import { Flatten } from './TypingUtils'; | ||
export type StatsigLoadingStatus = 'Uninitialized' | 'Loading' | 'Ready'; | ||
@@ -5,0 +5,0 @@ type EventNameToEventDataMap = { |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "1.3.0"; | ||
export declare const SDK_VERSION = "1.3.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.3.0'; | ||
exports.SDK_VERSION = '1.3.1'; | ||
let metadata = { | ||
@@ -6,0 +6,0 @@ sdkVersion: exports.SDK_VERSION, |
import { DynamicConfigEvaluation, EvaluationDetails, GateEvaluation, LayerEvaluation } from './EvaluationTypes'; | ||
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; | ||
@@ -9,5 +8,2 @@ export declare function _makeDynamicConfig(name: string, details: EvaluationDetails, evaluation: DynamicConfigEvaluation | null): DynamicConfig; | ||
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._makeTypedGet = exports._isTypeMatch = exports._typeOf = exports._mergeOverride = exports._makeLayer = exports._makeExperiment = exports._makeDynamicConfig = exports._makeFeatureGate = void 0; | ||
exports._makeTypedGet = exports._mergeOverride = exports._makeLayer = exports._makeExperiment = exports._makeDynamicConfig = exports._makeFeatureGate = void 0; | ||
const TypingUtils_1 = require("./TypingUtils"); | ||
const DEFAULT_RULE = 'default'; | ||
@@ -40,11 +41,2 @@ function _makeEvaluation(name, details, evaluation, value) { | ||
exports._mergeOverride = _mergeOverride; | ||
function _typeOf(input) { | ||
return Array.isArray(input) ? 'array' : typeof input; | ||
} | ||
exports._typeOf = _typeOf; | ||
function _isTypeMatch(a, b) { | ||
const typeOf = (x) => (Array.isArray(x) ? 'array' : typeof x); | ||
return typeOf(a) === typeOf(b); | ||
} | ||
exports._isTypeMatch = _isTypeMatch; | ||
function _makeTypedGet(value, exposeFunc) { | ||
@@ -57,3 +49,3 @@ return (param, fallback) => { | ||
} | ||
if (fallback != null && !_isTypeMatch(found, fallback)) { | ||
if (fallback != null && !(0, TypingUtils_1._isTypeMatch)(found, fallback)) { | ||
return (fallback !== null && fallback !== void 0 ? fallback : null); | ||
@@ -60,0 +52,0 @@ } |
import { EvaluationDetails, ExperimentEvaluation, GateEvaluation, LayerEvaluation } from './EvaluationTypes'; | ||
import { ParamStoreConfig } from './ParamStoreTypes'; | ||
import { Flatten } from './UtitlityTypes'; | ||
import { Flatten } from './TypingUtils'; | ||
export type TypedGet = <T = unknown>(key: string, fallback?: T) => TypedReturn<T>; | ||
@@ -5,0 +5,0 @@ export type ParamStoreTypedGet = <T = unknown>(key: string, fallback: T) => T; |
120009
2842