@statsig/client-core 3.31.1-beta.2 → 3.31.2
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/ErrorBoundary.d.ts +0 -2
- package/src/ErrorBoundary.js +3 -23
- package/src/EventLogger.d.ts +23 -14
- package/src/EventLogger.js +187 -85
- package/src/EventRetryConstants.d.ts +1 -3
- package/src/EventRetryConstants.js +1 -3
- package/src/NetworkCore.d.ts +0 -1
- package/src/NetworkCore.js +3 -5
- package/src/SessionID.d.ts +3 -3
- package/src/SessionID.js +82 -60
- package/src/StatsigClientBase.js +1 -1
- package/src/StatsigMetadata.d.ts +1 -1
- package/src/StatsigMetadata.js +1 -1
- package/src/BatchedEventsQueue.d.ts +0 -14
- package/src/BatchedEventsQueue.js +0 -51
- package/src/EventSender.d.ts +0 -23
- package/src/EventSender.js +0 -96
- package/src/FlushCoordinator.d.ts +0 -50
- package/src/FlushCoordinator.js +0 -332
- package/src/FlushInterval.d.ts +0 -13
- package/src/FlushInterval.js +0 -44
- package/src/FlushTypes.d.ts +0 -7
- package/src/FlushTypes.js +0 -12
- package/src/PendingEvents.d.ts +0 -10
- package/src/PendingEvents.js +0 -26
package/src/SessionID.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StatsigSession = exports.SessionID = void 0;
|
|
4
|
-
const __StatsigGlobal_1 = require("./$_StatsigGlobal");
|
|
5
4
|
const CacheKey_1 = require("./CacheKey");
|
|
6
5
|
const Log_1 = require("./Log");
|
|
7
6
|
const StorageProvider_1 = require("./StorageProvider");
|
|
8
7
|
const UUID_1 = require("./UUID");
|
|
8
|
+
const VisibilityObserving_1 = require("./VisibilityObserving");
|
|
9
9
|
const MAX_SESSION_IDLE_TIME = 30 * 60 * 1000; // 30 minutes
|
|
10
10
|
const MAX_SESSION_AGE = 4 * 60 * 60 * 1000; // 4 hours
|
|
11
|
-
const
|
|
11
|
+
const PERSIST_THROTTLE_MS = 15000;
|
|
12
|
+
const SESSION_MAP = {};
|
|
13
|
+
(0, VisibilityObserving_1._subscribeToVisiblityChanged)((visibility) => {
|
|
14
|
+
if (visibility === 'background') {
|
|
15
|
+
Object.values(SESSION_MAP).forEach((session) => _persistNow(session));
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
exports.SessionID = {
|
|
13
19
|
get: (sdkKey) => {
|
|
14
20
|
return exports.StatsigSession.get(sdkKey).data.sessionID;
|
|
@@ -16,72 +22,59 @@ exports.SessionID = {
|
|
|
16
22
|
};
|
|
17
23
|
exports.StatsigSession = {
|
|
18
24
|
get: (sdkKey, bumpSession = true) => {
|
|
19
|
-
if (
|
|
20
|
-
|
|
25
|
+
if (SESSION_MAP[sdkKey] == null) {
|
|
26
|
+
SESSION_MAP[sdkKey] = _loadOrCreateSharedSession(sdkKey);
|
|
21
27
|
}
|
|
22
|
-
const session =
|
|
23
|
-
return
|
|
28
|
+
const session = SESSION_MAP[sdkKey];
|
|
29
|
+
return _maybeBumpSession(session, bumpSession);
|
|
24
30
|
},
|
|
25
31
|
overrideInitialSessionID: (override, sdkKey) => {
|
|
26
|
-
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
const session = {
|
|
34
|
+
data: {
|
|
35
|
+
sessionID: override,
|
|
36
|
+
startTime: now,
|
|
37
|
+
lastUpdate: now,
|
|
38
|
+
},
|
|
39
|
+
sdkKey,
|
|
40
|
+
lastPersistedAt: Date.now(),
|
|
41
|
+
storageKey: _getSessionIDStorageKey(sdkKey),
|
|
42
|
+
};
|
|
43
|
+
_persistNow(session);
|
|
44
|
+
SESSION_MAP[sdkKey] = session;
|
|
45
|
+
},
|
|
46
|
+
checkForIdleSession: (sdkKey) => {
|
|
47
|
+
const session = SESSION_MAP[sdkKey];
|
|
48
|
+
if (!session) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const sessionExpired = _checkForExpiredSession(session);
|
|
52
|
+
if (sessionExpired) {
|
|
53
|
+
_persistNow(session);
|
|
54
|
+
}
|
|
27
55
|
},
|
|
28
56
|
};
|
|
29
|
-
function
|
|
30
|
-
let data = _loadFromStorage(sdkKey);
|
|
57
|
+
function _maybeBumpSession(session, allowSessionBump) {
|
|
31
58
|
const now = Date.now();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
startTime: now,
|
|
36
|
-
lastUpdate: now,
|
|
37
|
-
};
|
|
59
|
+
const sessionExpired = _checkForExpiredSession(session);
|
|
60
|
+
if (sessionExpired) {
|
|
61
|
+
_persistNow(session);
|
|
38
62
|
}
|
|
39
|
-
|
|
40
|
-
data
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function _overrideSessionId(override, sdkKey) {
|
|
45
|
-
const now = Date.now();
|
|
46
|
-
return {
|
|
47
|
-
data: {
|
|
48
|
-
sessionID: override,
|
|
49
|
-
startTime: now,
|
|
50
|
-
lastUpdate: now,
|
|
51
|
-
},
|
|
52
|
-
sdkKey,
|
|
53
|
-
};
|
|
63
|
+
else if (allowSessionBump) {
|
|
64
|
+
session.data.lastUpdate = now;
|
|
65
|
+
_persistThrottled(session);
|
|
66
|
+
}
|
|
67
|
+
return session;
|
|
54
68
|
}
|
|
55
|
-
function
|
|
69
|
+
function _checkForExpiredSession(session) {
|
|
56
70
|
var _a;
|
|
57
|
-
const now = Date.now();
|
|
58
71
|
const data = session.data;
|
|
59
|
-
const sdkKey = session.sdkKey;
|
|
60
72
|
const sessionExpired = _isIdle(data) || _hasRunTooLong(data);
|
|
61
73
|
if (sessionExpired) {
|
|
62
|
-
data
|
|
63
|
-
|
|
74
|
+
session.data = _newSessionData();
|
|
75
|
+
(_a = __STATSIG__ === null || __STATSIG__ === void 0 ? void 0 : __STATSIG__.instance(session.sdkKey)) === null || _a === void 0 ? void 0 : _a.$emt({ name: 'session_expired' });
|
|
64
76
|
}
|
|
65
|
-
|
|
66
|
-
_persistToStorage(data, session.sdkKey);
|
|
67
|
-
clearTimeout(session.idleTimeoutID);
|
|
68
|
-
clearTimeout(session.ageTimeoutID);
|
|
69
|
-
const lifetime = now - data.startTime;
|
|
70
|
-
session.idleTimeoutID = _createSessionTimeout(sdkKey, MAX_SESSION_IDLE_TIME);
|
|
71
|
-
session.ageTimeoutID = _createSessionTimeout(sdkKey, MAX_SESSION_AGE - lifetime);
|
|
72
|
-
if (sessionExpired) {
|
|
73
|
-
(_a = __STATSIG__ === null || __STATSIG__ === void 0 ? void 0 : __STATSIG__.instance(sdkKey)) === null || _a === void 0 ? void 0 : _a.$emt({ name: 'session_expired' });
|
|
74
|
-
}
|
|
75
|
-
return session;
|
|
76
|
-
}
|
|
77
|
-
function _createSessionTimeout(sdkKey, duration) {
|
|
78
|
-
return setTimeout(() => {
|
|
79
|
-
var _a;
|
|
80
|
-
const client = (_a = (0, __StatsigGlobal_1._getStatsigGlobal)()) === null || _a === void 0 ? void 0 : _a.instance(sdkKey);
|
|
81
|
-
if (client) {
|
|
82
|
-
client.$emt({ name: 'session_expired' });
|
|
83
|
-
}
|
|
84
|
-
}, duration);
|
|
77
|
+
return sessionExpired;
|
|
85
78
|
}
|
|
86
79
|
function _isIdle({ lastUpdate }) {
|
|
87
80
|
return Date.now() - lastUpdate > MAX_SESSION_IDLE_TIME;
|
|
@@ -92,16 +85,45 @@ function _hasRunTooLong({ startTime }) {
|
|
|
92
85
|
function _getSessionIDStorageKey(sdkKey) {
|
|
93
86
|
return `statsig.session_id.${(0, CacheKey_1._getStorageKey)(sdkKey)}`;
|
|
94
87
|
}
|
|
95
|
-
function
|
|
96
|
-
const storageKey = _getSessionIDStorageKey(sdkKey);
|
|
88
|
+
function _persistNow(session) {
|
|
97
89
|
try {
|
|
98
|
-
(0, StorageProvider_1._setObjectInStorage)(storageKey, session);
|
|
90
|
+
(0, StorageProvider_1._setObjectInStorage)(session.storageKey, session.data);
|
|
91
|
+
session.lastPersistedAt = Date.now();
|
|
99
92
|
}
|
|
100
93
|
catch (e) {
|
|
101
94
|
Log_1.Log.warn('Failed to save SessionID');
|
|
102
95
|
}
|
|
103
96
|
}
|
|
104
|
-
function
|
|
97
|
+
function _persistThrottled(session) {
|
|
98
|
+
const now = Date.now();
|
|
99
|
+
if (now - session.lastPersistedAt > PERSIST_THROTTLE_MS) {
|
|
100
|
+
_persistNow(session);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function _loadSessionFromStorage(storageKey) {
|
|
104
|
+
const data = (0, StorageProvider_1._getObjectFromStorage)(storageKey);
|
|
105
|
+
return data;
|
|
106
|
+
}
|
|
107
|
+
function _loadOrCreateSharedSession(sdkKey) {
|
|
105
108
|
const storageKey = _getSessionIDStorageKey(sdkKey);
|
|
106
|
-
|
|
109
|
+
const existing = _loadSessionFromStorage(storageKey);
|
|
110
|
+
if (existing &&
|
|
111
|
+
existing.sessionID &&
|
|
112
|
+
existing.startTime &&
|
|
113
|
+
existing.lastUpdate) {
|
|
114
|
+
return { data: existing, sdkKey, lastPersistedAt: 0, storageKey };
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
data: _newSessionData(),
|
|
118
|
+
sdkKey,
|
|
119
|
+
lastPersistedAt: 0,
|
|
120
|
+
storageKey,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function _newSessionData() {
|
|
124
|
+
return {
|
|
125
|
+
sessionID: (0, UUID_1.getUUID)(),
|
|
126
|
+
startTime: Date.now(),
|
|
127
|
+
lastUpdate: Date.now(),
|
|
128
|
+
};
|
|
107
129
|
}
|
package/src/StatsigClientBase.js
CHANGED
|
@@ -41,8 +41,8 @@ class StatsigClientBase {
|
|
|
41
41
|
this._options = options !== null && options !== void 0 ? options : {};
|
|
42
42
|
this._memoCache = {};
|
|
43
43
|
this.overrideAdapter = (_a = options === null || options === void 0 ? void 0 : options.overrideAdapter) !== null && _a !== void 0 ? _a : null;
|
|
44
|
+
this._logger = new EventLogger_1.EventLogger(sdkKey, emitter, network, options);
|
|
44
45
|
this._errorBoundary = new ErrorBoundary_1.ErrorBoundary(sdkKey, options, emitter);
|
|
45
|
-
this._logger = new EventLogger_1.EventLogger(sdkKey, emitter, network, options, this._errorBoundary);
|
|
46
46
|
this._errorBoundary.wrap(this);
|
|
47
47
|
this._errorBoundary.wrap(adapter);
|
|
48
48
|
this._errorBoundary.wrap(this._logger);
|
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.31.
|
|
4
|
+
exports.SDK_VERSION = '3.31.2';
|
|
5
5
|
let metadata = {
|
|
6
6
|
sdkVersion: exports.SDK_VERSION,
|
|
7
7
|
sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { EventBatch } from './EventBatch';
|
|
2
|
-
import { StatsigEventInternal } from './StatsigEvent';
|
|
3
|
-
export declare class BatchQueue {
|
|
4
|
-
private _batches;
|
|
5
|
-
private _batchSize;
|
|
6
|
-
constructor(batchSize?: number);
|
|
7
|
-
batchSize(): number;
|
|
8
|
-
requeueBatch(batch: EventBatch): number;
|
|
9
|
-
hasFullBatch(): boolean;
|
|
10
|
-
takeNextBatch(): EventBatch | null;
|
|
11
|
-
takeAllBatches(): EventBatch[];
|
|
12
|
-
createBatches(events: StatsigEventInternal[]): number;
|
|
13
|
-
private _enqueueBatch;
|
|
14
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BatchQueue = void 0;
|
|
4
|
-
const EventBatch_1 = require("./EventBatch");
|
|
5
|
-
const EventRetryConstants_1 = require("./EventRetryConstants");
|
|
6
|
-
class BatchQueue {
|
|
7
|
-
constructor(batchSize = EventRetryConstants_1.EventRetryConstants.DEFAULT_BATCH_SIZE) {
|
|
8
|
-
this._batches = [];
|
|
9
|
-
this._batchSize = batchSize;
|
|
10
|
-
}
|
|
11
|
-
batchSize() {
|
|
12
|
-
return this._batchSize;
|
|
13
|
-
}
|
|
14
|
-
requeueBatch(batch) {
|
|
15
|
-
return this._enqueueBatch(batch);
|
|
16
|
-
}
|
|
17
|
-
hasFullBatch() {
|
|
18
|
-
return this._batches.some((batch) => batch.events.length >= this._batchSize);
|
|
19
|
-
}
|
|
20
|
-
takeNextBatch() {
|
|
21
|
-
var _a;
|
|
22
|
-
return (_a = this._batches.shift()) !== null && _a !== void 0 ? _a : null;
|
|
23
|
-
}
|
|
24
|
-
takeAllBatches() {
|
|
25
|
-
const batches = this._batches;
|
|
26
|
-
this._batches = [];
|
|
27
|
-
return batches;
|
|
28
|
-
}
|
|
29
|
-
createBatches(events) {
|
|
30
|
-
let i = 0;
|
|
31
|
-
let droppedCount = 0;
|
|
32
|
-
while (i < events.length) {
|
|
33
|
-
const chunk = events.slice(i, i + this._batchSize);
|
|
34
|
-
droppedCount += this._enqueueBatch(new EventBatch_1.EventBatch(chunk));
|
|
35
|
-
i += this._batchSize;
|
|
36
|
-
}
|
|
37
|
-
return droppedCount;
|
|
38
|
-
}
|
|
39
|
-
_enqueueBatch(batch) {
|
|
40
|
-
this._batches.push(batch);
|
|
41
|
-
let droppedEventCount = 0;
|
|
42
|
-
while (this._batches.length > EventRetryConstants_1.EventRetryConstants.MAX_PENDING_BATCHES) {
|
|
43
|
-
const dropped = this._batches.shift();
|
|
44
|
-
if (dropped) {
|
|
45
|
-
droppedEventCount += dropped.events.length;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return droppedEventCount;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.BatchQueue = BatchQueue;
|
package/src/EventSender.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { EventBatch } from './EventBatch';
|
|
2
|
-
import { NetworkCore } from './NetworkCore';
|
|
3
|
-
import { StatsigClientEmitEventFunc } from './StatsigClientBase';
|
|
4
|
-
import { LogEventCompressionMode, LoggingEnabledOption, NetworkConfigCommon, StatsigOptionsCommon } from './StatsigOptionsCommon';
|
|
5
|
-
import { UrlConfiguration } from './UrlConfiguration';
|
|
6
|
-
export declare class EventSender {
|
|
7
|
-
private _network;
|
|
8
|
-
private _sdkKey;
|
|
9
|
-
private _options;
|
|
10
|
-
private _logEventUrlConfig;
|
|
11
|
-
private _emitter;
|
|
12
|
-
private _loggingEnabled;
|
|
13
|
-
constructor(sdkKey: string, network: NetworkCore, emitter: StatsigClientEmitEventFunc, logEventUrlConfig: UrlConfiguration, options: StatsigOptionsCommon<NetworkConfigCommon> | null, loggingEnabled: LoggingEnabledOption);
|
|
14
|
-
setLogEventCompressionMode(mode: LogEventCompressionMode): void;
|
|
15
|
-
setLoggingEnabled(enabled: LoggingEnabledOption): void;
|
|
16
|
-
sendBatch(batch: EventBatch): Promise<{
|
|
17
|
-
success: boolean;
|
|
18
|
-
statusCode: number;
|
|
19
|
-
}>;
|
|
20
|
-
private _sendEventsViaPost;
|
|
21
|
-
private _sendEventsViaBeacon;
|
|
22
|
-
private _getRequestData;
|
|
23
|
-
}
|
package/src/EventSender.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EventSender = void 0;
|
|
13
|
-
const Log_1 = require("./Log");
|
|
14
|
-
const NetworkConfig_1 = require("./NetworkConfig");
|
|
15
|
-
const VisibilityObserving_1 = require("./VisibilityObserving");
|
|
16
|
-
class EventSender {
|
|
17
|
-
constructor(sdkKey, network, emitter, logEventUrlConfig, options, loggingEnabled) {
|
|
18
|
-
this._sdkKey = sdkKey;
|
|
19
|
-
this._network = network;
|
|
20
|
-
this._emitter = emitter;
|
|
21
|
-
this._options = options;
|
|
22
|
-
this._logEventUrlConfig = logEventUrlConfig;
|
|
23
|
-
this._loggingEnabled = loggingEnabled;
|
|
24
|
-
}
|
|
25
|
-
setLogEventCompressionMode(mode) {
|
|
26
|
-
this._network.setLogEventCompressionMode(mode);
|
|
27
|
-
}
|
|
28
|
-
setLoggingEnabled(enabled) {
|
|
29
|
-
this._loggingEnabled = enabled;
|
|
30
|
-
}
|
|
31
|
-
sendBatch(batch) {
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
var _a, _b;
|
|
34
|
-
try {
|
|
35
|
-
const isClosing = (0, VisibilityObserving_1._isUnloading)();
|
|
36
|
-
const shouldUseBeacon = isClosing &&
|
|
37
|
-
this._network.isBeaconSupported() &&
|
|
38
|
-
((_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.networkConfig) === null || _b === void 0 ? void 0 : _b.networkOverrideFunc) == null;
|
|
39
|
-
this._emitter({
|
|
40
|
-
name: 'pre_logs_flushed',
|
|
41
|
-
events: batch.events,
|
|
42
|
-
});
|
|
43
|
-
const response = shouldUseBeacon
|
|
44
|
-
? this._sendEventsViaBeacon(batch)
|
|
45
|
-
: yield this._sendEventsViaPost(batch);
|
|
46
|
-
if (response.success) {
|
|
47
|
-
this._emitter({
|
|
48
|
-
name: 'logs_flushed',
|
|
49
|
-
events: batch.events,
|
|
50
|
-
});
|
|
51
|
-
return response;
|
|
52
|
-
}
|
|
53
|
-
return { success: false, statusCode: -1 };
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
Log_1.Log.warn('Failed to send batch:', error);
|
|
57
|
-
return { success: false, statusCode: -1 };
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
_sendEventsViaPost(batch) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
var _a;
|
|
64
|
-
const result = yield this._network.post(this._getRequestData(batch));
|
|
65
|
-
const code = (_a = result === null || result === void 0 ? void 0 : result.code) !== null && _a !== void 0 ? _a : -1;
|
|
66
|
-
return { success: code >= 200 && code < 300, statusCode: code };
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
_sendEventsViaBeacon(batch) {
|
|
70
|
-
const success = this._network.beacon(this._getRequestData(batch));
|
|
71
|
-
return {
|
|
72
|
-
success,
|
|
73
|
-
statusCode: success ? 200 : -1,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
_getRequestData(batch) {
|
|
77
|
-
return {
|
|
78
|
-
sdkKey: this._sdkKey,
|
|
79
|
-
data: {
|
|
80
|
-
events: batch.events,
|
|
81
|
-
},
|
|
82
|
-
urlConfig: this._logEventUrlConfig,
|
|
83
|
-
retries: 3,
|
|
84
|
-
isCompressable: true,
|
|
85
|
-
params: {
|
|
86
|
-
[NetworkConfig_1.NetworkParam.EventCount]: String(batch.events.length),
|
|
87
|
-
},
|
|
88
|
-
headers: {
|
|
89
|
-
'statsig-event-count': String(batch.events.length),
|
|
90
|
-
'statsig-retry-count': String(batch.attempts),
|
|
91
|
-
},
|
|
92
|
-
credentials: 'same-origin',
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.EventSender = EventSender;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { BatchQueue } from './BatchedEventsQueue';
|
|
2
|
-
import { ErrorBoundary } from './ErrorBoundary';
|
|
3
|
-
import { NetworkCore } from './NetworkCore';
|
|
4
|
-
import { PendingEvents } from './PendingEvents';
|
|
5
|
-
import { StatsigClientEmitEventFunc } from './StatsigClientBase';
|
|
6
|
-
import { StatsigEventInternal } from './StatsigEvent';
|
|
7
|
-
import { LogEventCompressionMode, LoggingEnabledOption, NetworkConfigCommon, StatsigOptionsCommon } from './StatsigOptionsCommon';
|
|
8
|
-
import { UrlConfiguration } from './UrlConfiguration';
|
|
9
|
-
type PrepareFlushCallBack = () => void;
|
|
10
|
-
export declare class FlushCoordinator {
|
|
11
|
-
private _flushInterval;
|
|
12
|
-
private _batchQueue;
|
|
13
|
-
private _pendingEvents;
|
|
14
|
-
private _eventSender;
|
|
15
|
-
private _onPrepareFlush;
|
|
16
|
-
private _errorBoundary;
|
|
17
|
-
private _cooldownTimer;
|
|
18
|
-
private _maxIntervalTimer;
|
|
19
|
-
private _hasRunQuickFlush;
|
|
20
|
-
private _currentFlushPromise;
|
|
21
|
-
private _creationTime;
|
|
22
|
-
private _sdkKey;
|
|
23
|
-
private _storageKey;
|
|
24
|
-
constructor(batchQueue: BatchQueue, pendingEvents: PendingEvents, onPrepareFlush: PrepareFlushCallBack, sdkKey: string, network: NetworkCore, emitter: StatsigClientEmitEventFunc, logEventUrlConfig: UrlConfiguration, options: StatsigOptionsCommon<NetworkConfigCommon> | null, loggingEnabled: LoggingEnabledOption, errorBoundary: ErrorBoundary);
|
|
25
|
-
setLoggingEnabled(loggingEnabled: LoggingEnabledOption): void;
|
|
26
|
-
setLogEventCompressionMode(mode: LogEventCompressionMode): void;
|
|
27
|
-
startScheduledFlushCycle(): void;
|
|
28
|
-
stopScheduledFlushCycle(): void;
|
|
29
|
-
addEvent(event: StatsigEventInternal): void;
|
|
30
|
-
processManualFlush(): Promise<void>;
|
|
31
|
-
processShutdown(): Promise<void>;
|
|
32
|
-
private _executeFlush;
|
|
33
|
-
checkQuickFlush(): void;
|
|
34
|
-
private _attemptScheduledFlush;
|
|
35
|
-
processLimitFlush(): void;
|
|
36
|
-
private _processLimitFlushInternal;
|
|
37
|
-
private _scheduleNextFlush;
|
|
38
|
-
private _clearAllTimers;
|
|
39
|
-
private _processNextBatch;
|
|
40
|
-
private _processOneBatch;
|
|
41
|
-
private _prepareQueueForFlush;
|
|
42
|
-
containsAtLeastOneFullBatch(): boolean;
|
|
43
|
-
convertPendingEventsToBatches(): number;
|
|
44
|
-
private _handleFailure;
|
|
45
|
-
loadAndRetryShutdownFailedEvents(): Promise<void>;
|
|
46
|
-
private _getStorageKey;
|
|
47
|
-
private _saveShutdownFailedEventsToStorage;
|
|
48
|
-
private _getShutdownFailedEventsFromStorage;
|
|
49
|
-
}
|
|
50
|
-
export {};
|