@statsig/client-core 3.26.0 → 3.28.0

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/client-core",
3
- "version": "3.26.0",
3
+ "version": "3.28.0",
4
4
  "license": "ISC",
5
5
  "homepage": "https://github.com/statsig-io/js-client-monorepo",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
  import { DownloadConfigSpecsResponse } from './DownloadConfigSpecsResponse';
2
2
  import { ErrorBoundary } from './ErrorBoundary';
3
3
  import { DynamicConfigEvaluationOptions, ExperimentEvaluationOptions, FeatureGateEvaluationOptions, LayerEvaluationOptions, ParameterStoreEvaluationOptions } from './EvaluationOptions';
4
- import { InitializeResponseWithUpdates } from './InitializeResponse';
4
+ import { AnyInitializeResponse, ClientInitializeResponseOptions } from './InitializeResponse';
5
5
  import { StatsigSession } from './SessionID';
6
6
  import { StatsigClientEventEmitterInterface } from './StatsigClientEventEmitter';
7
7
  import { EvaluationsDataAdapter, SpecsDataAdapter } from './StatsigDataAdapter';
@@ -39,9 +39,10 @@ export interface OnDeviceEvaluationsInterface extends StatsigClientCommonInterfa
39
39
  getLayer(name: string, user: StatsigUser, options?: LayerEvaluationOptions): Layer;
40
40
  logEvent(event: StatsigEvent, user: StatsigUser): void;
41
41
  logEvent(eventName: string, user: StatsigUser, value?: string | number, metadata?: Record<string, string>): void;
42
+ getClientInitializeResponse(user: StatsigUser, options?: ClientInitializeResponseOptions): AnyInitializeResponse | null;
42
43
  }
43
44
  export type PrecomputedEvaluationsContext = Flatten<CommonContext & {
44
- values: InitializeResponseWithUpdates | null;
45
+ values: AnyInitializeResponse | null;
45
46
  user: StatsigUser;
46
47
  }>;
