@statsig/statsig-node-core 0.14.1-rc.2512160223 → 0.14.1-rc.2512190311

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/statsig-node-core",
3
- "version": "0.14.1-rc.2512160223",
3
+ "version": "0.14.1-rc.2512190311",
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.14.1-rc.2512160223",
59
- "@statsig/statsig-node-core-linux-x64-gnu": "0.14.1-rc.2512160223",
60
- "@statsig/statsig-node-core-win32-x64-msvc": "0.14.1-rc.2512160223",
61
- "@statsig/statsig-node-core-darwin-x64": "0.14.1-rc.2512160223",
62
- "@statsig/statsig-node-core-win32-ia32-msvc": "0.14.1-rc.2512160223",
63
- "@statsig/statsig-node-core-linux-arm64-musl": "0.14.1-rc.2512160223",
64
- "@statsig/statsig-node-core-linux-arm64-gnu": "0.14.1-rc.2512160223",
65
- "@statsig/statsig-node-core-darwin-arm64": "0.14.1-rc.2512160223"
58
+ "@statsig/statsig-node-core-linux-x64-musl": "0.14.1-rc.2512190311",
59
+ "@statsig/statsig-node-core-linux-x64-gnu": "0.14.1-rc.2512190311",
60
+ "@statsig/statsig-node-core-win32-x64-msvc": "0.14.1-rc.2512190311",
61
+ "@statsig/statsig-node-core-darwin-x64": "0.14.1-rc.2512190311",
62
+ "@statsig/statsig-node-core-win32-ia32-msvc": "0.14.1-rc.2512190311",
63
+ "@statsig/statsig-node-core-linux-arm64-musl": "0.14.1-rc.2512190311",
64
+ "@statsig/statsig-node-core-linux-arm64-gnu": "0.14.1-rc.2512190311",
65
+ "@statsig/statsig-node-core-darwin-arm64": "0.14.1-rc.2512190311"
66
66
  }
67
67
  }
@@ -16,7 +16,7 @@ export declare class StatsigNapiInternal {
16
16
  initialize(): Promise<StatsigResult>
17
17
  shutdown(timeoutMs?: number | undefined | null): Promise<StatsigResult>
18
18
  flushEvents(): Promise<StatsigResult>
19
- logEvent(user: StatsigUser, eventName: string, value?: string | number | null, metadata?: Record<string, string> | undefined | null): void
19
+ logEvent(user: StatsigUser, eventName: string, value?: string | number | null, metadata?: Record<string, string | number | boolean | null | undefined> | null | undefined): void
20
20
  forwardLogLineEvent(user: StatsigUser, logLevel: 'trace' | 'debug' |'log' | 'info' | 'warn' | 'error', value?: string | undefined | null, metadata?: Record<string, string> | undefined | null): void
21
21
  checkGate(user: StatsigUser, gateName: string, options?: FeatureGateEvaluationOptions | undefined | null): boolean
22
22
  __INTERNAL_getFeatureGate(user: StatsigUser, featureName: string, options?: FeatureGateEvaluationOptions | undefined | null): string
@@ -1,7 +1,6 @@
1
1
  import { EvaluationDetails, SecondaryExposure } from './statsig-generated';
2
- export type TypedGet = <T = unknown>(key: string, fallback?: T) => TypedReturn<T>;
2
+ export type TypedGet = <T = unknown>(key: string, defaultValue: T, typeGuard?: ((value: unknown) => value is T | null) | null) => T;
3
3
  export type UnknownGet = (key: string, fallback?: boolean | number | string | object | Array<any> | null) => unknown | null;
4
- export type TypedReturn<T = unknown> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends readonly unknown[] ? T : T extends object ? T : unknown;
5
4
  declare class BaseEvaluation {
6
5
  readonly name: string;
7
6
  readonly ruleID: string;
package/statsig_types.js CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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
+ }
4
7
  class BaseEvaluation {
5
8
  constructor(name, data) {
6
9
  var _a, _b, _c;
@@ -94,23 +97,32 @@ function _parseRawEvaluation(raw) {
94
97
  return {};
95
98
  }
96
99
  }
97
- function _isTypeMatch(a, b) {
98
- const typeOf = (x) => Array.isArray(x) ? 'array' : x === null ? 'null' : typeof x;
99
- return typeOf(a) === typeOf(b);
100
- }
101
100
  function _makeTypedGet(name, value, exposeFunc) {
102
- return (param, fallback) => {
101
+ return (key, defaultValue, typeGuard = null) => {
103
102
  var _a;
104
- const found = (_a = value[param]) !== null && _a !== void 0 ? _a : null;
105
- if (found == null) {
106
- return (fallback !== null && fallback !== void 0 ? fallback : null);
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;
107
119
  }
108
- if (fallback != null && !_isTypeMatch(found, fallback)) {
109
- console.warn(`[Statsig] Parameter type mismatch. '${name}.${param}' was found to be type '${typeof found}' but fallback/return type is '${typeof fallback}'`);
110
- return (fallback !== null && fallback !== void 0 ? fallback : null);
120
+ if (defaultValue == null || expectedType === actualType) {
121
+ exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(key);
122
+ return val;
111
123
  }
112
- exposeFunc === null || exposeFunc === void 0 ? void 0 : exposeFunc(param);
113
- return found;
124
+ console.warn(`[Statsig] Parameter type mismatch. '${name}.${key}' was found to be type '${actualType}' but fallback/return type is '${expectedType}'`);
125
+ return defaultValue;
114
126
  };
115
127
  }
116
128
  function _makeUnknownGet(value, exposeFunc) {