@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
@@ -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
  */
@@ -18,20 +18,24 @@
18
18
  var ObjDefineProperty = ObjClass["defineProperty"];
19
19
  var ObjHasOwnProperty = ObjProto[strShimHasOwnProperty];
20
20
 
21
- function getGlobal() {
22
- if (typeof globalThis !== strShimUndefined && globalThis) {
23
- return globalThis;
24
- }
25
- if (typeof self !== strShimUndefined && self) {
26
- return self;
27
- }
28
- if (typeof window !== strShimUndefined && window) {
29
- return window;
30
- }
31
- if (typeof global !== strShimUndefined && global) {
32
- return global;
21
+ var _cachedGlobal = null;
22
+ function getGlobal(useCached) {
23
+ if (useCached === void 0) { useCached = true; }
24
+ if (!_cachedGlobal || !useCached) {
25
+ if (typeof globalThis !== strShimUndefined && globalThis) {
26
+ _cachedGlobal = globalThis;
27
+ }
28
+ if (typeof self !== strShimUndefined && self) {
29
+ _cachedGlobal = self;
30
+ }
31
+ if (typeof window !== strShimUndefined && window) {
32
+ _cachedGlobal = window;
33
+ }
34
+ if (typeof global !== strShimUndefined && global) {
35
+ _cachedGlobal = global;
36
+ }
33
37
  }
34
- return null;
38
+ return _cachedGlobal;
35
39
  }
36
40
  function throwTypeError(message) {
37
41
  throw new TypeError(message);
@@ -46,7 +50,7 @@
46
50
  }
47
51
  var type = typeof obj;
48
52
  if (type !== strShimObject && type !== strShimFunction) {
49
- throwTypeError('Object prototype may only be an Object:' + obj);
53
+ throwTypeError("Object prototype may only be an Object:" + obj);
50
54
  }
51
55
  function tmpFunc() { }
52
56
  tmpFunc[strShimPrototype] = obj;
@@ -431,10 +435,19 @@
431
435
  var strOnPrefix = "on";
432
436
  var strAttachEvent = "attachEvent";
433
437
  var strAddEventHelper = "addEventListener";
438
+ var cStrStartsWith = "startsWith";
439
+ var strIndexOf = "indexOf";
440
+ var cStrTrim = "trim";
441
+ var strToString = "toString";
434
442
  var _objDefineProperty = ObjDefineProperty;
435
- function objToString(obj) {
436
- return ObjProto.toString.call(obj);
437
- }
443
+ var _objKeys = ObjClass.keys;
444
+ var StringProto = String[strShimPrototype];
445
+ var _strTrim = StringProto[cStrTrim];
446
+ var _strStartsWith = StringProto[cStrStartsWith];
447
+ var _isArray = Array.isArray;
448
+ var _objToString = ObjProto[strToString];
449
+ var _fnToString = ObjHasOwnProperty[strToString];
450
+ _fnToString.call(ObjClass);
438
451
  function isUndefined(value) {
439
452
  return value === undefined || typeof value === strShimUndefined;
440
453
  }
@@ -442,13 +455,13 @@
442
455
  return (value === null || isUndefined(value));
443
456
  }
444
457
  function hasOwnProperty(obj, prop) {
445
- return obj && ObjHasOwnProperty.call(obj, prop);
458
+ return !!(obj && ObjHasOwnProperty.call(obj, prop));
446
459
  }
447
460
  function isObject(value) {
448
- return typeof value === strShimObject;
461
+ return !!(value && typeof value === strShimObject);
449
462
  }
450
463
  function isFunction(value) {
451
- return typeof value === strShimFunction;
464
+ return !!(value && typeof value === strShimFunction);
452
465
  }
453
466
  function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
454
467
  if (useCapture === void 0) { useCapture = false; }
@@ -480,24 +493,27 @@
480
493
  }
