@microsoft/1ds-post-js 3.2.0 → 3.2.3
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 +1 -1
- package/bundle/{ms.post-3.2.0.gbl.js → ms.post-3.2.3.gbl.js} +1022 -986
- package/bundle/ms.post-3.2.3.gbl.js.map +1 -0
- package/bundle/ms.post-3.2.3.gbl.min.js +7 -0
- package/bundle/ms.post-3.2.3.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.2.3.integrity.json +46 -0
- package/bundle/{ms.post-3.2.0.js → ms.post-3.2.3.js} +1022 -986
- package/bundle/ms.post-3.2.3.js.map +1 -0
- package/bundle/ms.post-3.2.3.min.js +7 -0
- package/bundle/ms.post-3.2.3.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +1021 -985
- 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 +1021 -985
- 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 +56 -27
- 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.d.ts +2 -1
- package/dist-esm/src/HttpManager.js +67 -67
- 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 +2 -5
- package/dist-esm/src/PostChannel.js +84 -66
- package/dist-esm/src/PostChannel.js.map +1 -1
- package/dist-esm/src/RetryPolicy.js +1 -1
- package/dist-esm/src/Serializer.js +1 -1
- package/dist-esm/src/TimeoutOverrideWrapper.d.ts +18 -0
- package/dist-esm/src/TimeoutOverrideWrapper.js +28 -0
- package/dist-esm/src/TimeoutOverrideWrapper.js.map +1 -0
- package/dist-esm/src/typings/XDomainRequest.js +1 -1
- package/package.json +3 -3
- package/src/HttpManager.ts +5 -4
- package/src/PostChannel.ts +59 -27
- package/src/TimeoutOverrideWrapper.ts +29 -0
- package/bundle/ms.post-3.2.0.gbl.js.map +0 -1
- package/bundle/ms.post-3.2.0.gbl.min.js +0 -7
- package/bundle/ms.post-3.2.0.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.2.0.integrity.json +0 -46
- package/bundle/ms.post-3.2.0.js.map +0 -1
- package/bundle/ms.post-3.2.0.min.js +0 -7
- package/bundle/ms.post-3.2.0.min.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.2.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.3
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
@@ -9,20 +9,20 @@ 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
|
|
12
|
+
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
13
|
+
import { BaseTelemetryPlugin, EventsDiscardedReason, isValueAssigned, setProcessTelemetryTimings, arrForEach, doPerf, objForEachKey, optimizeObject, isChromium, getWindow, isNumber, mergeEvtNamespace, createUniqueNamespace, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, removePageUnloadEventListener, removePageHideEventListener, removePageShowEventListener, _throwInternal, objDefineAccessors } from "@microsoft/1ds-core-js";
|
|
13
14
|
import { RT_PROFILE, NRT_PROFILE, BE_PROFILE, } from "./DataModels";
|
|
14
15
|
import { EventBatch } from "./EventBatch";
|
|
15
16
|
import { HttpManager } from "./HttpManager";
|
|
16
17
|
import { retryPolicyGetMillisToBackoffForRetry } from "./RetryPolicy";
|
|
17
|
-
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
18
18
|
import { strMsaDeviceTicket } from "./Constants";
|
|
19
|
+
import { createTimeoutWrapper } from "./TimeoutOverrideWrapper";
|
|
19
20
|
var FlushCheckTimer = 0.250; // This needs to be in seconds, so this is 250ms
|
|
20
21
|
var MaxNumberEventPerBatch = 500;
|
|
21
22
|
var EventsDroppedAtOneTime = 20;
|
|
22
23
|
var MaxSendAttempts = 6;
|
|
23
24
|
var MaxSyncUnloadSendAttempts = 2; // Assuming 2 based on beforeunload and unload
|
|
24
25
|
var MaxBackoffCount = 4;
|
|
25
|
-
var globalContext = isWindowObjectAvailable ? window : this;
|
|
26
26
|
var MaxConnections = 2;
|
|
27
27
|
var MaxRequestRetriesBeforeBackoff = 1;
|
|
28
28
|
var strEventsDiscarded = "eventsDiscarded";
|
|
@@ -40,7 +40,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
40
40
|
var _this = _super.call(this) || this;
|
|
41
41
|
_this.identifier = "PostChannel";
|
|
42
42
|
_this.priority = 1011;
|
|
43
|
-
_this.version = '3.2.
|
|
43
|
+
_this.version = '3.2.3';
|
|
44
44
|
var _config;
|
|
45
45
|
var _isTeardownCalled = false;
|
|
46
46
|
var _flushCallbackQueue = [];
|
|
@@ -66,10 +66,10 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
66
66
|
var _delayedBatchReason;
|
|
67
67
|
var _optimizeObject = true;
|
|
68
68
|
var _isPageUnloadTriggered = false;
|
|
69
|
-
var _disableXhrSync = false;
|
|
70
69
|
var _maxEventSendAttempts = MaxSendAttempts;
|
|
71
70
|
var _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
|
|
72
71
|
var _evtNamespace;
|
|
72
|
+
var _timeoutWrapper;
|
|
73
73
|
dynamicProto(PostChannel, _this, function (_self, _base) {
|
|
74
74
|
_initDefaults();
|
|
75
75
|
// Special internal method to allow the DebugPlugin to hook embedded objects
|
|
@@ -86,8 +86,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
86
86
|
var ctx = _self._getTelCtx();
|
|
87
87
|
coreConfig.extensionConfig[_self.identifier] = coreConfig.extensionConfig[_self.identifier] || {};
|
|
88
88
|
_config = ctx.getExtCfg(_self.identifier);
|
|
89
|
-
|
|
90
|
-
_self._clearTimeoutOverride = _config.clearTimeoutOverride ? _config.clearTimeoutOverride : clearTimeout.bind(globalContext);
|
|
89
|
+
_timeoutWrapper = createTimeoutWrapper(_config.setTimeoutOverride, _config.clearTimeoutOverride);
|
|
91
90
|
// Only try and use the optimizeObject() if this appears to be a chromium based browser and it has not been explicitly disabled
|
|
92
91
|
_optimizeObject = !_config.disableOptimizeObj && isChromium();
|
|
93
92
|
_hookWParam(extendedCore);
|
|
@@ -100,7 +99,6 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
100
99
|
if (_config.autoFlushEventsLimit > 0) {
|
|
101
100
|
_autoFlushEventsLimit = _config.autoFlushEventsLimit;
|
|
102
101
|
}
|
|
103
|
-
_disableXhrSync = _config.disableXhrSync;
|
|
104
102
|
if (isNumber(_config[strMaxEventRetryAttempts])) {
|
|
105
103
|
_maxEventSendAttempts = _config[strMaxEventRetryAttempts];
|
|
106
104
|
}
|
|
@@ -157,7 +155,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
157
155
|
_addEventToQueues(event, true);
|
|
158
156
|
if (_isPageUnloadTriggered) {
|
|
159
157
|
// Unload event has been received so we need to try and flush new events
|
|
160
|
-
_releaseAllQueues(2 /* SendBeacon */, 2 /* Unload */);
|
|
158
|
+
_releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);
|
|
161
159
|
}
|
|
162
160
|
else {
|
|
163
161
|
_scheduleTimer();
|
|
@@ -166,7 +164,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
166
164
|
_self.processNext(event, itemCtx);
|
|
167
165
|
};
|
|
168
166
|
_self._doTeardown = function (unloadCtx, unloadState) {
|
|
169
|
-
_releaseAllQueues(2 /* SendBeacon */, 2 /* Unload */);
|
|
167
|
+
_releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);
|
|
170
168
|
_isTeardownCalled = true;
|
|
171
169
|
_httpManager.teardown();
|
|
172
170
|
removePageUnloadEventListener(null, _evtNamespace);
|
|
@@ -193,7 +191,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
193
191
|
_isPageUnloadTriggered = true;
|
|
194
192
|
_httpManager.setUnloading(_isPageUnloadTriggered);
|
|
195
193
|
}
|
|
196
|
-
_releaseAllQueues(2 /* SendBeacon */, 2 /* Unload */);
|
|
194
|
+
_releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);
|
|
197
195
|
}
|
|
198
196
|
function _handleShowEvents(evt) {
|
|
199
197
|
// Handle the page becoming visible again
|
|
@@ -207,7 +205,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
207
205
|
}
|
|
208
206
|
// Add default latency
|
|
209
207
|
if (!event.latency) {
|
|
210
|
-
event.latency = 1 /* Normal */;
|
|
208
|
+
event.latency = 1 /* EventLatencyValue.Normal */;
|
|
211
209
|
}
|
|
212
210
|
// Remove extra AI properties if present
|
|
213
211
|
if (event.ext && event.ext["trace"]) {
|
|
@@ -230,7 +228,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
230
228
|
// If the transmission is backed off then do not send synchronous events.
|
|
231
229
|
// We will convert these events to Real time latency instead.
|
|
232
230
|
if (_currentBackoffCount || _paused) {
|
|
233
|
-
event.latency = 3 /* RealTime */;
|
|
231
|
+
event.latency = 3 /* EventLatencyValue.RealTime */;
|
|
234
232
|
event.sync = false;
|
|
235
233
|
}
|
|
236
234
|
else {
|
|
@@ -240,7 +238,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
240
238
|
if (_optimizeObject) {
|
|
241
239
|
event = optimizeObject(event);
|
|
242
240
|
}
|
|
243
|
-
_httpManager.sendSynchronousBatch(EventBatch.create(event.iKey, [event]), event.sync === true ? 1 /* Synchronous */ : event.sync, 3 /* SyncEvent */);
|
|
241
|
+
_httpManager.sendSynchronousBatch(EventBatch.create(event.iKey, [event]), event.sync === true ? 1 /* EventSendType.Synchronous */ : event.sync, 3 /* SendRequestReason.SyncEvent */);
|
|
244
242
|
return;
|
|
245
243
|
}
|
|
246
244
|
}
|
|
@@ -248,7 +246,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
248
246
|
var evtLatency = event.latency;
|
|
249
247
|
var queueSize = _queueSize;
|
|
250
248
|
var queueLimit = _queueSizeLimit;
|
|
251
|
-
if (evtLatency === 4 /* Immediate */) {
|
|
249
|
+
if (evtLatency === 4 /* EventLatencyValue.Immediate */) {
|
|
252
250
|
queueSize = _immediateQueueSize;
|
|
253
251
|
queueLimit = _immediateQueueSizeLimit;
|
|
254
252
|
}
|
|
@@ -258,11 +256,11 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
258
256
|
eventDropped = !_addEventToProperQueue(event, append);
|
|
259
257
|
}
|
|
260
258
|
else {
|
|
261
|
-
var dropLatency = 1 /* Normal */;
|
|
259
|
+
var dropLatency = 1 /* EventLatencyValue.Normal */;
|
|
262
260
|
var dropNumber = EventsDroppedAtOneTime;
|
|
263
|
-
if (evtLatency === 4 /* Immediate */) {
|
|
261
|
+
if (evtLatency === 4 /* EventLatencyValue.Immediate */) {
|
|
264
262
|
// Only drop other immediate events as they are not technically sharing the general queue
|
|
265
|
-
dropLatency = 4 /* Immediate */;
|
|
263
|
+
dropLatency = 4 /* EventLatencyValue.Immediate */;
|
|
266
264
|
dropNumber = 1;
|
|
267
265
|
}
|
|
268
266
|
// Drop old event from lower or equal latency
|
|
@@ -284,7 +282,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
284
282
|
var doFlush = _queueSize > eventLimit;
|
|
285
283
|
if (!doFlush && _autoFlushBatchLimit > 0) {
|
|
286
284
|
// Check the auto flush max batch size
|
|
287
|
-
for (var latency = 1 /* Normal */; !doFlush && latency <= 3 /* RealTime */; latency++) {
|
|
285
|
+
for (var latency = 1 /* EventLatencyValue.Normal */; !doFlush && latency <= 3 /* EventLatencyValue.RealTime */; latency++) {
|
|
288
286
|
var batchQueue = _batchQueues[latency];
|
|
289
287
|
if (batchQueue && batchQueue.batches) {
|
|
290
288
|
arrForEach(batchQueue.batches, function (theBatch) {
|
|
@@ -341,16 +339,15 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
341
339
|
_self.flush = function (async, callback, sendReason) {
|
|
342
340
|
if (async === void 0) { async = true; }
|
|
343
341
|
if (!_paused) {
|
|
344
|
-
|
|
345
|
-
_clearScheduledTimer();
|
|
346
|
-
sendReason = sendReason || 1 /* ManualFlush */;
|
|
342
|
+
sendReason = sendReason || 1 /* SendRequestReason.ManualFlush */;
|
|
347
343
|
if (async) {
|
|
348
|
-
// Move all queued events to the HttpManager
|
|
349
|
-
_queueBatches(1 /* Normal */, 0 /* Batched */, sendReason);
|
|
350
|
-
// All events (should) have been queue -- lets just make sure the queue counts are correct to avoid queue exhaustion (previous bug #9685112)
|
|
351
|
-
_resetQueueCounts();
|
|
352
344
|
if (_flushCallbackTimerId == null) {
|
|
345
|
+
// Clear the normal schedule timer as we are going to try and flush ASAP
|
|
346
|
+
_clearScheduledTimer();
|
|
347
|
+
// Move all queued events to the HttpManager so that we don't discard new events (Auto flush scenario)
|
|
348
|
+
_queueBatches(1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, sendReason);
|
|
353
349
|
_flushCallbackTimerId = _createTimer(function () {
|
|
350
|
+
_flushCallbackTimerId = null;
|
|
354
351
|
_flushImpl(callback, sendReason);
|
|
355
352
|
}, 0);
|
|
356
353
|
}
|
|
@@ -361,11 +358,17 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
361
358
|
}
|
|
362
359
|
}
|
|
363
360
|
else {
|
|
361
|
+
// Clear the normal schedule timer as we are going to try and flush ASAP
|
|
362
|
+
var cleared = _clearScheduledTimer();
|
|
364
363
|
// Now cause all queued events to be sent synchronously
|
|
365
|
-
_sendEventsForLatencyAndAbove(1 /* Normal */, 1 /* Synchronous */, sendReason);
|
|
364
|
+
_sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, 1 /* EventSendType.Synchronous */, sendReason);
|
|
366
365
|
if (callback !== null && callback !== undefined) {
|
|
367
366
|
callback();
|
|
368
367
|
}
|
|
368
|
+
if (cleared) {
|
|
369
|
+
// restart the normal event timer if it was cleared
|
|
370
|
+
_scheduleTimer();
|
|
371
|
+
}
|
|
369
372
|
}
|
|
370
373
|
}
|
|
371
374
|
};
|
|
@@ -401,8 +404,8 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
401
404
|
function _scheduleTimer() {
|
|
402
405
|
// If we had previously attempted to send requests, but the http manager didn't have any idle connections then the requests where delayed
|
|
403
406
|
// so try and requeue then again now
|
|
404
|
-
if (_delayedBatchSendLatency >= 0 && _queueBatches(_delayedBatchSendLatency, 0 /* Batched */, _delayedBatchReason)) {
|
|
405
|
-
_httpManager.sendQueuedRequests(0 /* Batched */, _delayedBatchReason);
|
|
407
|
+
if (_delayedBatchSendLatency >= 0 && _queueBatches(_delayedBatchSendLatency, 0 /* EventSendType.Batched */, _delayedBatchReason)) {
|
|
408
|
+
_httpManager.sendQueuedRequests(0 /* EventSendType.Batched */, _delayedBatchReason);
|
|
406
409
|
}
|
|
407
410
|
if (_immediateQueueSize > 0 && !_immediateTimerId && !_paused) {
|
|
408
411
|
// During initialization _profiles enforce that the direct [2] is less than real time [1] timer value
|
|
@@ -412,7 +415,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
412
415
|
_immediateTimerId = _createTimer(function () {
|
|
413
416
|
_immediateTimerId = null;
|
|
414
417
|
// Only try to send direct events
|
|
415
|
-
_sendEventsForLatencyAndAbove(4 /* Immediate */, 0 /* Batched */, 1 /* NormalSchedule */);
|
|
418
|
+
_sendEventsForLatencyAndAbove(4 /* EventLatencyValue.Immediate */, 0 /* EventSendType.Batched */, 1 /* SendRequestReason.NormalSchedule */);
|
|
416
419
|
_scheduleTimer();
|
|
417
420
|
}, immediateTimeOut);
|
|
418
421
|
}
|
|
@@ -423,7 +426,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
423
426
|
if (_hasEvents()) {
|
|
424
427
|
_scheduledTimerId = _createTimer(function () {
|
|
425
428
|
_scheduledTimerId = null;
|
|
426
|
-
_sendEventsForLatencyAndAbove(_timerCount === 0 ? 3 /* RealTime */ : 1 /* Normal */, 0 /* Batched */, 1 /* NormalSchedule */);
|
|
429
|
+
_sendEventsForLatencyAndAbove(_timerCount === 0 ? 3 /* EventLatencyValue.RealTime */ : 1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, 1 /* SendRequestReason.NormalSchedule */);
|
|
427
430
|
// Increment the count for next cycle
|
|
428
431
|
_timerCount++;
|
|
429
432
|
_timerCount %= 2;
|
|
@@ -474,10 +477,10 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
474
477
|
_delayedBatchReason = null;
|
|
475
478
|
_optimizeObject = true;
|
|
476
479
|
_isPageUnloadTriggered = false;
|
|
477
|
-
_disableXhrSync = false;
|
|
478
480
|
_maxEventSendAttempts = MaxSendAttempts;
|
|
479
481
|
_maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
|
|
480
482
|
_evtNamespace = null;
|
|
483
|
+
_timeoutWrapper = createTimeoutWrapper();
|
|
481
484
|
_httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {
|
|
482
485
|
requeue: _requeueEvents,
|
|
483
486
|
send: _sendingEvent,
|
|
@@ -485,7 +488,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
485
488
|
drop: _eventsDropped,
|
|
486
489
|
rspFail: _eventsResponseFail,
|
|
487
490
|
oth: _otherEvent
|
|
488
|
-
});
|
|
491
|
+
}, _timeoutWrapper);
|
|
489
492
|
_initializeProfiles();
|
|
490
493
|
_clearQueues();
|
|
491
494
|
_setAutoLimits();
|
|
@@ -499,26 +502,28 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
499
502
|
if (_currentBackoffCount) {
|
|
500
503
|
timerMultiplier = retryPolicyGetMillisToBackoffForRetry(_currentBackoffCount - 1);
|
|
501
504
|
}
|
|
502
|
-
return
|
|
505
|
+
return _timeoutWrapper.set(theTimerFunc, timeOut * timerMultiplier);
|
|
503
506
|
}
|
|
504
507
|
function _clearScheduledTimer() {
|
|
505
508
|
if (_scheduledTimerId !== null) {
|
|
506
|
-
|
|
509
|
+
_timeoutWrapper.clear(_scheduledTimerId);
|
|
507
510
|
_scheduledTimerId = null;
|
|
508
511
|
_timerCount = 0;
|
|
512
|
+
return true;
|
|
509
513
|
}
|
|
514
|
+
return false;
|
|
510
515
|
}
|
|
511
516
|
// Try to send all queued events using beacons if available
|
|
512
517
|
function _releaseAllQueues(sendType, sendReason) {
|
|
513
518
|
_clearScheduledTimer();
|
|
514
519
|
// Cancel all flush callbacks
|
|
515
520
|
if (_flushCallbackTimerId) {
|
|
516
|
-
|
|
521
|
+
_timeoutWrapper.clear(_flushCallbackTimerId);
|
|
517
522
|
_flushCallbackTimerId = null;
|
|
518
523
|
}
|
|
519
524
|
if (!_paused) {
|
|
520
525
|
// Queue all the remaining requests to be sent. The requests will be sent using HTML5 Beacons if they are available.
|
|
521
|
-
_sendEventsForLatencyAndAbove(1 /* Normal */, sendType, sendReason);
|
|
526
|
+
_sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, sendType, sendReason);
|
|
522
527
|
}
|
|
523
528
|
}
|
|
524
529
|
/**
|
|
@@ -527,19 +532,19 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
527
532
|
* after flush are stored separately till we flush the current events.
|
|
528
533
|
*/
|
|
529
534
|
function _clearQueues() {
|
|
530
|
-
_batchQueues[4 /* Immediate */] = {
|
|
535
|
+
_batchQueues[4 /* EventLatencyValue.Immediate */] = {
|
|
531
536
|
batches: [],
|
|
532
537
|
iKeyMap: {}
|
|
533
538
|
};
|
|
534
|
-
_batchQueues[3 /* RealTime */] = {
|
|
539
|
+
_batchQueues[3 /* EventLatencyValue.RealTime */] = {
|
|
535
540
|
batches: [],
|
|
536
541
|
iKeyMap: {}
|
|
537
542
|
};
|
|
538
|
-
_batchQueues[2 /* CostDeferred */] = {
|
|
543
|
+
_batchQueues[2 /* EventLatencyValue.CostDeferred */] = {
|
|
539
544
|
batches: [],
|
|
540
545
|
iKeyMap: {}
|
|
541
546
|
};
|
|
542
|
-
_batchQueues[1 /* Normal */] = {
|
|
547
|
+
_batchQueues[1 /* EventLatencyValue.Normal */] = {
|
|
543
548
|
batches: [],
|
|
544
549
|
iKeyMap: {}
|
|
545
550
|
};
|
|
@@ -547,7 +552,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
547
552
|
function _getEventBatch(iKey, latency, create) {
|
|
548
553
|
var batchQueue = _batchQueues[latency];
|
|
549
554
|
if (!batchQueue) {
|
|
550
|
-
latency = 1 /* Normal */;
|
|
555
|
+
latency = 1 /* EventLatencyValue.Normal */;
|
|
551
556
|
batchQueue = _batchQueues[latency];
|
|
552
557
|
}
|
|
553
558
|
var eventBatch = batchQueue.iKeyMap[iKey];
|
|
@@ -567,7 +572,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
567
572
|
}
|
|
568
573
|
if (doFlush && _flushCallbackTimerId == null) {
|
|
569
574
|
// Auto flush the queue
|
|
570
|
-
_self.flush(isAsync, null, 20 /* MaxQueuedEvents */);
|
|
575
|
+
_self.flush(isAsync, null, 20 /* SendRequestReason.MaxQueuedEvents */);
|
|
571
576
|
}
|
|
572
577
|
}
|
|
573
578
|
}
|
|
@@ -579,7 +584,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
579
584
|
var latency = event.latency;
|
|
580
585
|
var eventBatch = _getEventBatch(event.iKey, latency, true);
|
|
581
586
|
if (eventBatch.addEvent(event)) {
|
|
582
|
-
if (latency !== 4 /* Immediate */) {
|
|
587
|
+
if (latency !== 4 /* EventLatencyValue.Immediate */) {
|
|
583
588
|
_queueSize++;
|
|
584
589
|
// Check for auto flushing based on total events in the queue, but not for requeued or retry events
|
|
585
590
|
if (append && event.sendAttempt === 0) {
|
|
@@ -603,7 +608,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
603
608
|
var droppedEvents = eventBatch.split(0, dropNumber);
|
|
604
609
|
var droppedCount = droppedEvents.count();
|
|
605
610
|
if (droppedCount > 0) {
|
|
606
|
-
if (currentLatency === 4 /* Immediate */) {
|
|
611
|
+
if (currentLatency === 4 /* EventLatencyValue.Immediate */) {
|
|
607
612
|
_immediateQueueSize -= droppedCount;
|
|
608
613
|
}
|
|
609
614
|
else {
|
|
@@ -630,7 +635,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
630
635
|
var batchQueue = _batchQueues[latency];
|
|
631
636
|
if (batchQueue && batchQueue.batches) {
|
|
632
637
|
arrForEach(batchQueue.batches, function (theBatch) {
|
|
633
|
-
if (latency === 4 /* Immediate */) {
|
|
638
|
+
if (latency === 4 /* EventLatencyValue.Immediate */) {
|
|
634
639
|
immediateQueue += theBatch.count();
|
|
635
640
|
}
|
|
636
641
|
else {
|
|
@@ -639,7 +644,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
639
644
|
});
|
|
640
645
|
}
|
|
641
646
|
};
|
|
642
|
-
for (var latency = 1 /* Normal */; latency <= 4 /* Immediate */; latency++) {
|
|
647
|
+
for (var latency = 1 /* EventLatencyValue.Normal */; latency <= 4 /* EventLatencyValue.Immediate */; latency++) {
|
|
643
648
|
_loop_1(latency);
|
|
644
649
|
}
|
|
645
650
|
_queueSize = normalQueue;
|
|
@@ -647,14 +652,14 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
647
652
|
}
|
|
648
653
|
function _queueBatches(latency, sendType, sendReason) {
|
|
649
654
|
var eventsQueued = false;
|
|
650
|
-
var isAsync = sendType === 0 /* Batched */;
|
|
655
|
+
var isAsync = sendType === 0 /* EventSendType.Batched */;
|
|
651
656
|
// Only queue batches (to the HttpManager) if this is a sync request or the httpManager has an idle connection
|
|
652
657
|
// Thus keeping the events within the PostChannel until the HttpManager has a connection available
|
|
653
658
|
// This is so we can drop "old" events if the queue is getting full because we can't successfully send events
|
|
654
659
|
if (!isAsync || _httpManager.canSendRequest()) {
|
|
655
660
|
doPerf(_self.core, function () { return "PostChannel._queueBatches"; }, function () {
|
|
656
661
|
var droppedEvents = [];
|
|
657
|
-
var latencyToProcess = 4 /* Immediate */;
|
|
662
|
+
var latencyToProcess = 4 /* EventLatencyValue.Immediate */;
|
|
658
663
|
while (latencyToProcess >= latency) {
|
|
659
664
|
var batchQueue = _batchQueues[latencyToProcess];
|
|
660
665
|
if (batchQueue && batchQueue.batches && batchQueue.batches.length > 0) {
|
|
@@ -667,7 +672,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
667
672
|
else {
|
|
668
673
|
eventsQueued = eventsQueued || (theBatch && theBatch.count() > 0);
|
|
669
674
|
}
|
|
670
|
-
if (latencyToProcess === 4 /* Immediate */) {
|
|
675
|
+
if (latencyToProcess === 4 /* EventLatencyValue.Immediate */) {
|
|
671
676
|
_immediateQueueSize -= theBatch.count();
|
|
672
677
|
}
|
|
673
678
|
else {
|
|
@@ -686,7 +691,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
686
691
|
if (eventsQueued && _delayedBatchSendLatency >= latency) {
|
|
687
692
|
// We have queued events at the same level as the delayed values so clear the setting
|
|
688
693
|
_delayedBatchSendLatency = -1;
|
|
689
|
-
_delayedBatchReason = 0 /* Undefined */;
|
|
694
|
+
_delayedBatchReason = 0 /* SendRequestReason.Undefined */;
|
|
690
695
|
}
|
|
691
696
|
}, function () { return ({ latency: latency, sendType: sendType, sendReason: sendReason }); }, !isAsync);
|
|
692
697
|
}
|
|
@@ -704,22 +709,25 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
704
709
|
*/
|
|
705
710
|
function _flushImpl(callback, sendReason) {
|
|
706
711
|
// Add any additional queued events and cause all queued events to be sent asynchronously
|
|
707
|
-
_sendEventsForLatencyAndAbove(1 /* Normal */, 0 /* Batched */, sendReason);
|
|
712
|
+
_sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, sendReason);
|
|
713
|
+
// All events (should) have been queue -- lets just make sure the queue counts are correct to avoid queue exhaustion (previous bug #9685112)
|
|
714
|
+
_resetQueueCounts();
|
|
708
715
|
_waitForIdleManager(function () {
|
|
709
716
|
// Only called AFTER the httpManager does not have any outstanding requests
|
|
710
717
|
if (callback) {
|
|
711
718
|
callback();
|
|
712
719
|
}
|
|
713
720
|
if (_flushCallbackQueue.length > 0) {
|
|
714
|
-
_flushCallbackTimerId = _createTimer(function () {
|
|
721
|
+
_flushCallbackTimerId = _createTimer(function () {
|
|
722
|
+
_flushCallbackTimerId = null;
|
|
723
|
+
_flushImpl(_flushCallbackQueue.shift(), sendReason);
|
|
724
|
+
}, 0);
|
|
715
725
|
}
|
|
716
726
|
else {
|
|
717
727
|
// No more flush requests
|
|
718
728
|
_flushCallbackTimerId = null;
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
_scheduleTimer();
|
|
722
|
-
}
|
|
729
|
+
// Restart the normal timer schedule
|
|
730
|
+
_scheduleTimer();
|
|
723
731
|
}
|
|
724
732
|
});
|
|
725
733
|
}
|
|
@@ -729,6 +737,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
729
737
|
}
|
|
730
738
|
else {
|
|
731
739
|
_flushCallbackTimerId = _createTimer(function () {
|
|
740
|
+
_flushCallbackTimerId = null;
|
|
732
741
|
_waitForIdleManager(callback);
|
|
733
742
|
}, FlushCheckTimer);
|
|
734
743
|
}
|
|
@@ -766,7 +775,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
766
775
|
if (theEvent) {
|
|
767
776
|
// Check if the request being added back is for a sync event in which case mark it no longer a sync event
|
|
768
777
|
if (theEvent.sync) {
|
|
769
|
-
theEvent.latency = 4 /* Immediate */;
|
|
778
|
+
theEvent.latency = 4 /* EventLatencyValue.Immediate */;
|
|
770
779
|
theEvent.sync = false;
|
|
771
780
|
}
|
|
772
781
|
if (theEvent.sendAttempt < maxSendAttempts) {
|
|
@@ -786,7 +795,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
786
795
|
}
|
|
787
796
|
if (_isPageUnloadTriggered) {
|
|
788
797
|
// Unload event has been received so we need to try and flush new events
|
|
789
|
-
_releaseAllQueues(2 /* SendBeacon */, 2 /* Unload */);
|
|
798
|
+
_releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);
|
|
790
799
|
}
|
|
791
800
|
}
|
|
792
801
|
function _callNotification(evtName, theArgs) {
|
|
@@ -797,7 +806,7 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
797
806
|
notifyFunc.apply(manager, theArgs);
|
|
798
807
|
}
|
|
799
808
|
catch (e) {
|
|
800
|
-
_throwInternal(_self.diagLog(), 1 /* CRITICAL */, 74 /* NotificationException */, evtName + " notification failed: " + e);
|
|
809
|
+
_throwInternal(_self.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 74 /* _eInternalMessageId.NotificationException */, evtName + " notification failed: " + e);
|
|
801
810
|
}
|
|
802
811
|
}
|
|
803
812
|
}
|
|
@@ -829,9 +838,9 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
829
838
|
*/
|
|
830
839
|
function _sendingEvent(batches, reason, isSyncRequest) {
|
|
831
840
|
if (batches && batches.length > 0) {
|
|
832
|
-
_callNotification("eventsSendRequest", [(reason >= 1000 /* SendingUndefined */ && reason <= 1999 /* SendingEventMax */ ?
|
|
833
|
-
reason - 1000 /* SendingUndefined */ :
|
|
834
|
-
0 /* Undefined */), isSyncRequest !== true]);
|
|
841
|
+
_callNotification("eventsSendRequest", [(reason >= 1000 /* EventBatchNotificationReason.SendingUndefined */ && reason <= 1999 /* EventBatchNotificationReason.SendingEventMax */ ?
|
|
842
|
+
reason - 1000 /* EventBatchNotificationReason.SendingUndefined */ :
|
|
843
|
+
0 /* SendRequestReason.Undefined */), isSyncRequest !== true]);
|
|
835
844
|
}
|
|
836
845
|
}
|
|
837
846
|
/**
|
|
@@ -845,8 +854,8 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
845
854
|
_scheduleTimer();
|
|
846
855
|
}
|
|
847
856
|
function _eventsDropped(batches, reason) {
|
|
848
|
-
_notifyBatchEvents(strEventsDiscarded, batches, (reason >= 8000 /* EventsDropped */ && reason <= 8999 /* EventsDroppedMax */ ?
|
|
849
|
-
reason - 8000 /* EventsDropped */ :
|
|
857
|
+
_notifyBatchEvents(strEventsDiscarded, batches, (reason >= 8000 /* EventBatchNotificationReason.EventsDropped */ && reason <= 8999 /* EventBatchNotificationReason.EventsDroppedMax */ ?
|
|
858
|
+
reason - 8000 /* EventBatchNotificationReason.EventsDropped */ :
|
|
850
859
|
EventsDiscardedReason.Unknown));
|
|
851
860
|
}
|
|
852
861
|
function _eventsResponseFail(batches) {
|
|
@@ -867,6 +876,15 @@ var PostChannel = /** @class */ (function (_super) {
|
|
|
867
876
|
_autoFlushBatchLimit = 0;
|
|
868
877
|
}
|
|
869
878
|
}
|
|
879
|
+
// Provided for backward compatibility they are not "expected" to be in current use but they are public
|
|
880
|
+
objDefineAccessors(_self, "_setTimeoutOverride", function () { return _timeoutWrapper.set; }, function (value) {
|
|
881
|
+
// Recreate the timeout wrapper
|
|
882
|
+
_timeoutWrapper = createTimeoutWrapper(value, _timeoutWrapper.clear);
|
|
883
|
+
});
|
|
884
|
+
objDefineAccessors(_self, "_clearTimeoutOverride", function () { return _timeoutWrapper.clear; }, function (value) {
|
|
885
|
+
// Recreate the timeout wrapper
|
|
886
|
+
_timeoutWrapper = createTimeoutWrapper(_timeoutWrapper.set, value);
|
|
887
|
+
});
|
|
870
888
|
});
|
|
871
889
|
return _this;
|
|
872
890
|
}
|