@statsig/statsig-node-core 0.13.1-rc.2512020014 → 0.14.1-beta.2512170241

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/error_boundary.js CHANGED
@@ -35,7 +35,8 @@ class ErrorBoundary {
35
35
  }
36
36
  static _onError(tag, error) {
37
37
  _tryConvertInvalidArgError(error);
38
- console.error('Statsig::' + tag, error);
38
+ const printableTag = tag.replace('__INTERNAL_', '');
39
+ console.error('Statsig::' + printableTag, error);
39
40
  }
40
41
  }
41
42
  exports.ErrorBoundary = ErrorBoundary;
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { DynamicConfig, Experiment, Layer, ParameterStore, SdkEvent, StatsigNapiInternal, StatsigOptions, StatsigResult, StatsigUser } from './statsig-generated';
1
+ import { DynamicConfigEvaluationOptions, ExperimentEvaluationOptions, FeatureGateEvaluationOptions, LayerEvaluationOptions, SdkEvent, StatsigNapiInternal, StatsigOptions, StatsigResult, StatsigUser } from './statsig-generated';
2
+ import { DynamicConfig, Experiment, FeatureGate, Layer } from './statsig_types';
2
3
  export * from './statsig-generated';
3
- export { StatsigUser, Experiment, DynamicConfig, Layer, ParameterStore };
4
+ export * from './statsig_types';
4
5
  export declare class Statsig extends StatsigNapiInternal {
5
6
  private static _sharedInstance;
6
7
  static shared(): Statsig;
@@ -11,4 +12,9 @@ export declare class Statsig extends StatsigNapiInternal {
11
12
  stopConsoleCapture(): void;
12
13
  shutdown(timeout_ms?: number): Promise<StatsigResult>;
13
14
  subscribe(eventName: SdkEvent, callback: (event: any) => void): string;
15
+ getFeatureGate(user: StatsigUser, gateName: string, options?: FeatureGateEvaluationOptions): FeatureGate;
16
+ getDynamicConfig(user: StatsigUser, configName: string, options?: DynamicConfigEvaluationOptions): DynamicConfig;
17
+ getExperiment(user: StatsigUser, experimentName: string, options?: ExperimentEvaluationOptions): Experiment;
18
+ getExperimentByGroupName(experimentName: string, groupName: string): Experiment;
19
+ getLayer(user: StatsigUser, layerName: string, options?: LayerEvaluationOptions): Layer;
14
20
  }
package/index.js CHANGED
@@ -26,36 +26,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Statsig = exports.ParameterStore = exports.Layer = exports.DynamicConfig = exports.Experiment = exports.StatsigUser = void 0;
29
+ exports.Statsig = void 0;
30
30
  const https_proxy_agent_1 = require("https-proxy-agent");
31
31
  const node_fetch_1 = __importDefault(require("node-fetch"));
32
32
  const console_capture_1 = require("./console_capture");
33
33
  const error_boundary_1 = require("./error_boundary");
34
34
  const statsig_generated_1 = require("./statsig-generated");
35
- Object.defineProperty(exports, "DynamicConfig", { enumerable: true, get: function () { return statsig_generated_1.DynamicConfig; } });
36
- Object.defineProperty(exports, "Experiment", { enumerable: true, get: function () { return statsig_generated_1.Experiment; } });
37
- Object.defineProperty(exports, "Layer", { enumerable: true, get: function () { return statsig_generated_1.Layer; } });
38
- Object.defineProperty(exports, "ParameterStore", { enumerable: true, get: function () { return statsig_generated_1.ParameterStore; } });
39
- Object.defineProperty(exports, "StatsigUser", { enumerable: true, get: function () { return statsig_generated_1.StatsigUser; } });
35
+ const statsig_types_1 = require("./statsig_types");
40
36
  __exportStar(require("./statsig-generated"), exports);
37
+ __exportStar(require("./statsig_types"), exports);
41
38
  const inspectSym = Symbol.for('nodejs.util.inspect.custom');
42
39
  // @ts-expect-error - prototype assignment
43
40
  statsig_generated_1.StatsigUser.prototype[inspectSym] = function () {
44
41
  return this.toJSON();
45
42
  };
46
43
  // @ts-expect-error - prototype assignment
47
- statsig_generated_1.Experiment.prototype[inspectSym] = function () {
48
- return this.toJSON();
49
- };
50
- // @ts-expect-error - prototype assignment
51
- statsig_generated_1.DynamicConfig.prototype[inspectSym] = function () {
52
- return this.toJSON();
53
- };
54
- // @ts-expect-error - prototype assignment
55
- statsig_generated_1.Layer.prototype[inspectSym] = function () {
56
- return this.toJSON();
57
- };
58
- // @ts-expect-error - prototype assignment
59
44
  statsig_generated_1.ParameterStore.prototype[inspectSym] = function () {
60
45
  return this.toJSON();
61
46
  };
@@ -79,7 +64,7 @@ function createFetchFunc(options) {
79
64
  try {
80
65
  const res = yield (0, node_fetch_1.default)(url, {
81
66
  method,
82
- headers: Object.assign(Object.assign({}, headers), { 'Accept-Encoding': 'gzip, deflate, br' }),
67
+ headers: Object.assign({ 'accept-encoding': 'gzip, deflate, br' }, headers),
83
68
  body: body ? Buffer.from(body) : undefined,
84
69
  agent: proxyAgent,
85
70
  });
@@ -153,6 +138,26 @@ class Statsig extends statsig_generated_1.StatsigNapiInternal {
153
138
  }
154
139
  });
155
140
  }
