@microsoft/1ds-post-js 3.2.2 → 3.2.5

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.
Files changed (76) hide show
  1. package/CODE_OF_CONDUCT.md +9 -0
  2. package/CONTRIBUTING.md +14 -0
  3. package/LICENSE.TXT +3 -3
  4. package/NOTICE +17 -0
  5. package/PRIVACY +3 -0
  6. package/README.md +16 -2
  7. package/SECURITY.md +41 -0
  8. package/SUPPORT.md +14 -0
  9. package/bundle/{ms.post-3.2.2.gbl.js → ms.post-3.2.5.gbl.js} +933 -858
  10. package/bundle/ms.post-3.2.5.gbl.js.map +1 -0
  11. package/bundle/ms.post-3.2.5.gbl.min.js +7 -0
  12. package/bundle/ms.post-3.2.5.gbl.min.js.map +1 -0
  13. package/bundle/ms.post-3.2.5.integrity.json +46 -0
  14. package/bundle/{ms.post-3.2.2.js → ms.post-3.2.5.js} +933 -858
  15. package/bundle/ms.post-3.2.5.js.map +1 -0
  16. package/bundle/ms.post-3.2.5.min.js +7 -0
  17. package/bundle/ms.post-3.2.5.min.js.map +1 -0
  18. package/bundle/ms.post.gbl.js +932 -857
  19. package/bundle/ms.post.gbl.js.map +1 -1
  20. package/bundle/ms.post.gbl.min.js +2 -2
  21. package/bundle/ms.post.gbl.min.js.map +1 -1
  22. package/bundle/ms.post.integrity.json +17 -17
  23. package/bundle/ms.post.js +932 -857
  24. package/bundle/ms.post.js.map +1 -1
  25. package/bundle/ms.post.min.js +2 -2
  26. package/bundle/ms.post.min.js.map +1 -1
  27. package/dist/ms.post.js +213 -197
  28. package/dist/ms.post.js.map +1 -1
  29. package/dist/ms.post.min.js +2 -2
  30. package/dist/ms.post.min.js.map +1 -1
  31. package/dist-esm/src/BatchNotificationActions.js +1 -1
  32. package/dist-esm/src/ClockSkewManager.js +6 -1
  33. package/dist-esm/src/ClockSkewManager.js.map +1 -1
  34. package/dist-esm/src/DataModels.js +1 -1
  35. package/dist-esm/src/EventBatch.d.ts +0 -5
  36. package/dist-esm/src/EventBatch.js +9 -4
  37. package/dist-esm/src/EventBatch.js.map +1 -1
  38. package/dist-esm/src/HttpManager.d.ts +2 -7
  39. package/dist-esm/src/HttpManager.js +116 -108
  40. package/dist-esm/src/HttpManager.js.map +1 -1
  41. package/dist-esm/src/Index.js +1 -1
  42. package/dist-esm/src/InternalConstants.d.ts +27 -0
  43. package/dist-esm/src/InternalConstants.js +40 -0
  44. package/dist-esm/src/InternalConstants.js.map +1 -0
  45. package/dist-esm/src/KillSwitch.js +7 -2
  46. package/dist-esm/src/KillSwitch.js.map +1 -1
  47. package/dist-esm/src/PostChannel.d.ts +1 -1
  48. package/dist-esm/src/PostChannel.js +79 -65
  49. package/dist-esm/src/PostChannel.js.map +1 -1
  50. package/dist-esm/src/RetryPolicy.js +1 -1
  51. package/dist-esm/src/Serializer.d.ts +1 -1
  52. package/dist-esm/src/Serializer.js +9 -3
  53. package/dist-esm/src/Serializer.js.map +1 -1
  54. package/dist-esm/src/TimeoutOverrideWrapper.d.ts +5 -5
  55. package/dist-esm/src/TimeoutOverrideWrapper.js +6 -6
  56. package/dist-esm/src/TimeoutOverrideWrapper.js.map +1 -1
  57. package/dist-esm/src/typings/XDomainRequest.js +1 -1
  58. package/package.json +4 -2
  59. package/src/EventBatch.ts +4 -4
  60. package/src/HttpManager.ts +70 -68
  61. package/src/InternalConstants.ts +41 -0
  62. package/src/KillSwitch.ts +1 -1
  63. package/src/PostChannel.ts +45 -36
  64. package/src/Serializer.ts +7 -5
  65. package/src/TimeoutOverrideWrapper.ts +6 -6
  66. package/bundle/ms.post-3.2.2.gbl.js.map +0 -1
  67. package/bundle/ms.post-3.2.2.gbl.min.js +0 -7
  68. package/bundle/ms.post-3.2.2.gbl.min.js.map +0 -1
  69. package/bundle/ms.post-3.2.2.integrity.json +0 -46
  70. package/bundle/ms.post-3.2.2.js.map +0 -1
  71. package/bundle/ms.post-3.2.2.min.js +0 -7
  72. package/bundle/ms.post-3.2.2.min.js.map +0 -1
  73. package/dist-esm/src/Constants.d.ts +0 -25
  74. package/dist-esm/src/Constants.js +0 -31
  75. package/dist-esm/src/Constants.js.map +0 -1
  76. package/src/Constants.ts +0 -28