47
48
  export interface PrecomputedEvaluationsInterface extends StatsigClientCommonInterface {
@@ -135,7 +135,8 @@ class DataAdapterCore {
135
135
  }
136
136
  catch (error) {
137
137
  if (!(error instanceof Error) ||
138
- error.name !== 'QuotaExceededError' ||
138
+ !(error.toString().includes('QuotaExceededError') ||
139
+ error.toString().includes('QUOTA_EXCEEDED_ERR')) ||
139
140
  this._cacheLimit <= 1) {
140
141
  throw error;
141
142
  }
@@ -44,9 +44,18 @@ export type DownloadConfigSpecsResponse = {
44
44
  dynamic_configs: Spec[];
45
45
  layer_configs: Spec[];
46
46
  param_stores?: Record<string, ParamStore>;
47
+ layers?: Record<string, string[]>;
47
48
  time: number;
48
49
  has_updates: boolean;
49
50
  sdkInfo?: Record<string, string>;
50
51
  user?: StatsigUser;
51
52
  default_environment?: string;
53
+ sdk_keys_to_app_ids?: Record<string, string>;
54
+ hashed_sdk_keys_to_app_ids?: Record<string, string>;
55
+ hashed_sdk_keys_to_entities?: Record<string, {
56
+ gates: string[];
57
+ configs: string[];
58
+ experiments: string[];
59
+ }>;
60
+ app_id?: string;
52
61
  };
@@ -23,6 +23,8 @@ export type ExperimentEvaluation = Flatten<EvaluationBase<Record<string, unknown
23
23
  is_experiment_active?: boolean;
24
24
  is_user_in_experiment?: boolean;
25
25
  passed?: boolean;
26
+ is_in_layer?: boolean;
27
+ explicit_parameters?: string[];
26
28
  }>;
27
29
  export type DynamicConfigEvaluation = ExperimentEvaluation;
28
30
  export type LayerEvaluation = Flatten<Omit<ExperimentEvaluation, 'id_type'> & {
@@ -0,0 +1,30 @@
1
+ export type GateEvaluationV2 = {
2
+ v?: true;
3
+ r?: string | null;
4
+ i?: string;
5
+ s?: string[];
6
+ };
7
+ export type ExperimentEvaluationV2 = {
8
+ r: string;
9
+ v: string;
10
+ gn?: string | null;
11
+ i?: string;
12
+ s?: string[];
13
+ ue?: true;
14
+ ea?: true;
15
+ p?: true;
16
+ };
17
+ export type DynamicConfigEvaluationV2 = ExperimentEvaluationV2;
18
+ export type LayerEvaluationV2 = {
19
+ r: string;
20
+ v: string;
21
+ gn?: string | null;
22
+ i?: string;
23
+ s?: string[];
24
+ us?: string[];
25
+ ue?: true;
26
+ ea?: true;
27
+ ep?: string[];
28
+ ae?: string;
29
+ pr?: Record<string, string>;
30
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  import { DynamicConfigEvaluation, GateEvaluation, LayerEvaluation, SecondaryExposure } from './EvaluationTypes';
2
+ import { DynamicConfigEvaluationV2, GateEvaluationV2, LayerEvaluationV2 } from './EvaluationTypesV2';
2
3
  import { ParamStoreConfig } from './ParamStoreTypes';
3
4
  import { StatsigUser } from './StatsigUser';
4
5
  type SessionReplayFields = {
@@ -18,22 +19,41 @@ type AutoCaptureFields = {
18
19
  disabled_events: Record<string, boolean>;
19
20
  };
20
21
  };
21
- export type InitializeResponseWithUpdates = SessionReplayFields & AutoCaptureFields & {
22
- feature_gates: Record<string, GateEvaluation>;
23
- dynamic_configs: Record<string, DynamicConfigEvaluation>;
24
- layer_configs: Record<string, LayerEvaluation>;
22
+ type InitResponseCommon = SessionReplayFields & AutoCaptureFields & {
25
23
  param_stores?: Record<string, ParamStoreConfig>;
26
24
  time: number;
27
25
  has_updates: true;
28
26
  hash_used: 'none' | 'sha256' | 'djb2';
29
- derived_fields?: Record<string, unknown>;
30
- user?: StatsigUser;
27
+ user: StatsigUser;
31
28
  sdkInfo?: Record<string, string>;
29
+ sdkParams?: Record<string, unknown>;
30
+ generator?: string;
31
+ evaluated_keys?: Record<string, unknown>;
32
+ pa_hash?: string;
33
+ derived_fields?: Record<string, unknown>;
32
34
  sdk_flags?: Record<string, boolean>;
33
35
  full_checksum?: string;
34
36
  exposures?: Record<string, SecondaryExposure>;
35
37
  };
36
- export type InitializeResponse = InitializeResponseWithUpdates | {
38
+ export type InitializeResponseV1WithUpdates = InitResponseCommon & {
39
+ feature_gates: Record<string, GateEvaluation>;
40
+ dynamic_configs: Record<string, DynamicConfigEvaluation>;
41
+ layer_configs: Record<string, LayerEvaluation>;
42
+ response_format?: 'init-v1' | null | undefined;
43
+ };
44
+ export type InitializeResponseV2 = InitResponseCommon & {
45
+ feature_gates: Record<string, GateEvaluationV2>;
46
+ dynamic_configs: Record<string, DynamicConfigEvaluationV2>;
47
+ layer_configs: Record<string, LayerEvaluationV2>;
48
+ values: Record<string, Record<string, unknown>>;
49
+ response_format: 'init-v2';
50
+ };
51
+ export type InitializeResponse = InitializeResponseV1WithUpdates | {
37
52
  has_updates: false;
38
53
  };
54
+ export type ClientInitializeResponseOptions = {
55
+ hash?: 'none' | 'sha256' | 'djb2';
56
+ clientSDKKey?: string;
57
+ };
58
+ export type AnyInitializeResponse = InitializeResponseV1WithUpdates | InitializeResponseV2;
39
59
  export {};
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "3.26.0";
1
+ export declare const SDK_VERSION = "3.28.0";
2
2
  export type StatsigMetadata = {
3
3
  readonly [key: string]: string | undefined | null;
4
4
  readonly appVersion?: string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '3.26.0';
4
+ exports.SDK_VERSION = '3.28.0';
5
5
  let metadata = {
6
6
  sdkVersion: exports.SDK_VERSION,
7
7
  sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients
@@ -19,9 +19,9 @@ function _makeFeatureGate(name, details, evaluation) {
19
19
  }
20
20
  exports._makeFeatureGate = _makeFeatureGate;
21
21
  function _makeDynamicConfig(name, details, evaluation) {
22
- var _a;
22
+ var _a, _b;
23
23
  const value = (_a = evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) !== null && _a !== void 0 ? _a : {};
24
- return Object.assign(Object.assign({}, _makeEvaluation(name, details, evaluation, value)), { get: _makeTypedGet(name, evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) });
24
+ return Object.assign(Object.assign({}, _makeEvaluation(name, details, evaluation, value)), { idType: (_b = evaluation === null || evaluation === void 0 ? void 0 : evaluation.id_type) !== null && _b !== void 0 ? _b : null, get: _makeTypedGet(name, evaluation === null || evaluation === void 0 ? void 0 : evaluation.value) });
25
25
  }
26
26
  exports._makeDynamicConfig = _makeDynamicConfig;
27
27
  function _makeExperiment(name, details, evaluation) {
@@ -19,6 +19,7 @@ export type Experiment = Flatten<{
19
19
  readonly details: EvaluationDetails;
20
20
  readonly value: Record<string, unknown>;
21
21
  readonly groupName: string | null;
22
+ readonly idType: string | null;
22
23
  readonly __evaluation: ExperimentEvaluation | null;
23
24
  readonly get: TypedGet;
24
25
  }>;
@@ -48,11 +48,6 @@ function _inMemoryBreaker(action) {
48
48
  exports.Storage._setProvider(_inMemoryProvider);
49
49
  return null;
50
50
  }
51
- if (error instanceof Error && error.name === 'QuotaExceededError') {
52
- const allKeys = exports.Storage.getAllKeys();
53
- const statsigKeys = allKeys.filter((key) => key.startsWith('statsig.'));
54
- error.message = `${error.message}. Statsig Keys: ${statsigKeys.length}`;
55
- }
56
51
  throw error;
57
52
  }
58
53
  }