141
+ getFeatureGate(user, gateName, options) {
142
+ const raw = this.__INTERNAL_getFeatureGate(user, gateName, options);
143
+ return new statsig_types_1.FeatureGate(gateName, raw);
144
+ }
145
+ getDynamicConfig(user, configName, options) {
146
+ const raw = this.__INTERNAL_getDynamicConfig(user, configName, options);
147
+ return new statsig_types_1.DynamicConfig(configName, raw);
148
+ }
149
+ getExperiment(user, experimentName, options) {
150
+ const raw = this.__INTERNAL_getExperiment(user, experimentName, options);
151
+ return new statsig_types_1.Experiment(experimentName, raw);
152
+ }
153
+ getExperimentByGroupName(experimentName, groupName) {
154
+ const raw = this.__INTERNAL_getExperimentByGroupName(experimentName, groupName);
155
+ return new statsig_types_1.Experiment(experimentName, raw);
156
+ }
157
+ getLayer(user, layerName, options) {
158
+ const raw = this.__INTERNAL_getLayer(user, layerName, options);
159
+ return new statsig_types_1.Layer((param) => this.__INTERNAL_logLayerParamExposure(raw, param), layerName, raw);
160
+ }
156
161
  }
157
162
  exports.Statsig = Statsig;
158
163
  Statsig._sharedInstance = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/statsig-node-core",
3
- "version": "0.13.1-rc.2512020014",
3
+ "version": "0.14.1-beta.2512170241",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest --colors"
@@ -55,13 +55,13 @@
55
55
  ]
56
56
  },
