@statsig/client-core 3.6.0-beta.1 → 3.7.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/DownloadConfigSpecsResponse.d.ts +1 -0
- package/src/EventLogger.js +1 -1
- package/src/NetworkCore.js +13 -0
- package/src/StatsigMetadata.d.ts +1 -1
- package/src/StatsigMetadata.js +1 -1
- package/src/StatsigUser.d.ts +1 -1
- package/src/StatsigUser.js +4 -1
- package/src/UrlConfiguration.js +3 -1
package/package.json
CHANGED
package/src/EventLogger.js
CHANGED
|
@@ -300,7 +300,7 @@ class EventLogger {
|
|
|
300
300
|
const flushInterval = (_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.loggingIntervalMs) !== null && _b !== void 0 ? _b : DEFAULT_FLUSH_INTERVAL_MS;
|
|
301
301
|
const intervalId = setInterval(() => {
|
|
302
302
|
const logger = EVENT_LOGGER_MAP[this._sdkKey];
|
|
303
|
-
if (logger._flushIntervalId !== intervalId) {
|
|
303
|
+
if (!logger || logger._flushIntervalId !== intervalId) {
|
|
304
304
|
clearInterval(intervalId);
|
|
305
305
|
}
|
|
306
306
|
else {
|
package/src/NetworkCore.js
CHANGED
|
@@ -24,6 +24,8 @@ const StatsigClientEventEmitter_1 = require("./StatsigClientEventEmitter");
|
|
|
24
24
|
const StatsigMetadata_1 = require("./StatsigMetadata");
|
|
25
25
|
const VisibilityObserving_1 = require("./VisibilityObserving");
|
|
26
26
|
const DEFAULT_TIMEOUT_MS = 10000;
|
|
27
|
+
const BACKOFF_BASE_MS = 500;
|
|
28
|
+
const BACKOFF_MAX_MS = 30000;
|
|
27
29
|
const RETRYABLE_CODES = new Set([408, 500, 502, 503, 504, 522, 524, 599]);
|
|
28
30
|
class NetworkCore {
|
|
29
31
|
constructor(options, _emitter) {
|
|
@@ -144,6 +146,7 @@ class NetworkCore {
|
|
|
144
146
|
Log_1.Log.error(`A networking error occured during ${method} request to ${populatedUrl}.`, errorMessage, error);
|
|
145
147
|
return null;
|
|
146
148
|
}
|
|
149
|
+
yield _exponentialBackoff(currentAttempt);
|
|
147
150
|
return this._sendRequest(Object.assign(Object.assign({}, args), { retries, attempt: currentAttempt + 1 }));
|
|
148
151
|
}
|
|
149
152
|
});
|
|
@@ -238,3 +241,13 @@ function _tryMarkInitEnd(args, response, attempt, body, err) {
|
|
|
238
241
|
}
|
|
239
242
|
Diagnostics_1.Diagnostics._markInitNetworkReqEnd(args.sdkKey, Diagnostics_1.Diagnostics._getDiagnosticsData(response, attempt, body, err));
|
|
240
243
|
}
|
|
244
|
+
function _exponentialBackoff(attempt) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
// 1*1*1000 1s
|
|
247
|
+
// 2*2*1000 4s
|
|
248
|
+
// 3*3*1000 9s
|
|
249
|
+
// 4*4*1000 16s
|
|
250
|
+
// 5*5*1000 25s
|
|
251
|
+
yield new Promise((r) => setTimeout(r, Math.min(BACKOFF_BASE_MS * (attempt * attempt), BACKOFF_MAX_MS)));
|
|
252
|
+
});
|
|
253
|
+
}
|
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.7.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
|
package/src/StatsigUser.d.ts
CHANGED
|
@@ -18,6 +18,6 @@ export type StatsigUser = {
|
|
|
18
18
|
export type StatsigUserInternal = StatsigUser & {
|
|
19
19
|
statsigEnvironment: StatsigEnvironment | undefined;
|
|
20
20
|
};
|
|
21
|
-
export declare function _normalizeUser(original: StatsigUser, options?: AnyStatsigOptions | null): StatsigUserInternal;
|
|
21
|
+
export declare function _normalizeUser(original: StatsigUser, options?: AnyStatsigOptions | null, fallbackEnvironment?: string | null): StatsigUserInternal;
|
|
22
22
|
export declare function _getFullUserHash(user: StatsigUser | undefined): string | null;
|
|
23
23
|
export {};
|
package/src/StatsigUser.js
CHANGED
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports._getFullUserHash = exports._normalizeUser = void 0;
|
|
4
4
|
const Hashing_1 = require("./Hashing");
|
|
5
5
|
const Log_1 = require("./Log");
|
|
6
|
-
function _normalizeUser(original, options) {
|
|
6
|
+
function _normalizeUser(original, options, fallbackEnvironment) {
|
|
7
7
|
try {
|
|
8
8
|
const copy = JSON.parse(JSON.stringify(original));
|
|
9
9
|
if (options != null && options.environment != null) {
|
|
10
10
|
copy.statsigEnvironment = options.environment;
|
|
11
11
|
}
|
|
12
|
+
else if (fallbackEnvironment != null) {
|
|
13
|
+
copy.statsigEnvironment = { tier: fallbackEnvironment };
|
|
14
|
+
}
|
|
12
15
|
return copy;
|
|
13
16
|
}
|
|
14
17
|
catch (error) {
|
package/src/UrlConfiguration.js
CHANGED
|
@@ -17,7 +17,9 @@ class UrlConfiguration {
|
|
|
17
17
|
this.customUrl = customUrl;
|
|
18
18
|
}
|
|
19
19
|
if (!customUrl && customApi) {
|
|
20
|
-
this.customUrl =
|
|
20
|
+
this.customUrl = customApi.endsWith('/')
|
|
21
|
+
? `${customApi}${endpoint}`
|
|
22
|
+
: `${customApi}/${endpoint}`;
|
|
21
23
|
}
|
|
22
24
|
if (fallbackUrls) {
|
|
23
25
|
this.fallbackUrls = fallbackUrls;
|