@microsoft/1ds-post-js 3.1.8 → 3.1.11

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 (56) hide show
  1. package/README.md +124 -5
  2. package/bundle/{ms.post-3.1.8.gbl.js → ms.post-3.1.11.gbl.js} +353 -172
  3. package/bundle/ms.post-3.1.11.gbl.js.map +1 -0
  4. package/bundle/ms.post-3.1.11.gbl.min.js +7 -0
  5. package/bundle/ms.post-3.1.11.gbl.min.js.map +1 -0
  6. package/bundle/ms.post-3.1.11.integrity.json +46 -0
  7. package/bundle/{ms.post-3.1.8.js → ms.post-3.1.11.js} +353 -172
  8. package/bundle/ms.post-3.1.11.js.map +1 -0
  9. package/bundle/ms.post-3.1.11.min.js +7 -0
  10. package/bundle/ms.post-3.1.11.min.js.map +1 -0
  11. package/bundle/ms.post.gbl.js +352 -171
  12. package/bundle/ms.post.gbl.js.map +1 -1
  13. package/bundle/ms.post.gbl.min.js +2 -2
  14. package/bundle/ms.post.gbl.min.js.map +1 -1
  15. package/bundle/ms.post.integrity.json +17 -17
  16. package/bundle/ms.post.js +352 -171
  17. package/bundle/ms.post.js.map +1 -1
  18. package/bundle/ms.post.min.js +2 -2
  19. package/bundle/ms.post.min.js.map +1 -1
  20. package/dist/ms.post.js +238 -116
  21. package/dist/ms.post.js.map +1 -1
  22. package/dist/ms.post.min.js +2 -2
  23. package/dist/ms.post.min.js.map +1 -1
  24. package/dist-esm/src/BatchNotificationActions.js +1 -1
  25. package/dist-esm/src/ClockSkewManager.js +1 -1
  26. package/dist-esm/src/Constants.d.ts +25 -0
  27. package/dist-esm/src/Constants.js +31 -0
  28. package/dist-esm/src/Constants.js.map +1 -0
  29. package/dist-esm/src/DataModels.d.ts +55 -0
  30. package/dist-esm/src/DataModels.js +1 -1
  31. package/dist-esm/src/EventBatch.d.ts +5 -2
  32. package/dist-esm/src/EventBatch.js +35 -15
  33. package/dist-esm/src/EventBatch.js.map +1 -1
  34. package/dist-esm/src/HttpManager.d.ts +2 -2
  35. package/dist-esm/src/HttpManager.js +172 -85
  36. package/dist-esm/src/HttpManager.js.map +1 -1
  37. package/dist-esm/src/Index.js +1 -1
  38. package/dist-esm/src/KillSwitch.js +1 -1
  39. package/dist-esm/src/PostChannel.js +55 -31
  40. package/dist-esm/src/PostChannel.js.map +1 -1
  41. package/dist-esm/src/RetryPolicy.js +1 -1
  42. package/dist-esm/src/Serializer.js +1 -1
  43. package/dist-esm/src/typings/XDomainRequest.js +1 -1
  44. package/package.json +3 -3
  45. package/src/Constants.ts +28 -0
  46. package/src/DataModels.ts +68 -0
  47. package/src/EventBatch.ts +47 -14
  48. package/src/HttpManager.ts +206 -84
  49. package/src/PostChannel.ts +60 -31
  50. package/bundle/ms.post-3.1.8.gbl.js.map +0 -1
  51. package/bundle/ms.post-3.1.8.gbl.min.js +0 -7
  52. package/bundle/ms.post-3.1.8.gbl.min.js.map +0 -1
  53. package/bundle/ms.post-3.1.8.integrity.json +0 -46
  54. package/bundle/ms.post-3.1.8.js.map +0 -1
  55. package/bundle/ms.post-3.1.8.min.js +0 -7
  56. package/bundle/ms.post-3.1.8.min.js.map +0 -1
package/bundle/ms.post.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * 1DS JS SDK POST plugin, 3.1.8
2
+ * 1DS JS SDK POST plugin, 3.1.11
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -21,20 +21,24 @@
21
21
  var ObjDefineProperty = ObjClass["defineProperty"];
22
22
  var ObjHasOwnProperty = ObjProto[strShimHasOwnProperty];
23
23
 
24
- function getGlobal() {
25
- if (typeof globalThis !== strShimUndefined && globalThis) {
26
- return globalThis;
27
- }
28
- if (typeof self !== strShimUndefined && self) {
29
- return self;
30
- }
31
- if (typeof window !== strShimUndefined && window) {
32
- return window;
33
- }
34
- if (typeof global !== strShimUndefined && global) {
35
- return global;
24
+ var _cachedGlobal = null;
25
+ function getGlobal(useCached) {
26
+ if (useCached === void 0) { useCached = true; }
27
+ if (!_cachedGlobal || !useCached) {
28
+ if (typeof globalThis !== strShimUndefined && globalThis) {
29
+ _cachedGlobal = globalThis;
30
+ }
31
+ if (typeof self !== strShimUndefined && self) {
32
+ _cachedGlobal = self;
33
+ }
34
+ if (typeof window !== strShimUndefined && window) {
35
+ _cachedGlobal = window;
36
+ }
37
+ if (typeof global !== strShimUndefined && global) {
38
+ _cachedGlobal = global;
39
+ }
36
40
  }
37
- return null;
41
+ return _cachedGlobal;
38
42
  }
39
43
  function throwTypeError(message) {
40
44
  throw new TypeError(message);
@@ -49,7 +53,7 @@
49
53
  }
50
54
  var type = typeof obj;
51
55
  if (type !== strShimObject && type !== strShimFunction) {
52
- throwTypeError('Object prototype may only be an Object:' + obj);
56
+ throwTypeError("Object prototype may only be an Object:" + obj);
53
57
  }
54
58
  function tmpFunc() { }
55
59
  tmpFunc[strShimPrototype] = obj;
@@ -434,10 +438,19 @@
434
438
  var strOnPrefix = "on";
435
439
  var strAttachEvent = "attachEvent";
436
440
  var strAddEventHelper = "addEventListener";
441
+ var cStrStartsWith = "startsWith";
442
+ var strIndexOf = "indexOf";
443
+ var cStrTrim = "trim";
444
+ var strToString = "toString";
437
445
  var _objDefineProperty = ObjDefineProperty;
438
- function objToString(obj) {
439
- return ObjProto.toString.call(obj);
440
- }
446
+ var _objKeys = ObjClass.keys;
447
+ var StringProto = String[strShimPrototype];
448
+ var _strTrim = StringProto[cStrTrim];
449
+ var _strStartsWith = StringProto[cStrStartsWith];
450
+ var _isArray = Array.isArray;
451
+ var _objToString = ObjProto[strToString];
452
+ var _fnToString = ObjHasOwnProperty[strToString];
453
+ _fnToString.call(ObjClass);
441
454
  function isUndefined(value) {
442
455
  return value === undefined || typeof value === strShimUndefined;
443
456
  }
@@ -445,13 +458,13 @@
445
458
  return (value === null || isUndefined(value));
446
459
  }
447
460
  function hasOwnProperty(obj, prop) {
448
- return obj && ObjHasOwnProperty.call(obj, prop);
461
+ return !!(obj && ObjHasOwnProperty.call(obj, prop));
449
462
  }
450
463
  function isObject(value) {
451
- return typeof value === strShimObject;
464
+ return !!(value && typeof value === strShimObject);
452
465
  }
453
466
  function isFunction(value) {
454
- return typeof value === strShimFunction;
467
+ return !!(value && typeof value === strShimFunction);
455
468
  }
456
469
  function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
457
470
  if (useCapture === void 0) { useCapture = false; }
@@ -483,24 +496,27 @@
483
496
  }