57
57
  "optionalDependencies": {
58
- "@statsig/statsig-node-core-linux-x64-musl": "0.13.1-rc.2512020014",
59
- "@statsig/statsig-node-core-linux-x64-gnu": "0.13.1-rc.2512020014",
60
- "@statsig/statsig-node-core-win32-x64-msvc": "0.13.1-rc.2512020014",
61
- "@statsig/statsig-node-core-darwin-x64": "0.13.1-rc.2512020014",
62
- "@statsig/statsig-node-core-win32-ia32-msvc": "0.13.1-rc.2512020014",
63
- "@statsig/statsig-node-core-linux-arm64-musl": "0.13.1-rc.2512020014",
64
- "@statsig/statsig-node-core-linux-arm64-gnu": "0.13.1-rc.2512020014",
65
- "@statsig/statsig-node-core-darwin-arm64": "0.13.1-rc.2512020014"
58
+ "@statsig/statsig-node-core-linux-x64-musl": "0.14.1-beta.2512170241",
59
+ "@statsig/statsig-node-core-linux-x64-gnu": "0.14.1-beta.2512170241",
60
+ "@statsig/statsig-node-core-win32-x64-msvc": "0.14.1-beta.2512170241",
61
+ "@statsig/statsig-node-core-darwin-x64": "0.14.1-beta.2512170241",
62
+ "@statsig/statsig-node-core-win32-ia32-msvc": "0.14.1-beta.2512170241",
63
+ "@statsig/statsig-node-core-linux-arm64-musl": "0.14.1-beta.2512170241",
64
+ "@statsig/statsig-node-core-linux-arm64-gnu": "0.14.1-beta.2512170241",
65
+ "@statsig/statsig-node-core-darwin-arm64": "0.14.1-beta.2512170241"
66
66
  }
67
67
  }