@@ -1,5 +1,5 @@
1
1
  /*
2
- * 1DS JS SDK POST plugin, 3.2.2
2
+ * 1DS JS SDK POST plugin, 3.2.5
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -10,12 +10,12 @@ import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
10
10
  * @copyright Microsoft 2018-2020
11
11
  */
12
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";
14
- import { RT_PROFILE, NRT_PROFILE, BE_PROFILE, } from "./DataModels";
13
+ import { BaseTelemetryPlugin, EventsDiscardedReason, _throwInternal, addPageHideEventListener, addPageShowEventListener, addPageUnloadEventListener, arrForEach, createUniqueNamespace, doPerf, getWindow, isChromium, isNumber, isValueAssigned, mergeEvtNamespace, objDefineAccessors, objForEachKey, optimizeObject, removePageHideEventListener, removePageShowEventListener, removePageUnloadEventListener, setProcessTelemetryTimings } from "@microsoft/1ds-core-js";
14
+ import { BE_PROFILE, NRT_PROFILE, RT_PROFILE } from "./DataModels";
15
15
  import { EventBatch } from "./EventBatch";
16
16
  import { HttpManager } from "./HttpManager";
17
+ import { STR_MSA_DEVICE_TICKET, STR_TRACE, STR_USER } from "./InternalConstants";
17
18
  import { retryPolicyGetMillisToBackoffForRetry } from "./RetryPolicy";
18
- import { strMsaDeviceTicket } from "./Constants";
19
19
  import { createTimeoutWrapper } from "./TimeoutOverrideWrapper";
20
20
  var FlushCheckTimer = 0.250; // This needs to be in seconds, so this is 250ms
21
21
  var MaxNumberEventPerBatch = 500;
@@ -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.2';
43
+ _this.version = '3.2.5';
44
44
  var _config;
45
45
  var _isTeardownCalled = false;
46
46
  var _flushCallbackQueue = [];