484
497
  function strStartsWith(value, checkValue) {
485
498
  var result = false;
486
- if (value && checkValue) {
487
- var chkLen = checkValue.length;
488
- if (value === checkValue) {
489
- return true;
490
- }
491
- else if (value.length >= chkLen) {
492
- for (var lp = 0; lp < chkLen; lp++) {
493
- if (value[lp] !== checkValue[lp]) {
494
- return false;
495
- }
499
+ if (value && checkValue && !(result = value === checkValue)) {
500
+ result = _strStartsWith ? value[cStrStartsWith](checkValue) : _strStartsWithPoly(value, checkValue);
501
+ }
502
+ return result;
503
+ }
504
+ function _strStartsWithPoly(value, checkValue) {
505
+ var result = false;
506
+ var chkLen = checkValue ? checkValue.length : 0;
507
+ if (value && chkLen && value.length >= chkLen && !(result = value === checkValue)) {
508
+ for (var lp = 0; lp < chkLen; lp++) {
509
+ if (value[lp] !== checkValue[lp]) {
510
+ return false;
496
511
  }
497
- result = true;
498
512
  }
513
+ result = true;
499
514
  }
500
515
  return result;
501
516
  }
502
- function isArray(obj) {
503
- return objToString(obj) === "[object Array]";
517
+ var isArray = _isArray || _isArrayPoly;
518
+ function _isArrayPoly(obj) {
519
+ return !!(obj && _objToString.call(obj) === "[object Array]");
504
520
  }
505
521
  function isString(value) {
506
522
  return typeof value === "string";
@@ -526,24 +542,29 @@
526
542
  }
527
543
  }
528
544
  function arrIndexOf(arr, searchElement, fromIndex) {
529
- var len = arr.length;
530
- var from = fromIndex || 0;
531
- try {
532
- for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
533
- if (lp in arr && arr[lp] === searchElement) {
534
- return lp;
545
+ if (arr) {
546
+ if (arr[strIndexOf]) {
547
+ return arr[strIndexOf](searchElement, fromIndex);
548
+ }
549
+ var len = arr.length;
550
+ var from = fromIndex || 0;
551
+ try {
552
+ for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
553
+ if (lp in arr && arr[lp] === searchElement) {
554
+ return lp;
555
+ }
535
556
  }
536
557
  }
537
- }
538
- catch (e) {
558
+ catch (e) {
559
+ }
539
560
  }
540
561
  return -1;
541
562
  }
542
563
  function strTrim(str) {
543
- if (typeof str !== "string") {
544
- return str;
564
+ if (str) {
565
+ str = (_strTrim && str[cStrTrim]) ? str[cStrTrim]() : (str.replace ? str.replace(/^\s+|\s+$/g, "") : str);
545
566
  }
546
- return str.replace(/^\s+|\s+$/g, "");
567
+ return str;
547
568
  }
548
569
  var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
549
570
  var _objKeysDontEnums = [
@@ -560,6 +581,9 @@
560
581
  if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
561
582
  throwTypeError("objKeys called on non-object");
562
583
  }
584
+ if (!_objKeysHasDontEnumBug && _objKeys) {
585
+ return _objKeys(obj);
586
+ }
563
587
  var result = [];
564
588
  for (var prop in obj) {
565
589
  if (obj && ObjHasOwnProperty.call(obj, prop)) {
@@ -599,10 +623,7 @@
599
623
  }
600
624
  function dateNow() {
601
625
  var dt = Date;
602
- if (dt.now) {
603
- return dt.now();
604
- }
605
- return new dt().getTime();
626
+ return dt.now ? dt.now() : new dt().getTime();
606
627
  }
607
628
  function setValue(target, field, value, valChk, srcChk) {
608
629
  var theValue = value;
@@ -616,8 +637,8 @@
616
637
  return theValue;
617
638
  }
618
639
  function optimizeObject(theObject) {
619
- if (theObject) {
620
- theObject = ObjClass(ObjAssign ? ObjAssign({}, theObject) : theObject);
640
+ if (theObject && ObjAssign) {
641
+ theObject = ObjClass(ObjAssign({}, theObject));
621
642
  }
622
643
  return theObject;
623
644
  }
@@ -765,7 +786,7 @@
765
786
  }
766
787
  function useXDomainRequest() {
767
788
  if (_useXDomainRequest === null) {
768
- _useXDomainRequest = (typeof XDomainRequest !== undefined);
789
+ _useXDomainRequest = (typeof XDomainRequest !== "undefined");
769
790
  if (_useXDomainRequest && isXhrSupported()) {
770
791
  _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
771
792
  }
@@ -783,6 +804,22 @@
783
804
  return isSupported;
784
805
  }
785
806
 
807
+ var _aiNamespace = null;
808
+ function _getExtensionNamespace() {
809
+ var target = getGlobalInst("Microsoft");
810
+ if (target) {
811
+ _aiNamespace = target["ApplicationInsights"];
812
+ }
813
+ return _aiNamespace;
814
+ }
815
+ function getDebugExt(config) {
816
+ var ns = _aiNamespace;
817
+ if (!ns && config.disableDbgExt !== true) {
818
+ ns = _aiNamespace || _getExtensionNamespace();
819
+ }
820
+ return ns ? ns["ChromeDbgExt"] : null;
821
+ }
822
+
786
823
  var AiNonUserActionablePrefix = "AI (Internal): ";
787
824
  var AiUserActionablePrefix = "AI: ";
788
825
  var AIInternalMessagePrefix = "AITR_";
@@ -866,13 +903,18 @@
866
903
  }
867
904
  _self.logInternalMessage(severity, message);
868
905
  }
906
+ else {
907
+ _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
908
+ }
869
909
  }
870
910
  };
871
911
  _self.warnToConsole = function (message) {
872
912
  _logToConsole("warn", message);
913
+ _debugExtMsg("warning", message);
873
914
  };
874
915
  _self.errorToConsole = function (message) {
875
916
  _logToConsole("error", message);
917
+ _debugExtMsg("error", message);
876
918
  };
877
919
  _self.resetInternalMessageCount = function () {
878
920
  _messageCount = 0;
@@ -894,12 +936,18 @@
894
936
  if (severity <= _self.telemetryLoggingLevel()) {
895
937
  _self.queue.push(message);
896
938
  _messageCount++;
939
+ _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
897
940
  }
898
941
  if (_messageCount === _self.maxInternalMessageLimit()) {
899
942
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
900
943
  var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
901
944
  _self.queue.push(throttleMessage);
902
- _self.warnToConsole(throttleLimitMessage);
945
+ if (severity === LoggingSeverity.CRITICAL) {
946
+ _self.errorToConsole(throttleLimitMessage);
947
+ }
948
+ else {
949
+ _self.warnToConsole(throttleLimitMessage);
950
+ }
903
951
  }
904
952
  }
905
953
  };
@@ -913,6 +961,12 @@
913
961
  function _areInternalMessagesThrottled() {
914
962
  return _messageCount >= _self.maxInternalMessageLimit();
915
963
  }
964
+ function _debugExtMsg(name, data) {
965
+ var dbgExt = getDebugExt(config);
966
+ if (dbgExt && dbgExt.diagLog) {
967
+ dbgExt.diagLog(name, data);
968
+ }
969
+ }
916
970
  });