481
494
  function strStartsWith(value, checkValue) {
482
495
  var result = false;
483
- if (value && checkValue) {
484
- var chkLen = checkValue.length;
485
- if (value === checkValue) {
486
- return true;
487
- }
488
- else if (value.length >= chkLen) {
489
- for (var lp = 0; lp < chkLen; lp++) {
490
- if (value[lp] !== checkValue[lp]) {
491
- return false;
492
- }
496
+ if (value && checkValue && !(result = value === checkValue)) {
497
+ result = _strStartsWith ? value[cStrStartsWith](checkValue) : _strStartsWithPoly(value, checkValue);
498
+ }
499
+ return result;
500
+ }
501
+ function _strStartsWithPoly(value, checkValue) {
502
+ var result = false;
503
+ var chkLen = checkValue ? checkValue.length : 0;
504
+ if (value && chkLen && value.length >= chkLen && !(result = value === checkValue)) {
505
+ for (var lp = 0; lp < chkLen; lp++) {
506
+ if (value[lp] !== checkValue[lp]) {
507
+ return false;
493
508
  }
494
- result = true;
495
509
  }
510
+ result = true;
496
511
  }
497
512
  return result;
498
513
  }
499
- function isArray(obj) {
500
- return objToString(obj) === "[object Array]";
514
+ var isArray = _isArray || _isArrayPoly;
515
+ function _isArrayPoly(obj) {
516
+ return !!(obj && _objToString.call(obj) === "[object Array]");
501
517
  }
502
518
  function isString(value) {
503
519
  return typeof value === "string";
@@ -523,24 +539,29 @@
523
539
  }
524
540
  }
525
541
  function arrIndexOf(arr, searchElement, fromIndex) {
526
- var len = arr.length;
527
- var from = fromIndex || 0;
528
- try {
529
- for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
530
- if (lp in arr && arr[lp] === searchElement) {
531
- return lp;
542
+ if (arr) {
543
+ if (arr[strIndexOf]) {
544
+ return arr[strIndexOf](searchElement, fromIndex);
545
+ }
546
+ var len = arr.length;
547
+ var from = fromIndex || 0;
548
+ try {
549
+ for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
550
+ if (lp in arr && arr[lp] === searchElement) {
551
+ return lp;
552
+ }
532
553
  }
533
554
  }
534
- }
535
- catch (e) {
555
+ catch (e) {
556
+ }
536
557
  }
537
558
  return -1;
538
559
  }
539
560
  function strTrim(str) {
540
- if (typeof str !== "string") {
541
- return str;
561
+ if (str) {
562
+ str = (_strTrim && str[cStrTrim]) ? str[cStrTrim]() : (str.replace ? str.replace(/^\s+|\s+$/g, "") : str);
542
563
  }
543
- return str.replace(/^\s+|\s+$/g, "");
564
+ return str;
544
565
  }
545
566
  var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
546
567
  var _objKeysDontEnums = [
@@ -557,6 +578,9 @@
557
578
  if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
558
579
  throwTypeError("objKeys called on non-object");
559
580
  }
581
+ if (!_objKeysHasDontEnumBug && _objKeys) {
582
+ return _objKeys(obj);
583
+ }
560
584
  var result = [];
561
585
  for (var prop in obj) {
562
586
  if (obj && ObjHasOwnProperty.call(obj, prop)) {
@@ -596,10 +620,7 @@
596
620
  }
597
621
  function dateNow() {
598
622
  var dt = Date;
599
- if (dt.now) {
600
- return dt.now();
601
- }
602
- return new dt().getTime();
623
+ return dt.now ? dt.now() : new dt().getTime();
603
624
  }
604
625
  function setValue(target, field, value, valChk, srcChk) {
605
626
  var theValue = value;
@@ -613,8 +634,8 @@
613
634
  return theValue;
614
635
  }
615
636
  function optimizeObject(theObject) {
616
- if (theObject) {
617
- theObject = ObjClass(ObjAssign ? ObjAssign({}, theObject) : theObject);
637
+ if (theObject && ObjAssign) {
638
+ theObject = ObjClass(ObjAssign({}, theObject));
618
639
  }
619
640
  return theObject;
620
641
  }
@@ -762,7 +783,7 @@
762
783
  }
763
784
  function useXDomainRequest() {
764
785
  if (_useXDomainRequest === null) {
765
- _useXDomainRequest = (typeof XDomainRequest !== undefined);
786
+ _useXDomainRequest = (typeof XDomainRequest !== "undefined");
766
787
  if (_useXDomainRequest && isXhrSupported()) {
767
788
  _useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
768
789
  }
@@ -780,6 +801,22 @@
780
801
  return isSupported;
781
802
  }
782
803
 
804
+ var _aiNamespace = null;
805
+ function _getExtensionNamespace() {
806
+ var target = getGlobalInst("Microsoft");
807
+ if (target) {
808
+ _aiNamespace = target["ApplicationInsights"];
809
+ }
810
+ return _aiNamespace;
811
+ }
812
+ function getDebugExt(config) {
813
+ var ns = _aiNamespace;
814
+ if (!ns && config.disableDbgExt !== true) {
815
+ ns = _aiNamespace || _getExtensionNamespace();
816
+ }
817
+ return ns ? ns["ChromeDbgExt"] : null;
818
+ }
819
+
783
820
  var AiNonUserActionablePrefix = "AI (Internal): ";
784
821
  var AiUserActionablePrefix = "AI: ";
785
822
  var AIInternalMessagePrefix = "AITR_";
@@ -863,13 +900,18 @@
863
900
  }
864
901
  _self.logInternalMessage(severity, message);
865
902
  }
903
+ else {
904
+ _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
905
+ }
866
906
  }
867
907
  };
868
908
  _self.warnToConsole = function (message) {
869
909
  _logToConsole("warn", message);
910
+ _debugExtMsg("warning", message);
870
911
  };
871
912
  _self.errorToConsole = function (message) {
872
913
  _logToConsole("error", message);
914
+ _debugExtMsg("error", message);
873
915
  };
874
916
  _self.resetInternalMessageCount = function () {
875
917
  _messageCount = 0;
@@ -891,12 +933,18 @@
891
933
  if (severity <= _self.telemetryLoggingLevel()) {
892
934
  _self.queue.push(message);
893
935
  _messageCount++;
936
+ _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
894
937
  }
895
938
  if (_messageCount === _self.maxInternalMessageLimit()) {
896
939
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
897
940
  var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
898
941
  _self.queue.push(throttleMessage);
899
- _self.warnToConsole(throttleLimitMessage);
942
+ if (severity === LoggingSeverity.CRITICAL) {
943
+ _self.errorToConsole(throttleLimitMessage);
944
+ }
945
+ else {
946
+ _self.warnToConsole(throttleLimitMessage);
947
+ }
900
948
  }
901
949
  }
902
950
  };
@@ -910,6 +958,12 @@
910
958
  function _areInternalMessagesThrottled() {
911
959
  return _messageCount >= _self.maxInternalMessageLimit();
912
960
  }
961
+ function _debugExtMsg(name, data) {
962
+ var dbgExt = getDebugExt(config);
963
+ if (dbgExt && dbgExt.diagLog) {
964
+ dbgExt.diagLog(name, data);
965
+ }
966
+ }
913
967
  });
914
968
  }
915
969
  return DiagnosticLogger;
@@ -1397,10 +1451,11 @@
1397
1451
  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 });
1398
1452
 
1399
1453
  var _a$1;
1400
- var Version = '3.1.8';
1454
+ var Version = '3.1.11';
1401
1455
  var FullVersionString = "1DS-Web-JS-" + Version;
1402
1456
  var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
1403
1457
  var strWithCredentials = "withCredentials";