@@ -1,53 +1,5 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
- export declare class DynamicConfig {
4
- name: string
5
- value: Record<string, any>
6
- ruleID: string
7
- idType: string
8
- details: EvaluationDetails
9
- getValue(paramName: string, fallback?: boolean | number | string | object | Array<any> | null): any | null
10
- get<T>(paramName: string, fallback: T): T
11
- getRuleId(): string
12
- getIdType(): string
13
- getEvaluationDetails(): EvaluationDetails
14
- getSecondaryExposures(): Array<SecondaryExposure> | null
15
- toJSON(): Record<string, any>
16
- }
17
-
18
- export declare class Experiment {
19
- name: string
20
- value: Record<string, any>
21
- ruleID: string
22
- idType: string
23
- groupName?: string
24
- details: EvaluationDetails
25
- getValue(paramName: string, fallback?: boolean | number | string | object | Array<any> | null): any | null
26
- get<T>(paramName: string, fallback: T): T
27
- getRuleId(): string
28
- getIdType(): string
29
- getGroupName(): string | null
30
- getEvaluationDetails(): EvaluationDetails
31
- getSecondaryExposures(): Array<SecondaryExposure> | null
32
- toJSON(): Record<string, any>
33
- }
34
-
35
- export declare class Layer {
36
- name: string
37
- ruleID: string
38
- groupName?: string
39
- allocatedExperimentName?: string
40
- value: Record<string, any>
41
- details: EvaluationDetails
42
- getValue(paramName: string, fallback?: boolean | number | string | object | Array<any> | null): any | null
43
- get<T>(paramName: string, fallback: T): T
44
- getRuleId(): string
45
- getGroupName(): string | null
46
- getEvaluationDetails(): EvaluationDetails
47
- getSecondaryExposures(): Array<SecondaryExposure> | null
48
- toJSON(): Record<string, any>
49
- }
50
-
51
3
  export declare class ParameterStore {
52
4
  name: string
53
5
  getValue<T>(paramName: string, fallback?: T): T
@@ -67,14 +19,15 @@ export declare class StatsigNapiInternal {
67
19
  logEvent(user: StatsigUser, eventName: string, value?: string | number | null, metadata?: Record<string, string> | undefined | null): void
68
20
  forwardLogLineEvent(user: StatsigUser, logLevel: 'trace' | 'debug' |'log' | 'info' | 'warn' | 'error', value?: string | undefined | null, metadata?: Record<string, string> | undefined | null): void
69
21
  checkGate(user: StatsigUser, gateName: string, options?: FeatureGateEvaluationOptions | undefined | null): boolean
70
- getFeatureGate(user: StatsigUser, featureName: string, options?: FeatureGateEvaluationOptions | undefined | null): FeatureGate
22
+ __INTERNAL_getFeatureGate(user: StatsigUser, featureName: string, options?: FeatureGateEvaluationOptions | undefined | null): string
71
23
  getFieldsNeededForGate(gateName: string): Array<string>
72
- getDynamicConfig(user: StatsigUser, configName: string, options?: DynamicConfigEvaluationOptions | undefined | null): DynamicConfig
24
+ __INTERNAL_getDynamicConfig(user: StatsigUser, configName: string, options?: DynamicConfigEvaluationOptions | undefined | null): string
73
25
  getFieldsNeededForDynamicConfig(configName: string): Array<string>
74
- getExperiment(user: StatsigUser, experimentName: string, options?: ExperimentEvaluationOptions | undefined | null): Experiment
75
- getExperimentByGroupName(experimentName: string, groupName: string): Experiment
26
+ __INTERNAL_getExperiment(user: StatsigUser, experimentName: string, options?: ExperimentEvaluationOptions | undefined | null): string
27
+ __INTERNAL_getExperimentByGroupName(experimentName: string, groupName: string): string
76
28
  getFieldsNeededForExperiment(experimentName: string): Array<string>
77
- getLayer(user: StatsigUser, layerName: string, options?: LayerEvaluationOptions | undefined | null): Layer
29
+ __INTERNAL_getLayer(user: StatsigUser, layerName: string, options?: LayerEvaluationOptions | undefined | null): string
30
+ __INTERNAL_logLayerParamExposure(raw: string, paramName: string): void
78
31
  getFieldsNeededForLayer(layerName: string): Array<string>
79
32
  identify(user: StatsigUser): void
80
33
  getParameterStore(user: StatsigUser, parameterStoreName: string, options?: ParameterStoreEvaluationOptions | undefined | null): ParameterStore
@@ -106,12 +59,12 @@ export declare class StatsigUser {
106
59
  static withCustomIDs(customIds: Record<string, string>): StatsigUser
107
60
  get customIDs(): Record<string, string> | null
108
61
  set customIDs(value: Record<string, string> | null)
109
- get custom(): Record<string, string> | null
62
+ get custom(): Record<string, string | number | boolean | Array<string | number | boolean>> | null
110
63
  set custom(value: Record<string, string | number | boolean | Array<string | number | boolean>> | null)
111
- get privateAttributes(): Record<string, string> | null
64
+ get privateAttributes(): Record<string, string | number | boolean | Array<string | number | boolean>> | null
112
65
  set privateAttributes(value: Record<string, string | number | boolean | Array<string | number | boolean>> | null)
113
66
  get statsigEnvironment(): Record<string, string> | null
114
- set statsigEnvironment(value: { tier?: string, [key: string]: string | undefined } | null | undefined)
67
+ set statsigEnvironment(value: { tier?: string, [key: string]: string | undefined } | undefined)
115
68
  get userID(): string | null
116
69
  set userID(value: any)
117
70
  get email(): string | null
@@ -126,7 +79,7 @@ export declare class StatsigUser {
126
79
  set locale(value: any)
127
80
  get appVersion(): string | null
128
81
  set appVersion(value: any)
129
- toJSON(): string
82
+ toJSON(): any
130
83
  }
131
84
 
132
85
  export declare function __internal__testDataStore(store: DataStore, path: string, value: string): Promise<[DataStoreResponse | undefined | null, boolean]>
@@ -148,6 +101,7 @@ export interface ClientInitResponseOptions {
148
101
  paramStoreFilter?: Set<string>
149
102
  removeIdType?: boolean
150
103
  removeDefaultValueGates?: boolean
104
+ responseFormat?: GCIRResponseFormat
151
105
  }
152
106
 
153
107
  export interface ConsoleCaptureOptions {
@@ -188,18 +142,16 @@ export interface ExperimentEvaluationOptions {
188
142
  userPersistedValues?: Record<string, any>
189
143
  }
190
144
 
191
- export interface FeatureGate {
192
- name: string
193
- value: boolean
194
- ruleID: string
195
- idType: string
196
- details: EvaluationDetails
197
- }
198
-
199
145
  export interface FeatureGateEvaluationOptions {
200
146
  disableExposureLogging?: boolean
201
147
  }
202
148
 
149
+ export declare const enum GCIRResponseFormat {
150
+ Initialize = 0,
151
+ InitializeWithSecondaryExposureMapping = 1,
152
+ InitializeV2 = 2
153
+ }
154
+
203
155
  export interface LayerEvaluationOptions {
204
156
  disableExposureLogging?: boolean
205
157
  userPersistedValues?: Record<string, any>
@@ -275,6 +227,7 @@ export declare function statsigCaptureLogLine(level: string, payload: Array<stri
275
227
 
276
228
  export interface StatsigOptions {
277
229
  dataStore?: DataStore
230
+ dataStoreKeySchemaVersion?: 'v2' | 'v3'
278
231
  disableAllLogging?: boolean
279
232
  disableCountryLookup?: boolean
280
233
  disableNetwork?: boolean
@@ -320,9 +273,9 @@ export interface StatsigUserArgs {
320
273
  country?: string
321
274
  locale?: string
322
275
  appVersion?: string
323
- statsigEnvironment?: { tier?: string, [key: string]: string | undefined } | null | undefined
276
+ statsigEnvironment?: { tier?: string, [key: string]: string | undefined } | undefined
324
277
  custom?: Record<string, string | number | boolean | Array<string | number | boolean> | null | undefined | Record<string, unknown>>
325
- privateAttributes?: Record<string, string | number | boolean | Array<string | number | boolean> | null | Record<string, unknown>>
278
+ privateAttributes?: Record<string, string | number | boolean | Array<string | number | boolean> | Record<string, unknown>>
326
279
  }
327
280
  // ---- Manually defined typing section -----
328
281
 
@@ -364,9 +364,6 @@ if (!nativeBinding) {
364
364
  throw new Error(`Failed to load native binding`)
365
365
  }
366
366
 
367
- module.exports.DynamicConfig = nativeBinding.DynamicConfig
368
- module.exports.Experiment = nativeBinding.Experiment
369
- module.exports.Layer = nativeBinding.Layer
370
367
  module.exports.ParameterStore = nativeBinding.ParameterStore
371
368
  module.exports.StatsigNapiInternal = nativeBinding.StatsigNapiInternal
372
369
  module.exports.StatsigUser = nativeBinding.StatsigUser
@@ -374,5 +371,6 @@ module.exports.__internal__testDataStore = nativeBinding.__internal__testDataSto
374
371
  module.exports.__internal__testObservabilityClient = nativeBinding.__internal__testObservabilityClient
375
372
  module.exports.__internal__testOutputLogger = nativeBinding.__internal__testOutputLogger
376
373
  module.exports.__internal__testPersistentStorage = nativeBinding.__internal__testPersistentStorage
374
+ module.exports.GCIRResponseFormat = nativeBinding.GCIRResponseFormat
377
375
  module.exports.OverrideAdapterType = nativeBinding.OverrideAdapterType
378
376
  module.exports.statsigCaptureLogLine = nativeBinding.statsigCaptureLogLine
@@ -0,0 +1,44 @@
1
+ import { EvaluationDetails, SecondaryExposure } from './statsig-generated';
2
+ export type TypedGet = <T = unknown>(key: string, defaultValue: T, typeGuard?: ((value: unknown) => value is T | null) | null) => T;
3
+ export type UnknownGet = (key: string, fallback?: boolean | number | string | object | Array<any> | null) => unknown | null;
4
+ declare class BaseEvaluation {
5
+ readonly name: string;
6
+ readonly ruleID: string;
7
+ readonly idType: string;
8
+ readonly details: EvaluationDetails;
9
+ readonly secondaryExposures: SecondaryExposure[];
10
+ constructor(name: string, data: Record<string, unknown>);
11
+ getEvaluationDetails(): EvaluationDetails;
12
+ getRuleId(): string;
13
+ getIdType(): string;
14
+ getSecondaryExposures(): SecondaryExposure[];
15
+ }
16
+ export declare class FeatureGate extends BaseEvaluation {
17
+ readonly value: boolean;
18
+ constructor(name: string, raw: string | null);
19
+ }
20
+ export declare class DynamicConfig extends BaseEvaluation {
21
+ readonly value: Record<string, unknown>;
22
+ readonly get: TypedGet;
23
+ readonly getValue: UnknownGet;
24
+ constructor(name: string, raw: string);
25
+ }
26
+ export declare class Experiment extends BaseEvaluation {
27
+ readonly groupName: string | null;
28
+ readonly value: Record<string, unknown>;
29
+ readonly get: TypedGet;
30
+ readonly getValue: UnknownGet;
31
+ constructor(name: string, raw: string);
32
+ getGroupName(): string | null;
33
+ }
34
+ export declare class Layer extends BaseEvaluation {
35
+ readonly groupName: string | null;
36
+ readonly allocatedExperimentName: string | null;
37
+ readonly __value: Record<string, unknown>;
38
+ readonly get: TypedGet;
39
+ readonly getValue: UnknownGet;
40
+ constructor(exposeFn: (param: string) => void, name: string, raw: string);
41
+ getGroupName(): string | null;
42
+ getAllocatedExperimentName(): string | null;
43
+ }
44
+ export {};
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Layer = exports.Experiment = exports.DynamicConfig = exports.FeatureGate = void 0;
4
+ function _getTypeOf(x) {
5
+ return Array.isArray(x) ? 'array' : x === null ? 'null' : typeof x;
6
+ }
7
+ class BaseEvaluation {
8
+ constructor(name, data) {
9
+ var _a, _b, _c;
10
+ this.secondaryExposures = [];
11
+ this.name = name;
12
+ this.ruleID = (_a = data.ruleID) !== null && _a !== void 0 ? _a : '';
13
+ this.idType = (_b = data.idType) !== null && _b !== void 0 ? _b : '';
14
+ this.details = _extractEvaluationDetails(data.details);
15
+ this.secondaryExposures =
16
+ (_c = data.secondaryExposures) !== null && _c !== void 0 ? _c : [];
17
+ }
18
+ getEvaluationDetails() {
19
+ return this.details;
20
+ }
21
+ getRuleId() {
22
+ return this.ruleID;
23
+ }
24
+ getIdType() {
25
+ return this.idType;
26
+ }
27
+ getSecondaryExposures() {
28
+ return this.secondaryExposures;
29
+ }
30
+ }
31
+ class FeatureGate extends BaseEvaluation {
32
+ constructor(name, raw) {
33
+ const data = _parseRawEvaluation(raw);
34
+ super(name, data);
35
+ this.value = data.value === true;
36
+ }
37
+ }
38
+ exports.FeatureGate = FeatureGate;
39
+ class DynamicConfig extends BaseEvaluation {
40
+ constructor(name, raw) {
41
+ var _a;
42
+ const data = _parseRawEvaluation(raw);
43
+ super(name, data);
44
+ this.value = {};
45
+ this.value = (_a = data.value) !== null && _a !== void 0 ? _a : {};
46
+ this.get = _makeTypedGet(name, this.value);
47
+ this.getValue = _makeUnknownGet(this.value);
48
+ }
49
+ }
50
+ exports.DynamicConfig = DynamicConfig;
51
+ class Experiment extends BaseEvaluation {
52
+ constructor(name, raw) {
53
+ var _a, _b;
54
+ const data = _parseRawEvaluation(raw);
55
+ super(name, data);
56
+ this.groupName = null;
57
+ this.value = {};
58
+ this.groupName = (_a = data.groupName) !== null && _a !== void 0 ? _a : null;
59
+ this.value = (_b = data.value) !== null && _b !== void 0 ? _b : {};
60
+ this.get = _makeTypedGet(name, this.value);
61
+ this.getValue = _makeUnknownGet(this.value);
62
+ }
63
+ getGroupName() {
64
+ return this.groupName;
65
+ }
66
+ }
67
+ exports.Experiment = Experiment;
68
+ class Layer extends BaseEvaluation {
69
+ constructor(exposeFn, name, raw) {
70
+ var _a, _b, _c;
71
+ const data = _parseRawEvaluation(raw);
72
+ super(name, data);
73
+ this.groupName = null;
74
+ this.allocatedExperimentName = null;
75
+ this.__value = {};
76
+ this.__value = (_a = data.value) !== null && _a !== void 0 ? _a : {};
77
+ this.groupName = (_b = data.groupName) !== null && _b !== void 0 ? _b : null;
78
+ this.allocatedExperimentName =
79
+ (_c = data.allocatedExperimentName) !== null && _c !== void 0 ? _c : null;
80
+ this.get = _makeTypedGet(name, this.__value, exposeFn);
81
+ this.getValue = _makeUnknownGet(this.__value, exposeFn);
82
+ }
83
+ getGroupName() {
84
+ return this.groupName;
85
+ }
86
+ getAllocatedExperimentName() {
87
+ return this.allocatedExperimentName;
88
+ }
89
+ }
90
+ exports.Layer = Layer;
91
+ function _parseRawEvaluation(raw) {
92
+ try {
93
+ return JSON.parse(raw !== null && raw !== void 0 ? raw : '{}');
94
+ }
95
+ catch (error) {
96
+ console.error(`[Statsig] Error parsing BaseEvaluation: ${error}`);
97
+ return {};
98
+ }
99
+ }
100
+ function _makeTypedGet(name, value, exposeFunc) {
101
+ return (key, defaultValue, typeGuard = null) => {
102
+ var _a;
103
+ // @ts-ignore - intentionally matches legacy behavior exactly
104
+ defaultValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : null;
105
+ // Equivalent to legacy `this.getValue(key, defaultValue)`
106
+ const val = ((_a = value[key]) !== null && _a !== void 0 ? _a : defaultValue);
107
+ if (val == null) {
108
+ return defaultValue;
109
+ }
110
+ const expectedType = _getTypeOf(defaultValue);
111
+ const actualType = _getTypeOf(val);
112
+ if (typeGuard != null) {
113
+ if (typeGuard(val)) {
114
+ exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(key);
115
+ return val;
116
+ }
117
+ console.warn(`[Statsig] Parameter type mismatch. '${name}.${key}' failed typeGuard. Expected '${expectedType}', got '${actualType}'`);
118
+ return defaultValue;
119
+ }
120
+ if (defaultValue == null || expectedType === actualType) {
121
+ exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(key);
122
+ return val;
123
+ }
124
+ console.warn(`[Statsig] Parameter type mismatch. '${name}.${key}' was found to be type '${actualType}' but fallback/return type is '${expectedType}'`);
125
+ return defaultValue;
126
+ };
127
+ }
128
+ function _makeUnknownGet(value, exposeFunc) {
129
+ return (param, fallback) => {
130
+ var _a;
131
+ if (fallback === undefined) {
132
+ fallback = null;
133
+ }
134
+ if (param == null) {
135
+ return fallback;
136
+ }
137
+ if (value[param] != null) {
138
+ exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(param);
139
+ }
140
+ return (_a = value[param]) !== null && _a !== void 0 ? _a : fallback;
141
+ };
142
+ }
143
+ function _extractEvaluationDetails(data) {
144
+ if (data == null) {
145
+ return {
146
+ reason: '',
147
+ lcut: 0,
148
+ receivedAt: 0,
149
+ version: 0,
150
+ };
151
+ }
152
+ return {
153
+ reason: data.reason,
154
+ lcut: data.lcut,
155
+ receivedAt: data.received_at,
156
+ version: data.version,
157
+ };
158
+ }