917
971
  }
918
972
  return DiagnosticLogger;
@@ -1400,10 +1454,11 @@
1400
1454
  var _ExtendedInternalMessageId = __assignFn(__assignFn({}, _InternalMessageId), { AuthHandShakeError: 501, AuthRedirectFail: 502, BrowserCannotReadLocalStorage: 503, BrowserCannotWriteLocalStorage: 504, BrowserDoesNotSupportLocalStorage: 505, CannotParseBiBlobValue: 506, CannotParseDataAttribute: 507, CVPluginNotAvailable: 508, DroppedEvent: 509, ErrorParsingAISessionCookie: 510, ErrorProvidedChannels: 511, FailedToGetCookies: 512, FailedToInitializeCorrelationVector: 513, FailedToInitializeSDK: 514, InvalidContentBlob: 515, InvalidCorrelationValue: 516, SessionRenewalDateIsZero: 517, SendPostOnCompleteFailure: 518, PostResponseHandler: 519, SDKNotInitialized: 520 });
1401
1455
 
1402
1456
  var _a$1;
1403
- var Version = '3.1.8';
1457
+ var Version = '3.1.11';
1404
1458
  var FullVersionString = "1DS-Web-JS-" + Version;
1405
1459
  var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
1406
1460
  var strWithCredentials = "withCredentials";