1458
+ var strTimeout = "timeout";
1404
1459
  var _fieldTypeEventPropMap = (_a$1 = {},
1405
1460
  _a$1[0 ] = EventPropertyType.Unspecified,
1406
1461
  _a$1[2 ] = EventPropertyType.Double,
@@ -1572,7 +1627,7 @@
1572
1627
  function isChromium() {
1573
1628
  return !!getGlobalInst("chrome");
1574
1629
  }
1575
- function openXhr(method, urlString, withCredentials, disabled, isSync) {
1630
+ function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {
1576
1631
  if (disabled === void 0) { disabled = false; }
1577
1632
  if (isSync === void 0) { isSync = false; }
1578
1633
  function _wrapSetXhrProp(xhr, prop, value) {
@@ -1593,6 +1648,9 @@
1593
1648
  if (withCredentials) {
1594
1649
  _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
1595
1650
  }
1651
+ if (!isSync && timeout) {
1652
+ _wrapSetXhrProp(xhr, strTimeout, timeout);
1653
+ }
1596
1654
  return xhr;
1597
1655
  }
1598
1656
 
@@ -1600,42 +1658,82 @@
1600
1658
  var NRT_PROFILE = "NEAR_REAL_TIME";
1601
1659
  var BE_PROFILE = "BEST_EFFORT";
1602
1660
 
1661
+ var Method = "POST";
1662
+ var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
1663
+ var strDropped = "drop";
1664
+ var strSending = "send";
1665
+ var strRequeue = "requeue";
1666
+ var strResponseFail = "rspFail";
1667
+ var strOther = "oth";
1668
+ var defaultCacheControl = "no-cache, no-store";
1669
+ var defaultContentType = "application/x-json-stream";
1670
+ var strCacheControl = "cache-control";
1671
+ var strContentTypeHeader = "content-type";
1672
+ var strKillTokensHeader = "kill-tokens";
1673
+ var strKillDurationHeader = "kill-duration";
1674
+ var strKillDurationSecondsHeader = "kill-duration-seconds";
1675
+ var strTimeDeltaHeader = "time-delta-millis";
1676
+ var strClientVersion = "client-version";
1677
+ var strClientId = "client-id";
1678
+ var strTimeDeltaToApply = "time-delta-to-apply-millis";
1679
+ var strUploadTime = "upload-time";
1680
+ var strApiKey = "apikey";
1681
+ var strMsaDeviceTicket = "AuthMsaDeviceTicket";
1682
+ var strNoResponseBody = "NoResponseBody";
1683
+ var strMsfpc = "msfpc";
1684
+
1685
+ function _getEventMsfpc(theEvent) {
1686
+ var intWeb = ((theEvent.ext || {})["intweb"]);
1687
+ if (intWeb && isValueAssigned(intWeb[strMsfpc])) {
1688
+ return intWeb[strMsfpc];
1689
+ }
1690
+ return null;
1691
+ }
1692
+ function _getMsfpc(theEvents) {
1693
+ var msfpc = null;
1694
+ for (var lp = 0; msfpc === null && lp < theEvents.length; lp++) {
1695
+ msfpc = _getEventMsfpc(theEvents[lp]);
1696
+ }
1697
+ return msfpc;
1698
+ }
1603
1699
  var EventBatch = /** @class */ (function () {
1604
1700
  function EventBatch(iKey, addEvents) {
1605
1701
  var events = addEvents ? [].concat(addEvents) : [];
1606
1702
  var _self = this;
1703
+ var _msfpc = _getMsfpc(events);
1607
1704
  _self.iKey = function () {
1608
1705
  return iKey;
1609
1706
  };
1707
+ _self.Msfpc = function () {
1708
+ return _msfpc || "";
1709
+ };
1610
1710
  _self.count = function () {
1611
1711
  return events.length;
1612
1712
  };
1613
1713
  _self.events = function () {
1614
1714
  return events;
1615
1715
  };
1616
- _self.addEvents = function (theEvents, append) {
1617
- if (append === void 0) { append = true; }
1618
- if (theEvents && theEvents.length > 0) {
1619
- if (append) {
1620
- events = events.concat(theEvents);
1716
+ _self.addEvent = function (theEvent) {
1717
+ if (theEvent) {
1718
+ events.push(theEvent);
1719
+ if (!_msfpc) {
1720
+ _msfpc = _getEventMsfpc(theEvent);
1621
1721
  }
1622
- else {
1623
- events = theEvents.concat(events);
1624
- }
1625
- return theEvents.length;
1722
+ return true;
1626
1723
  }
1627
- return 0;
1724
+ return false;
1628
1725
  };
1629
1726
  _self.split = function (fromEvent, numEvents) {
1630
- var newBatch = new EventBatch(iKey);
1727
+ var theEvents;
1631
1728
  if (fromEvent < events.length) {
1632
1729
  var cnt = events.length - fromEvent;
1633
1730
  if (!isNullOrUndefined(numEvents)) {
1634
1731
  cnt = numEvents < cnt ? numEvents : cnt;
1635
1732
  }
1636
- newBatch.addEvents(events.splice(fromEvent, cnt), true);
1733
+ theEvents = events.splice(fromEvent, cnt);
1734
+ _msfpc = _getMsfpc(events);
1637
1735
  }
1638
- return newBatch;
1736
+ return new EventBatch(iKey, theEvents);
1639
1737
  };
1640
1738
  }
1641
1739
  EventBatch.create = function (iKey, theEvents) {
@@ -2005,21 +2103,8 @@
2005
2103
  var EVTClockSkewManager = ClockSkewManager;
2006
2104
 
2007
2105
  var _a;
2008
- var Method = "POST";
2009
- var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
2010
- var strDropped = "drop";
2011
- var strSending = "send";
2012
- var strRequeue = "requeue";
2013
- var strResponseFail = "rspFail";
2014
- var strOther = "oth";
2015
- var defaultCacheControl = "no-cache, no-store";
2016
- var defaultContentType = "application/x-json-stream";
2017
- var strCacheControl = "cache-control";
2018
- var strContentTypeHeader = "content-type";
2019
- var strKillTokensHeader = "kill-tokens";
2020
- var strKillDurationHeader = "kill-duration";
2021
- var strKillDurationSecondsHeader = "kill-duration-seconds";
2022
- var strTimeDeltaHeader = "time-delta-millis";
2106
+ var strSendAttempt = "sendAttempt";
2107
+ var _noResponseQs = "&" + strNoResponseBody + "=true";
2023
2108
  var _eventActionMap = (_a = {},
2024
2109
  _a[1 ] = strRequeue,
2025
2110
  _a[100 ] = strRequeue,
@@ -2027,6 +2112,13 @@
2027
2112
  _a[8004 ] = strDropped,
2028
2113
  _a[8003 ] = strDropped,
2029
2114
  _a);
2115
+ var _collectorQsHeaders = {};
2116
+ var _collectorHeaderToQs = {};
2117
+ function _addCollectorHeaderQsMapping(qsName, headerName) {
2118
+ _collectorQsHeaders[qsName] = headerName;
2119
+ _collectorHeaderToQs[headerName] = qsName;
2120
+ }
2121
+ _addCollectorHeaderQsMapping(strMsaDeviceTicket, strMsaDeviceTicket);
2030
2122
  function _getResponseText(xhr) {
2031
2123
  try {
2032
2124
  return xhr.responseText;
@@ -2053,11 +2145,21 @@
2053
2145
  }
2054
2146
  return hasHeader;
2055
2147
  }
2148
+ function _addRequestDetails(details, name, value, useHeaders) {
2149
+ if (name && value && value.length > 0) {
2150
+ if (useHeaders && _collectorQsHeaders[name]) {
2151
+ details.hdrs[_collectorQsHeaders[name]] = value;
2152
+ details.useHdrs = true;
2153
+ }
2154
+ else {
2155
+ details.url += "&" + name + "=" + value;
2156
+ }
2157
+ }
2158
+ }
2056
2159
  var HttpManager = /** @class */ (function () {
2057
- function HttpManager(maxEventsPerBatch, maxConnections, maxRetries, actions) {
2160
+ function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions) {
2058
2161
  this._responseHandlers = [];
2059
- var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType + "&client-id=NO_AUTH&client-version="
2060
- + FullVersionString;
2162
+ var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType;
2061
2163
  var _killSwitch = new EVTKillSwitch();
2062
2164
  var _paused = false;
2063
2165
  var _clockSkewManager = new EVTClockSkewManager();
@@ -2074,6 +2176,9 @@
2074
2176
  var _enableEventTimings = false;
2075
2177
  var _cookieMgr;
2076
2178
  var _isUnloading = false;
2179
+ var _useHeaders = false;
2180
+ var _xhrTimeout;
2181
+ var _disableXhrSync;
2077
2182
  dynamicProto(HttpManager, this, function (_self) {
2078
2183
  var _sendCredentials = true;
2079
2184
  _self.initialize = function (endpointUrl, core, postChannel, httpInterface, channelConfig) {
@@ -2082,6 +2187,7 @@
2082
2187
  channelConfig = {};
2083
2188
  }
2084
2189
  _urlString = endpointUrl + _urlString;
2190
+ _useHeaders = !isUndefined(channelConfig.avoidOptions) ? !channelConfig.avoidOptions : false;
2085
2191
  _core = core;
2086
2192
  _cookieMgr = core.getCookieMgr();
2087
2193
  _enableEventTimings = !_core.config.disableEventTimings;
@@ -2092,9 +2198,13 @@
2092
2198
  if (!isUndefined(channelConfig.enableCompoundKey)) {
2093
2199
  enableCompoundKey = !!channelConfig.enableCompoundKey;
2094
2200
  }
2201
+ _xhrTimeout = channelConfig.xhrTimeout;
2202
+ _disableXhrSync = channelConfig.disableXhrSync;
2095
2203
  _useBeacons = !isReactNative();
2096
2204
  _serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey);
2097
2205
  var syncHttpInterface = httpInterface;
2206
+ var beaconHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
2207
+ var fetchSyncHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
2098
2208
  if (!httpInterface) {
2099
2209
  _customHttpInterface = false;
2100
2210
  var location_1 = getLocation();
@@ -2126,8 +2236,8 @@
2126
2236
  _sendInterfaces = (_a = {},
2127
2237
  _a[0 ] = httpInterface,
2128
2238
  _a[1 ] = syncHttpInterface || _getSenderInterface([1 , 2 , 3 ], true),
2129
- _a[2 ] = _getSenderInterface([3 , 2 , 1 ], true) || syncHttpInterface,
2130
- _a[3 ] = _getSenderInterface([2 , 3 , 1 ], true) || syncHttpInterface,
2239
+ _a[2 ] = beaconHttpInterface || _getSenderInterface([3 , 2 ], true) || syncHttpInterface || _getSenderInterface([1 ], true),
2240
+ _a[3 ] = fetchSyncHttpInterface || _getSenderInterface([2 , 3 ], true) || syncHttpInterface || _getSenderInterface([1 ], true),
2131
2241
  _a);
2132
2242
  };
2133
2243
  function _getSenderInterface(transports, syncSupport) {
@@ -2167,6 +2277,9 @@
2167
2277
  function _xdrSendPost(payload, oncomplete, sync) {
2168
2278
  var xdr = new XDomainRequest();
2169
2279
  xdr.open(Method, payload.urlString);
2280
+ if (payload.timeout) {
2281
+ xdr.timeout = payload.timeout;
2282
+ }
2170
2283
  xdr.onload = function () {
2171
2284
  var response = _getResponseText(xdr);
2172
2285
  _doOnComplete(oncomplete, 200, {}, response);
@@ -2190,6 +2303,9 @@
2190
2303
  }
2191
2304
  function _fetchSendPost(payload, oncomplete, sync) {
2192
2305
  var _a;
2306
+ var theUrl = payload.urlString;
2307
+ var ignoreResponse = false;
2308
+ var responseHandled = false;
2193
2309
  var requestInit = (_a = {
2194
2310
  body: payload.data,
2195
2311
  method: Method
@@ -2198,6 +2314,10 @@
2198
2314
  _a);
2199
2315
  if (sync) {
2200
2316
  requestInit.keepalive = true;
2317
+ if (payload._sendReason === 2 ) {
2318
+ ignoreResponse = true;
2319
+ theUrl += _noResponseQs;
2320
+ }
2201
2321
  }
2202
2322
  if (_sendCredentials) {
2203
2323
  requestInit.credentials = "include";
@@ -2205,7 +2325,7 @@
2205
2325
  if (payload.headers && objKeys(payload.headers).length > 0) {
2206
2326
  requestInit.headers = payload.headers;
2207
2327
  }
2208
- fetch(payload.urlString, requestInit).then(function (response) {
2328
+ fetch(theUrl, requestInit).then(function (response) {
2209
2329
  var headerMap = {};
2210
2330
  var responseText = "";
2211
2331
  if (response.headers) {
@@ -2218,13 +2338,32 @@
2218
2338
  responseText = text;
2219
2339
  });
2220
2340
  }
2221
- _doOnComplete(oncomplete, response.status, headerMap, responseText);
2222
- _handleCollectorResponse(responseText);
2341
+ if (!responseHandled) {
2342
+ responseHandled = true;
2343
+ _doOnComplete(oncomplete, response.status, headerMap, responseText);
2344
+ _handleCollectorResponse(responseText);
2345
+ }
2223
2346
  })["catch"](function (error) {
2224
- _doOnComplete(oncomplete, 0, {});
2347
+ if (!responseHandled) {
2348
+ responseHandled = true;
2349
+ _doOnComplete(oncomplete, 0, {});
2350
+ }
2225
2351
  });
2352
+ if (ignoreResponse && !responseHandled) {
2353
+ responseHandled = true;
2354
+ _doOnComplete(oncomplete, 200, {});
2355
+ }
2356
+ if (!responseHandled && payload.timeout > 0) {
2357
+ _postManager._setTimeoutOverride(function () {
2358
+ if (!responseHandled) {
2359
+ responseHandled = true;
2360
+ _doOnComplete(oncomplete, 500, {});
2361
+ }
2362
+ }, payload.timeout);
2363
+ }
2226
2364
  }
2227
2365
  function _xhrSendPost(payload, oncomplete, sync) {
2366
+ var theUrl = payload.urlString;
2228
2367
  function _appendHeader(theHeaders, xhr, name) {
2229
2368
  if (!theHeaders[name] && xhr && xhr.getResponseHeader) {
2230
2369
  var value = xhr.getResponseHeader(name);
@@ -2249,22 +2388,25 @@
2249
2388
  function xhrComplete(xhr, responseTxt) {
2250
2389
  _doOnComplete(oncomplete, xhr.status, _getAllResponseHeaders(xhr), responseTxt);
2251
2390
  }
2252
- var xhRequest = openXhr(Method, payload.urlString, _sendCredentials, true, sync);
2391
+ if (sync && payload.disableXhrSync) {
2392
+ sync = false;
2393
+ }
2394
+ var xhrRequest = openXhr(Method, theUrl, _sendCredentials, true, sync, payload.timeout);
2253
2395
  objForEachKey(payload.headers, function (name, value) {
2254
- xhRequest.setRequestHeader(name, value);
2396
+ xhrRequest.setRequestHeader(name, value);
2255
2397
  });
2256
- xhRequest.onload = function () {
2257
- var response = _getResponseText(xhRequest);
2258
- xhrComplete(xhRequest, response);
2398
+ xhrRequest.onload = function () {
2399
+ var response = _getResponseText(xhrRequest);
2400
+ xhrComplete(xhrRequest, response);
2259
2401
  _handleCollectorResponse(response);
2260
2402
  };
2261
- xhRequest.onerror = function () {
2262
- xhrComplete(xhRequest);
2403
+ xhrRequest.onerror = function () {
2404
+ xhrComplete(xhrRequest);
2263
2405
  };
2264
- xhRequest.ontimeout = function () {
2265
- xhrComplete(xhRequest);
2406
+ xhrRequest.ontimeout = function () {
2407
+ xhrComplete(xhrRequest);
2266
2408
  };
2267
- xhRequest.send(payload.data);
2409
+ xhrRequest.send(payload.data);
2268
2410
  }
2269
2411
  function _doOnComplete(oncomplete, status, headers, response) {
2270
2412
  try {
@@ -2278,16 +2420,17 @@
2278
2420
  var internalPayloadData = payload;
2279
2421
  var status = 200;
2280
2422
  var thePayload = internalPayloadData._thePayload;
2423
+ var theUrl = payload.urlString + _noResponseQs;
2281
2424
  try {
2282
2425
  var nav_1 = getNavigator();
2283
- if (!nav_1.sendBeacon(payload.urlString, payload.data)) {
2426
+ if (!nav_1.sendBeacon(theUrl, payload.data)) {
2284
2427
  if (thePayload) {
2285
2428
  var droppedBatches_1 = [];
2286
2429
  arrForEach(thePayload.batches, function (theBatch) {
2287
2430
  if (droppedBatches_1 && theBatch && theBatch.count() > 0) {
2288
2431
  var theEvents = theBatch.events();
2289
2432
  for (var lp = 0; lp < theEvents.length; lp++) {
2290
- if (!nav_1.sendBeacon(payload.urlString, _serializer.getEventBlob(theEvents[lp]))) {
2433
+ if (!nav_1.sendBeacon(theUrl, _serializer.getEventBlob(theEvents[lp]))) {
2291
2434
  droppedBatches_1.push(theBatch.split(lp));
2292
2435
  break;
2293
2436
  }
@@ -2472,8 +2615,16 @@
2472
2615
  _postManager.diagLog().throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.CannotSerializeObject, "Unexpected Exception sending batch: " + dumpObj(ex));
2473
2616
  }
2474
2617
  }
2475
- function _buildQueryString(thePayload) {
2476
- var urlString = _urlString;
2618
+ function _buildRequestDetails(thePayload, useHeaders) {
2619
+ var requestDetails = {
2620
+ url: _urlString,
2621
+ hdrs: {},
2622
+ useHdrs: false
2623
+ };
2624
+ requestDetails.hdrs = extend(requestDetails.hdrs, _headers);
2625
+ requestDetails.useHdrs = (objKeys(requestDetails.hdrs).length > 0);
2626
+ _addRequestDetails(requestDetails, strClientId, "NO_AUTH", useHeaders);
2627
+ _addRequestDetails(requestDetails, strClientVersion, FullVersionString, useHeaders);
2477
2628
  var apiQsKeys = "";
2478
2629
  arrForEach(thePayload.apiKeys, function (apiKey) {
2479
2630
  if (apiQsKeys.length > 0) {
@@ -2481,27 +2632,25 @@
2481
2632
  }
2482
2633
  apiQsKeys += apiKey;
2483
2634
  });
2484
- if (apiQsKeys.length > 0) {
2485
- urlString += "&apikey=" + apiQsKeys;
2486
- }
2487
- urlString += "&upload-time=" + dateNow().toString();
2635
+ _addRequestDetails(requestDetails, strApiKey, apiQsKeys, useHeaders);
2636
+ _addRequestDetails(requestDetails, strUploadTime, dateNow().toString(), useHeaders);
2488
2637
  var msfpc = _getMsfpc(thePayload);
2489
2638
  if (isValueAssigned(msfpc)) {
2490
- urlString = urlString + "&ext.intweb.msfpc=" + msfpc;
2639
+ requestDetails.url += "&ext.intweb.msfpc=" + msfpc;
2491
2640
  }
2492
2641
  if (_clockSkewManager.shouldAddClockSkewHeaders()) {
2493
- urlString += "&time-delta-to-apply-millis=" + _clockSkewManager.getClockSkewHeaderValue();
2642
+ _addRequestDetails(requestDetails, strTimeDeltaToApply, _clockSkewManager.getClockSkewHeaderValue(), useHeaders);
2494
2643
  }
2495
2644
  if (_core.getWParam) {
2496
2645
  var wParam = _core.getWParam();
2497
2646
  if (wParam >= 0) {
2498
- urlString += "&w=" + wParam;
2647
+ requestDetails.url += "&w=" + wParam;
2499
2648
  }
2500
2649
  }
2501
2650
  for (var i = 0; i < _queryStringParameters.length; i++) {
2502
- urlString += "&" + _queryStringParameters[i].name + "=" + _queryStringParameters[i].value;
2651
+ requestDetails.url += "&" + _queryStringParameters[i].name + "=" + _queryStringParameters[i].value;
2503
2652
  }
2504
- return urlString;
2653
+ return requestDetails;
2505
2654
  }
2506
2655
  function _canUseSendBeaconApi() {
2507
2656
  return !_customHttpInterface && _useBeacons && isBeaconsSupported();
@@ -2512,9 +2661,18 @@
2512
2661
  }
2513
2662
  function _doPayloadSend(thePayload, serializationStart, serializationCompleted, sendReason) {
2514
2663
  if (thePayload && thePayload.payloadBlob && thePayload.payloadBlob.length > 0) {
2515
- var urlString_1 = _buildQueryString(thePayload);
2664
+ var useSendHook_1 = !!_self.sendHook;
2665
+ var sendInterface_1 = _sendInterfaces[thePayload.sendType];
2666
+ if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 ) {
2667
+ sendInterface_1 = _sendInterfaces[2 ] || _sendInterfaces[3 ] || sendInterface_1;
2668
+ }
2669
+ var useHeaders_1 = _useHeaders;
2670
+ if (thePayload.isBeacon || sendInterface_1._transport === 3 ) {
2671
+ useHeaders_1 = false;
2672
+ }
2673
+ var requestDetails_1 = _buildRequestDetails(thePayload, useHeaders_1);
2674
+ useHeaders_1 = useHeaders_1 || requestDetails_1.useHdrs;
2516
2675
  var sendEventStart_1 = getTime();
2517
- var strSendAttempt_1 = "sendAttempt";
2518
2676
  doPerf(_core, function () { return "HttpManager:_doPayloadSend"; }, function () {
2519
2677
  for (var batchLp = 0; batchLp < thePayload.batches.length; batchLp++) {
2520
2678
  var theBatch = thePayload.batches[batchLp];
@@ -2527,30 +2685,31 @@
2527
2685
  _setTimingValue(timings, "serializationStart", serializationStart);
2528
2686
  _setTimingValue(timings, "serializationCompleted", serializationCompleted);
2529
2687
  }
2530
- telemetryItem[strSendAttempt_1] > 0 ? telemetryItem[strSendAttempt_1]++ : telemetryItem[strSendAttempt_1] = 1;
2688
+ telemetryItem[strSendAttempt] > 0 ? telemetryItem[strSendAttempt]++ : telemetryItem[strSendAttempt] = 1;
2531
2689
  }
2532
2690
  }
2533
2691
  _sendBatchesNotification(thePayload.batches, (1000 + (sendReason || 0 )), thePayload.sendType, true);
2534
2692
  var orgPayloadData = {
2535
2693
  data: thePayload.payloadBlob,
2536
- urlString: urlString_1,
2537
- headers: extend({}, _headers),
2694
+ urlString: requestDetails_1.url,
2695
+ headers: requestDetails_1.hdrs,
2538
2696
  _thePayload: thePayload,
2539
- _sendReason: sendReason
2697
+ _sendReason: sendReason,
2698
+ timeout: _xhrTimeout
2540
2699
  };
2541
- if (!_hasHeader(orgPayloadData.headers, strCacheControl)) {
2542
- orgPayloadData.headers[strCacheControl] = defaultCacheControl;
2700
+ if (!isUndefined(_disableXhrSync)) {
2701
+ orgPayloadData.disableXhrSync = !!_disableXhrSync;
2543
2702
  }
2544
- if (!_hasHeader(orgPayloadData.headers, strContentTypeHeader)) {
2545
- orgPayloadData.headers[strContentTypeHeader] = defaultContentType;
2703
+ if (useHeaders_1) {
2704
+ if (!_hasHeader(orgPayloadData.headers, strCacheControl)) {
2705
+ orgPayloadData.headers[strCacheControl] = defaultCacheControl;
2706
+ }
2707
+ if (!_hasHeader(orgPayloadData.headers, strContentTypeHeader)) {
2708
+ orgPayloadData.headers[strContentTypeHeader] = defaultContentType;
2709
+ }
2546
2710
  }
2547
2711
  var sender = null;
2548
- var useSendHook = !!_self.sendHook;
2549
- var sendInterface = _sendInterfaces[thePayload.sendType];
2550
- if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 ) {
2551
- sendInterface = _sendInterfaces[2 ] || _sendInterfaces[3 ] || sendInterface;
2552
- }
2553
- if (sendInterface) {
2712
+ if (sendInterface_1) {
2554
2713
  sender = function (payload) {
2555
2714
  _clockSkewManager.firstRequestSent();
2556
2715
  var onComplete = function (status, headers) {
@@ -2558,7 +2717,7 @@
2558
2717
  };
2559
2718
  var isSync = thePayload.isTeardown || thePayload.isSync;
2560
2719
  try {
2561
- sendInterface.sendPOST(payload, onComplete, isSync);
2720
+ sendInterface_1.sendPOST(payload, onComplete, isSync);
2562
2721
  if (_self.sendListener) {
2563
2722
  _self.sendListener(orgPayloadData, payload, isSync, thePayload.isBeacon);
2564
2723
  }
@@ -2574,11 +2733,13 @@
2574
2733
  if (thePayload.sendType === 0 ) {
2575
2734
  _outstandingRequests++;
2576
2735
  }
2577
- if (useSendHook && !thePayload.isBeacon && sendInterface._transport !== 3 ) {
2736
+ if (useSendHook_1 && !thePayload.isBeacon && sendInterface_1._transport !== 3 ) {
2578
2737
  var hookData_1 = {
2579
2738
  data: orgPayloadData.data,
2580
2739
  urlString: orgPayloadData.urlString,
2581
- headers: extend({}, orgPayloadData.headers)
2740
+ headers: extend({}, orgPayloadData.headers),
2741
+ timeout: orgPayloadData.timeout,
2742
+ disableXhrSync: orgPayloadData.disableXhrSync
2582
2743
  };
2583
2744
  var senderCalled_1 = false;
2584
2745
  doPerf(_core, function () { return "HttpManager:_doPayloadSend.sendHook"; }, function () {
@@ -2643,7 +2804,7 @@
2643
2804
  });
2644
2805
  });
2645
2806
  }
2646
- if (status == 200) {
2807
+ if (status == 200 || status == 204) {
2647
2808
  reason = 200 ;
2648
2809
  return;
2649
2810
  }
@@ -2656,7 +2817,7 @@
2656
2817
  reason = 100 ;
2657
2818
  var retryCount_1 = thePayload.retryCnt;
2658
2819
  if (thePayload.sendType === 0 ) {
2659
- if (retryCount_1 < maxRetries) {
2820
+ if (retryCount_1 < maxRequestRetriesBeforeBackoff) {
2660
2821
  isRetrying = true;
2661
2822
  _doAction(function () {
2662
2823
  if (thePayload.sendType === 0 ) {
@@ -2667,6 +2828,9 @@
2667
2828
  }
2668
2829
  else {
2669
2830
  backOffTrans = true;
2831
+ if (_isUnloading) {
2832
+ reason = 8001 ;
2833
+ }
2670
2834
  }
2671
2835
  }
2672
2836
  }
@@ -2741,12 +2905,9 @@
2741
2905
  }
2742
2906
  function _getMsfpc(thePayload) {
2743
2907
  for (var lp = 0; lp < thePayload.batches.length; lp++) {
2744
- var batchEvents = thePayload.batches[lp].events();
2745
- for (var evtLp = 0; evtLp < batchEvents.length; evtLp++) {
2746
- var intWeb = ((batchEvents[evtLp].ext || {})["intweb"] || {});
2747
- if (isValueAssigned(intWeb["msfpc"])) {
2748
- return encodeURIComponent(intWeb["msfpc"]);
2749
- }
2908
+ var msfpc = thePayload.batches[lp].Msfpc();
2909
+ if (msfpc) {
2910
+ return encodeURIComponent(msfpc);
2750
2911
  }
2751
2912
  }
2752
2913
  return "";
@@ -2764,8 +2925,8 @@
2764
2925
  }
2765
2926
  if (responseText) {
2766
2927
  var response = JSON.parse(responseText);
2767
- if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult.msfpc)) {
2768
- _cookieMgr.set("MSFPC", response.webResult.msfpc, 365 * 86400);
2928
+ if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult[strMsfpc])) {
2929
+ _cookieMgr.set("MSFPC", response.webResult[strMsfpc], 365 * 86400);
2769
2930
  }
2770
2931
  }
2771
2932
  }
@@ -2810,25 +2971,27 @@
2810
2971
  }
2811
2972
  return HttpManager;
2812
2973
  }());
2813
- var HttpManager$1 = HttpManager;
2814
2974
 
2815
2975
  var FlushCheckTimer = 0.250;
2816
2976
  var MaxNumberEventPerBatch = 500;
2817
2977
  var EventsDroppedAtOneTime = 20;
2818
2978
  var MaxSendAttempts = 6;
2979
+ var MaxSyncUnloadSendAttempts = 2;
2819
2980
  var MaxBackoffCount = 4;
2820
2981
  var globalContext = isWindowObjectAvailable ? window : undefined;
2821
2982
  var MaxConnections = 2;
2822
- var MaxRetries = 1;
2983
+ var MaxRequestRetriesBeforeBackoff = 1;
2823
2984
  var strEventsDiscarded = "eventsDiscarded";
2824
2985
  var strOverrideInstrumentationKey = "overrideInstrumentationKey";
2986
+ var strMaxEventRetryAttempts = "maxEventRetryAttempts";
2987
+ var strMaxUnloadEventRetryAttempts = "maxUnloadEventRetryAttempts";
2825
2988
  var PostChannel = /** @class */ (function (_super) {
2826
2989
  __extendsFn(PostChannel, _super);
2827
2990
  function PostChannel() {
2828
2991
  var _this = _super.call(this) || this;
2829
2992
  _this.identifier = "PostChannel";
2830
2993
  _this.priority = 1011;
2831
- _this.version = '3.1.8';
2994
+ _this.version = '3.1.11';
2832
2995
  var _config;
2833
2996
  var _isTeardownCalled = false;
2834
2997
  var _flushCallbackQueue = [];
@@ -2853,11 +3016,14 @@
2853
3016
  var _delayedBatchReason;
2854
3017
  var _optimizeObject = true;
2855
3018
  var _isPageUnloadTriggered = false;
3019
+ var _disableXhrSync = false;
3020
+ var _maxEventSendAttempts = MaxSendAttempts;
3021
+ var _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
2856
3022
  dynamicProto(PostChannel, _this, function (_self, _base) {
2857
3023
  _initializeProfiles();
2858
3024
  _clearQueues();
2859
3025
  _setAutoLimits();
2860
- _httpManager = new HttpManager$1(MaxNumberEventPerBatch, MaxConnections, MaxRetries, {
3026
+ _httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {
2861
3027
  requeue: _requeueEvents,
2862
3028
  send: _sendingEvent,
2863
3029
  sent: _eventsSentEvent,
@@ -2879,14 +3045,7 @@
2879
3045
  _self._setTimeoutOverride = _config.setTimeoutOverride ? _config.setTimeoutOverride : setTimeout.bind(globalContext);
2880
3046
  _self._clearTimeoutOverride = _config.clearTimeoutOverride ? _config.clearTimeoutOverride : clearTimeout.bind(globalContext);
2881
3047
  _optimizeObject = !_config.disableOptimizeObj && isChromium();
2882
- var existingGetWParamMethod = extendedCore.getWParam;
2883
- extendedCore.getWParam = function () {
2884
- var wparam = 0;
2885
- if (_config.ignoreMc1Ms0CookieProcessing) {
2886
- wparam = wparam | 2;
2887
- }
2888
- return wparam | existingGetWParamMethod();
2889
- };
3048
+ _hookWParam(extendedCore);
2890
3049
  if (_config.eventsLimitInMem > 0) {
2891
3050
  _queueSizeLimit = _config.eventsLimitInMem;
2892
3051
  }
@@ -2896,6 +3055,13 @@
2896
3055
  if (_config.autoFlushEventsLimit > 0) {
2897
3056
  _autoFlushEventsLimit = _config.autoFlushEventsLimit;
2898
3057
  }
3058
+ _disableXhrSync = _config.disableXhrSync;
3059
+ if (isNumber(_config[strMaxEventRetryAttempts])) {
3060
+ _maxEventSendAttempts = _config[strMaxEventRetryAttempts];
3061
+ }
3062
+ if (isNumber(_config[strMaxUnloadEventRetryAttempts])) {
3063
+ _maxUnloadEventSendAttempts = _config[strMaxUnloadEventRetryAttempts];
3064
+ }
2899
3065
  _setAutoLimits();
2900
3066
  if (_config.httpXHROverride && _config.httpXHROverride.sendPOST) {
2901
3067
  _xhrOverride = _config.httpXHROverride;
@@ -2908,21 +3074,10 @@
2908
3074
  var endpointUrl = _config.overrideEndpointUrl ? _config.overrideEndpointUrl : coreConfig.endpointUrl;
2909
3075
  _self._notificationManager = coreConfig.extensionConfig.NotificationManager;
2910
3076
  _httpManager.initialize(endpointUrl, _self.core, _self, _xhrOverride, _config);
2911
- function _handleUnloadEvents(evt) {
2912
- var theEvt = evt || getWindow().event;
2913
- if (theEvt.type !== "beforeunload") {
2914
- _isPageUnloadTriggered = true;
2915
- _httpManager.setUnloading(_isPageUnloadTriggered);
2916
- }
2917
- _releaseAllQueues(2 , 2 );
2918
- }
2919
3077
  var excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || [];
2920
3078
  addPageUnloadEventListener(_handleUnloadEvents, excludePageUnloadEvents);
2921
3079
  addPageHideEventListener(_handleUnloadEvents, excludePageUnloadEvents);
2922
- addPageShowEventListener(function (evt) {
2923
- _isPageUnloadTriggered = false;
2924
- _httpManager.setUnloading(_isPageUnloadTriggered);
2925
- }, coreConfig.disablePageShowEvents);
3080
+ addPageShowEventListener(_handleShowEvents, coreConfig.disablePageShowEvents);
2926
3081
  _self.setInitialized(true);
2927
3082
  }, function () { return ({ coreConfig: coreConfig, core: core, extensions: extensions }); });
2928
3083
  };
@@ -2952,6 +3107,28 @@
2952
3107
  }
2953
3108
  _self.processNext(event, itemCtx);
2954
3109
  };
3110
+ function _hookWParam(extendedCore) {
3111
+ var existingGetWParamMethod = extendedCore.getWParam;
3112
+ extendedCore.getWParam = function () {
3113
+ var wparam = 0;
3114
+ if (_config.ignoreMc1Ms0CookieProcessing) {
3115
+ wparam = wparam | 2;
3116
+ }
3117
+ return wparam | existingGetWParamMethod();
3118
+ };
3119
+ }
3120
+ function _handleUnloadEvents(evt) {
3121
+ var theEvt = evt || getWindow().event;
3122
+ if (theEvt.type !== "beforeunload") {
3123
+ _isPageUnloadTriggered = true;
3124
+ _httpManager.setUnloading(_isPageUnloadTriggered);
3125
+ }
3126
+ _releaseAllQueues(2 , 2 );
3127
+ }
3128
+ function _handleShowEvents(evt) {
3129
+ _isPageUnloadTriggered = false;
3130
+ _httpManager.setUnloading(_isPageUnloadTriggered);
3131
+ }
2955
3132
  function _addEventToQueues(event, append) {
2956
3133
  if (!event.sendAttempt) {
2957
3134
  event.sendAttempt = 0;
@@ -3101,7 +3278,7 @@
3101
3278
  }
3102
3279
  };
3103
3280
  _self.setMsaAuthTicket = function (ticket) {
3104
- _httpManager.addHeader("AuthMsaDeviceTicket", ticket);
3281
+ _httpManager.addHeader(strMsaDeviceTicket, ticket);
3105
3282
  };
3106
3283
  _self.hasEvents = _hasEvents;
3107
3284
  _self._setTransmitProfile = function (profileName) {
@@ -3238,7 +3415,7 @@
3238
3415
  }
3239
3416
  var latency = event.latency;
3240
3417
  var eventBatch = _getEventBatch(event.iKey, latency, true);
3241
- if (eventBatch.addEvents([event], append)) {
3418
+ if (eventBatch.addEvent(event)) {
3242
3419
  if (latency !== EventLatency.Immediate) {
3243
3420
  _queueSize++;
3244
3421
  if (append && event.sendAttempt === 0) {
@@ -3381,6 +3558,10 @@
3381
3558
  }
3382
3559
  function _requeueEvents(batches, reason) {
3383
3560
  var droppedEvents = [];
3561
+ var maxSendAttempts = _maxEventSendAttempts;
3562
+ if (_isPageUnloadTriggered) {
3563
+ maxSendAttempts = _maxUnloadEventSendAttempts;
3564
+ }
3384
3565
  arrForEach(batches, function (theBatch) {
3385
3566
  if (theBatch && theBatch.count() > 0) {
3386
3567
  arrForEach(theBatch.events(), function (theEvent) {
@@ -3389,7 +3570,7 @@
3389
3570
  theEvent.latency = EventLatency.Immediate;
3390
3571
  theEvent.sync = false;
3391
3572
  }
3392
- if (theEvent.sendAttempt < MaxSendAttempts) {
3573
+ if (theEvent.sendAttempt < maxSendAttempts) {
3393
3574
  setProcessTelemetryTimings(theEvent, _self.identifier);
3394
3575
  _addEventToQueues(theEvent, false);
3395
3576
  }
@@ -3488,4 +3669,4 @@
3488
3669
  (function(obj, prop, descriptor) { /* ai_es3_polyfil defineProperty */ var func = Object["defineProperty"]; if (func) { try { return func(obj, prop, descriptor); } catch(e) { /* IE8 defines defineProperty, but will throw */ } } if (descriptor && typeof descriptor.value !== undefined) { obj[prop] = descriptor.value; } return obj; })(exports, '__esModule', { value: true });
3489
3670
 
3490
3671
  })(this.oneDS = this.oneDS || {});
3491
- //# sourceMappingURL=ms.post-3.1.8.gbl.js.map
3672
+ //# sourceMappingURL=ms.post-3.1.11.gbl.js.map