@statsig/client-core 3.10.0 → 3.11.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/InitializeResponse.d.ts +1 -0
- package/src/MemoKey.d.ts +9 -1
- package/src/MemoKey.js +12 -5
- package/src/SDKFlags.d.ts +4 -0
- package/src/SDKFlags.js +13 -0
- package/src/StatsigClientBase.d.ts +2 -1
- package/src/StatsigClientBase.js +5 -2
- package/src/StatsigMetadata.d.ts +1 -1
- package/src/StatsigMetadata.js +1 -1
- package/src/StatsigOptionsCommon.d.ts +6 -0
- package/src/index.d.ts +3 -1
- package/src/index.js +3 -1
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@ export type InitializeResponseWithUpdates = SessionReplayFields & AutoCaptureFie
|
|
|
21
21
|
derived_fields?: Record<string, unknown>;
|
|
22
22
|
user?: StatsigUser;
|
|
23
23
|
sdkInfo?: Record<string, string>;
|
|
24
|
+
sdk_flags?: Record<string, boolean>;
|
|
24
25
|
};
|
|
25
26
|
export type InitializeResponse = InitializeResponseWithUpdates | {
|
|
26
27
|
has_updates: false;
|
package/src/MemoKey.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { AnyEvaluationOptions } from './EvaluationOptions';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const MemoPrefix: {
|
|
3
|
+
readonly _gate: "g";
|
|
4
|
+
readonly _dynamicConfig: "c";
|
|
5
|
+
readonly _experiment: "e";
|
|
6
|
+
readonly _layer: "l";
|
|
7
|
+
readonly _paramStore: "p";
|
|
8
|
+
};
|
|
9
|
+
export type MemoPrefix = (typeof MemoPrefix)[keyof typeof MemoPrefix];
|
|
10
|
+
export declare function createMemoKey(prefix: MemoPrefix, name: string, options?: AnyEvaluationOptions): string | undefined;
|
package/src/MemoKey.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createMemoKey = void 0;
|
|
3
|
+
exports.createMemoKey = exports.MemoPrefix = void 0;
|
|
4
|
+
exports.MemoPrefix = {
|
|
5
|
+
_gate: 'g',
|
|
6
|
+
_dynamicConfig: 'c',
|
|
7
|
+
_experiment: 'e',
|
|
8
|
+
_layer: 'l',
|
|
9
|
+
_paramStore: 'p',
|
|
10
|
+
};
|
|
4
11
|
const EXIST_KEYS = new Set([
|
|
5
12
|
// Add keys that should be memoized based only on their existence, not their value
|
|
6
13
|
]);
|
|
@@ -8,8 +15,8 @@ const DO_NOT_MEMO_KEYS = new Set([
|
|
|
8
15
|
// Add keys that if exist, should not be memoized
|
|
9
16
|
'userPersistedValues',
|
|
10
17
|
]);
|
|
11
|
-
function createMemoKey(name, options) {
|
|
12
|
-
let cacheKey = name
|
|
18
|
+
function createMemoKey(prefix, name, options) {
|
|
19
|
+
let cacheKey = `${prefix}|${name}`;
|
|
13
20
|
if (!options) {
|
|
14
21
|
return cacheKey;
|
|
15
22
|
}
|
|
@@ -18,10 +25,10 @@ function createMemoKey(name, options) {
|
|
|
18
25
|
return undefined;
|
|
19
26
|
}
|
|
20
27
|
if (EXIST_KEYS.has(key)) {
|
|
21
|
-
cacheKey +=
|
|
28
|
+
cacheKey += `|${key}=true`;
|
|
22
29
|
}
|
|
23
30
|
else {
|
|
24
|
-
cacheKey +=
|
|
31
|
+
cacheKey += `|${key}=${options[key]}`;
|
|
25
32
|
}
|
|
26
33
|
}
|
|
27
34
|
return cacheKey;
|
package/src/SDKFlags.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SDKFlags = void 0;
|
|
4
|
+
const FLAGMAP = {};
|
|
5
|
+
exports.SDKFlags = {
|
|
6
|
+
setFlags: (sdkKey, flags) => {
|
|
7
|
+
FLAGMAP[sdkKey] = flags;
|
|
8
|
+
},
|
|
9
|
+
get: (sdkKey, flagKey) => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
return (_b = (_a = FLAGMAP[sdkKey]) === null || _a === void 0 ? void 0 : _a[flagKey]) !== null && _b !== void 0 ? _b : false;
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -2,6 +2,7 @@ import './$_StatsigGlobal';
|
|
|
2
2
|
import { ErrorBoundary } from './ErrorBoundary';
|
|
3
3
|
import { AnyEvaluationOptions, EvaluationOptionsCommon } from './EvaluationOptions';
|
|
4
4
|
import { EventLogger } from './EventLogger';
|
|
5
|
+
import { MemoPrefix } from './MemoKey';
|
|
5
6
|
import { NetworkCore } from './NetworkCore';
|
|
6
7
|
import { OverrideAdapter } from './OverrideAdapter';
|
|
7
8
|
import { AnyStatsigClientEvent, StatsigClientEventCallback, StatsigClientEventEmitterInterface, StatsigClientEventName, StatsigLoadingStatus } from './StatsigClientEventEmitter';
|
|
@@ -68,6 +69,6 @@ export declare abstract class StatsigClientBase<TAdapter extends EvaluationsData
|
|
|
68
69
|
$emt(event: AnyStatsigClientEvent): void;
|
|
69
70
|
protected _setStatus(newStatus: StatsigLoadingStatus, values: DataAdapterResult | null): void;
|
|
70
71
|
protected _enqueueExposure(name: string, exposure: StatsigEventInternal, options?: EvaluationOptionsCommon): void;
|
|
71
|
-
protected _memoize<T, O extends AnyEvaluationOptions>(fn: (name: string, options?: O) => T): (name: string, options?: O) => T;
|
|
72
|
+
protected _memoize<T, O extends AnyEvaluationOptions>(prefix: MemoPrefix, fn: (name: string, options?: O) => T): (name: string, options?: O) => T;
|
|
72
73
|
protected abstract _primeReadyRipcord(): void;
|
|
73
74
|
}
|
package/src/StatsigClientBase.js
CHANGED
|
@@ -147,9 +147,12 @@ class StatsigClientBase {
|
|
|
147
147
|
}
|
|
148
148
|
this._logger.enqueue(exposure);
|
|
149
149
|
}
|
|
150
|
-
_memoize(fn) {
|
|
150
|
+
_memoize(prefix, fn) {
|
|
151
151
|
return (name, options) => {
|
|
152
|
-
|
|
152
|
+
if (this._options.disableEvaluationMemoization) {
|
|
153
|
+
return fn(name, options);
|
|
154
|
+
}
|
|
155
|
+
const memoKey = (0, MemoKey_1.createMemoKey)(prefix, name, options);
|
|
153
156
|
if (!memoKey) {
|
|
154
157
|
return fn(name, options);
|
|
155
158
|
}
|
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.11.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
|
|
@@ -121,6 +121,12 @@ export type StatsigOptionsCommon<NetworkConfig extends NetworkConfigCommon> = St
|
|
|
121
121
|
* default: `window.localStorage` on Web. `@react-native-async-storage/async-storage` on Mobile.
|
|
122
122
|
*/
|
|
123
123
|
storageProvider?: StorageProvider;
|
|
124
|
+
/**
|
|
125
|
+
* Disables all memoization of the core evaluation functions.
|
|
126
|
+
*
|
|
127
|
+
* default: `false`
|
|
128
|
+
*/
|
|
129
|
+
disableEvaluationMemoization?: boolean;
|
|
124
130
|
};
|
|
125
131
|
export type AnyStatsigOptions = StatsigOptionsCommon<NetworkConfigCommon>;
|
|
126
132
|
export type StatsigEnvironment = {
|
package/src/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './EvaluationTypes';
|
|
|
16
16
|
export * from './Hashing';
|
|
17
17
|
export * from './InitializeResponse';
|
|
18
18
|
export * from './Log';
|
|
19
|
+
export * from './MemoKey';
|
|
19
20
|
export * from './NetworkConfig';
|
|
20
21
|
export * from './NetworkCore';
|
|
21
22
|
export * from './OverrideAdapter';
|
|
@@ -41,4 +42,5 @@ export * from './UrlConfiguration';
|
|
|
41
42
|
export * from './UUID';
|
|
42
43
|
export * from './VisibilityObserving';
|
|
43
44
|
export * from './StatsigUpdateDetails';
|
|
44
|
-
export
|
|
45
|
+
export * from './SDKFlags';
|
|
46
|
+
export { Diagnostics, EventLogger, Log, Storage };
|
package/src/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.Storage = exports.Log = exports.EventLogger = exports.Diagnostics = void 0;
|
|
18
18
|
/** Statsig Global should go first */
|
|
19
19
|
require("./$_StatsigGlobal");
|
|
20
20
|
const Diagnostics_1 = require("./Diagnostics");
|
|
@@ -38,6 +38,7 @@ __exportStar(require("./EvaluationTypes"), exports);
|
|
|
38
38
|
__exportStar(require("./Hashing"), exports);
|
|
39
39
|
__exportStar(require("./InitializeResponse"), exports);
|
|
40
40
|
__exportStar(require("./Log"), exports);
|
|
41
|
+
__exportStar(require("./MemoKey"), exports);
|
|
41
42
|
__exportStar(require("./NetworkConfig"), exports);
|
|
42
43
|
__exportStar(require("./NetworkCore"), exports);
|
|
43
44
|
__exportStar(require("./OverrideAdapter"), exports);
|
|
@@ -63,5 +64,6 @@ __exportStar(require("./UrlConfiguration"), exports);
|
|
|
63
64
|
__exportStar(require("./UUID"), exports);
|
|
64
65
|
__exportStar(require("./VisibilityObserving"), exports);
|
|
65
66
|
__exportStar(require("./StatsigUpdateDetails"), exports);
|
|
67
|
+
__exportStar(require("./SDKFlags"), exports);
|
|
66
68
|
__STATSIG__ = Object.assign(Object.assign({}, (__STATSIG__ !== null && __STATSIG__ !== void 0 ? __STATSIG__ : {})), { Log: Log_1.Log,
|
|
67
69
|
SDK_VERSION: StatsigMetadata_1.SDK_VERSION });
|