1461
+ var strTimeout = "timeout";
1407
1462
  var _fieldTypeEventPropMap = (_a$1 = {},
1408
1463
  _a$1[0 ] = EventPropertyType.Unspecified,
1409
1464
  _a$1[2 ] = EventPropertyType.Double,
@@ -1575,7 +1630,7 @@
1575
1630
  function isChromium() {
1576
1631
  return !!getGlobalInst("chrome");
1577
1632
  }
1578
- function openXhr(method, urlString, withCredentials, disabled, isSync) {
1633
+ function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {
1579
1634
  if (disabled === void 0) { disabled = false; }
1580
1635
  if (isSync === void 0) { isSync = false; }
1581
1636
  function _wrapSetXhrProp(xhr, prop, value) {
@@ -1596,6 +1651,9 @@
1596
1651
  if (withCredentials) {
1597
1652
  _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
1598
1653
  }
1654
+ if (!isSync && timeout) {
1655
+ _wrapSetXhrProp(xhr, strTimeout, timeout);
1656
+ }
1599
1657
  return xhr;
1600
1658
  }
1601
1659
 
@@ -1603,42 +1661,82 @@
1603
1661
  var NRT_PROFILE = "NEAR_REAL_TIME";
1604
1662
  var BE_PROFILE = "BEST_EFFORT";
1605
1663
 
1664
+ var Method = "POST";
1665
+ var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
1666
+ var strDropped = "drop";
1667
+ var strSending = "send";
1668
+ var strRequeue = "requeue";
1669
+ var strResponseFail = "rspFail";
1670
+ var strOther = "oth";
1671
+ var defaultCacheControl = "no-cache, no-store";
1672
+ var defaultContentType = "application/x-json-stream";
1673
+ var strCacheControl = "cache-control";
1674
+ var strContentTypeHeader = "content-type";
1675
+ var strKillTokensHeader = "kill-tokens";
1676
+ var strKillDurationHeader = "kill-duration";
1677
+ var strKillDurationSecondsHeader = "kill-duration-seconds";
1678
+ var strTimeDeltaHeader = "time-delta-millis";
1679
+ var strClientVersion = "client-version";
1680
+ var strClientId = "client-id";
1681
+ var strTimeDeltaToApply = "time-delta-to-apply-millis";
1682
+ var strUploadTime = "upload-time";
1683
+ var strApiKey = "apikey";
1684
+ var strMsaDeviceTicket = "AuthMsaDeviceTicket";
1685
+ var strNoResponseBody = "NoResponseBody";
1686
+ var strMsfpc = "msfpc";
1687
+
1688
+ function _getEventMsfpc(theEvent) {
1689
+ var intWeb = ((theEvent.ext || {})["intweb"]);
1690
+ if (intWeb && isValueAssigned(intWeb[strMsfpc])) {
1691
+ return intWeb[strMsfpc];
1692
+ }
1693
+ return null;
1694
+ }
1695
+ function _getMsfpc(theEvents) {
1696
+ var msfpc = null;
1697
+ for (var lp = 0; msfpc === null && lp < theEvents.length; lp++) {
1698
+ msfpc = _getEventMsfpc(theEvents[lp]);
1699
+ }
1700
+ return msfpc;
1701
+ }
1606
1702
  var EventBatch = /** @class */ (function () {
1607
1703
  function EventBatch(iKey, addEvents) {
1608
1704
  var events = addEvents ? [].concat(addEvents) : [];
1609
1705
  var _self = this;
1706
+ var _msfpc = _getMsfpc(events);
1610
1707
  _self.iKey = function () {
1611
1708
  return iKey;
1612
1709
  };
1710
+ _self.Msfpc = function () {
1711
+ return _msfpc || "";
1712
+ };
1613
1713
  _self.count = function () {
1614
1714
  return events.length;
1615
1715
  };
1616
1716
  _self.events = function () {
1617
1717
  return events;
1618
1718
  };
1619
- _self.addEvents = function (theEvents, append) {
1620
- if (append === void 0) { append = true; }
1621
- if (theEvents && theEvents.length > 0) {
1622
- if (append) {
1623
- events = events.concat(theEvents);
1719
+ _self.addEvent = function (theEvent) {
1720
+ if (theEvent) {
1721
+ events.push(theEvent);
1722
+ if (!_msfpc) {
1723
+ _msfpc = _getEventMsfpc(theEvent);
1624
1724
  }
1625
- else {
1626
- events = theEvents.concat(events);
1627
- }
1628
- return theEvents.length;
1725
+ return true;
1629
1726
  }
1630
- return 0;
1727
+ return false;
1631
1728
  };
1632
1729
  _self.split = function (fromEvent, numEvents) {
1633
- var newBatch = new EventBatch(iKey);
1730
+ var theEvents;
1634
1731
  if (fromEvent < events.length) {
1635
1732
  var cnt = events.length - fromEvent;
1636
1733
  if (!isNullOrUndefined(numEvents)) {
1637
1734
  cnt = numEvents < cnt ? numEvents : cnt;
1638
1735
  }
1639
- newBatch.addEvents(events.splice(fromEvent, cnt), true);
1736
+ theEvents = events.splice(fromEvent, cnt);
1737
+ _msfpc = _getMsfpc(events);
1640
1738
  }
1641
- return newBatch;
1739
+ return new EventBatch(iKey, theEvents);
1642
1740
  };
1643
1741
  }
1644
1742
  EventBatch.create = function (iKey, theEvents) {
@@ -2008,21 +2106,8 @@
2008
2106
  var EVTClockSkewManager = ClockSkewManager;
2009
2107
 
2010
2108
  var _a;
2011
- var Method = "POST";
2012
- var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
2013
- var strDropped = "drop";
2014
- var strSending = "send";
2015
- var strRequeue = "requeue";
2016
- var strResponseFail = "rspFail";
2017
- var strOther = "oth";
2018
- var defaultCacheControl = "no-cache, no-store";
2019
- var defaultContentType = "application/x-json-stream";
2020
- var strCacheControl = "cache-control";
2021
- var strContentTypeHeader = "content-type";
2022
- var strKillTokensHeader = "kill-tokens";
2023
- var strKillDurationHeader = "kill-duration";
2024
- var strKillDurationSecondsHeader = "kill-duration-seconds";
2025
- var strTimeDeltaHeader = "time-delta-millis";
2109
+ var strSendAttempt = "sendAttempt";
2110
+ var _noResponseQs = "&" + strNoResponseBody + "=true";
2026
2111
  var _eventActionMap = (_a = {},
2027
2112
  _a[1 ] = strRequeue,
2028
2113
  _a[100 ] = strRequeue,
@@ -2030,6 +2115,13 @@
2030
2115
  _a[8004 ] = strDropped,
2031
2116
  _a[8003 ] = strDropped,
2032
2117
  _a);
2118
+ var _collectorQsHeaders = {};
2119
+ var _collectorHeaderToQs = {};
2120
+ function _addCollectorHeaderQsMapping(qsName, headerName) {
2121
+ _collectorQsHeaders[qsName] = headerName;
2122
+ _collectorHeaderToQs[headerName] = qsName;
2123
+ }
2124
+ _addCollectorHeaderQsMapping(strMsaDeviceTicket, strMsaDeviceTicket);
2033
2125
  function _getResponseText(xhr) {
2034
2126
  try {
2035
2127
  return xhr.responseText;
@@ -2056,11 +2148,21 @@
2056
2148
  }
2057
2149
  return hasHeader;
2058
2150
  }
2151
+ function _addRequestDetails(details, name, value, useHeaders) {
2152
+ if (name && value && value.length > 0) {
2153
+ if (useHeaders && _collectorQsHeaders[name]) {
2154
+ details.hdrs[_collectorQsHeaders[name]] = value;
2155
+ details.useHdrs = true;
2156
+ }
2157
+ else {
2158
+ details.url += "&" + name + "=" + value;
2159
+ }
2160
+ }
2161
+ }
2059
2162
  var HttpManager = /** @class */ (function () {
2060
- function HttpManager(maxEventsPerBatch, maxConnections, maxRetries, actions) {
2163
+ function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions) {
2061
2164
  this._responseHandlers = [];
2062
- var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType + "&client-id=NO_AUTH&client-version="
2063
- + FullVersionString;
2165
+ var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType;
2064
2166
  var _killSwitch = new EVTKillSwitch();
2065
2167
  var _paused = false;
2066
2168
  var _clockSkewManager = new EVTClockSkewManager();
@@ -2077,6 +2179,9 @@
2077
2179
  var _enableEventTimings = false;
2078
2180
  var _cookieMgr;
2079
2181
  var _isUnloading = false;
2182
+ var _useHeaders = false;
2183
+ var _xhrTimeout;
2184
+ var _disableXhrSync;
2080
2185
  dynamicProto(HttpManager, this, function (_self) {
2081
2186
  var _sendCredentials = true;
2082
2187
  _self.initialize = function (endpointUrl, core, postChannel, httpInterface, channelConfig) {
@@ -2085,6 +2190,7 @@
2085
2190
  channelConfig = {};
2086
2191
  }
2087
2192
  _urlString = endpointUrl + _urlString;
2193
+ _useHeaders = !isUndefined(channelConfig.avoidOptions) ? !channelConfig.avoidOptions : false;
2088
2194
  _core = core;
2089
2195
  _cookieMgr = core.getCookieMgr();
2090
2196
  _enableEventTimings = !_core.config.disableEventTimings;
@@ -2095,9 +2201,13 @@
2095
2201
  if (!isUndefined(channelConfig.enableCompoundKey)) {
2096
2202
  enableCompoundKey = !!channelConfig.enableCompoundKey;
2097
2203
  }
2204
+ _xhrTimeout = channelConfig.xhrTimeout;
2205
+ _disableXhrSync = channelConfig.disableXhrSync;
2098
2206
  _useBeacons = !isReactNative();
2099
2207
  _serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey);
2100
2208
  var syncHttpInterface = httpInterface;
2209
+ var beaconHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
2210
+ var fetchSyncHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
2101
2211
  if (!httpInterface) {
2102
2212
  _customHttpInterface = false;
2103
2213
  var location_1 = getLocation();
@@ -2129,8 +2239,8 @@
2129
2239
  _sendInterfaces = (_a = {},
2130
2240
  _a[0 ] = httpInterface,
2131
2241
  _a[1 ] = syncHttpInterface || _getSenderInterface([1 , 2 , 3 ], true),
2132
- _a[2 ] = _getSenderInterface([3 , 2 , 1 ], true) || syncHttpInterface,
2133
- _a[3 ] = _getSenderInterface([2 , 3 , 1 ], true) || syncHttpInterface,
2242
+ _a[2 ] = beaconHttpInterface || _getSenderInterface([3 , 2 ], true) || syncHttpInterface || _getSenderInterface([1 ], true),
2243
+ _a[3 ] = fetchSyncHttpInterface || _getSenderInterface([2 , 3 ], true) || syncHttpInterface || _getSenderInterface([1 ], true),
2134
2244
  _a);
2135
2245
  };
2136
2246
  function _getSenderInterface(transports, syncSupport) {
@@ -2170,6 +2280,9 @@
2170
2280
  function _xdrSendPost(payload, oncomplete, sync) {
2171
2281
  var xdr = new XDomainRequest();
2172
2282
  xdr.open(Method, payload.urlString);
2283
+ if (payload.timeout) {
2284
+ xdr.timeout = payload.timeout;
2285
+ }
2173
2286
  xdr.onload = function () {
2174
2287
  var response = _getResponseText(xdr);
2175
2288
  _doOnComplete(oncomplete, 200, {}, response);
@@ -2193,6 +2306,9 @@
2193
2306
  }
2194
2307
  function _fetchSendPost(payload, oncomplete, sync) {
2195
2308
  var _a;
2309
+ var theUrl = payload.urlString;
2310
+ var ignoreResponse = false;
2311
+ var responseHandled = false;
2196
2312
  var requestInit = (_a = {
2197
2313
  body: payload.data,
2198
2314
  method: Method
@@ -2201,6 +2317,10 @@
2201
2317
  _a);
2202
2318
  if (sync) {
2203
2319
  requestInit.keepalive = true;
2320
+ if (payload._sendReason === 2 ) {
2321
+ ignoreResponse = true;
2322
+ theUrl += _noResponseQs;
2323
+ }
2204
2324
  }
2205
2325
  if (_sendCredentials) {
2206
2326
  requestInit.credentials = "include";
@@ -2208,7 +2328,7 @@
2208
2328
  if (payload.headers && objKeys(payload.headers).length > 0) {
2209
2329
  requestInit.headers = payload.headers;
2210
2330
  }
2211
- fetch(payload.urlString, requestInit).then(function (response) {
2331
+ fetch(theUrl, requestInit).then(function (response) {
2212
2332
  var headerMap = {};
2213
2333
  var responseText = "";
2214
2334
  if (response.headers) {
@@ -2221,13 +2341,32 @@
2221
2341
  responseText = text;
2222
2342
  });
2223
2343
  }
2224
- _doOnComplete(oncomplete, response.status, headerMap, responseText);
2225
- _handleCollectorResponse(responseText);
2344
+ if (!responseHandled) {
2345
+ responseHandled = true;
2346
+ _doOnComplete(oncomplete, response.status, headerMap, responseText);
2347
+ _handleCollectorResponse(responseText);
2348
+ }
2226
2349
  })["catch"](function (error) {
2227
- _doOnComplete(oncomplete, 0, {});
2350
+ if (!responseHandled) {
2351
+ responseHandled = true;
2352
+ _doOnComplete(oncomplete, 0, {});
2353
+ }
2228
2354
  });
2355
+ if (ignoreResponse && !responseHandled) {
2356
+ responseHandled = true;
2357
+ _doOnComplete(oncomplete, 200, {});
2358
+ }
2359
+ if (!responseHandled && payload.timeout > 0) {
2360
+ _postManager._setTimeoutOverride(function () {
2361
+ if (!responseHandled) {
2362
+ responseHandled = true;
2363
+ _doOnComplete(oncomplete, 500, {});
2364
+ }
2365
+ }, payload.timeout);
2366
+ }
2229
2367
  }
2230
2368
  function _xhrSendPost(payload, oncomplete, sync) {
2369
+ var theUrl = payload.urlString;
2231
2370
  function _appendHeader(theHeaders, xhr, name) {
2232
2371
  if (!theHeaders[name] && xhr && xhr.getResponseHeader) {
2233
2372
  var value = xhr.getResponseHeader(name);
@@ -2252,22 +2391,25 @@
2252
2391
  function xhrComplete(xhr, responseTxt) {
2253
2392
  _doOnComplete(oncomplete, xhr.status, _getAllResponseHeaders(xhr), responseTxt);
2254
2393
  }
2255
- var xhRequest = openXhr(Method, payload.urlString, _sendCredentials, true, sync);
2394
+ if (sync && payload.disableXhrSync) {
2395
+ sync = false;
2396
+ }
2397
+ var xhrRequest = openXhr(Method, theUrl, _sendCredentials, true, sync, payload.timeout);
2256
2398
  objForEachKey(payload.headers, function (name, value) {
2257
- xhRequest.setRequestHeader(name, value);
2399
+ xhrRequest.setRequestHeader(name, value);
2258
2400
  });
2259
- xhRequest.onload = function () {
2260
- var response = _getResponseText(xhRequest);
2261
- xhrComplete(xhRequest, response);
2401
+ xhrRequest.onload = function () {
2402
+ var response = _getResponseText(xhrRequest);
2403
+ xhrComplete(xhrRequest, response);
2262
2404
  _handleCollectorResponse(response);
2263
2405
  };
2264
- xhRequest.onerror = function () {
2265
- xhrComplete(xhRequest);
2406
+ xhrRequest.onerror = function () {
2407
+ xhrComplete(xhrRequest);
2266
2408
  };
2267
- xhRequest.ontimeout = function () {
2268
- xhrComplete(xhRequest);
2409
+ xhrRequest.ontimeout = function () {
2410
+ xhrComplete(xhrRequest);
2269
2411
  };
2270
- xhRequest.send(payload.data);
2412
+ xhrRequest.send(payload.data);
2271
2413
  }
2272
2414
  function _doOnComplete(oncomplete, status, headers, response) {
2273
2415
  try {
@@ -2281,16 +2423,17 @@
2281
2423
  var internalPayloadData = payload;
2282
2424
  var status = 200;
2283
2425
  var thePayload = internalPayloadData._thePayload;
2426
+ var theUrl = payload.urlString + _noResponseQs;
2284
2427
  try {
2285
2428
  var nav_1 = getNavigator();
2286
- if (!nav_1.sendBeacon(payload.urlString, payload.data)) {
2429
+ if (!nav_1.sendBeacon(theUrl, payload.data)) {
2287
2430
  if (thePayload) {
2288
2431
  var droppedBatches_1 = [];
2289
2432
  arrForEach(thePayload.batches, function (theBatch) {
2290
2433
  if (droppedBatches_1 && theBatch && theBatch.count() > 0) {
2291
2434
  var theEvents = theBatch.events();
2292
2435
  for (var lp = 0; lp < theEvents.length; lp++) {
2293
- if (!nav_1.sendBeacon(payload.urlString, _serializer.getEventBlob(theEvents[lp]))) {
2436
+ if (!nav_1.sendBeacon(theUrl, _serializer.getEventBlob(theEvents[lp]))) {
2294
2437
  droppedBatches_1.push(theBatch.split(lp));
2295
2438
  break;
2296
2439
  }
@@ -2475,8 +2618,16 @@
2475
2618
  _postManager.diagLog().throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.CannotSerializeObject, "Unexpected Exception sending batch: " + dumpObj(ex));
2476
2619
  }
2477
2620
  }
2478
- function _buildQueryString(thePayload) {
2479
- var urlString = _urlString;
2621
+ function _buildRequestDetails(thePayload, useHeaders) {
2622
+ var requestDetails = {
2623
+ url: _urlString,
2624
+ hdrs: {},
2625
+ useHdrs: false
2626
+ };
2627
+ requestDetails.hdrs = extend(requestDetails.hdrs, _headers);
2628
+ requestDetails.useHdrs = (objKeys(requestDetails.hdrs).length > 0);
2629
+ _addRequestDetails(requestDetails, strClientId, "NO_AUTH", useHeaders);
2630
+ _addRequestDetails(requestDetails, strClientVersion, FullVersionString, useHeaders);
2480
2631
  var apiQsKeys = "";
2481
2632
  arrForEach(thePayload.apiKeys, function (apiKey) {
2482
2633
  if (apiQsKeys.length > 0) {
@@ -2484,27 +2635,25 @@
2484
2635
  }
2485
2636
  apiQsKeys += apiKey;
2486
2637
  });
2487
- if (apiQsKeys.length > 0) {
2488
- urlString += "&apikey=" + apiQsKeys;
2489
- }
2490
- urlString += "&upload-time=" + dateNow().toString();
2638
+ _addRequestDetails(requestDetails, strApiKey, apiQsKeys, useHeaders);
2639
+ _addRequestDetails(requestDetails, strUploadTime, dateNow().toString(), useHeaders);
2491
2640
  var msfpc = _getMsfpc(thePayload);
2492
2641
  if (isValueAssigned(msfpc)) {
2493
- urlString = urlString + "&ext.intweb.msfpc=" + msfpc;
2642
+ requestDetails.url += "&ext.intweb.msfpc=" + msfpc;
2494
2643
  }
2495
2644
  if (_clockSkewManager.shouldAddClockSkewHeaders()) {
2496
- urlString += "&time-delta-to-apply-millis=" + _clockSkewManager.getClockSkewHeaderValue();
2645
+ _addRequestDetails(requestDetails, strTimeDeltaToApply, _clockSkewManager.getClockSkewHeaderValue(), useHeaders);
2497
2646
  }
2498
2647
  if (_core.getWParam) {
2499
2648
  var wParam = _core.getWParam();
2500
2649
  if (wParam >= 0) {
2501
- urlString += "&w=" + wParam;
2650
+ requestDetails.url += "&w=" + wParam;
2502
2651
  }
2503
2652
  }
2504
2653
  for (var i = 0; i < _queryStringParameters.length; i++) {
2505
- urlString += "&" + _queryStringParameters[i].name + "=" + _queryStringParameters[i].value;
2654
+ requestDetails.url += "&" + _queryStringParameters[i].name + "=" + _queryStringParameters[i].value;
2506
2655
  }
2507
- return urlString;
2656
+ return requestDetails;
2508
2657
  }
2509
2658
  function _canUseSendBeaconApi() {
2510
2659
  return !_customHttpInterface && _useBeacons && isBeaconsSupported();
@@ -2515,9 +2664,18 @@
2515
2664
  }
2516
2665
  function _doPayloadSend(thePayload, serializationStart, serializationCompleted, sendReason) {
2517
2666
  if (thePayload && thePayload.payloadBlob && thePayload.payloadBlob.length > 0) {
2518
- var urlString_1 = _buildQueryString(thePayload);
2667
+ var useSendHook_1 = !!_self.sendHook;
2668
+ var sendInterface_1 = _sendInterfaces[thePayload.sendType];
2669
+ if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 ) {
2670
+ sendInterface_1 = _sendInterfaces[2 ] || _sendInterfaces[3 ] || sendInterface_1;
2671
+ }
2672
+ var useHeaders_1 = _useHeaders;
2673
+ if (thePayload.isBeacon || sendInterface_1._transport === 3 ) {
2674
+ useHeaders_1 = false;
2675
+ }
2676
+ var requestDetails_1 = _buildRequestDetails(thePayload, useHeaders_1);
2677
+ useHeaders_1 = useHeaders_1 || requestDetails_1.useHdrs;
2519
2678
  var sendEventStart_1 = getTime();
2520
- var strSendAttempt_1 = "sendAttempt";
2521
2679
  doPerf(_core, function () { return "HttpManager:_doPayloadSend"; }, function () {
2522
2680
  for (var batchLp = 0; batchLp < thePayload.batches.length; batchLp++) {
2523
2681
  var theBatch = thePayload.batches[batchLp];
@@ -2530,30 +2688,31 @@
2530
2688
  _setTimingValue(timings, "serializationStart", serializationStart);
2531
2689
  _setTimingValue(timings, "serializationCompleted", serializationCompleted);
2532
2690
  }
2533
- telemetryItem[strSendAttempt_1] > 0 ? telemetryItem[strSendAttempt_1]++ : telemetryItem[strSendAttempt_1] = 1;
2691
+ telemetryItem[strSendAttempt] > 0 ? telemetryItem[strSendAttempt]++ : telemetryItem[strSendAttempt] = 1;
2534
2692
  }
2535
2693
  }
2536
2694
  _sendBatchesNotification(thePayload.batches, (1000 + (sendReason || 0 )), thePayload.sendType, true);
2537
2695
  var orgPayloadData = {
2538
2696
  data: thePayload.payloadBlob,
2539
- urlString: urlString_1,
2540
- headers: extend({}, _headers),
2697
+ urlString: requestDetails_1.url,
2698
+ headers: requestDetails_1.hdrs,
2541
2699
  _thePayload: thePayload,
2542
- _sendReason: sendReason
2700
+ _sendReason: sendReason,
2701
+ timeout: _xhrTimeout
2543
2702
  };
2544
- if (!_hasHeader(orgPayloadData.headers, strCacheControl)) {
2545
- orgPayloadData.headers[strCacheControl] = defaultCacheControl;
2703
+ if (!isUndefined(_disableXhrSync)) {
2704
+ orgPayloadData.disableXhrSync = !!_disableXhrSync;
2546
2705
  }
2547
- if (!_hasHeader(orgPayloadData.headers, strContentTypeHeader)) {
2548
- orgPayloadData.headers[strContentTypeHeader] = defaultContentType;
2706
+ if (useHeaders_1) {
2707
+ if (!_hasHeader(orgPayloadData.headers, strCacheControl)) {
2708
+ orgPayloadData.headers[strCacheControl] = defaultCacheControl;
2709
+ }
2710
+ if (!_hasHeader(orgPayloadData.headers, strContentTypeHeader)) {
2711
+ orgPayloadData.headers[strContentTypeHeader] = defaultContentType;
2712
+ }
2549
2713
  }
2550
2714
  var sender = null;
2551
- var useSendHook = !!_self.sendHook;
2552
- var sendInterface = _sendInterfaces[thePayload.sendType];
2553
- if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 ) {
2554
- sendInterface = _sendInterfaces[2 ] || _sendInterfaces[3 ] || sendInterface;
2555
- }
2556
- if (sendInterface) {
2715
+ if (sendInterface_1) {
2557
2716
  sender = function (payload) {
2558
2717
  _clockSkewManager.firstRequestSent();
2559
2718
  var onComplete = function (status, headers) {
@@ -2561,7 +2720,7 @@
2561
2720
  };
2562
2721
  var isSync = thePayload.isTeardown || thePayload.isSync;
2563
2722
  try {
2564
- sendInterface.sendPOST(payload, onComplete, isSync);
2723
+ sendInterface_1.sendPOST(payload, onComplete, isSync);
2565
2724
  if (_self.sendListener) {
2566
2725
  _self.sendListener(orgPayloadData, payload, isSync, thePayload.isBeacon);
2567
2726
  }
@@ -2577,11 +2736,13 @@
2577
2736
  if (thePayload.sendType === 0 ) {
2578
2737
  _outstandingRequests++;
2579
2738
  }
2580
- if (useSendHook && !thePayload.isBeacon && sendInterface._transport !== 3 ) {
2739
+ if (useSendHook_1 && !thePayload.isBeacon && sendInterface_1._transport !== 3 ) {
2581
2740
  var hookData_1 = {
2582
2741
  data: orgPayloadData.data,
2583
2742
  urlString: orgPayloadData.urlString,
2584
- headers: extend({}, orgPayloadData.headers)
2743
+ headers: extend({}, orgPayloadData.headers),
2744
+ timeout: orgPayloadData.timeout,
2745
+ disableXhrSync: orgPayloadData.disableXhrSync
2585
2746
  };
2586
2747
  var senderCalled_1 = false;
2587
2748
  doPerf(_core, function () { return "HttpManager:_doPayloadSend.sendHook"; }, function () {
@@ -2646,7 +2807,7 @@
2646
2807
  });
2647
2808
  });
2648
2809
  }
2649
- if (status == 200) {
2810
+ if (status == 200 || status == 204) {
2650
2811
  reason = 200 ;
2651
2812
  return;
2652
2813
  }
@@ -2659,7 +2820,7 @@
2659
2820
  reason = 100 ;
2660
2821
  var retryCount_1 = thePayload.retryCnt;
2661
2822
  if (thePayload.sendType === 0 ) {
2662
- if (retryCount_1 < maxRetries) {
2823
+ if (retryCount_1 < maxRequestRetriesBeforeBackoff) {
2663
2824
  isRetrying = true;
2664
2825
  _doAction(function () {
2665
2826
  if (thePayload.sendType === 0 ) {
@@ -2670,6 +2831,9 @@
2670
2831
  }
2671
2832
  else {
2672
2833
  backOffTrans = true;
2834
+ if (_isUnloading) {
2835
+ reason = 8001 ;
2836
+ }
2673
2837
  }
2674
2838
  }
2675
2839
  }
@@ -2744,12 +2908,9 @@
2744
2908
  }
2745
2909
  function _getMsfpc(thePayload) {
2746
2910
  for (var lp = 0; lp < thePayload.batches.length; lp++) {
2747
- var batchEvents = thePayload.batches[lp].events();
2748
- for (var evtLp = 0; evtLp < batchEvents.length; evtLp++) {
2749
- var intWeb = ((batchEvents[evtLp].ext || {})["intweb"] || {});
2750
- if (isValueAssigned(intWeb["msfpc"])) {
2751
- return encodeURIComponent(intWeb["msfpc"]);
2752
- }
2911
+ var msfpc = thePayload.batches[lp].Msfpc();
2912
+ if (msfpc) {
2913
+ return encodeURIComponent(msfpc);
2753
2914
  }
2754
2915
  }
2755
2916
  return "";
@@ -2767,8 +2928,8 @@
2767
2928
  }
2768
2929
  if (responseText) {
2769
2930
  var response = JSON.parse(responseText);
2770
- if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult.msfpc)) {
2771
- _cookieMgr.set("MSFPC", response.webResult.msfpc, 365 * 86400);
2931
+ if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult[strMsfpc])) {
2932
+ _cookieMgr.set("MSFPC", response.webResult[strMsfpc], 365 * 86400);
2772
2933
  }
2773
2934
  }
2774
2935
  }
@@ -2813,25 +2974,27 @@
2813
2974
  }
2814
2975
  return HttpManager;
2815
2976
  }());
2816
- var HttpManager$1 = HttpManager;
2817
2977
 
2818
2978
  var FlushCheckTimer = 0.250;
2819
2979
  var MaxNumberEventPerBatch = 500;
2820
2980
  var EventsDroppedAtOneTime = 20;
2821
2981
  var MaxSendAttempts = 6;
2982
+ var MaxSyncUnloadSendAttempts = 2;
2822
2983
  var MaxBackoffCount = 4;
2823
2984
  var globalContext = isWindowObjectAvailable ? window : undefined;
2824
2985
  var MaxConnections = 2;
2825
- var MaxRetries = 1;
2986
+ var MaxRequestRetriesBeforeBackoff = 1;
2826
2987
  var strEventsDiscarded = "eventsDiscarded";
2827
2988
  var strOverrideInstrumentationKey = "overrideInstrumentationKey";
2989
+ var strMaxEventRetryAttempts = "maxEventRetryAttempts";
2990
+ var strMaxUnloadEventRetryAttempts = "maxUnloadEventRetryAttempts";
2828
2991
  var PostChannel = /** @class */ (function (_super) {
2829
2992
  __extendsFn(PostChannel, _super);
2830
2993
  function PostChannel() {
2831
2994
  var _this = _super.call(this) || this;
2832
2995
  _this.identifier = "PostChannel";
2833
2996
  _this.priority = 1011;
2834
- _this.version = '3.1.8';
2997
+ _this.version = '3.1.11';
2835
2998
  var _config;
2836
2999
  var _isTeardownCalled = false;
2837
3000
  var _flushCallbackQueue = [];
@@ -2856,11 +3019,14 @@
2856
3019
  var _delayedBatchReason;
2857
3020
  var _optimizeObject = true;
2858
3021
  var _isPageUnloadTriggered = false;
3022
+ var _disableXhrSync = false;
3023
+ var _maxEventSendAttempts = MaxSendAttempts;
3024
+ var _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
2859
3025
  dynamicProto(PostChannel, _this, function (_self, _base) {
2860
3026
  _initializeProfiles();
2861
3027
  _clearQueues();
2862
3028
  _setAutoLimits();
2863
- _httpManager = new HttpManager$1(MaxNumberEventPerBatch, MaxConnections, MaxRetries, {
3029
+ _httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {
2864
3030
  requeue: _requeueEvents,
2865
3031
  send: _sendingEvent,
2866
3032
  sent: _eventsSentEvent,
@@ -2882,14 +3048,7 @@
2882
3048
  _self._setTimeoutOverride = _config.setTimeoutOverride ? _config.setTimeoutOverride : setTimeout.bind(globalContext);
2883
3049
  _self._clearTimeoutOverride = _config.clearTimeoutOverride ? _config.clearTimeoutOverride : clearTimeout.bind(globalContext);
2884
3050
  _optimizeObject = !_config.disableOptimizeObj && isChromium();
2885
- var existingGetWParamMethod = extendedCore.getWParam;
2886
- extendedCore.getWParam = function () {
2887
- var wparam = 0;
2888
- if (_config.ignoreMc1Ms0CookieProcessing) {
2889
- wparam = wparam | 2;
2890
- }
2891
- return wparam | existingGetWParamMethod();
2892
- };
3051
+ _hookWParam(extendedCore);
2893
3052
  if (_config.eventsLimitInMem > 0) {
2894
3053
  _queueSizeLimit = _config.eventsLimitInMem;
2895
3054
  }
@@ -2899,6 +3058,13 @@
2899
3058
  if (_config.autoFlushEventsLimit > 0) {
2900
3059
  _autoFlushEventsLimit = _config.autoFlushEventsLimit;
2901
3060
  }
3061
+ _disableXhrSync = _config.disableXhrSync;
3062
+ if (isNumber(_config[strMaxEventRetryAttempts])) {
3063
+ _maxEventSendAttempts = _config[strMaxEventRetryAttempts];
3064
+ }
3065
+ if (isNumber(_config[strMaxUnloadEventRetryAttempts])) {
3066
+ _maxUnloadEventSendAttempts = _config[strMaxUnloadEventRetryAttempts];
3067
+ }
2902
3068
  _setAutoLimits();
2903
3069
  if (_config.httpXHROverride && _config.httpXHROverride.sendPOST) {
2904
3070
  _xhrOverride = _config.httpXHROverride;
@@ -2911,21 +3077,10 @@
2911
3077
  var endpointUrl = _config.overrideEndpointUrl ? _config.overrideEndpointUrl : coreConfig.endpointUrl;
2912
3078
  _self._notificationManager = coreConfig.extensionConfig.NotificationManager;
2913
3079
  _httpManager.initialize(endpointUrl, _self.core, _self, _xhrOverride, _config);
2914
- function _handleUnloadEvents(evt) {
2915
- var theEvt = evt || getWindow().event;
2916
- if (theEvt.type !== "beforeunload") {
2917
- _isPageUnloadTriggered = true;
2918
- _httpManager.setUnloading(_isPageUnloadTriggered);
2919
- }
2920
- _releaseAllQueues(2 , 2 );
2921
- }
2922
3080
  var excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || [];
2923
3081
  addPageUnloadEventListener(_handleUnloadEvents, excludePageUnloadEvents);
2924
3082
  addPageHideEventListener(_handleUnloadEvents, excludePageUnloadEvents);
2925
- addPageShowEventListener(function (evt) {
2926
- _isPageUnloadTriggered = false;
2927
- _httpManager.setUnloading(_isPageUnloadTriggered);
2928
- }, coreConfig.disablePageShowEvents);
3083
+ addPageShowEventListener(_handleShowEvents, coreConfig.disablePageShowEvents);
2929
3084
  _self.setInitialized(true);
2930
3085
  }, function () { return ({ coreConfig: coreConfig, core: core, extensions: extensions }); });
2931
3086
  };
@@ -2955,6 +3110,28 @@
2955
3110
  }
2956
3111
  _self.processNext(event, itemCtx);
2957
3112
  };
3113
+ function _hookWParam(extendedCore) {
3114
+ var existingGetWParamMethod = extendedCore.getWParam;
3115
+ extendedCore.getWParam = function () {
3116
+ var wparam = 0;
3117
+ if (_config.ignoreMc1Ms0CookieProcessing) {
3118
+ wparam = wparam | 2;
3119
+ }
3120
+ return wparam | existingGetWParamMethod();
3121
+ };
3122
+ }
3123
+ function _handleUnloadEvents(evt) {
3124
+ var theEvt = evt || getWindow().event;
3125
+ if (theEvt.type !== "beforeunload") {
3126
+ _isPageUnloadTriggered = true;
3127
+ _httpManager.setUnloading(_isPageUnloadTriggered);
3128
+ }
3129
+ _releaseAllQueues(2 , 2 );
3130
+ }
3131
+ function _handleShowEvents(evt) {
3132
+ _isPageUnloadTriggered = false;
3133
+ _httpManager.setUnloading(_isPageUnloadTriggered);
3134
+ }
2958
3135
  function _addEventToQueues(event, append) {
2959
3136
  if (!event.sendAttempt) {
2960
3137
  event.sendAttempt = 0;
@@ -3104,7 +3281,7 @@
3104
3281
  }
3105
3282
  };
3106
3283
  _self.setMsaAuthTicket = function (ticket) {
3107
- _httpManager.addHeader("AuthMsaDeviceTicket", ticket);
3284
+ _httpManager.addHeader(strMsaDeviceTicket, ticket);
3108
3285
  };
3109
3286
  _self.hasEvents = _hasEvents;
3110
3287
  _self._setTransmitProfile = function (profileName) {
@@ -3241,7 +3418,7 @@
3241
3418
  }
3242
3419
  var latency = event.latency;
3243
3420
  var eventBatch = _getEventBatch(event.iKey, latency, true);
3244
- if (eventBatch.addEvents([event], append)) {
3421
+ if (eventBatch.addEvent(event)) {
3245
3422
  if (latency !== EventLatency.Immediate) {
3246
3423
  _queueSize++;
3247
3424
  if (append && event.sendAttempt === 0) {
@@ -3384,6 +3561,10 @@
3384
3561
  }
3385
3562
  function _requeueEvents(batches, reason) {
3386
3563
  var droppedEvents = [];
3564
+ var maxSendAttempts = _maxEventSendAttempts;
3565
+ if (_isPageUnloadTriggered) {
3566
+ maxSendAttempts = _maxUnloadEventSendAttempts;
3567
+ }
3387
3568
  arrForEach(batches, function (theBatch) {
3388
3569
  if (theBatch && theBatch.count() > 0) {
3389
3570
  arrForEach(theBatch.events(), function (theEvent) {
@@ -3392,7 +3573,7 @@
3392
3573
  theEvent.latency = EventLatency.Immediate;
3393
3574
  theEvent.sync = false;
3394
3575
  }
3395
- if (theEvent.sendAttempt < MaxSendAttempts) {
3576
+ if (theEvent.sendAttempt < maxSendAttempts) {
3396
3577
  setProcessTelemetryTimings(theEvent, _self.identifier);
3397
3578
  _addEventToQueues(theEvent, false);
3398
3579
  }