@@ -66,7 +66,6 @@ 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;
@@ -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,17 +205,18 @@ 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
- if (event.ext && event.ext["trace"]) {
214
- delete (event.ext["trace"]);
211
+ if (event.ext && event.ext[STR_TRACE]) {
212
+ delete (event.ext[STR_TRACE]);
215
213
  }
216
- if (event.ext && event.ext["user"] && event.ext["user"]["id"]) {
217
- delete (event.ext["user"]["id"]);
214
+ if (event.ext && event.ext[STR_USER] && event.ext[STR_USER]["id"]) {
215
+ delete (event.ext[STR_USER]["id"]);
218
216
  }
219
217
  // v8 performance optimization for iterating over the keys
220
218
  if (_optimizeObject) {
219
+ setProcessTelemetryTimings;
221
220
  event.ext = optimizeObject(event.ext);
222
221
  if (event.baseData) {
223
222
  event.baseData = optimizeObject(event.baseData);
@@ -230,7 +229,7 @@ var PostChannel = /** @class */ (function (_super) {
230
229
  // If the transmission is backed off then do not send synchronous events.
231
230
  // We will convert these events to Real time latency instead.
232
231
  if (_currentBackoffCount || _paused) {
233
- event.latency = 3 /* RealTime */;
232
+ event.latency = 3 /* EventLatencyValue.RealTime */;
234
233
  event.sync = false;
235
234
  }
236
235
  else {
@@ -240,7 +239,7 @@ var PostChannel = /** @class */ (function (_super) {
240
239
  if (_optimizeObject) {
241
240
  event = optimizeObject(event);
242
241
  }
243
- _httpManager.sendSynchronousBatch(EventBatch.create(event.iKey, [event]), event.sync === true ? 1 /* Synchronous */ : event.sync, 3 /* SyncEvent */);
242
+ _httpManager.sendSynchronousBatch(EventBatch.create(event.iKey, [event]), event.sync === true ? 1 /* EventSendType.Synchronous */ : event.sync, 3 /* SendRequestReason.SyncEvent */);
244
243
  return;
245
244
  }
246
245
  }
@@ -248,7 +247,7 @@ var PostChannel = /** @class */ (function (_super) {
248
247
  var evtLatency = event.latency;
249
248
  var queueSize = _queueSize;
250
249
  var queueLimit = _queueSizeLimit;
251
- if (evtLatency === 4 /* Immediate */) {
250
+ if (evtLatency === 4 /* EventLatencyValue.Immediate */) {
252
251
  queueSize = _immediateQueueSize;
253
252
  queueLimit = _immediateQueueSizeLimit;
254
253
  }
@@ -258,11 +257,11 @@ var PostChannel = /** @class */ (function (_super) {
258
257
  eventDropped = !_addEventToProperQueue(event, append);
259
258
  }
260
259
  else {
261
- var dropLatency = 1 /* Normal */;
260
+ var dropLatency = 1 /* EventLatencyValue.Normal */;
262
261
  var dropNumber = EventsDroppedAtOneTime;
263
- if (evtLatency === 4 /* Immediate */) {
262
+ if (evtLatency === 4 /* EventLatencyValue.Immediate */) {
264
263
  // Only drop other immediate events as they are not technically sharing the general queue
265
- dropLatency = 4 /* Immediate */;
264
+ dropLatency = 4 /* EventLatencyValue.Immediate */;
266
265
  dropNumber = 1;
267
266
  }
268
267
  // Drop old event from lower or equal latency
@@ -284,7 +283,7 @@ var PostChannel = /** @class */ (function (_super) {
284
283
  var doFlush = _queueSize > eventLimit;
285
284
  if (!doFlush && _autoFlushBatchLimit > 0) {
286
285
  // Check the auto flush max batch size
287
- for (var latency = 1 /* Normal */; !doFlush && latency <= 3 /* RealTime */; latency++) {
286
+ for (var latency = 1 /* EventLatencyValue.Normal */; !doFlush && latency <= 3 /* EventLatencyValue.RealTime */; latency++) {
288
287
  var batchQueue = _batchQueues[latency];
289
288
  if (batchQueue && batchQueue.batches) {
290
289
  arrForEach(batchQueue.batches, function (theBatch) {
@@ -341,16 +340,15 @@ var PostChannel = /** @class */ (function (_super) {
341
340
  _self.flush = function (async, callback, sendReason) {
342
341
  if (async === void 0) { async = true; }
343
342
  if (!_paused) {
344
- // Clear the normal schedule timer as we are going to try and flush ASAP
345
- _clearScheduledTimer();
346
- sendReason = sendReason || 1 /* ManualFlush */;
343
+ sendReason = sendReason || 1 /* SendRequestReason.ManualFlush */;
347
344
  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
345
  if (_flushCallbackTimerId == null) {
346
+ // Clear the normal schedule timer as we are going to try and flush ASAP
347
+ _clearScheduledTimer();
348
+ // Move all queued events to the HttpManager so that we don't discard new events (Auto flush scenario)
349
+ _queueBatches(1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, sendReason);
353
350
  _flushCallbackTimerId = _createTimer(function () {
351
+ _flushCallbackTimerId = null;
354
352
  _flushImpl(callback, sendReason);
355
353
  }, 0);
356
354
  }
@@ -361,16 +359,22 @@ var PostChannel = /** @class */ (function (_super) {
361
359
  }
362
360
  }
363
361
  else {
362
+ // Clear the normal schedule timer as we are going to try and flush ASAP
363
+ var cleared = _clearScheduledTimer();
364
364
  // Now cause all queued events to be sent synchronously
365
- _sendEventsForLatencyAndAbove(1 /* Normal */, 1 /* Synchronous */, sendReason);
365
+ _sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, 1 /* EventSendType.Synchronous */, sendReason);
366
366
  if (callback !== null && callback !== undefined) {
367
367
  callback();
368
368
  }
369
+ if (cleared) {
370
+ // restart the normal event timer if it was cleared
371
+ _scheduleTimer();
372
+ }
369
373
  }
370
374
  }
371
375
  };
372
376
  _self.setMsaAuthTicket = function (ticket) {
373
- _httpManager.addHeader(strMsaDeviceTicket, ticket);
377
+ _httpManager.addHeader(STR_MSA_DEVICE_TICKET, ticket);
374
378
  };
375
379
  _self.hasEvents = _hasEvents;
376
380
  _self._setTransmitProfile = function (profileName) {
@@ -401,8 +405,8 @@ var PostChannel = /** @class */ (function (_super) {
401
405
  function _scheduleTimer() {
402
406
  // If we had previously attempted to send requests, but the http manager didn't have any idle connections then the requests where delayed
403
407
  // so try and requeue then again now
404
- if (_delayedBatchSendLatency >= 0 && _queueBatches(_delayedBatchSendLatency, 0 /* Batched */, _delayedBatchReason)) {
405
- _httpManager.sendQueuedRequests(0 /* Batched */, _delayedBatchReason);
408
+ if (_delayedBatchSendLatency >= 0 && _queueBatches(_delayedBatchSendLatency, 0 /* EventSendType.Batched */, _delayedBatchReason)) {
409
+ _httpManager.sendQueuedRequests(0 /* EventSendType.Batched */, _delayedBatchReason);
406
410
  }
407
411
  if (_immediateQueueSize > 0 && !_immediateTimerId && !_paused) {
408
412
  // During initialization _profiles enforce that the direct [2] is less than real time [1] timer value
@@ -412,7 +416,7 @@ var PostChannel = /** @class */ (function (_super) {
412
416
  _immediateTimerId = _createTimer(function () {
413
417
  _immediateTimerId = null;
414
418
  // Only try to send direct events
415
- _sendEventsForLatencyAndAbove(4 /* Immediate */, 0 /* Batched */, 1 /* NormalSchedule */);
419
+ _sendEventsForLatencyAndAbove(4 /* EventLatencyValue.Immediate */, 0 /* EventSendType.Batched */, 1 /* SendRequestReason.NormalSchedule */);
416
420
  _scheduleTimer();
417
421
  }, immediateTimeOut);
418
422
  }
@@ -423,7 +427,7 @@ var PostChannel = /** @class */ (function (_super) {
423
427
  if (_hasEvents()) {
424
428
  _scheduledTimerId = _createTimer(function () {
425
429
  _scheduledTimerId = null;
426
- _sendEventsForLatencyAndAbove(_timerCount === 0 ? 3 /* RealTime */ : 1 /* Normal */, 0 /* Batched */, 1 /* NormalSchedule */);
430
+ _sendEventsForLatencyAndAbove(_timerCount === 0 ? 3 /* EventLatencyValue.RealTime */ : 1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, 1 /* SendRequestReason.NormalSchedule */);
427
431
  // Increment the count for next cycle
428
432
  _timerCount++;
429
433
  _timerCount %= 2;
@@ -474,7 +478,6 @@ var PostChannel = /** @class */ (function (_super) {
474
478
  _delayedBatchReason = null;
475
479
  _optimizeObject = true;
476
480
  _isPageUnloadTriggered = false;
477
- _disableXhrSync = false;
478
481
  _maxEventSendAttempts = MaxSendAttempts;
479
482
  _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
480
483
  _evtNamespace = null;
@@ -507,7 +510,9 @@ var PostChannel = /** @class */ (function (_super) {
507
510
  _timeoutWrapper.clear(_scheduledTimerId);
508
511
  _scheduledTimerId = null;
509
512
  _timerCount = 0;
513
+ return true;
510
514
  }
515
+ return false;
511
516
  }
512
517
  // Try to send all queued events using beacons if available
513
518
  function _releaseAllQueues(sendType, sendReason) {
@@ -519,7 +524,7 @@ var PostChannel = /** @class */ (function (_super) {
519
524
  }
520
525
  if (!_paused) {
521
526
  // Queue all the remaining requests to be sent. The requests will be sent using HTML5 Beacons if they are available.
522
- _sendEventsForLatencyAndAbove(1 /* Normal */, sendType, sendReason);
527
+ _sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, sendType, sendReason);
523
528
  }
524
529
  }
525
530
  /**
@@ -528,19 +533,19 @@ var PostChannel = /** @class */ (function (_super) {
528
533
  * after flush are stored separately till we flush the current events.
529
534
  */
530
535
  function _clearQueues() {
531
- _batchQueues[4 /* Immediate */] = {
536
+ _batchQueues[4 /* EventLatencyValue.Immediate */] = {
532
537
  batches: [],
533
538
  iKeyMap: {}
534
539
  };
535
- _batchQueues[3 /* RealTime */] = {
540
+ _batchQueues[3 /* EventLatencyValue.RealTime */] = {
536
541
  batches: [],
537
542
  iKeyMap: {}
538
543
  };
539
- _batchQueues[2 /* CostDeferred */] = {
544
+ _batchQueues[2 /* EventLatencyValue.CostDeferred */] = {
540
545
  batches: [],
541
546
  iKeyMap: {}
542
547
  };
543
- _batchQueues[1 /* Normal */] = {
548
+ _batchQueues[1 /* EventLatencyValue.Normal */] = {
544
549
  batches: [],
545
550
  iKeyMap: {}
546
551
  };
@@ -548,7 +553,7 @@ var PostChannel = /** @class */ (function (_super) {
548
553
  function _getEventBatch(iKey, latency, create) {
549
554
  var batchQueue = _batchQueues[latency];
550
555
  if (!batchQueue) {
551
- latency = 1 /* Normal */;
556
+ latency = 1 /* EventLatencyValue.Normal */;
552
557
  batchQueue = _batchQueues[latency];
553
558
  }
554
559
  var eventBatch = batchQueue.iKeyMap[iKey];
@@ -568,7 +573,7 @@ var PostChannel = /** @class */ (function (_super) {
568
573
  }
569
574
  if (doFlush && _flushCallbackTimerId == null) {
570
575
  // Auto flush the queue
571
- _self.flush(isAsync, null, 20 /* MaxQueuedEvents */);
576
+ _self.flush(isAsync, null, 20 /* SendRequestReason.MaxQueuedEvents */);
572
577
  }
573
578
  }
574
579
  }
@@ -580,7 +585,7 @@ var PostChannel = /** @class */ (function (_super) {
580
585
  var latency = event.latency;
581
586
  var eventBatch = _getEventBatch(event.iKey, latency, true);
582
587
  if (eventBatch.addEvent(event)) {
583
- if (latency !== 4 /* Immediate */) {
588
+ if (latency !== 4 /* EventLatencyValue.Immediate */) {
584
589
  _queueSize++;
585
590
  // Check for auto flushing based on total events in the queue, but not for requeued or retry events
586
591
  if (append && event.sendAttempt === 0) {
@@ -604,7 +609,7 @@ var PostChannel = /** @class */ (function (_super) {
604
609
  var droppedEvents = eventBatch.split(0, dropNumber);
605
610
  var droppedCount = droppedEvents.count();
606
611
  if (droppedCount > 0) {
607
- if (currentLatency === 4 /* Immediate */) {
612
+ if (currentLatency === 4 /* EventLatencyValue.Immediate */) {
608
613
  _immediateQueueSize -= droppedCount;
609
614
  }
610
615
  else {
@@ -631,7 +636,7 @@ var PostChannel = /** @class */ (function (_super) {
631
636
  var batchQueue = _batchQueues[latency];
632
637
  if (batchQueue && batchQueue.batches) {
633
638
  arrForEach(batchQueue.batches, function (theBatch) {
634
- if (latency === 4 /* Immediate */) {
639
+ if (latency === 4 /* EventLatencyValue.Immediate */) {
635
640
  immediateQueue += theBatch.count();
636
641
  }
637
642
  else {
@@ -640,7 +645,7 @@ var PostChannel = /** @class */ (function (_super) {
640
645
  });
641
646
  }
642
647
  };
643
- for (var latency = 1 /* Normal */; latency <= 4 /* Immediate */; latency++) {
648
+ for (var latency = 1 /* EventLatencyValue.Normal */; latency <= 4 /* EventLatencyValue.Immediate */; latency++) {
644
649
  _loop_1(latency);
645
650
  }
646
651
  _queueSize = normalQueue;
@@ -648,14 +653,14 @@ var PostChannel = /** @class */ (function (_super) {
648
653
  }
649
654
  function _queueBatches(latency, sendType, sendReason) {
650
655
  var eventsQueued = false;
651
- var isAsync = sendType === 0 /* Batched */;
656
+ var isAsync = sendType === 0 /* EventSendType.Batched */;
652
657
  // Only queue batches (to the HttpManager) if this is a sync request or the httpManager has an idle connection
653
658
  // Thus keeping the events within the PostChannel until the HttpManager has a connection available
654
659
  // This is so we can drop "old" events if the queue is getting full because we can't successfully send events
655
660
  if (!isAsync || _httpManager.canSendRequest()) {
656
661
  doPerf(_self.core, function () { return "PostChannel._queueBatches"; }, function () {
657
662
  var droppedEvents = [];
658
- var latencyToProcess = 4 /* Immediate */;
663
+ var latencyToProcess = 4 /* EventLatencyValue.Immediate */;
659
664
  while (latencyToProcess >= latency) {
660
665
  var batchQueue = _batchQueues[latencyToProcess];
661
666
  if (batchQueue && batchQueue.batches && batchQueue.batches.length > 0) {
@@ -668,7 +673,7 @@ var PostChannel = /** @class */ (function (_super) {
668
673
  else {
669
674
  eventsQueued = eventsQueued || (theBatch && theBatch.count() > 0);
670
675
  }
671
- if (latencyToProcess === 4 /* Immediate */) {
676
+ if (latencyToProcess === 4 /* EventLatencyValue.Immediate */) {
672
677
  _immediateQueueSize -= theBatch.count();
673
678
  }
674
679
  else {
@@ -687,7 +692,7 @@ var PostChannel = /** @class */ (function (_super) {
687
692
  if (eventsQueued && _delayedBatchSendLatency >= latency) {
688
693
  // We have queued events at the same level as the delayed values so clear the setting
689
694
  _delayedBatchSendLatency = -1;
690
- _delayedBatchReason = 0 /* Undefined */;
695
+ _delayedBatchReason = 0 /* SendRequestReason.Undefined */;
691
696
  }
692
697
  }, function () { return ({ latency: latency, sendType: sendType, sendReason: sendReason }); }, !isAsync);
693
698
  }
@@ -705,22 +710,25 @@ var PostChannel = /** @class */ (function (_super) {
705
710
  */
706
711
  function _flushImpl(callback, sendReason) {
707
712
  // Add any additional queued events and cause all queued events to be sent asynchronously
708
- _sendEventsForLatencyAndAbove(1 /* Normal */, 0 /* Batched */, sendReason);
713
+ _sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, sendReason);
714
+ // All events (should) have been queue -- lets just make sure the queue counts are correct to avoid queue exhaustion (previous bug #9685112)
715
+ _resetQueueCounts();
709
716
  _waitForIdleManager(function () {
710
717
  // Only called AFTER the httpManager does not have any outstanding requests
711
718
  if (callback) {
712
719
  callback();
713
720
  }
714
721
  if (_flushCallbackQueue.length > 0) {
715
- _flushCallbackTimerId = _createTimer(function () { return _flushImpl(_flushCallbackQueue.shift(), sendReason); }, 0);
722
+ _flushCallbackTimerId = _createTimer(function () {
723
+ _flushCallbackTimerId = null;
724
+ _flushImpl(_flushCallbackQueue.shift(), sendReason);
725
+ }, 0);
716
726
  }
717
727
  else {
718
728
  // No more flush requests
719
729
  _flushCallbackTimerId = null;
720
- if (_hasEvents()) {
721
- // We still have events, so restart the normal timer schedule
722
- _scheduleTimer();
723
- }
730
+ // Restart the normal timer schedule
731
+ _scheduleTimer();
724
732
  }
725
733
  });
726
734
  }
@@ -730,6 +738,7 @@ var PostChannel = /** @class */ (function (_super) {
730
738
  }
731
739
  else {
732
740
  _flushCallbackTimerId = _createTimer(function () {
741
+ _flushCallbackTimerId = null;
733
742
  _waitForIdleManager(callback);
734
743
  }, FlushCheckTimer);
735
744
  }
@@ -767,7 +776,7 @@ var PostChannel = /** @class */ (function (_super) {
767
776
  if (theEvent) {
768
777
  // Check if the request being added back is for a sync event in which case mark it no longer a sync event
769
778
  if (theEvent.sync) {
770
- theEvent.latency = 4 /* Immediate */;
779
+ theEvent.latency = 4 /* EventLatencyValue.Immediate */;
771
780
  theEvent.sync = false;
772
781
  }
773
782
  if (theEvent.sendAttempt < maxSendAttempts) {
@@ -787,7 +796,7 @@ var PostChannel = /** @class */ (function (_super) {
787
796
  }
788
797
  if (_isPageUnloadTriggered) {
789
798
  // Unload event has been received so we need to try and flush new events
790
- _releaseAllQueues(2 /* SendBeacon */, 2 /* Unload */);
799
+ _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);
791
800
  }
792
801
  }
793
802
  function _callNotification(evtName, theArgs) {
@@ -798,7 +807,7 @@ var PostChannel = /** @class */ (function (_super) {
798
807
  notifyFunc.apply(manager, theArgs);
799
808
  }
800
809
  catch (e) {
801
- _throwInternal(_self.diagLog(), 1 /* CRITICAL */, 74 /* NotificationException */, evtName + " notification failed: " + e);
810
+ _throwInternal(_self.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 74 /* _eInternalMessageId.NotificationException */, evtName + " notification failed: " + e);
802
811
  }
803
812
  }
804
813
  }
@@ -830,9 +839,9 @@ var PostChannel = /** @class */ (function (_super) {
830
839
  */
831
840
  function _sendingEvent(batches, reason, isSyncRequest) {
832
841
  if (batches && batches.length > 0) {
833
- _callNotification("eventsSendRequest", [(reason >= 1000 /* SendingUndefined */ && reason <= 1999 /* SendingEventMax */ ?
834
- reason - 1000 /* SendingUndefined */ :
835
- 0 /* Undefined */), isSyncRequest !== true]);
842
+ _callNotification("eventsSendRequest", [(reason >= 1000 /* EventBatchNotificationReason.SendingUndefined */ && reason <= 1999 /* EventBatchNotificationReason.SendingEventMax */ ?
843
+ reason - 1000 /* EventBatchNotificationReason.SendingUndefined */ :
844
+ 0 /* SendRequestReason.Undefined */), isSyncRequest !== true]);
836
845
  }
837
846
  }
838
847
  /**
@@ -846,8 +855,8 @@ var PostChannel = /** @class */ (function (_super) {
846
855
  _scheduleTimer();
847
856
  }
848
857
  function _eventsDropped(batches, reason) {
849
- _notifyBatchEvents(strEventsDiscarded, batches, (reason >= 8000 /* EventsDropped */ && reason <= 8999 /* EventsDroppedMax */ ?
850
- reason - 8000 /* EventsDropped */ :
858
+ _notifyBatchEvents(strEventsDiscarded, batches, (reason >= 8000 /* EventBatchNotificationReason.EventsDropped */ && reason <= 8999 /* EventBatchNotificationReason.EventsDroppedMax */ ?
859
+ reason - 8000 /* EventBatchNotificationReason.EventsDropped */ :
851
860
  EventsDiscardedReason.Unknown));
852
861
  }
853
862
  function _eventsResponseFail(batches) {
@@ -893,6 +902,11 @@ var PostChannel = /** @class */ (function (_super) {
893
902
  // Removed Stub for PostChannel.prototype._setTransmitProfile.
894
903
  // Removed Stub for PostChannel.prototype._backOffTransmission.
895
904
  // Removed Stub for PostChannel.prototype._clearBackOff.
905
+ // This is a workaround for an IE8 bug when using dynamicProto() with classes that don't have any
906
+ // non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
907
+ // this will be removed when ES3 support is dropped.
908
+ PostChannel.__ieDyn=1;
909
+
896
910
  return PostChannel;
897
911
  }(BaseTelemetryPlugin));
898
912
  export default PostChannel;