@statsig/client-core 0.0.1-beta.6 → 0.0.1-beta.7
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
|
@@ -4,7 +4,8 @@ import { StatsigEvent } from './StatsigEvent';
|
|
|
4
4
|
import { DynamicConfig, Experiment, FeatureGate, Layer } from './StatsigTypes';
|
|
5
5
|
import { StatsigUser } from './StatsigUser';
|
|
6
6
|
export interface StatsigClientCommonInterface extends StatsigClientEventEmitterInterface {
|
|
7
|
-
|
|
7
|
+
initializeSync(): void;
|
|
8
|
+
initializeAsync(): Promise<void>;
|
|
8
9
|
shutdown(): Promise<void>;
|
|
9
10
|
}
|
|
10
11
|
export interface OnDeviceEvaluationsInterface extends StatsigClientCommonInterface {
|
|
@@ -17,7 +18,8 @@ export interface OnDeviceEvaluationsInterface extends StatsigClientCommonInterfa
|
|
|
17
18
|
}
|
|
18
19
|
export interface PrecomputedEvaluationsInterface extends StatsigClientCommonInterface {
|
|
19
20
|
getCurrentUser(): StatsigUser;
|
|
20
|
-
|
|
21
|
+
updateUserSync(user: StatsigUser): void;
|
|
22
|
+
updateUserAsync(user: StatsigUser): Promise<void>;
|
|
21
23
|
checkGate(name: string, options: EvaluationOptions): boolean;
|
|
22
24
|
getFeatureGate(name: string, options: EvaluationOptions): FeatureGate;
|
|
23
25
|
getDynamicConfig(name: string, options: EvaluationOptions): DynamicConfig;
|
package/src/StatsigClientBase.js
CHANGED
|
@@ -63,8 +63,7 @@ var StatsigClientBase = /** @class */ (function () {
|
|
|
63
63
|
this._logger.enqueue(exposure);
|
|
64
64
|
};
|
|
65
65
|
StatsigClientBase.prototype._runPostUpdate = function (current, user) {
|
|
66
|
-
|
|
67
|
-
(_b = (_a = this._adapter).handlePostUpdate) === null || _b === void 0 ? void 0 : _b.call(_a, current, user).catch(function (err) {
|
|
66
|
+
this._adapter.getDataAsync(current, user).catch(function (err) {
|
|
68
67
|
Log_1.Log.error('An error occurred after update.', err);
|
|
69
68
|
});
|
|
70
69
|
};
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { StatsigOptionsCommon } from './StatsigOptionsCommon';
|
|
2
2
|
import { StatsigUser } from './StatsigUser';
|
|
3
|
-
export type DataSource = 'Uninitialized' | 'Loading' | 'NoValues' | 'Cache' | 'Network' | 'NetworkNotModified' | 'Bootstrap'
|
|
3
|
+
export type DataSource = 'Uninitialized' | 'Loading' | 'NoValues' | 'Cache' | 'Network' | 'NetworkNotModified' | 'Bootstrap';
|
|
4
4
|
export type StatsigDataAdapterResult = {
|
|
5
5
|
readonly source: DataSource;
|
|
6
6
|
readonly data: string;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Describes a type that is used during intialize/update operations of a Statsig client.
|
|
10
|
+
*
|
|
11
|
+
* See below to find the default adapters, but know that it is possible to create your
|
|
12
|
+
* own StatsigDataAdapter and provide it via {@link StatsigOptions.dataAdapter}.
|
|
13
|
+
*
|
|
14
|
+
* Defaults:
|
|
15
|
+
*
|
|
16
|
+
* - {@link PrecomputedEvaluationsClient} uses {@link EvaluationsDataAdapter}
|
|
17
|
+
*
|
|
18
|
+
* - {@link OnDeviceEvaluationsClient} uses {@link SpecsDataAdapter}
|
|
19
|
+
*/
|
|
8
20
|
export type StatsigDataAdapter = {
|
|
9
21
|
/**
|
|
10
22
|
* Called when the StatsigDataAdapter is attached to the Statsig client instance during construction.
|
|
@@ -13,15 +25,16 @@ export type StatsigDataAdapter = {
|
|
|
13
25
|
*/
|
|
14
26
|
readonly attach: (sdkKey: string, options: StatsigOptionsCommon | null) => void;
|
|
15
27
|
/**
|
|
16
|
-
* Synchronously get data for the given user (if any). Called during
|
|
28
|
+
* Synchronously get data for the given user (if any). Called during initializeSync and/or updateUserSync.
|
|
29
|
+
* It is also called during async update operations before StatsigDataAdapter.getDataAsync is called.
|
|
17
30
|
* @param {StatsigUser | undefined} user The StatsigUser to get data for.
|
|
18
31
|
* @returns {StatsigDataAdapterResult | null} The data that was found for the given StatsigUser.
|
|
19
32
|
*/
|
|
20
|
-
readonly
|
|
33
|
+
readonly getDataSync: (user?: StatsigUser) => StatsigDataAdapterResult | null;
|
|
21
34
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @
|
|
35
|
+
* Asynchronously get data for the given user (if any). Called during initializeAsync and/or updateUserAsync.
|
|
36
|
+
* @param {StatsigUser | undefined} user The StatsigUser to get data for.
|
|
37
|
+
* @returns {StatsigDataAdapterResult | null} The data that was found for the given StatsigUser.
|
|
25
38
|
*/
|
|
26
|
-
readonly
|
|
39
|
+
readonly getDataAsync: (current: StatsigDataAdapterResult | null, user?: StatsigUser) => Promise<StatsigDataAdapterResult | null>;
|
|
27
40
|
};
|
package/src/StatsigMetadata.js
CHANGED
|
@@ -12,7 +12,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.StatsigMetadataProvider = void 0;
|
|
15
|
-
var SDK_VERSION = '0.0.1-beta.
|
|
15
|
+
var SDK_VERSION = '0.0.1-beta.7';
|
|
16
16
|
var metadata = {
|
|
17
17
|
sdkVersion: SDK_VERSION,
|
|
18
18
|
sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients
|
|
@@ -22,7 +22,7 @@ export type StatsigOptionsCommon = {
|
|
|
22
22
|
*/
|
|
23
23
|
logLevel?: LogLevel;
|
|
24
24
|
/**
|
|
25
|
-
* StatsigDataAdapter implementor used to customize the initialization flow.
|
|
25
|
+
* StatsigDataAdapter implementor used to customize the initialization/update flow.
|
|
26
26
|
* Default: EvaluationsDataAdapter (Precomputed) or SpecsDataAdapter (OnDevice)
|
|
27
27
|
*/
|
|
28
28
|
dataAdapter?: StatsigDataAdapter;
|