@microsoft/1ds-post-js 3.1.11 → 3.2.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/README.md +2 -2
- package/bundle/{ms.post-3.1.11.gbl.js → ms.post-3.2.0.gbl.js} +1486 -786
- package/bundle/ms.post-3.2.0.gbl.js.map +1 -0
- package/bundle/ms.post-3.2.0.gbl.min.js +7 -0
- package/bundle/ms.post-3.2.0.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.2.0.integrity.json +46 -0
- package/bundle/{ms.post-3.1.11.js → ms.post-3.2.0.js} +1486 -786
- package/bundle/ms.post-3.2.0.js.map +1 -0
- package/bundle/ms.post-3.2.0.min.js +7 -0
- package/bundle/ms.post-3.2.0.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +1485 -785
- package/bundle/ms.post.gbl.js.map +1 -1
- package/bundle/ms.post.gbl.min.js +2 -2
- package/bundle/ms.post.gbl.min.js.map +1 -1
- package/bundle/ms.post.integrity.json +17 -17
- package/bundle/ms.post.js +1485 -785
- package/bundle/ms.post.js.map +1 -1
- package/bundle/ms.post.min.js +2 -2
- package/bundle/ms.post.min.js.map +1 -1
- package/dist/ms.post.js +177 -116
- package/dist/ms.post.js.map +1 -1
- package/dist/ms.post.min.js +2 -2
- package/dist/ms.post.min.js.map +1 -1
- package/dist-esm/src/BatchNotificationActions.js +1 -1
- package/dist-esm/src/ClockSkewManager.js +1 -1
- package/dist-esm/src/Constants.js +1 -1
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.js +1 -1
- package/dist-esm/src/HttpManager.js +41 -36
- package/dist-esm/src/HttpManager.js.map +1 -1
- package/dist-esm/src/Index.js +1 -1
- package/dist-esm/src/KillSwitch.js +1 -1
- package/dist-esm/src/PostChannel.d.ts +0 -4
- package/dist-esm/src/PostChannel.js +136 -92
- package/dist-esm/src/PostChannel.js.map +1 -1
- package/dist-esm/src/RetryPolicy.d.ts +20 -25
- package/dist-esm/src/RetryPolicy.js +35 -44
- package/dist-esm/src/RetryPolicy.js.map +1 -1
- package/dist-esm/src/Serializer.js +1 -1
- package/dist-esm/src/typings/XDomainRequest.js +1 -1
- package/package.json +2 -2
- package/src/HttpManager.ts +43 -47
- package/src/PostChannel.ts +162 -114
- package/src/RetryPolicy.ts +33 -38
- package/bundle/ms.post-3.1.11.gbl.js.map +0 -1
- package/bundle/ms.post-3.1.11.gbl.min.js +0 -7
- package/bundle/ms.post-3.1.11.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.1.11.integrity.json +0 -46
- package/bundle/ms.post-3.1.11.js.map +0 -1
- package/bundle/ms.post-3.1.11.min.js +0 -7
- package/bundle/ms.post-3.1.11.min.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.0
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
@@ -9,11 +9,11 @@ import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
|
9
9
|
* @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)
|
|
10
10
|
* @copyright Microsoft 2018-2020
|
|
11
11
|
*/
|
|
12
|
-
import { BaseTelemetryPlugin,
|
|
12
|
+
import { BaseTelemetryPlugin, EventsDiscardedReason, isValueAssigned, setProcessTelemetryTimings, isWindowObjectAvailable, arrForEach, doPerf, objForEachKey, optimizeObject, isChromium, getWindow, isNumber, mergeEvtNamespace, createUniqueNamespace, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, removePageUnloadEventListener, removePageHideEventListener, removePageShowEventListener, _throwInternal } from "@microsoft/1ds-core-js";
|
|
13
13
|
import { RT_PROFILE, NRT_PROFILE, BE_PROFILE, } from "./DataModels";
|
|
14
14
|
import { EventBatch } from "./EventBatch";
|
|
15
15
|
import { HttpManager } from "./HttpManager";
|
|
16
|
-
import
|
|
16
|
+
import { retryPolicyGetMillisToBackoffForRetry } from "./RetryPolicy";
|
|
17
17
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
18
18
|
import { strMsaDeviceTicket } from "./Constants";
|
|
19
19
|
var FlushCheckTimer = 0.250; // This needs to be in seconds, so this is 250ms
|
|
@@ -29,6 +29,7 @@ var strEventsDiscarded = "eventsDiscarded";
|
|
|
29
29
|
var strOverrideInstrumentationKey = "overrideInstrumentationKey";
|
|
30
30
|
var strMaxEventRetryAttempts = "maxEventRetryAttempts";
|
|
31
31
|
var strMaxUnloadEventRetryAttempts = "maxUnloadEventRetryAttempts";
|
|
32
|
+
var strAddUnloadCb = "addUnloadCb";
|
|
32
33
|
/**
|
|
33
34
|
* Class that manages adding events to inbound queues and batching of events
|
|
34
35
|
* into requests.
|
|
@@ -39,7 +40,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
39
40
|
var _this = _super.call(this) || this;
|
|
40
41
|
_this.identifier = "PostChannel";
|
|
41
42
|
_this.priority = 1011;
|
|
42
|
-
_this.version = '3.
|
|
43
|
+
_this.version = '3.2.0';
|
|
43
44
|
var _config;
|
|
44
45
|
var _isTeardownCalled = false;
|
|
45
46
|
var _flushCallbackQueue = [];
|
|
@@ -68,18 +69,9 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
68
69
|
var _disableXhrSync = false;
|
|
69
70
|
var _maxEventSendAttempts = MaxSendAttempts;
|
|
70
71
|
var _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
|
|
72
|
+
var _evtNamespace;
|
|
71
73
|
dynamicProto(PostChannel, _this, function (_self, _base) {
|
|
72
|
-
|
|
73
|
-
_clearQueues();
|
|
74
|
-
_setAutoLimits();
|
|
75
|
-
_httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {
|
|
76
|
-
requeue: _requeueEvents,
|
|
77
|
-
send: _sendingEvent,
|
|
78
|
-
sent: _eventsSentEvent,
|
|
79
|
-
drop: _eventsDropped,
|
|
80
|
-
rspFail: _eventsResponseFail,
|
|
81
|
-
oth: _otherEvent
|
|
82
|
-
});
|
|
74
|
+
_initDefaults();
|
|
83
75
|
// Special internal method to allow the DebugPlugin to hook embedded objects
|
|
84
76
|
_self["_getDbgPlgTargets"] = function () {
|
|
85
77
|
return [_httpManager];
|
|
@@ -88,50 +80,57 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
88
80
|
doPerf(core, function () { return "PostChannel:initialize"; }, function () {
|
|
89
81
|
var extendedCore = core;
|
|
90
82
|
_base.initialize(coreConfig, core, extensions);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
83
|
+
try {
|
|
84
|
+
var hasAddUnloadCb = !!core[strAddUnloadCb];
|
|
85
|
+
_evtNamespace = mergeEvtNamespace(createUniqueNamespace(_self.identifier), core.evtNamespace && core.evtNamespace());
|
|
86
|
+
var ctx = _self._getTelCtx();
|
|
87
|
+
coreConfig.extensionConfig[_self.identifier] = coreConfig.extensionConfig[_self.identifier] || {};
|
|
88
|
+
_config = ctx.getExtCfg(_self.identifier);
|
|
89
|
+
_self._setTimeoutOverride = _config.setTimeoutOverride ? _config.setTimeoutOverride : setTimeout.bind(globalContext);
|
|
90
|
+
_self._clearTimeoutOverride = _config.clearTimeoutOverride ? _config.clearTimeoutOverride : clearTimeout.bind(globalContext);
|
|
91
|
+
// Only try and use the optimizeObject() if this appears to be a chromium based browser and it has not been explicitly disabled
|
|
92
|
+
_optimizeObject = !_config.disableOptimizeObj && isChromium();
|
|
93
|
+
_hookWParam(extendedCore);
|
|
94
|
+
if (_config.eventsLimitInMem > 0) {
|
|
95
|
+
_queueSizeLimit = _config.eventsLimitInMem;
|
|
96
|
+
}
|
|
97
|
+
if (_config.immediateEventLimit > 0) {
|
|
98
|
+
_immediateQueueSizeLimit = _config.immediateEventLimit;
|
|
99
|
+
}
|
|
100
|
+
if (_config.autoFlushEventsLimit > 0) {
|
|
101
|
+
_autoFlushEventsLimit = _config.autoFlushEventsLimit;
|
|
102
|
+
}
|
|
103
|
+
_disableXhrSync = _config.disableXhrSync;
|
|
104
|
+
if (isNumber(_config[strMaxEventRetryAttempts])) {
|
|
105
|
+
_maxEventSendAttempts = _config[strMaxEventRetryAttempts];
|
|
106
|
+
}
|
|
107
|
+
if (isNumber(_config[strMaxUnloadEventRetryAttempts])) {
|
|
108
|
+
_maxUnloadEventSendAttempts = _config[strMaxUnloadEventRetryAttempts];
|
|
109
|
+
}
|
|
110
|
+
_setAutoLimits();
|
|
111
|
+
if (_config.httpXHROverride && _config.httpXHROverride.sendPOST) {
|
|
112
|
+
_xhrOverride = _config.httpXHROverride;
|
|
113
|
+
}
|
|
114
|
+
if (isValueAssigned(coreConfig.anonCookieName)) {
|
|
115
|
+
_httpManager.addQueryStringParameter("anoncknm", coreConfig.anonCookieName);
|
|
116
|
+
}
|
|
117
|
+
_httpManager.sendHook = _config.payloadPreprocessor;
|
|
118
|
+
_httpManager.sendListener = _config.payloadListener;
|
|
119
|
+
// Override endpointUrl if provided in Post config
|
|
120
|
+
var endpointUrl = _config.overrideEndpointUrl ? _config.overrideEndpointUrl : coreConfig.endpointUrl;
|
|
121
|
+
_self._notificationManager = coreConfig.extensionConfig.NotificationManager;
|
|
122
|
+
_httpManager.initialize(endpointUrl, _self.core, _self, _xhrOverride, _config);
|
|
123
|
+
var excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || [];
|
|
124
|
+
// When running in Web browsers try to send all telemetry if page is unloaded
|
|
125
|
+
addPageUnloadEventListener(_handleUnloadEvents, excludePageUnloadEvents, _evtNamespace);
|
|
126
|
+
addPageHideEventListener(_handleUnloadEvents, excludePageUnloadEvents, _evtNamespace);
|
|
127
|
+
addPageShowEventListener(_handleShowEvents, coreConfig.disablePageShowEvents, _evtNamespace);
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
// resetting the initialized state because of failure
|
|
131
|
+
_self.setInitialized(false);
|
|
132
|
+
throw e;
|
|
133
|
+
}
|
|
135
134
|
}, function () { return ({ coreConfig: coreConfig, core: core, extensions: extensions }); });
|
|
136
135
|
};
|
|
137
136
|
_self.processTelemetry = function (ev, itemCtx) {
|
|
@@ -166,6 +165,16 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
166
165
|
}
|
|
167
166
|
_self.processNext(event, itemCtx);
|
|
168
167
|
};
|
|
168
|
+
_self._doTeardown = function (unloadCtx, unloadState) {
|
|
169
|
+
_releaseAllQueues(2 /* SendBeacon */, 2 /* Unload */);
|
|
170
|
+
_isTeardownCalled = true;
|
|
171
|
+
_httpManager.teardown();
|
|
172
|
+
removePageUnloadEventListener(null, _evtNamespace);
|
|
173
|
+
removePageHideEventListener(null, _evtNamespace);
|
|
174
|
+
removePageShowEventListener(null, _evtNamespace);
|
|
175
|
+
// Just register to remove all events associated with this namespace
|
|
176
|
+
_initDefaults();
|
|
177
|
+
};
|
|
169
178
|
function _hookWParam(extendedCore) {
|
|
170
179
|
var existingGetWParamMethod = extendedCore.getWParam;
|
|
171
180
|
extendedCore.getWParam = function () {
|
|
@@ -198,7 +207,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
198
207
|
}
|
|
199
208
|
// Add default latency
|
|
200
209
|
if (!event.latency) {
|
|
201
|
-
event.latency =
|
|
210
|
+
event.latency = 1 /* Normal */;
|
|
202
211
|
}
|
|
203
212
|
// Remove extra AI properties if present
|
|
204
213
|
if (event.ext && event.ext["trace"]) {
|
|
@@ -221,7 +230,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
221
230
|
// If the transmission is backed off then do not send synchronous events.
|
|
222
231
|
// We will convert these events to Real time latency instead.
|
|
223
232
|
if (_currentBackoffCount || _paused) {
|
|
224
|
-
event.latency =
|
|
233
|
+
event.latency = 3 /* RealTime */;
|
|
225
234
|
event.sync = false;
|
|
226
235
|
}
|
|
227
236
|
else {
|
|
@@ -239,7 +248,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
239
248
|
var evtLatency = event.latency;
|
|
240
249
|
var queueSize = _queueSize;
|
|
241
250
|
var queueLimit = _queueSizeLimit;
|
|
242
|
-
if (evtLatency ===
|
|
251
|
+
if (evtLatency === 4 /* Immediate */) {
|
|
243
252
|
queueSize = _immediateQueueSize;
|
|
244
253
|
queueLimit = _immediateQueueSizeLimit;
|
|
245
254
|
}
|
|
@@ -249,11 +258,11 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
249
258
|
eventDropped = !_addEventToProperQueue(event, append);
|
|
250
259
|
}
|
|
251
260
|
else {
|
|
252
|
-
var dropLatency =
|
|
261
|
+
var dropLatency = 1 /* Normal */;
|
|
253
262
|
var dropNumber = EventsDroppedAtOneTime;
|
|
254
|
-
if (evtLatency ===
|
|
263
|
+
if (evtLatency === 4 /* Immediate */) {
|
|
255
264
|
// Only drop other immediate events as they are not technically sharing the general queue
|
|
256
|
-
dropLatency =
|
|
265
|
+
dropLatency = 4 /* Immediate */;
|
|
257
266
|
dropNumber = 1;
|
|
258
267
|
}
|
|
259
268
|
// Drop old event from lower or equal latency
|
|
@@ -275,7 +284,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
275
284
|
var doFlush = _queueSize > eventLimit;
|
|
276
285
|
if (!doFlush && _autoFlushBatchLimit > 0) {
|
|
277
286
|
// Check the auto flush max batch size
|
|
278
|
-
for (var latency =
|
|
287
|
+
for (var latency = 1 /* Normal */; !doFlush && latency <= 3 /* RealTime */; latency++) {
|
|
279
288
|
var batchQueue = _batchQueues[latency];
|
|
280
289
|
if (batchQueue && batchQueue.batches) {
|
|
281
290
|
arrForEach(batchQueue.batches, function (theBatch) {
|
|
@@ -289,11 +298,6 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
289
298
|
}
|
|
290
299
|
_performAutoFlush(true, doFlush);
|
|
291
300
|
};
|
|
292
|
-
_self.teardown = function () {
|
|
293
|
-
_releaseAllQueues(2 /* SendBeacon */, 2 /* Unload */);
|
|
294
|
-
_isTeardownCalled = true;
|
|
295
|
-
_httpManager.teardown();
|
|
296
|
-
};
|
|
297
301
|
_self.pause = function () {
|
|
298
302
|
_clearScheduledTimer();
|
|
299
303
|
_paused = true;
|
|
@@ -342,7 +346,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
342
346
|
sendReason = sendReason || 1 /* ManualFlush */;
|
|
343
347
|
if (async) {
|
|
344
348
|
// Move all queued events to the HttpManager
|
|
345
|
-
_queueBatches(
|
|
349
|
+
_queueBatches(1 /* Normal */, 0 /* Batched */, sendReason);
|
|
346
350
|
// All events (should) have been queue -- lets just make sure the queue counts are correct to avoid queue exhaustion (previous bug #9685112)
|
|
347
351
|
_resetQueueCounts();
|
|
348
352
|
if (_flushCallbackTimerId == null) {
|
|
@@ -358,7 +362,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
358
362
|
}
|
|
359
363
|
else {
|
|
360
364
|
// Now cause all queued events to be sent synchronously
|
|
361
|
-
_sendEventsForLatencyAndAbove(
|
|
365
|
+
_sendEventsForLatencyAndAbove(1 /* Normal */, 1 /* Synchronous */, sendReason);
|
|
362
366
|
if (callback !== null && callback !== undefined) {
|
|
363
367
|
callback();
|
|
364
368
|
}
|
|
@@ -408,7 +412,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
408
412
|
_immediateTimerId = _createTimer(function () {
|
|
409
413
|
_immediateTimerId = null;
|
|
410
414
|
// Only try to send direct events
|
|
411
|
-
_sendEventsForLatencyAndAbove(
|
|
415
|
+
_sendEventsForLatencyAndAbove(4 /* Immediate */, 0 /* Batched */, 1 /* NormalSchedule */);
|
|
412
416
|
_scheduleTimer();
|
|
413
417
|
}, immediateTimeOut);
|
|
414
418
|
}
|
|
@@ -419,7 +423,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
419
423
|
if (_hasEvents()) {
|
|
420
424
|
_scheduledTimerId = _createTimer(function () {
|
|
421
425
|
_scheduledTimerId = null;
|
|
422
|
-
_sendEventsForLatencyAndAbove(_timerCount === 0 ?
|
|
426
|
+
_sendEventsForLatencyAndAbove(_timerCount === 0 ? 3 /* RealTime */ : 1 /* Normal */, 0 /* Batched */, 1 /* NormalSchedule */);
|
|
423
427
|
// Increment the count for next cycle
|
|
424
428
|
_timerCount++;
|
|
425
429
|
_timerCount %= 2;
|
|
@@ -445,6 +449,47 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
445
449
|
_scheduleTimer();
|
|
446
450
|
}
|
|
447
451
|
};
|
|
452
|
+
function _initDefaults() {
|
|
453
|
+
_config = null;
|
|
454
|
+
_isTeardownCalled = false;
|
|
455
|
+
_flushCallbackQueue = [];
|
|
456
|
+
_flushCallbackTimerId = null;
|
|
457
|
+
_paused = false;
|
|
458
|
+
_immediateQueueSize = 0;
|
|
459
|
+
_immediateQueueSizeLimit = 500;
|
|
460
|
+
_queueSize = 0;
|
|
461
|
+
_queueSizeLimit = 10000;
|
|
462
|
+
_profiles = {};
|
|
463
|
+
_currentProfile = RT_PROFILE;
|
|
464
|
+
_scheduledTimerId = null;
|
|
465
|
+
_immediateTimerId = null;
|
|
466
|
+
_currentBackoffCount = 0;
|
|
467
|
+
_timerCount = 0;
|
|
468
|
+
_xhrOverride = null;
|
|
469
|
+
_batchQueues = {};
|
|
470
|
+
_autoFlushEventsLimit = undefined;
|
|
471
|
+
// either MaxBatchSize * (1+ Max Connections) or _queueLimit / 6 (where 3 latency Queues [normal, realtime, cost deferred] * 2 [allow half full -- allow for retry])
|
|
472
|
+
_autoFlushBatchLimit = 0;
|
|
473
|
+
_delayedBatchSendLatency = -1;
|
|
474
|
+
_delayedBatchReason = null;
|
|
475
|
+
_optimizeObject = true;
|
|
476
|
+
_isPageUnloadTriggered = false;
|
|
477
|
+
_disableXhrSync = false;
|
|
478
|
+
_maxEventSendAttempts = MaxSendAttempts;
|
|
479
|
+
_maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
|
|
480
|
+
_evtNamespace = null;
|
|
481
|
+
_httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {
|
|
482
|
+
requeue: _requeueEvents,
|
|
483
|
+
send: _sendingEvent,
|
|
484
|
+
sent: _eventsSentEvent,
|
|
485
|
+
drop: _eventsDropped,
|
|
486
|
+
rspFail: _eventsResponseFail,
|
|
487
|
+
oth: _otherEvent
|
|
488
|
+
});
|
|
489
|
+
_initializeProfiles();
|
|
490
|
+
_clearQueues();
|
|
491
|
+
_setAutoLimits();
|
|
492
|
+
}
|
|
448
493
|
function _createTimer(theTimerFunc, timeOut) {
|
|
449
494
|
// If the transmission is backed off make the timer at least 1 sec to allow for back off.
|
|
450
495
|
if (timeOut === 0 && _currentBackoffCount) {
|
|
@@ -452,7 +497,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
452
497
|
}
|
|
453
498
|
var timerMultiplier = 1000;
|
|
454
499
|
if (_currentBackoffCount) {
|
|
455
|
-
timerMultiplier =
|
|
500
|
+
timerMultiplier = retryPolicyGetMillisToBackoffForRetry(_currentBackoffCount - 1);
|
|
456
501
|
}
|
|
457
502
|
return _self._setTimeoutOverride(theTimerFunc, timeOut * timerMultiplier);
|
|
458
503
|
}
|
|
@@ -473,7 +518,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
473
518
|
}
|
|
474
519
|
if (!_paused) {
|
|
475
520
|
// Queue all the remaining requests to be sent. The requests will be sent using HTML5 Beacons if they are available.
|
|
476
|
-
_sendEventsForLatencyAndAbove(
|
|
521
|
+
_sendEventsForLatencyAndAbove(1 /* Normal */, sendType, sendReason);
|
|
477
522
|
}
|
|
478
523
|
}
|
|
479
524
|
/**
|
|
@@ -482,19 +527,19 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
482
527
|
* after flush are stored separately till we flush the current events.
|
|
483
528
|
*/
|
|
484
529
|
function _clearQueues() {
|
|
485
|
-
_batchQueues[
|
|
530
|
+
_batchQueues[4 /* Immediate */] = {
|
|
486
531
|
batches: [],
|
|
487
532
|
iKeyMap: {}
|
|
488
533
|
};
|
|
489
|
-
_batchQueues[
|
|
534
|
+
_batchQueues[3 /* RealTime */] = {
|
|
490
535
|
batches: [],
|
|
491
536
|
iKeyMap: {}
|
|
492
537
|
};
|
|
493
|
-
_batchQueues[
|
|
538
|
+
_batchQueues[2 /* CostDeferred */] = {
|
|
494
539
|
batches: [],
|
|
495
540
|
iKeyMap: {}
|
|
496
541
|
};
|
|
497
|
-
_batchQueues[
|
|
542
|
+
_batchQueues[1 /* Normal */] = {
|
|
498
543
|
batches: [],
|
|
499
544
|
iKeyMap: {}
|
|
500
545
|
};
|
|
@@ -502,7 +547,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
502
547
|
function _getEventBatch(iKey, latency, create) {
|
|
503
548
|
var batchQueue = _batchQueues[latency];
|
|
504
549
|
if (!batchQueue) {
|
|
505
|
-
latency =
|
|
550
|
+
latency = 1 /* Normal */;
|
|
506
551
|
batchQueue = _batchQueues[latency];
|
|
507
552
|
}
|
|
508
553
|
var eventBatch = batchQueue.iKeyMap[iKey];
|
|
@@ -534,7 +579,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
534
579
|
var latency = event.latency;
|
|
535
580
|
var eventBatch = _getEventBatch(event.iKey, latency, true);
|
|
536
581
|
if (eventBatch.addEvent(event)) {
|
|
537
|
-
if (latency !==
|
|
582
|
+
if (latency !== 4 /* Immediate */) {
|
|
538
583
|
_queueSize++;
|
|
539
584
|
// Check for auto flushing based on total events in the queue, but not for requeued or retry events
|
|
540
585
|
if (append && event.sendAttempt === 0) {
|
|
@@ -558,7 +603,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
558
603
|
var droppedEvents = eventBatch.split(0, dropNumber);
|
|
559
604
|
var droppedCount = droppedEvents.count();
|
|
560
605
|
if (droppedCount > 0) {
|
|
561
|
-
if (currentLatency ===
|
|
606
|
+
if (currentLatency === 4 /* Immediate */) {
|
|
562
607
|
_immediateQueueSize -= droppedCount;
|
|
563
608
|
}
|
|
564
609
|
else {
|
|
@@ -585,7 +630,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
585
630
|
var batchQueue = _batchQueues[latency];
|
|
586
631
|
if (batchQueue && batchQueue.batches) {
|
|
587
632
|
arrForEach(batchQueue.batches, function (theBatch) {
|
|
588
|
-
if (latency ===
|
|
633
|
+
if (latency === 4 /* Immediate */) {
|
|
589
634
|
immediateQueue += theBatch.count();
|
|
590
635
|
}
|
|
591
636
|
else {
|
|
@@ -594,7 +639,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
594
639
|
});
|
|
595
640
|
}
|
|
596
641
|
};
|
|
597
|
-
for (var latency =
|
|
642
|
+
for (var latency = 1 /* Normal */; latency <= 4 /* Immediate */; latency++) {
|
|
598
643
|
_loop_1(latency);
|
|
599
644
|
}
|
|
600
645
|
_queueSize = normalQueue;
|
|
@@ -609,7 +654,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
609
654
|
if (!isAsync || _httpManager.canSendRequest()) {
|
|
610
655
|
doPerf(_self.core, function () { return "PostChannel._queueBatches"; }, function () {
|
|
611
656
|
var droppedEvents = [];
|
|
612
|
-
var latencyToProcess =
|
|
657
|
+
var latencyToProcess = 4 /* Immediate */;
|
|
613
658
|
while (latencyToProcess >= latency) {
|
|
614
659
|
var batchQueue = _batchQueues[latencyToProcess];
|
|
615
660
|
if (batchQueue && batchQueue.batches && batchQueue.batches.length > 0) {
|
|
@@ -622,7 +667,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
622
667
|
else {
|
|
623
668
|
eventsQueued = eventsQueued || (theBatch && theBatch.count() > 0);
|
|
624
669
|
}
|
|
625
|
-
if (latencyToProcess ===
|
|
670
|
+
if (latencyToProcess === 4 /* Immediate */) {
|
|
626
671
|
_immediateQueueSize -= theBatch.count();
|
|
627
672
|
}
|
|
628
673
|
else {
|
|
@@ -659,7 +704,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
659
704
|
*/
|
|
660
705
|
function _flushImpl(callback, sendReason) {
|
|
661
706
|
// Add any additional queued events and cause all queued events to be sent asynchronously
|
|
662
|
-
_sendEventsForLatencyAndAbove(
|
|
707
|
+
_sendEventsForLatencyAndAbove(1 /* Normal */, 0 /* Batched */, sendReason);
|
|
663
708
|
_waitForIdleManager(function () {
|
|
664
709
|
// Only called AFTER the httpManager does not have any outstanding requests
|
|
665
710
|
if (callback) {
|
|
@@ -721,7 +766,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
721
766
|
if (theEvent) {
|
|
722
767
|
// Check if the request being added back is for a sync event in which case mark it no longer a sync event
|
|
723
768
|
if (theEvent.sync) {
|
|
724
|
-
theEvent.latency =
|
|
769
|
+
theEvent.latency = 4 /* Immediate */;
|
|
725
770
|
theEvent.sync = false;
|
|
726
771
|
}
|
|
727
772
|
if (theEvent.sendAttempt < maxSendAttempts) {
|
|
@@ -752,7 +797,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
752
797
|
notifyFunc.apply(manager, theArgs);
|
|
753
798
|
}
|
|
754
799
|
catch (e) {
|
|
755
|
-
_self.diagLog()
|
|
800
|
+
_throwInternal(_self.diagLog(), 1 /* CRITICAL */, 74 /* NotificationException */, evtName + " notification failed: " + e);
|
|
756
801
|
}
|
|
757
802
|
}
|
|
758
803
|
}
|
|
@@ -828,7 +873,6 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
828
873
|
// Removed Stub for PostChannel.prototype.initialize.
|
|
829
874
|
// Removed Stub for PostChannel.prototype.processTelemetry.
|
|
830
875
|
// Removed Stub for PostChannel.prototype.setEventQueueLimits.
|
|
831
|
-
// Removed Stub for PostChannel.prototype.teardown.
|
|
832
876
|
// Removed Stub for PostChannel.prototype.pause.
|
|
833
877
|
// Removed Stub for PostChannel.prototype.resume.
|
|
834
878
|
// Removed Stub for PostChannel.prototype.addResponseHandler.
|