@statsig/statsig-node-core 0.14.0 → 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/index.js CHANGED
@@ -64,7 +64,7 @@ function createFetchFunc(options) {
64
64
  try {
65
65
  const res = yield (0, node_fetch_1.default)(url, {
66
66
  method,
67
- headers: Object.assign(Object.assign({}, headers), { 'Accept-Encoding': 'gzip, deflate, br' }),
67
+ headers: Object.assign({ 'accept-encoding': 'gzip, deflate, br' }, headers),
68
68
  body: body ? Buffer.from(body) : undefined,
69
69
  agent: proxyAgent,
70
70
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/statsig-node-core",
3
- "version": "0.14.0",
3
+ "version": "0.14.1-beta.2512170241",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest --colors"
@@ -55,14 +55,13 @@
55
55
  ]
56
56
  },
57
57
  "optionalDependencies": {
58
- "@statsig/statsig-node-core-linux-x64-musl": "0.14.0",
59
- "@statsig/statsig-node-core-linux-x64-gnu": "0.14.0",
60
- "@statsig/statsig-node-core-win32-x64-msvc": "0.14.0",
61
- "@statsig/statsig-node-core-darwin-x64": "0.14.0",
62
- "@statsig/statsig-node-core-win32-ia32-msvc": "0.14.0",
63
- "@statsig/statsig-node-core-linux-arm64-musl": "0.14.0",
64
- "@statsig/statsig-node-core-linux-arm64-gnu": "0.14.0",
65
- "@statsig/statsig-node-core-win32-arm64-msvc": "0.14.0",
66
- "@statsig/statsig-node-core-darwin-arm64": "0.14.0"
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"
67
66
  }
68
67
  }
@@ -227,6 +227,7 @@ export declare function statsigCaptureLogLine(level: string, payload: Array<stri
227
227
 
228
228
  export interface StatsigOptions {
229
229
  dataStore?: DataStore
230
+ dataStoreKeySchemaVersion?: 'v2' | 'v3'
230
231
  disableAllLogging?: boolean
231
232
  disableCountryLookup?: boolean
232
233
  disableNetwork?: boolean
@@ -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) {