@statsig/client-core 3.25.6 → 3.27.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 +1 -1
- package/src/ClientInterfaces.d.ts +3 -2
- package/src/DataAdapterCore.js +2 -1
- package/src/DownloadConfigSpecsResponse.d.ts +9 -0
- package/src/EvaluationTypes.d.ts +2 -0
- package/src/EvaluationTypesV2.d.ts +30 -0
- package/src/EvaluationTypesV2.js +2 -0
- package/src/InitializeResponse.d.ts +27 -7
- package/src/NetworkCore.js +8 -19
- package/src/StatsigMetadata.d.ts +1 -1
- package/src/StatsigMetadata.js +1 -1
- package/src/StatsigTypeFactories.js +2 -2
- package/src/StatsigTypes.d.ts +1 -0
- package/src/StorageProvider.js +0 -5
package/package.json
CHANGED
|
@@ -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 {
|
|
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:
|
|
45
|
+
values: AnyInitializeResponse | null;
|
|
45
46
|
user: StatsigUser;
|
|
46
47
|
}>;
|
|
47
48
|
export interface PrecomputedEvaluationsInterface extends StatsigClientCommonInterface {
|
package/src/DataAdapterCore.js
CHANGED
|
@@ -135,7 +135,8 @@ class DataAdapterCore {
|
|
|
135
135
|
}
|
|
136
136
|
catch (error) {
|
|
137
137
|
if (!(error instanceof Error) ||
|
|
138
|
-
error.
|
|
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
|
};
|
package/src/EvaluationTypes.d.ts
CHANGED
|
@@ -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
|
+
};
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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 {};
|
package/src/NetworkCore.js
CHANGED
|
@@ -108,12 +108,7 @@ class NetworkCore {
|
|
|
108
108
|
return null;
|
|
109
109
|
}
|
|
110
110
|
const currentAttempt = attempt !== null && attempt !== void 0 ? attempt : 1;
|
|
111
|
-
const abortController = typeof AbortController !== 'undefined' ? new AbortController() : null;
|
|
112
111
|
let reqTimedOut = false;
|
|
113
|
-
const timeoutHandle = setTimeout(() => {
|
|
114
|
-
reqTimedOut = true;
|
|
115
|
-
abortController === null || abortController === void 0 ? void 0 : abortController.abort();
|
|
116
|
-
}, this._timeout);
|
|
117
112
|
const populatedUrl = this._getPopulatedURL(args);
|
|
118
113
|
let response = null;
|
|
119
114
|
const keepalive = (0, VisibilityObserving_1._isUnloading)();
|
|
@@ -122,7 +117,6 @@ class NetworkCore {
|
|
|
122
117
|
method,
|
|
123
118
|
body,
|
|
124
119
|
headers: Object.assign({}, args.headers),
|
|
125
|
-
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
126
120
|
priority: args.priority,
|
|
127
121
|
keepalive,
|
|
128
122
|
};
|
|
@@ -133,21 +127,16 @@ class NetworkCore {
|
|
|
133
127
|
this._leakyBucket[endpoint] = bucket;
|
|
134
128
|
}
|
|
135
129
|
const func = (_a = this._netConfig.networkOverrideFunc) !== null && _a !== void 0 ? _a : fetch;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
else {
|
|
142
|
-
// Fallback path: Promise.race timeout
|
|
143
|
-
response = yield Promise.race([
|
|
144
|
-
func(populatedUrl, config),
|
|
145
|
-
new Promise((_, reject) => setTimeout(() => {
|
|
130
|
+
let timeoutId;
|
|
131
|
+
response = yield Promise.race([
|
|
132
|
+
func(populatedUrl, config).finally(() => clearTimeout(timeoutId)),
|
|
133
|
+
new Promise((_, reject) => {
|
|
134
|
+
timeoutId = setTimeout(() => {
|
|
146
135
|
reqTimedOut = true;
|
|
147
136
|
reject(new Error(`Timeout of ${this._timeout}ms expired.`));
|
|
148
|
-
}, this._timeout)
|
|
149
|
-
|
|
150
|
-
|
|
137
|
+
}, this._timeout);
|
|
138
|
+
}),
|
|
139
|
+
]);
|
|
151
140
|
if (!response.ok) {
|
|
152
141
|
const text = yield response.text().catch(() => 'No Text');
|
|
153
142
|
const err = new Error(`NetworkError: ${populatedUrl} ${text}`);
|
package/src/StatsigMetadata.d.ts
CHANGED
package/src/StatsigMetadata.js
CHANGED
|
@@ -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.
|
|
4
|
+
exports.SDK_VERSION = '3.27.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) {
|
package/src/StatsigTypes.d.ts
CHANGED
|
@@ -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
|
}>;
|
package/src/StorageProvider.js
CHANGED
|
@@ -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
|
}
|