@microsoft/1ds-post-js 4.1.1-nightly3.2403-02 → 4.1.1-nightly3.2403-04

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 (50) hide show
  1. package/bundle/es5/{ms.post-4.1.1-nightly3.2403-02.gbl.js → ms.post-4.1.1-nightly3.2403-04.gbl.js} +1145 -711
  2. package/bundle/es5/ms.post-4.1.1-nightly3.2403-04.gbl.js.map +1 -0
  3. package/bundle/es5/ms.post-4.1.1-nightly3.2403-04.gbl.min.js +7 -0
  4. package/bundle/es5/ms.post-4.1.1-nightly3.2403-04.gbl.min.js.map +1 -0
  5. package/bundle/es5/ms.post-4.1.1-nightly3.2403-04.integrity.json +46 -0
  6. package/bundle/es5/{ms.post-4.1.1-nightly3.2403-02.js → ms.post-4.1.1-nightly3.2403-04.js} +1145 -711
  7. package/bundle/es5/ms.post-4.1.1-nightly3.2403-04.js.map +1 -0
  8. package/bundle/es5/ms.post-4.1.1-nightly3.2403-04.min.js +7 -0
  9. package/bundle/es5/ms.post-4.1.1-nightly3.2403-04.min.js.map +1 -0
  10. package/bundle/es5/ms.post.gbl.js +1144 -710
  11. package/bundle/es5/ms.post.gbl.js.map +1 -1
  12. package/bundle/es5/ms.post.gbl.min.js +2 -2
  13. package/bundle/es5/ms.post.gbl.min.js.map +1 -1
  14. package/bundle/es5/ms.post.integrity.json +17 -17
  15. package/bundle/es5/ms.post.js +1144 -710
  16. package/bundle/es5/ms.post.js.map +1 -1
  17. package/bundle/es5/ms.post.min.js +2 -2
  18. package/bundle/es5/ms.post.min.js.map +1 -1
  19. package/dist/es5/ms.post.js +1142 -708
  20. package/dist/es5/ms.post.js.map +1 -1
  21. package/dist/es5/ms.post.min.js +2 -2
  22. package/dist/es5/ms.post.min.js.map +1 -1
  23. package/dist-es5/BatchNotificationActions.js +1 -1
  24. package/dist-es5/ClockSkewManager.js +1 -1
  25. package/dist-es5/DataModels.js +1 -1
  26. package/dist-es5/EventBatch.js +1 -1
  27. package/dist-es5/HttpManager.js +123 -279
  28. package/dist-es5/HttpManager.js.map +1 -1
  29. package/dist-es5/Index.js +1 -1
  30. package/dist-es5/InternalConstants.js +1 -1
  31. package/dist-es5/KillSwitch.js +3 -3
  32. package/dist-es5/KillSwitch.js.map +1 -1
  33. package/dist-es5/PostChannel.js +34 -26
  34. package/dist-es5/PostChannel.js.map +1 -1
  35. package/dist-es5/RetryPolicy.js +1 -1
  36. package/dist-es5/Serializer.js +1 -1
  37. package/dist-es5/TimeoutOverrideWrapper.js +1 -1
  38. package/dist-es5/__DynamicConstants.js +21 -25
  39. package/dist-es5/__DynamicConstants.js.map +1 -1
  40. package/dist-es5/typings/XDomainRequest.js +1 -1
  41. package/package.json +2 -2
  42. package/types/1ds-post-js.d.ts +1 -1
  43. package/types/1ds-post-js.namespaced.d.ts +1 -1
  44. package/bundle/es5/ms.post-4.1.1-nightly3.2403-02.gbl.js.map +0 -1
  45. package/bundle/es5/ms.post-4.1.1-nightly3.2403-02.gbl.min.js +0 -7
  46. package/bundle/es5/ms.post-4.1.1-nightly3.2403-02.gbl.min.js.map +0 -1
  47. package/bundle/es5/ms.post-4.1.1-nightly3.2403-02.integrity.json +0 -46
  48. package/bundle/es5/ms.post-4.1.1-nightly3.2403-02.js.map +0 -1
  49. package/bundle/es5/ms.post-4.1.1-nightly3.2403-02.min.js +0 -7
  50. package/bundle/es5/ms.post-4.1.1-nightly3.2403-02.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * 1DS JS SDK POST plugin, 4.1.1-nightly3.2403-02
2
+ * 1DS JS SDK POST plugin, 4.1.1-nightly3.2403-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -1134,6 +1134,7 @@
1134
1134
  var _DYN_UPDATE = "update";
1135
1135
  var _DYN_GET_NEXT = "getNext";
1136
1136
  var _DYN_SET_NEXT_PLUGIN = "setNextPlugin";
1137
+ var _DYN_PROTOCOL = "protocol";
1137
1138
  var _DYN_USER_AGENT = "userAgent";
1138
1139
  var _DYN_SPLIT$1 = "split";
1139
1140
  var _DYN_NODE_TYPE = "nodeType";
@@ -1141,10 +1142,19 @@
1141
1142
  var _DYN_LOG_INTERNAL_MESSAGE = "logInternalMessage";
1142
1143
  var _DYN_TYPE = "type";
1143
1144
  var _DYN_HANDLER = "handler";
1145
+ var _DYN_STATUS = "status";
1146
+ var _DYN_GET_RESPONSE_HEADER = "getResponseHeader";
1147
+ var _DYN_GET_ALL_RESPONSE_HEA5 = "getAllResponseHeaders";
1144
1148
  var _DYN_IS_CHILD_EVT = "isChildEvt";
1149
+ var _DYN_DATA$1 = "data";
1145
1150
  var _DYN_GET_CTX = "getCtx";
1146
1151
  var _DYN_SET_CTX = "setCtx";
1147
1152
  var _DYN_COMPLETE = "complete";
1153
+ var _DYN_URL_STRING$1 = "urlString";
1154
+ var _DYN_SEND_POST = "sendPOST";
1155
+ var _DYN_HEADERS$1 = "headers";
1156
+ var _DYN_TIMEOUT = "timeout";
1157
+ var _DYN_SET_REQUEST_HEADER = "setRequestHeader";
1148
1158
 
1149
1159
  var aggregationErrorType;
1150
1160
  function throwAggregationError(message, sourceErrors) {
@@ -1162,6 +1172,60 @@
1162
1172
  throw new aggregationErrorType(theMessage, sourceErrors || []);
1163
1173
  }
1164
1174
 
1175
+ function doAwaitResponse(value, cb) {
1176
+ return doAwait(value, function (value) {
1177
+ return cb ? cb({
1178
+ value: value,
1179
+ rejected: false
1180
+ }) : value;
1181
+ }, function (reason) {
1182
+ return cb ? cb({
1183
+ rejected: true,
1184
+ reason: reason
1185
+ }) : reason;
1186
+ });
1187
+ }
1188
+ function doAwait(value, resolveFn, rejectFn, finallyFn) {
1189
+ var result = value;
1190
+ if (isPromiseLike(value)) {
1191
+ if (resolveFn || rejectFn) {
1192
+ result = value.then(resolveFn, rejectFn);
1193
+ }
1194
+ }
1195
+ else {
1196
+ if (resolveFn) {
1197
+ result = resolveFn(value);
1198
+ }
1199
+ }
1200
+ if (finallyFn) {
1201
+ doFinally(result, finallyFn);
1202
+ }
1203
+ return result;
1204
+ }
1205
+ function doFinally(value, finallyFn) {
1206
+ var result = value;
1207
+ if (finallyFn) {
1208
+ if (isPromiseLike(value)) {
1209
+ if (value.finally) {
1210
+ result = value.finally(finallyFn);
1211
+ }
1212
+ else {
1213
+ result = value.then(function (value) {
1214
+ finallyFn();
1215
+ return value;
1216
+ }, function (reason) {
1217
+ finallyFn();
1218
+ throw reason;
1219
+ });
1220
+ }
1221
+ }
1222
+ else {
1223
+ finallyFn();
1224
+ }
1225
+ }
1226
+ return result;
1227
+ }
1228
+
1165
1229
  var STRING_STATES = [
1166
1230
  "pending", "resolving", "resolved", "rejected"
1167
1231
  ];
@@ -1409,7 +1473,7 @@
1409
1473
  }
1410
1474
 
1411
1475
  var UNDEFINED_VALUE = undefined;
1412
- var STR_EMPTY$2 = "";
1476
+ var STR_EMPTY$3 = "";
1413
1477
  var STR_CORE = "core";
1414
1478
  var STR_DISABLED = "disabled";
1415
1479
  var STR_EXTENSION_CONFIG = "extensionConfig";
@@ -1418,72 +1482,20 @@
1418
1482
  var STR_GET_PERF_MGR = "getPerfMgr";
1419
1483
  var STR_NOT_DYNAMIC_ERROR = "Not dynamic - ";
1420
1484
 
1421
- var rCamelCase = /-([a-z])/g;
1422
- var rNormalizeInvalid = /([^\w\d_$])/g;
1423
- var rLeadingNumeric = /^(\d+[\w\d_$])/;
1424
- function isNotNullOrUndefined(value) {
1425
- return !isNullOrUndefined(value);
1426
- }
1427
- function normalizeJsName(name) {
1428
- var value = name;
1429
- if (value && isString(value)) {
1430
- value = value[_DYN_REPLACE ](rCamelCase, function (_all, letter) {
1431
- return letter.toUpperCase();
1432
- });
1433
- value = value[_DYN_REPLACE ](rNormalizeInvalid, "_");
1434
- value = value[_DYN_REPLACE ](rLeadingNumeric, function (_all, match) {
1435
- return "_" + match;
1436
- });
1437
- }
1438
- return value;
1439
- }
1440
- function strContains(value, search) {
1441
- if (value && search) {
1442
- return strIndexOf(value, search) !== -1;
1443
- }
1444
- return false;
1445
- }
1446
- function _createProxyFunction(source, funcName) {
1447
- var srcFunc = null;
1448
- var src = null;
1449
- if (isFunction(source)) {
1450
- srcFunc = source;
1451
- }
1452
- else {
1453
- src = source;
1454
- }
1455
- return function () {
1456
- var originalArguments = arguments;
1457
- if (srcFunc) {
1458
- src = srcFunc();
1459
- }
1460
- if (src) {
1461
- return src[funcName][_DYN_APPLY ](src, originalArguments);
1462
- }
1463
- };
1464
- }
1465
- function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
1466
- if (target && name && source) {
1467
- if (overwriteTarget !== false || isUndefined(target[name])) {
1468
- target[name] = _createProxyFunction(source, theFunc);
1469
- }
1470
- }
1471
- }
1472
- function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
1473
- if (target && source && isObject(target) && isArray(functionsToProxy)) {
1474
- arrForEach(functionsToProxy, function (theFuncName) {
1475
- if (isString(theFuncName)) {
1476
- proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
1477
- }
1478
- });
1485
+ var _aiNamespace = null;
1486
+ function _getExtensionNamespace() {
1487
+ var target = getInst("Microsoft");
1488
+ if (target) {
1489
+ _aiNamespace = target["ApplicationInsights"];
1479
1490
  }
1480
- return target;
1491
+ return _aiNamespace;
1481
1492
  }
1482
- function optimizeObject(theObject) {
1483
- if (theObject && objAssign) {
1484
- theObject = ObjClass$1(objAssign({}, theObject));
1493
+ function getDebugExt(config) {
1494
+ var ns = _aiNamespace;
1495
+ if (!ns && config.disableDbgExt !== true) {
1496
+ ns = _aiNamespace || _getExtensionNamespace();
1485
1497
  }
1486
- return theObject;
1498
+ return ns ? ns["ChromeDbgExt"] : null;
1487
1499
  }
1488
1500
 
1489
1501
  var strLocation = "location";
@@ -1563,54 +1575,413 @@
1563
1575
  if (nav && nav.product) {
1564
1576
  return nav.product === strReactNative;
1565
1577
  }
1566
- return false;
1567
- }
1568
- function isIE() {
1569
- var nav = getNavigator();
1570
- if (nav && (nav[_DYN_USER_AGENT ] !== _navUserAgentCheck || _isTrident === null)) {
1571
- _navUserAgentCheck = nav[_DYN_USER_AGENT ];
1572
- var userAgent = (_navUserAgentCheck || STR_EMPTY$2)[_DYN_TO_LOWER_CASE$1 ]();
1573
- _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1578
+ return false;
1579
+ }
1580
+ function isIE() {
1581
+ var nav = getNavigator();
1582
+ if (nav && (nav[_DYN_USER_AGENT ] !== _navUserAgentCheck || _isTrident === null)) {
1583
+ _navUserAgentCheck = nav[_DYN_USER_AGENT ];
1584
+ var userAgent = (_navUserAgentCheck || STR_EMPTY$3)[_DYN_TO_LOWER_CASE$1 ]();
1585
+ _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1586
+ }
1587
+ return _isTrident;
1588
+ }
1589
+ function isBeaconsSupported(useCached) {
1590
+ if (_beaconsSupported === null || useCached === false) {
1591
+ _beaconsSupported = hasNavigator() && Boolean(getNavigator().sendBeacon);
1592
+ }
1593
+ return _beaconsSupported;
1594
+ }
1595
+ function isFetchSupported(withKeepAlive) {
1596
+ var isSupported = false;
1597
+ try {
1598
+ isSupported = !!getInst("fetch");
1599
+ var request = getInst("Request");
1600
+ if (isSupported && withKeepAlive && request) {
1601
+ isSupported = _hasProperty(request, "keepalive");
1602
+ }
1603
+ }
1604
+ catch (e) {
1605
+ }
1606
+ return isSupported;
1607
+ }
1608
+ function useXDomainRequest() {
1609
+ if (_useXDomainRequest === null) {
1610
+ _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
1611
+ if (_useXDomainRequest && isXhrSupported()) {
1612
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getInst(strXMLHttpRequest), "withCredentials");
1613
+ }
1614
+ }
1615
+ return _useXDomainRequest;
1616
+ }
1617
+ function isXhrSupported() {
1618
+ var isSupported = false;
1619
+ try {
1620
+ var xmlHttpRequest = getInst(strXMLHttpRequest);
1621
+ isSupported = !!xmlHttpRequest;
1622
+ }
1623
+ catch (e) {
1624
+ }
1625
+ return isSupported;
1626
+ }
1627
+
1628
+ var _a$3;
1629
+ var STR_WARN_TO_CONSOLE = "warnToConsole";
1630
+ var AiNonUserActionablePrefix = "AI (Internal): ";
1631
+ var AiUserActionablePrefix = "AI: ";
1632
+ var AIInternalMessagePrefix = "AITR_";
1633
+ var defaultValues$1 = {
1634
+ loggingLevelConsole: 0,
1635
+ loggingLevelTelemetry: 1,
1636
+ maxMessageLimit: 25,
1637
+ enableDebug: false
1638
+ };
1639
+ var _logFuncs = (_a$3 = {},
1640
+ _a$3[0 ] = null,
1641
+ _a$3[1 ] = "errorToConsole",
1642
+ _a$3[2 ] = STR_WARN_TO_CONSOLE,
1643
+ _a$3[3 ] = "debugToConsole",
1644
+ _a$3);
1645
+ function _sanitizeDiagnosticText(text) {
1646
+ if (text) {
1647
+ return "\"" + text[_DYN_REPLACE ](/\"/g, STR_EMPTY$3) + "\"";
1648
+ }
1649
+ return STR_EMPTY$3;
1650
+ }
1651
+ function _logToConsole(func, message) {
1652
+ var theConsole = getConsole();
1653
+ if (!!theConsole) {
1654
+ var logFunc = "log";
1655
+ if (theConsole[func]) {
1656
+ logFunc = func;
1657
+ }
1658
+ if (isFunction(theConsole[logFunc])) {
1659
+ theConsole[logFunc](message);
1660
+ }
1661
+ }
1662
+ }
1663
+ var _InternalLogMessage = /** @class */ (function () {
1664
+ function _InternalLogMessage(msgId, msg, isUserAct, properties) {
1665
+ if (isUserAct === void 0) { isUserAct = false; }
1666
+ var _self = this;
1667
+ _self[_DYN_MESSAGE_ID ] = msgId;
1668
+ _self[_DYN_MESSAGE ] =
1669
+ (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
1670
+ msgId;
1671
+ var strProps = STR_EMPTY$3;
1672
+ if (hasJSON()) {
1673
+ strProps = getJSON().stringify(properties);
1674
+ }
1675
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : STR_EMPTY$3) +
1676
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : STR_EMPTY$3);
1677
+ _self[_DYN_MESSAGE ] += diagnosticText;
1678
+ }
1679
+ _InternalLogMessage.dataType = "MessageData";
1680
+ return _InternalLogMessage;
1681
+ }());
1682
+ function safeGetLogger(core, config) {
1683
+ return (core || {})[_DYN_LOGGER ] || new DiagnosticLogger(config);
1684
+ }
1685
+ var DiagnosticLogger = /** @class */ (function () {
1686
+ function DiagnosticLogger(config) {
1687
+ this.identifier = "DiagnosticLogger";
1688
+ this.queue = [];
1689
+ var _messageCount = 0;
1690
+ var _messageLogged = {};
1691
+ var _loggingLevelConsole;
1692
+ var _loggingLevelTelemetry;
1693
+ var _maxInternalMessageLimit;
1694
+ var _enableDebug;
1695
+ var _unloadHandler;
1696
+ dynamicProto(DiagnosticLogger, this, function (_self) {
1697
+ _unloadHandler = _setDefaultsFromConfig(config || {});
1698
+ _self.consoleLoggingLevel = function () { return _loggingLevelConsole; };
1699
+ _self[_DYN_THROW_INTERNAL ] = function (severity, msgId, msg, properties, isUserAct) {
1700
+ if (isUserAct === void 0) { isUserAct = false; }
1701
+ var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
1702
+ if (_enableDebug) {
1703
+ throw dumpObj(message);
1704
+ }
1705
+ else {
1706
+ var logFunc = _logFuncs[severity] || STR_WARN_TO_CONSOLE;
1707
+ if (!isUndefined(message[_DYN_MESSAGE ])) {
1708
+ if (isUserAct) {
1709
+ var messageKey = +message[_DYN_MESSAGE_ID ];
1710
+ if (!_messageLogged[messageKey] && _loggingLevelConsole >= severity) {
1711
+ _self[logFunc](message[_DYN_MESSAGE ]);
1712
+ _messageLogged[messageKey] = true;
1713
+ }
1714
+ }
1715
+ else {
1716
+ if (_loggingLevelConsole >= severity) {
1717
+ _self[logFunc](message[_DYN_MESSAGE ]);
1718
+ }
1719
+ }
1720
+ _logInternalMessage(severity, message);
1721
+ }
1722
+ else {
1723
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1724
+ }
1725
+ }
1726
+ };
1727
+ _self.debugToConsole = function (message) {
1728
+ _logToConsole("debug", message);
1729
+ _debugExtMsg("warning", message);
1730
+ };
1731
+ _self[_DYN_WARN_TO_CONSOLE ] = function (message) {
1732
+ _logToConsole("warn", message);
1733
+ _debugExtMsg("warning", message);
1734
+ };
1735
+ _self.errorToConsole = function (message) {
1736
+ _logToConsole("error", message);
1737
+ _debugExtMsg("error", message);
1738
+ };
1739
+ _self.resetInternalMessageCount = function () {
1740
+ _messageCount = 0;
1741
+ _messageLogged = {};
1742
+ };
1743
+ _self[_DYN_LOG_INTERNAL_MESSAGE ] = _logInternalMessage;
1744
+ _self[_DYN_UNLOAD ] = function (isAsync) {
1745
+ _unloadHandler && _unloadHandler.rm();
1746
+ _unloadHandler = null;
1747
+ };
1748
+ function _logInternalMessage(severity, message) {
1749
+ if (_areInternalMessagesThrottled()) {
1750
+ return;
1751
+ }
1752
+ var logMessage = true;
1753
+ var messageKey = AIInternalMessagePrefix + message[_DYN_MESSAGE_ID ];
1754
+ if (_messageLogged[messageKey]) {
1755
+ logMessage = false;
1756
+ }
1757
+ else {
1758
+ _messageLogged[messageKey] = true;
1759
+ }
1760
+ if (logMessage) {
1761
+ if (severity <= _loggingLevelTelemetry) {
1762
+ _self.queue[_DYN_PUSH$1 ](message);
1763
+ _messageCount++;
1764
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1765
+ }
1766
+ if (_messageCount === _maxInternalMessageLimit) {
1767
+ var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1768
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1769
+ _self.queue[_DYN_PUSH$1 ](throttleMessage);
1770
+ if (severity === 1 ) {
1771
+ _self.errorToConsole(throttleLimitMessage);
1772
+ }
1773
+ else {
1774
+ _self[_DYN_WARN_TO_CONSOLE ](throttleLimitMessage);
1775
+ }
1776
+ }
1777
+ }
1778
+ }
1779
+ function _setDefaultsFromConfig(config) {
1780
+ return onConfigChange(createDynamicConfig(config, defaultValues$1, _self).cfg, function (details) {
1781
+ var config = details.cfg;
1782
+ _loggingLevelConsole = config[_DYN_LOGGING_LEVEL_CONSOL4 ];
1783
+ _loggingLevelTelemetry = config.loggingLevelTelemetry;
1784
+ _maxInternalMessageLimit = config.maxMessageLimit;
1785
+ _enableDebug = config.enableDebug;
1786
+ });
1787
+ }
1788
+ function _areInternalMessagesThrottled() {
1789
+ return _messageCount >= _maxInternalMessageLimit;
1790
+ }
1791
+ function _debugExtMsg(name, data) {
1792
+ var dbgExt = getDebugExt(config || {});
1793
+ if (dbgExt && dbgExt[_DYN_DIAG_LOG ]) {
1794
+ dbgExt[_DYN_DIAG_LOG ](name, data);
1795
+ }
1796
+ }
1797
+ });
1798
+ }
1799
+ DiagnosticLogger.__ieDyn=1;
1800
+ return DiagnosticLogger;
1801
+ }());
1802
+ function _getLogger(logger) {
1803
+ return (logger || new DiagnosticLogger());
1804
+ }
1805
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1806
+ if (isUserAct === void 0) { isUserAct = false; }
1807
+ _getLogger(logger)[_DYN_THROW_INTERNAL ](severity, msgId, msg, properties, isUserAct);
1808
+ }
1809
+ function _warnToConsole(logger, message) {
1810
+ _getLogger(logger)[_DYN_WARN_TO_CONSOLE ](message);
1811
+ }
1812
+
1813
+ var rCamelCase = /-([a-z])/g;
1814
+ var rNormalizeInvalid = /([^\w\d_$])/g;
1815
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
1816
+ function isNotNullOrUndefined(value) {
1817
+ return !isNullOrUndefined(value);
1818
+ }
1819
+ function normalizeJsName(name) {
1820
+ var value = name;
1821
+ if (value && isString(value)) {
1822
+ value = value[_DYN_REPLACE ](rCamelCase, function (_all, letter) {
1823
+ return letter.toUpperCase();
1824
+ });
1825
+ value = value[_DYN_REPLACE ](rNormalizeInvalid, "_");
1826
+ value = value[_DYN_REPLACE ](rLeadingNumeric, function (_all, match) {
1827
+ return "_" + match;
1828
+ });
1829
+ }
1830
+ return value;
1831
+ }
1832
+ function strContains(value, search) {
1833
+ if (value && search) {
1834
+ return strIndexOf(value, search) !== -1;
1835
+ }
1836
+ return false;
1837
+ }
1838
+ function _createProxyFunction(source, funcName) {
1839
+ var srcFunc = null;
1840
+ var src = null;
1841
+ if (isFunction(source)) {
1842
+ srcFunc = source;
1843
+ }
1844
+ else {
1845
+ src = source;
1846
+ }
1847
+ return function () {
1848
+ var originalArguments = arguments;
1849
+ if (srcFunc) {
1850
+ src = srcFunc();
1851
+ }
1852
+ if (src) {
1853
+ return src[funcName][_DYN_APPLY ](src, originalArguments);
1854
+ }
1855
+ };
1856
+ }
1857
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
1858
+ if (target && name && source) {
1859
+ if (overwriteTarget !== false || isUndefined(target[name])) {
1860
+ target[name] = _createProxyFunction(source, theFunc);
1861
+ }
1862
+ }
1863
+ }
1864
+ function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
1865
+ if (target && source && isObject(target) && isArray(functionsToProxy)) {
1866
+ arrForEach(functionsToProxy, function (theFuncName) {
1867
+ if (isString(theFuncName)) {
1868
+ proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
1869
+ }
1870
+ });
1871
+ }
1872
+ return target;
1873
+ }
1874
+ function optimizeObject(theObject) {
1875
+ if (theObject && objAssign) {
1876
+ theObject = ObjClass$1(objAssign({}, theObject));
1877
+ }
1878
+ return theObject;
1879
+ }
1880
+ function getResponseText(xhr) {
1881
+ try {
1882
+ return xhr.responseText;
1883
+ }
1884
+ catch (e) {
1885
+ }
1886
+ return null;
1887
+ }
1888
+ function formatErrorMessageXdr(xdr, message) {
1889
+ if (xdr) {
1890
+ return "XDomainRequest,Response:" + getResponseText(xdr) || "";
1891
+ }
1892
+ return message;
1893
+ }
1894
+ function formatErrorMessageXhr(xhr, message) {
1895
+ if (xhr) {
1896
+ return "XMLHttpRequest,Status:" + xhr[_DYN_STATUS ] + ",Response:" + getResponseText(xhr) || xhr.response || "";
1897
+ }
1898
+ return message;
1899
+ }
1900
+ function prependTransports(theTransports, newTransports) {
1901
+ if (newTransports) {
1902
+ if (isNumber(newTransports)) {
1903
+ theTransports = [newTransports].concat(theTransports);
1904
+ }
1905
+ else if (isArray(newTransports)) {
1906
+ theTransports = newTransports.concat(theTransports);
1907
+ }
1908
+ }
1909
+ return theTransports;
1910
+ }
1911
+ var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
1912
+ var strWithCredentials = "withCredentials";
1913
+ var strTimeout = "timeout";
1914
+ function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {
1915
+ if (disabled === void 0) { disabled = false; }
1916
+ if (isSync === void 0) { isSync = false; }
1917
+ function _wrapSetXhrProp(xhr, prop, value) {
1918
+ try {
1919
+ xhr[prop] = value;
1920
+ }
1921
+ catch (e) {
1922
+ }
1923
+ }
1924
+ var xhr = new XMLHttpRequest();
1925
+ if (disabled) {
1926
+ _wrapSetXhrProp(xhr, strDisabledPropertyName, disabled);
1927
+ }
1928
+ if (withCredentials) {
1929
+ _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
1930
+ }
1931
+ xhr.open(method, urlString, !isSync);
1932
+ if (withCredentials) {
1933
+ _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
1934
+ }
1935
+ if (!isSync && timeout) {
1936
+ _wrapSetXhrProp(xhr, strTimeout, timeout);
1574
1937
  }
1575
- return _isTrident;
1938
+ return xhr;
1576
1939
  }
1577
- function isBeaconsSupported(useCached) {
1578
- if (_beaconsSupported === null || useCached === false) {
1579
- _beaconsSupported = hasNavigator() && Boolean(getNavigator().sendBeacon);
1940
+ function convertAllHeadersToMap(headersString) {
1941
+ var headers = {};
1942
+ if (isString(headersString)) {
1943
+ var headersArray = strTrim(headersString)[_DYN_SPLIT$1 ](/[\r\n]+/);
1944
+ arrForEach(headersArray, function (headerEntry) {
1945
+ if (headerEntry) {
1946
+ var idx = headerEntry.indexOf(": ");
1947
+ if (idx !== -1) {
1948
+ var header = strTrim(headerEntry.substring(0, idx))[_DYN_TO_LOWER_CASE$1 ]();
1949
+ var value = strTrim(headerEntry.substring(idx + 1));
1950
+ headers[header] = value;
1951
+ }
1952
+ else {
1953
+ headers[strTrim(headerEntry)] = 1;
1954
+ }
1955
+ }
1956
+ });
1580
1957
  }
1581
- return _beaconsSupported;
1958
+ return headers;
1582
1959
  }
1583
- function isFetchSupported(withKeepAlive) {
1584
- var isSupported = false;
1585
- try {
1586
- isSupported = !!getInst("fetch");
1587
- var request = getInst("Request");
1588
- if (isSupported && withKeepAlive && request) {
1589
- isSupported = _hasProperty(request, "keepalive");
1960
+ function _appendHeader(theHeaders, xhr, name) {
1961
+ if (!theHeaders[name] && xhr && xhr[_DYN_GET_RESPONSE_HEADER ]) {
1962
+ var value = xhr[_DYN_GET_RESPONSE_HEADER ](name);
1963
+ if (value) {
1964
+ theHeaders[name] = strTrim(value);
1590
1965
  }
1591
1966
  }
1592
- catch (e) {
1593
- }
1594
- return isSupported;
1967
+ return theHeaders;
1595
1968
  }
1596
- function useXDomainRequest() {
1597
- if (_useXDomainRequest === null) {
1598
- _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
1599
- if (_useXDomainRequest && isXhrSupported()) {
1600
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getInst(strXMLHttpRequest), "withCredentials");
1969
+ var STR_KILL_DURATION_HEADER$1 = "kill-duration";
1970
+ var STR_KILL_DURATION_SECONDS_HEADER = "kill-duration-seconds";
1971
+ var STR_TIME_DELTA_HEADER$1 = "time-delta-millis";
1972
+ function _getAllResponseHeaders(xhr, isOneDs) {
1973
+ var theHeaders = {};
1974
+ if (!xhr[_DYN_GET_ALL_RESPONSE_HEA5 ]) {
1975
+ if (!!isOneDs) {
1976
+ theHeaders = _appendHeader(theHeaders, xhr, STR_TIME_DELTA_HEADER$1);
1977
+ theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_HEADER$1);
1978
+ theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_SECONDS_HEADER);
1601
1979
  }
1602
1980
  }
1603
- return _useXDomainRequest;
1604
- }
1605
- function isXhrSupported() {
1606
- var isSupported = false;
1607
- try {
1608
- var xmlHttpRequest = getInst(strXMLHttpRequest);
1609
- isSupported = !!xmlHttpRequest;
1610
- }
1611
- catch (e) {
1981
+ else {
1982
+ theHeaders = convertAllHeadersToMap(xhr[_DYN_GET_ALL_RESPONSE_HEA5 ]());
1612
1983
  }
1613
- return isSupported;
1984
+ return theHeaders;
1614
1985
  }
1615
1986
 
1616
1987
  var UInt32Mask = 0x100000000;
@@ -1670,7 +2041,7 @@
1670
2041
  var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1671
2042
  var number = random32() >>> 0;
1672
2043
  var chars = 0;
1673
- var result = STR_EMPTY$2;
2044
+ var result = STR_EMPTY$3;
1674
2045
  while (result[_DYN_LENGTH$2 ] < maxLength) {
1675
2046
  chars++;
1676
2047
  result += base64chars.charAt(number & 0x3F);
@@ -1708,11 +2079,11 @@
1708
2079
  }
1709
2080
  function createUniqueNamespace(name, includeVersion) {
1710
2081
  if (includeVersion === void 0) { includeVersion = false; }
1711
- return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : STR_EMPTY$2) + instanceName);
2082
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : STR_EMPTY$3) + instanceName);
1712
2083
  }
1713
2084
  function createElmNodeData(name) {
1714
2085
  var data = {
1715
- id: createUniqueNamespace("_aiData-" + (name || STR_EMPTY$2) + "." + version),
2086
+ id: createUniqueNamespace("_aiData-" + (name || STR_EMPTY$3) + "." + version),
1716
2087
  accept: function (target) {
1717
2088
  return _canAcceptData(target);
1718
2089
  },
@@ -2333,226 +2704,27 @@
2333
2704
  logger[_DYN_THROW_INTERNAL ](2 , 108 , message);
2334
2705
  }
2335
2706
  else {
2336
- throwInvalidAccess(message);
2337
- }
2338
- }
2339
- function createDynamicConfig(config, defaultConfig, logger, inPlace) {
2340
- var dynamicHandler = _createDynamicHandler(logger, config || {}, inPlace);
2341
- if (defaultConfig) {
2342
- dynamicHandler[_DYN_SET_DF ](dynamicHandler.cfg, defaultConfig);
2343
- }
2344
- return dynamicHandler;
2345
- }
2346
- function onConfigChange(config, configHandler, logger) {
2347
- var handler = config[CFG_HANDLER_LINK] || config;
2348
- if (handler.cfg && (handler.cfg === config || handler.cfg[CFG_HANDLER_LINK] === handler)) {
2349
- return handler[_DYN_WATCH ](configHandler);
2350
- }
2351
- _logInvalidAccess(logger, STR_NOT_DYNAMIC_ERROR + dumpObj(config));
2352
- return createDynamicConfig(config, null, logger)[_DYN_WATCH ](configHandler);
2353
- }
2354
-
2355
- var _aiNamespace = null;
2356
- function _getExtensionNamespace() {
2357
- var target = getInst("Microsoft");
2358
- if (target) {
2359
- _aiNamespace = target["ApplicationInsights"];
2360
- }
2361
- return _aiNamespace;
2362
- }
2363
- function getDebugExt(config) {
2364
- var ns = _aiNamespace;
2365
- if (!ns && config.disableDbgExt !== true) {
2366
- ns = _aiNamespace || _getExtensionNamespace();
2367
- }
2368
- return ns ? ns["ChromeDbgExt"] : null;
2369
- }
2370
-
2371
- var _a$3;
2372
- var STR_WARN_TO_CONSOLE = "warnToConsole";
2373
- var AiNonUserActionablePrefix = "AI (Internal): ";
2374
- var AiUserActionablePrefix = "AI: ";
2375
- var AIInternalMessagePrefix = "AITR_";
2376
- var defaultValues$1 = {
2377
- loggingLevelConsole: 0,
2378
- loggingLevelTelemetry: 1,
2379
- maxMessageLimit: 25,
2380
- enableDebug: false
2381
- };
2382
- var _logFuncs = (_a$3 = {},
2383
- _a$3[0 ] = null,
2384
- _a$3[1 ] = "errorToConsole",
2385
- _a$3[2 ] = STR_WARN_TO_CONSOLE,
2386
- _a$3[3 ] = "debugToConsole",
2387
- _a$3);
2388
- function _sanitizeDiagnosticText(text) {
2389
- if (text) {
2390
- return "\"" + text[_DYN_REPLACE ](/\"/g, STR_EMPTY$2) + "\"";
2391
- }
2392
- return STR_EMPTY$2;
2393
- }
2394
- function _logToConsole(func, message) {
2395
- var theConsole = getConsole();
2396
- if (!!theConsole) {
2397
- var logFunc = "log";
2398
- if (theConsole[func]) {
2399
- logFunc = func;
2400
- }
2401
- if (isFunction(theConsole[logFunc])) {
2402
- theConsole[logFunc](message);
2403
- }
2404
- }
2405
- }
2406
- var _InternalLogMessage = /** @class */ (function () {
2407
- function _InternalLogMessage(msgId, msg, isUserAct, properties) {
2408
- if (isUserAct === void 0) { isUserAct = false; }
2409
- var _self = this;
2410
- _self[_DYN_MESSAGE_ID ] = msgId;
2411
- _self[_DYN_MESSAGE ] =
2412
- (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
2413
- msgId;
2414
- var strProps = STR_EMPTY$2;
2415
- if (hasJSON()) {
2416
- strProps = getJSON().stringify(properties);
2417
- }
2418
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : STR_EMPTY$2) +
2419
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : STR_EMPTY$2);
2420
- _self[_DYN_MESSAGE ] += diagnosticText;
2421
- }
2422
- _InternalLogMessage.dataType = "MessageData";
2423
- return _InternalLogMessage;
2424
- }());
2425
- function safeGetLogger(core, config) {
2426
- return (core || {})[_DYN_LOGGER ] || new DiagnosticLogger(config);
2427
- }
2428
- var DiagnosticLogger = /** @class */ (function () {
2429
- function DiagnosticLogger(config) {
2430
- this.identifier = "DiagnosticLogger";
2431
- this.queue = [];
2432
- var _messageCount = 0;
2433
- var _messageLogged = {};
2434
- var _loggingLevelConsole;
2435
- var _loggingLevelTelemetry;
2436
- var _maxInternalMessageLimit;
2437
- var _enableDebug;
2438
- var _unloadHandler;
2439
- dynamicProto(DiagnosticLogger, this, function (_self) {
2440
- _unloadHandler = _setDefaultsFromConfig(config || {});
2441
- _self.consoleLoggingLevel = function () { return _loggingLevelConsole; };
2442
- _self[_DYN_THROW_INTERNAL ] = function (severity, msgId, msg, properties, isUserAct) {
2443
- if (isUserAct === void 0) { isUserAct = false; }
2444
- var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
2445
- if (_enableDebug) {
2446
- throw dumpObj(message);
2447
- }
2448
- else {
2449
- var logFunc = _logFuncs[severity] || STR_WARN_TO_CONSOLE;
2450
- if (!isUndefined(message[_DYN_MESSAGE ])) {
2451
- if (isUserAct) {
2452
- var messageKey = +message[_DYN_MESSAGE_ID ];
2453
- if (!_messageLogged[messageKey] && _loggingLevelConsole >= severity) {
2454
- _self[logFunc](message[_DYN_MESSAGE ]);
2455
- _messageLogged[messageKey] = true;
2456
- }
2457
- }
2458
- else {
2459
- if (_loggingLevelConsole >= severity) {
2460
- _self[logFunc](message[_DYN_MESSAGE ]);
2461
- }
2462
- }
2463
- _logInternalMessage(severity, message);
2464
- }
2465
- else {
2466
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
2467
- }
2468
- }
2469
- };
2470
- _self.debugToConsole = function (message) {
2471
- _logToConsole("debug", message);
2472
- _debugExtMsg("warning", message);
2473
- };
2474
- _self[_DYN_WARN_TO_CONSOLE ] = function (message) {
2475
- _logToConsole("warn", message);
2476
- _debugExtMsg("warning", message);
2477
- };
2478
- _self.errorToConsole = function (message) {
2479
- _logToConsole("error", message);
2480
- _debugExtMsg("error", message);
2481
- };
2482
- _self.resetInternalMessageCount = function () {
2483
- _messageCount = 0;
2484
- _messageLogged = {};
2485
- };
2486
- _self[_DYN_LOG_INTERNAL_MESSAGE ] = _logInternalMessage;
2487
- _self[_DYN_UNLOAD ] = function (isAsync) {
2488
- _unloadHandler && _unloadHandler.rm();
2489
- _unloadHandler = null;
2490
- };
2491
- function _logInternalMessage(severity, message) {
2492
- if (_areInternalMessagesThrottled()) {
2493
- return;
2494
- }
2495
- var logMessage = true;
2496
- var messageKey = AIInternalMessagePrefix + message[_DYN_MESSAGE_ID ];
2497
- if (_messageLogged[messageKey]) {
2498
- logMessage = false;
2499
- }
2500
- else {
2501
- _messageLogged[messageKey] = true;
2502
- }
2503
- if (logMessage) {
2504
- if (severity <= _loggingLevelTelemetry) {
2505
- _self.queue[_DYN_PUSH$1 ](message);
2506
- _messageCount++;
2507
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
2508
- }
2509
- if (_messageCount === _maxInternalMessageLimit) {
2510
- var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
2511
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
2512
- _self.queue[_DYN_PUSH$1 ](throttleMessage);
2513
- if (severity === 1 ) {
2514
- _self.errorToConsole(throttleLimitMessage);
2515
- }
2516
- else {
2517
- _self[_DYN_WARN_TO_CONSOLE ](throttleLimitMessage);
2518
- }
2519
- }
2520
- }
2521
- }
2522
- function _setDefaultsFromConfig(config) {
2523
- return onConfigChange(createDynamicConfig(config, defaultValues$1, _self).cfg, function (details) {
2524
- var config = details.cfg;
2525
- _loggingLevelConsole = config[_DYN_LOGGING_LEVEL_CONSOL4 ];
2526
- _loggingLevelTelemetry = config.loggingLevelTelemetry;
2527
- _maxInternalMessageLimit = config.maxMessageLimit;
2528
- _enableDebug = config.enableDebug;
2529
- });
2530
- }
2531
- function _areInternalMessagesThrottled() {
2532
- return _messageCount >= _maxInternalMessageLimit;
2533
- }
2534
- function _debugExtMsg(name, data) {
2535
- var dbgExt = getDebugExt(config || {});
2536
- if (dbgExt && dbgExt[_DYN_DIAG_LOG ]) {
2537
- dbgExt[_DYN_DIAG_LOG ](name, data);
2538
- }
2539
- }
2540
- });
2541
- }
2542
- DiagnosticLogger.__ieDyn=1;
2543
- return DiagnosticLogger;
2544
- }());
2545
- function _getLogger(logger) {
2546
- return (logger || new DiagnosticLogger());
2707
+ throwInvalidAccess(message);
2708
+ }
2547
2709
  }
2548
- function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
2549
- if (isUserAct === void 0) { isUserAct = false; }
2550
- _getLogger(logger)[_DYN_THROW_INTERNAL ](severity, msgId, msg, properties, isUserAct);
2710
+ function createDynamicConfig(config, defaultConfig, logger, inPlace) {
2711
+ var dynamicHandler = _createDynamicHandler(logger, config || {}, inPlace);
2712
+ if (defaultConfig) {
2713
+ dynamicHandler[_DYN_SET_DF ](dynamicHandler.cfg, defaultConfig);
2714
+ }
2715
+ return dynamicHandler;
2551
2716
  }
2552
- function _warnToConsole(logger, message) {
2553
- _getLogger(logger)[_DYN_WARN_TO_CONSOLE ](message);
2717
+ function onConfigChange(config, configHandler, logger) {
2718
+ var handler = config[CFG_HANDLER_LINK] || config;
2719
+ if (handler.cfg && (handler.cfg === config || handler.cfg[CFG_HANDLER_LINK] === handler)) {
2720
+ return handler[_DYN_WATCH ](configHandler);
2721
+ }
2722
+ _logInvalidAccess(logger, STR_NOT_DYNAMIC_ERROR + dumpObj(config));
2723
+ return createDynamicConfig(config, null, logger)[_DYN_WATCH ](configHandler);
2554
2724
  }
2555
2725
 
2726
+ var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
2727
+
2556
2728
  var strExecutionContextKey = "ctx";
2557
2729
  var strParentContextKey = "ParentContextKey";
2558
2730
  var strChildrenContextKey = "ChildrenContextKey";
@@ -2949,7 +3121,7 @@
2949
3121
  doPerf(itemCtx[STR_CORE ](), function () { return identifier + ":" + name; }, function () {
2950
3122
  hasRunContext[chainId] = true;
2951
3123
  try {
2952
- var nextId = nextProxy ? nextProxy._id : STR_EMPTY$2;
3124
+ var nextId = nextProxy ? nextProxy._id : STR_EMPTY$3;
2953
3125
  if (nextId) {
2954
3126
  hasRunContext[nextId] = false;
2955
3127
  }
@@ -3148,76 +3320,507 @@
3148
3320
  _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx[_DYN_GET_NEXT ]());
3149
3321
  }
3150
3322
  }
3151
- if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
3152
- _updateCallback();
3323
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
3324
+ _updateCallback();
3325
+ }
3326
+ else {
3327
+ result = true;
3328
+ }
3329
+ return result;
3330
+ };
3331
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
3332
+ proxyFunctionAs(_self, "_addHook", function () { return _hookContainer; }, "add");
3333
+ objDefine(_self, "_unloadHooks", { g: function () { return _hookContainer; } });
3334
+ });
3335
+ _self[_DYN_DIAG_LOG ] = function (itemCtx) {
3336
+ return _getTelCtx(itemCtx)[_DYN_DIAG_LOG ]();
3337
+ };
3338
+ _self[_DYN_IS_INITIALIZED ] = function () {
3339
+ return _isinitialized;
3340
+ };
3341
+ _self.setInitialized = function (isInitialized) {
3342
+ _isinitialized = isInitialized;
3343
+ };
3344
+ _self[_DYN_SET_NEXT_PLUGIN ] = function (next) {
3345
+ _nextPlugin = next;
3346
+ };
3347
+ _self[_DYN_PROCESS_NEXT ] = function (env, itemCtx) {
3348
+ if (itemCtx) {
3349
+ itemCtx[_DYN_PROCESS_NEXT ](env);
3350
+ }
3351
+ else if (_nextPlugin && isFunction(_nextPlugin[STR_PROCESS_TELEMETRY ])) {
3352
+ _nextPlugin[STR_PROCESS_TELEMETRY ](env, null);
3353
+ }
3354
+ };
3355
+ _self._getTelCtx = _getTelCtx;
3356
+ function _getTelCtx(currentCtx) {
3357
+ if (currentCtx === void 0) { currentCtx = null; }
3358
+ var itemCtx = currentCtx;
3359
+ if (!itemCtx) {
3360
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self[STR_CORE ]);
3361
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
3362
+ itemCtx = rootCtx[_DYN_CREATE_NEW ](null, _nextPlugin[strGetPlugin]);
3363
+ }
3364
+ else {
3365
+ itemCtx = rootCtx[_DYN_CREATE_NEW ](null, _nextPlugin);
3366
+ }
3367
+ }
3368
+ return itemCtx;
3369
+ }
3370
+ function _setDefaults(config, core, pluginChain) {
3371
+ createDynamicConfig(config, defaultValues, safeGetLogger(core));
3372
+ if (!pluginChain && core) {
3373
+ pluginChain = core[_DYN_GET_PROCESS_TEL_CONT0 ]()[_DYN_GET_NEXT ]();
3374
+ }
3375
+ var nextPlugin = _nextPlugin;
3376
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
3377
+ nextPlugin = _nextPlugin[strGetPlugin]();
3378
+ }
3379
+ _self[STR_CORE ] = core;
3380
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
3381
+ }
3382
+ function _initDefaults() {
3383
+ _isinitialized = false;
3384
+ _self[STR_CORE ] = null;
3385
+ _rootCtx = null;
3386
+ _nextPlugin = null;
3387
+ _hookContainer = createUnloadHookContainer();
3388
+ _unloadHandlerContainer = createUnloadHandlerContainer();
3389
+ }
3390
+ }
3391
+ BaseTelemetryPlugin.__ieDyn=1;
3392
+ return BaseTelemetryPlugin;
3393
+ }());
3394
+
3395
+ var STR_EMPTY$2 = "";
3396
+ var STR_NO_RESPONSE_BODY$1 = "NoResponseBody";
3397
+ var _noResponseQs$1 = "&" + STR_NO_RESPONSE_BODY$1 + "=true";
3398
+ var STR_POST_METHOD = "POST";
3399
+ var SenderPostManager = /** @class */ (function () {
3400
+ function SenderPostManager() {
3401
+ var _syncFetchPayload = 0;
3402
+ var _enableSendPromise;
3403
+ var _isInitialized;
3404
+ var _diagLog;
3405
+ var _isOneDs;
3406
+ var _onCompleteFuncs;
3407
+ var _disableCredentials;
3408
+ var _fallbackInst;
3409
+ var _disableXhr;
3410
+ var _disableBeacon;
3411
+ var _disableBeaconSync;
3412
+ var _disableFetchKeepAlive;
3413
+ var _addNoResponse;
3414
+ var _timeoutWrapper;
3415
+ dynamicProto(SenderPostManager, this, function (_self, _base) {
3416
+ var _sendCredentials = true;
3417
+ _initDefaults();
3418
+ _self[_DYN_INITIALIZE$1 ] = function (config, diagLog) {
3419
+ _diagLog = diagLog;
3420
+ if (_isInitialized) {
3421
+ _throwInternal(_diagLog, 1 , 28 , "Sender is already initialized");
3422
+ }
3423
+ _self.SetConfig(config);
3424
+ _isInitialized = true;
3425
+ };
3426
+ _self["_getDbgPlgTargets"] = function () {
3427
+ return [_isInitialized, _isOneDs, _disableCredentials, _enableSendPromise];
3428
+ };
3429
+ _self.SetConfig = function (config) {
3430
+ try {
3431
+ _onCompleteFuncs = config.senderOnCompleteCallBack || {};
3432
+ _disableCredentials = !!config.disableCredentials;
3433
+ _isOneDs = !!config.isOneDs;
3434
+ _enableSendPromise = !!config.enableSendPromise;
3435
+ _disableXhr = !!config.disableXhr;
3436
+ _disableBeacon = !!config.disableBeacon;
3437
+ _disableBeaconSync = !!config.disableBeaconSync;
3438
+ _timeoutWrapper = config.timeWrapper;
3439
+ _addNoResponse = !!config.addNoResponse;
3440
+ _disableFetchKeepAlive = !!config.disableFetchKeepAlive;
3441
+ _fallbackInst = { sendPOST: _xhrSender };
3442
+ if (!_isOneDs) {
3443
+ _sendCredentials = false;
3444
+ }
3445
+ if (_disableCredentials) {
3446
+ var location_1 = getLocation();
3447
+ if (location_1 && location_1.protocol && location_1.protocol[_DYN_TO_LOWER_CASE$1 ]() === "file:") {
3448
+ _sendCredentials = false;
3449
+ }
3450
+ }
3451
+ return true;
3452
+ }
3453
+ catch (e) {
3454
+ }
3455
+ return false;
3456
+ };
3457
+ _self.getSyncFetchPayload = function () {
3458
+ return _syncFetchPayload;
3459
+ };
3460
+ _self.getSenderInst = function (transports, sync) {
3461
+ if (transports && transports[_DYN_LENGTH$2 ]) {
3462
+ return _getSenderInterface(transports, sync);
3463
+ }
3464
+ return null;
3465
+ };
3466
+ _self.getFallbackInst = function () {
3467
+ return _fallbackInst;
3468
+ };
3469
+ _self[_DYN__DO_TEARDOWN ] = function (unloadCtx, unloadState) {
3470
+ _initDefaults();
3471
+ };
3472
+ function _onSuccess(res, onComplete) {
3473
+ _doOnComplete(onComplete, 200, {}, res);
3474
+ }
3475
+ function _onError(message, onComplete) {
3476
+ _throwInternal(_diagLog, 2 , 26 , "Failed to send telemetry.", { message: message });
3477
+ _doOnComplete(onComplete, 400, {});
3478
+ }
3479
+ function _onNoPayloadUrl(onComplete) {
3480
+ _onError("No endpoint url is provided for the batch", onComplete);
3481
+ }
3482
+ function _getSenderInterface(transports, syncSupport) {
3483
+ var _a;
3484
+ var transportType = 0 ;
3485
+ var sendPostFunc = null;
3486
+ var lp = 0;
3487
+ while (sendPostFunc == null && lp < transports[_DYN_LENGTH$2 ]) {
3488
+ transportType = transports[lp];
3489
+ if (!_disableXhr && transportType === 1 ) {
3490
+ if (useXDomainRequest()) {
3491
+ sendPostFunc = _xdrSender;
3492
+ }
3493
+ else if (isXhrSupported()) {
3494
+ sendPostFunc = _xhrSender;
3495
+ }
3496
+ }
3497
+ else if (transportType === 2 && isFetchSupported(syncSupport) && (!syncSupport || !_disableFetchKeepAlive)) {
3498
+ sendPostFunc = _doFetchSender;
3499
+ }
3500
+ else if (transportType === 3 && isBeaconsSupported() && (syncSupport ? !_disableBeaconSync : !_disableBeacon)) {
3501
+ sendPostFunc = _beaconSender;
3502
+ }
3503
+ lp++;
3504
+ }
3505
+ if (sendPostFunc) {
3506
+ return _a = {
3507
+ _transport: transportType,
3508
+ _isSync: syncSupport
3509
+ },
3510
+ _a[_DYN_SEND_POST ] = sendPostFunc,
3511
+ _a;
3512
+ }
3513
+ return null;
3514
+ }
3515
+ function _doOnComplete(oncomplete, status, headers, response) {
3516
+ try {
3517
+ oncomplete && oncomplete(status, headers, response);
3518
+ }
3519
+ catch (e) {
3520
+ }
3521
+ }
3522
+ function _doBeaconSend(payload, oncomplete) {
3523
+ var nav = getNavigator();
3524
+ var url = payload[_DYN_URL_STRING$1 ];
3525
+ if (!url) {
3526
+ _onNoPayloadUrl(oncomplete);
3527
+ return true;
3528
+ }
3529
+ url = payload[_DYN_URL_STRING$1 ] + (_addNoResponse ? _noResponseQs$1 : STR_EMPTY$2);
3530
+ var data = payload[_DYN_DATA$1 ];
3531
+ var plainTextBatch = _isOneDs ? data : new Blob([data], { type: "text/plain;charset=UTF-8" });
3532
+ var queued = nav.sendBeacon(url, plainTextBatch);
3533
+ return queued;
3534
+ }
3535
+ function _beaconSender(payload, oncomplete, sync) {
3536
+ var data = payload[_DYN_DATA$1 ];
3537
+ try {
3538
+ if (data) {
3539
+ if (!_doBeaconSend(payload, oncomplete)) {
3540
+ var onRetry = _onCompleteFuncs && _onCompleteFuncs.beaconOnRetry;
3541
+ if (onRetry && isFunction(onRetry)) {
3542
+ onRetry(payload, oncomplete, _doBeaconSend);
3543
+ }
3544
+ else {
3545
+ _fallbackInst && _fallbackInst[_DYN_SEND_POST ](payload, oncomplete, true);
3546
+ _throwInternal(_diagLog, 2 , 40 , ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
3547
+ }
3548
+ }
3549
+ else {
3550
+ _onSuccess(STR_EMPTY$2, oncomplete);
3551
+ }
3552
+ }
3553
+ }
3554
+ catch (e) {
3555
+ _isOneDs && _warnToConsole(_diagLog, "Failed to send telemetry using sendBeacon API. Ex:" + dumpObj(e));
3556
+ _doOnComplete(oncomplete, _isOneDs ? 0 : 400, {}, STR_EMPTY$2);
3557
+ }
3558
+ return;
3559
+ }
3560
+ function _xhrSender(payload, oncomplete, sync) {
3561
+ var thePromise;
3562
+ var resolveFunc;
3563
+ var rejectFunc;
3564
+ var headers = payload[_DYN_HEADERS$1 ] || {};
3565
+ if (!sync && _enableSendPromise) {
3566
+ thePromise = createPromise(function (resolve, reject) {
3567
+ resolveFunc = resolve;
3568
+ rejectFunc = reject;
3569
+ });
3570
+ }
3571
+ if (_isOneDs && sync && payload.disableXhrSync) {
3572
+ sync = false;
3573
+ }
3574
+ var endPointUrl = payload[_DYN_URL_STRING$1 ];
3575
+ if (!endPointUrl) {
3576
+ _onNoPayloadUrl(oncomplete);
3577
+ resolveFunc && resolveFunc(false);
3578
+ return;
3579
+ }
3580
+ var xhr = openXhr(STR_POST_METHOD, endPointUrl, _sendCredentials, true, sync, payload[_DYN_TIMEOUT ]);
3581
+ xhr[_DYN_SET_REQUEST_HEADER ]("Content-type", "application/json");
3582
+ arrForEach(objKeys(headers), function (headerName) {
3583
+ xhr[_DYN_SET_REQUEST_HEADER ](headerName, headers[headerName]);
3584
+ });
3585
+ xhr.onreadystatechange = function () {
3586
+ if (!_isOneDs) {
3587
+ _doOnReadyFunc(xhr);
3588
+ if (xhr.readyState === 4) {
3589
+ resolveFunc && resolveFunc(true);
3590
+ }
3591
+ }
3592
+ };
3593
+ xhr.onload = function () {
3594
+ if (_isOneDs) {
3595
+ _doOnReadyFunc(xhr);
3596
+ }
3597
+ };
3598
+ function _doOnReadyFunc(xhr) {
3599
+ var onReadyFunc = _onCompleteFuncs && _onCompleteFuncs.xhrOnComplete;
3600
+ var onReadyFuncExist = onReadyFunc && isFunction(onReadyFunc);
3601
+ if (onReadyFuncExist) {
3602
+ onReadyFunc(xhr, oncomplete, payload);
3603
+ }
3604
+ else {
3605
+ var response = getResponseText(xhr);
3606
+ _doOnComplete(oncomplete, xhr[_DYN_STATUS ], _getAllResponseHeaders(xhr, _isOneDs), response);
3607
+ }
3608
+ }
3609
+ xhr.onerror = function (event) {
3610
+ _doOnComplete(oncomplete, _isOneDs ? xhr[_DYN_STATUS ] : 400, _getAllResponseHeaders(xhr, _isOneDs), _isOneDs ? STR_EMPTY$2 : formatErrorMessageXhr(xhr));
3611
+ rejectFunc && rejectFunc(event);
3612
+ };
3613
+ xhr.ontimeout = function () {
3614
+ _doOnComplete(oncomplete, _isOneDs ? xhr[_DYN_STATUS ] : 500, _getAllResponseHeaders(xhr, _isOneDs), _isOneDs ? STR_EMPTY$2 : formatErrorMessageXhr(xhr));
3615
+ resolveFunc && resolveFunc(false);
3616
+ };
3617
+ xhr.send(payload[_DYN_DATA$1 ]);
3618
+ return thePromise;
3619
+ }
3620
+ function _doFetchSender(payload, oncomplete, sync) {
3621
+ var _a;
3622
+ var endPointUrl = payload[_DYN_URL_STRING$1 ];
3623
+ var batch = payload[_DYN_DATA$1 ];
3624
+ var plainTextBatch = _isOneDs ? batch : new Blob([batch], { type: "application/json" });
3625
+ var thePromise;
3626
+ var resolveFunc;
3627
+ var rejectFunc;
3628
+ var requestHeaders = new Headers();
3629
+ var batchLength = batch[_DYN_LENGTH$2 ];
3630
+ var ignoreResponse = false;
3631
+ var responseHandled = false;
3632
+ var headers = payload[_DYN_HEADERS$1 ] || {};
3633
+ var init = (_a = {
3634
+ method: STR_POST_METHOD,
3635
+ body: plainTextBatch
3636
+ },
3637
+ _a[DisabledPropertyName] = true
3638
+ ,
3639
+ _a);
3640
+ if (payload.headers && objKeys(payload.headers)[_DYN_LENGTH$2 ] > 0) {
3641
+ arrForEach(objKeys(headers), function (headerName) {
3642
+ requestHeaders.append(headerName, headers[headerName]);
3643
+ });
3644
+ init[_DYN_HEADERS$1 ] = requestHeaders;
3645
+ }
3646
+ if (_sendCredentials && _isOneDs) {
3647
+ init.credentials = "include";
3648
+ }
3649
+ if (sync) {
3650
+ init.keepalive = true;
3651
+ _syncFetchPayload += batchLength;
3652
+ if (_isOneDs) {
3653
+ if (payload["_sendReason"] === 2 ) {
3654
+ ignoreResponse = true;
3655
+ if (_addNoResponse) {
3656
+ endPointUrl += _noResponseQs$1;
3657
+ }
3658
+ }
3659
+ }
3660
+ else {
3661
+ ignoreResponse = true;
3662
+ }
3663
+ }
3664
+ var request = new Request(endPointUrl, init);
3665
+ try {
3666
+ request[DisabledPropertyName] = true;
3667
+ }
3668
+ catch (e) {
3669
+ }
3670
+ if (!sync && _enableSendPromise) {
3671
+ thePromise = createPromise(function (resolve, reject) {
3672
+ resolveFunc = resolve;
3673
+ rejectFunc = reject;
3674
+ });
3675
+ }
3676
+ if (!endPointUrl) {
3677
+ _onNoPayloadUrl(oncomplete);
3678
+ resolveFunc && resolveFunc(false);
3679
+ return;
3680
+ }
3681
+ function _handleError(res) {
3682
+ _doOnComplete(oncomplete, _isOneDs ? 0 : 400, {}, _isOneDs ? STR_EMPTY$2 : res);
3683
+ }
3684
+ function _onFetchComplete(response, payload, value) {
3685
+ var status = response[_DYN_STATUS ];
3686
+ var onCompleteFunc = _onCompleteFuncs.fetchOnComplete;
3687
+ if (onCompleteFunc && isFunction(onCompleteFunc)) {
3688
+ onCompleteFunc(response, oncomplete, value || STR_EMPTY$2, payload);
3689
+ }
3690
+ else {
3691
+ _doOnComplete(oncomplete, status, {}, value || STR_EMPTY$2);
3692
+ }
3693
+ }
3694
+ try {
3695
+ doAwaitResponse(fetch(_isOneDs ? endPointUrl : request, _isOneDs ? init : null), function (result) {
3696
+ if (sync) {
3697
+ _syncFetchPayload -= batchLength;
3698
+ batchLength = 0;
3699
+ }
3700
+ if (!responseHandled) {
3701
+ responseHandled = true;
3702
+ if (!result.rejected) {
3703
+ var response_1 = result.value;
3704
+ try {
3705
+ if (!_isOneDs && !response_1.ok) {
3706
+ _handleError(response_1.statusText);
3707
+ resolveFunc && resolveFunc(false);
3708
+ }
3709
+ else {
3710
+ if (_isOneDs && !response_1.body) {
3711
+ _onFetchComplete(response_1, null, STR_EMPTY$2);
3712
+ resolveFunc && resolveFunc(true);
3713
+ }
3714
+ else {
3715
+ doAwaitResponse(response_1.text(), function (resp) {
3716
+ _onFetchComplete(response_1, payload, resp.value);
3717
+ resolveFunc && resolveFunc(true);
3718
+ });
3719
+ }
3720
+ }
3721
+ }
3722
+ catch (e) {
3723
+ _handleError(dumpObj(e));
3724
+ rejectFunc && rejectFunc(e);
3725
+ }
3726
+ }
3727
+ else {
3728
+ _handleError(result.reason && result.reason[_DYN_MESSAGE ]);
3729
+ rejectFunc && rejectFunc(result.reason);
3730
+ }
3731
+ }
3732
+ });
3733
+ }
3734
+ catch (e) {
3735
+ if (!responseHandled) {
3736
+ _handleError(dumpObj(e));
3737
+ rejectFunc && rejectFunc(e);
3738
+ }
3739
+ }
3740
+ if (ignoreResponse && !responseHandled) {
3741
+ responseHandled = true;
3742
+ _doOnComplete(oncomplete, 200, {});
3743
+ resolveFunc && resolveFunc(true);
3744
+ }
3745
+ if (_isOneDs && !responseHandled && payload[_DYN_TIMEOUT ] > 0) {
3746
+ _timeoutWrapper && _timeoutWrapper.set(function () {
3747
+ if (!responseHandled) {
3748
+ responseHandled = true;
3749
+ _doOnComplete(oncomplete, 500, {});
3750
+ resolveFunc && resolveFunc(true);
3751
+ }
3752
+ }, payload[_DYN_TIMEOUT ]);
3753
+ }
3754
+ return thePromise;
3755
+ }
3756
+ function _xdrSender(payload, oncomplete, sync) {
3757
+ var _window = getWindow();
3758
+ var xdr = new XDomainRequest();
3759
+ var data = payload[_DYN_DATA$1 ];
3760
+ xdr.onload = function () {
3761
+ var response = getResponseText(xdr);
3762
+ var onloadFunc = _onCompleteFuncs && _onCompleteFuncs.xdrOnComplete;
3763
+ if (onloadFunc && isFunction(onloadFunc)) {
3764
+ onloadFunc(xdr, oncomplete, payload);
3765
+ }
3766
+ else {
3767
+ _doOnComplete(oncomplete, 200, {}, response);
3768
+ }
3769
+ };
3770
+ xdr.onerror = function () {
3771
+ _doOnComplete(oncomplete, 400, {}, _isOneDs ? STR_EMPTY$2 : formatErrorMessageXdr(xdr));
3772
+ };
3773
+ xdr.ontimeout = function () {
3774
+ _doOnComplete(oncomplete, 500, {});
3775
+ };
3776
+ xdr.onprogress = function () { };
3777
+ var hostingProtocol = _window && _window.location && _window.location[_DYN_PROTOCOL ] || "";
3778
+ var endpoint = payload[_DYN_URL_STRING$1 ];
3779
+ if (!endpoint) {
3780
+ _onNoPayloadUrl(oncomplete);
3781
+ return;
3782
+ }
3783
+ if (!_isOneDs && endpoint.lastIndexOf(hostingProtocol, 0) !== 0) {
3784
+ var msg = "Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.";
3785
+ _throwInternal(_diagLog, 2 , 40 , ". " + msg);
3786
+ _onError(msg, oncomplete);
3787
+ return;
3153
3788
  }
3154
- else {
3155
- result = true;
3789
+ var endpointUrl = _isOneDs ? endpoint : endpoint[_DYN_REPLACE ](/^(https?:)/, "");
3790
+ xdr.open(STR_POST_METHOD, endpointUrl);
3791
+ if (payload[_DYN_TIMEOUT ]) {
3792
+ xdr[_DYN_TIMEOUT ] = payload[_DYN_TIMEOUT ];
3156
3793
  }
3157
- return result;
3158
- };
3159
- proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
3160
- proxyFunctionAs(_self, "_addHook", function () { return _hookContainer; }, "add");
3161
- objDefine(_self, "_unloadHooks", { g: function () { return _hookContainer; } });
3162
- });
3163
- _self[_DYN_DIAG_LOG ] = function (itemCtx) {
3164
- return _getTelCtx(itemCtx)[_DYN_DIAG_LOG ]();
3165
- };
3166
- _self[_DYN_IS_INITIALIZED ] = function () {
3167
- return _isinitialized;
3168
- };
3169
- _self.setInitialized = function (isInitialized) {
3170
- _isinitialized = isInitialized;
3171
- };
3172
- _self[_DYN_SET_NEXT_PLUGIN ] = function (next) {
3173
- _nextPlugin = next;
3174
- };
3175
- _self[_DYN_PROCESS_NEXT ] = function (env, itemCtx) {
3176
- if (itemCtx) {
3177
- itemCtx[_DYN_PROCESS_NEXT ](env);
3178
- }
3179
- else if (_nextPlugin && isFunction(_nextPlugin[STR_PROCESS_TELEMETRY ])) {
3180
- _nextPlugin[STR_PROCESS_TELEMETRY ](env, null);
3181
- }
3182
- };
3183
- _self._getTelCtx = _getTelCtx;
3184
- function _getTelCtx(currentCtx) {
3185
- if (currentCtx === void 0) { currentCtx = null; }
3186
- var itemCtx = currentCtx;
3187
- if (!itemCtx) {
3188
- var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self[STR_CORE ]);
3189
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
3190
- itemCtx = rootCtx[_DYN_CREATE_NEW ](null, _nextPlugin[strGetPlugin]);
3794
+ xdr.send(data);
3795
+ if (_isOneDs && sync) {
3796
+ _timeoutWrapper && _timeoutWrapper.set(function () {
3797
+ xdr.send(data);
3798
+ }, 0);
3191
3799
  }
3192
3800
  else {
3193
- itemCtx = rootCtx[_DYN_CREATE_NEW ](null, _nextPlugin);
3801
+ xdr.send(data);
3194
3802
  }
3195
3803
  }
3196
- return itemCtx;
3197
- }
3198
- function _setDefaults(config, core, pluginChain) {
3199
- createDynamicConfig(config, defaultValues, safeGetLogger(core));
3200
- if (!pluginChain && core) {
3201
- pluginChain = core[_DYN_GET_PROCESS_TEL_CONT0 ]()[_DYN_GET_NEXT ]();
3202
- }
3203
- var nextPlugin = _nextPlugin;
3204
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
3205
- nextPlugin = _nextPlugin[strGetPlugin]();
3804
+ function _initDefaults() {
3805
+ _syncFetchPayload = 0;
3806
+ _isInitialized = false;
3807
+ _enableSendPromise = false;
3808
+ _diagLog = null;
3809
+ _isOneDs = null;
3810
+ _onCompleteFuncs = null;
3811
+ _disableCredentials = null;
3812
+ _fallbackInst = null;
3813
+ _disableXhr = false;
3814
+ _disableBeacon = false;
3815
+ _disableBeaconSync = false;
3816
+ _disableFetchKeepAlive = false;
3817
+ _addNoResponse = false;
3818
+ _timeoutWrapper = null;
3206
3819
  }
3207
- _self[STR_CORE ] = core;
3208
- _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
3209
- }
3210
- function _initDefaults() {
3211
- _isinitialized = false;
3212
- _self[STR_CORE ] = null;
3213
- _rootCtx = null;
3214
- _nextPlugin = null;
3215
- _hookContainer = createUnloadHookContainer();
3216
- _unloadHandlerContainer = createUnloadHandlerContainer();
3217
- }
3820
+ });
3218
3821
  }
3219
- BaseTelemetryPlugin.__ieDyn=1;
3220
- return BaseTelemetryPlugin;
3822
+ SenderPostManager.__ieDyn=1;
3823
+ return SenderPostManager;
3221
3824
  }());
3222
3825
 
3223
3826
  var strOnPrefix = "on";
@@ -3240,16 +3843,16 @@
3240
3843
  var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
3241
3844
  function _normalizeNamespace(name) {
3242
3845
  if (name && name[_DYN_REPLACE ]) {
3243
- return name[_DYN_REPLACE ](/^[\s\.]+|(?=[\s\.])[\.\s]+$/g, STR_EMPTY$2);
3846
+ return name[_DYN_REPLACE ](/^[\s\.]+|(?=[\s\.])[\.\s]+$/g, STR_EMPTY$3);
3244
3847
  }
3245
3848
  return name;
3246
3849
  }
3247
3850
  function _getEvtNamespace(eventName, evtNamespace) {
3248
3851
  var _a;
3249
3852
  if (evtNamespace) {
3250
- var theNamespace_1 = STR_EMPTY$2;
3853
+ var theNamespace_1 = STR_EMPTY$3;
3251
3854
  if (isArray(evtNamespace)) {
3252
- theNamespace_1 = STR_EMPTY$2;
3855
+ theNamespace_1 = STR_EMPTY$3;
3253
3856
  arrForEach(evtNamespace, function (name) {
3254
3857
  name = _normalizeNamespace(name);
3255
3858
  if (name) {
@@ -3267,13 +3870,13 @@
3267
3870
  if (theNamespace_1[0] !== ".") {
3268
3871
  theNamespace_1 = "." + theNamespace_1;
3269
3872
  }
3270
- eventName = (eventName || STR_EMPTY$2) + theNamespace_1;
3873
+ eventName = (eventName || STR_EMPTY$3) + theNamespace_1;
3271
3874
  }
3272
3875
  }
3273
- var parsedEvent = (eventNamespace.exec(eventName || STR_EMPTY$2) || []);
3876
+ var parsedEvent = (eventNamespace.exec(eventName || STR_EMPTY$3) || []);
3274
3877
  return _a = {},
3275
3878
  _a[_DYN_TYPE ] = parsedEvent[1],
3276
- _a.ns = ((parsedEvent[2] || STR_EMPTY$2).replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, STR_EMPTY$2)[_DYN_SPLIT$1 ](".").sort()).join("."),
3879
+ _a.ns = ((parsedEvent[2] || STR_EMPTY$3).replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, STR_EMPTY$3)[_DYN_SPLIT$1 ](".").sort()).join("."),
3277
3880
  _a;
3278
3881
  }
3279
3882
  function _getRegisteredEvents(target, evtName, addDefault) {
@@ -3512,12 +4115,9 @@
3512
4115
  var _DYN_PROCESS_TELEMETRY_ST0 = "processTelemetryStart";
3513
4116
 
3514
4117
  var _a$1;
3515
- var Version = '4.1.1-nightly3.2403-02';
4118
+ var Version = '4.1.1-nightly3.2403-04';
3516
4119
  var FullVersionString = "1DS-Web-JS-" + Version;
3517
4120
  var ObjHasOwnProperty = ObjProto$1.hasOwnProperty;
3518
- var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
3519
- var strWithCredentials = "withCredentials";
3520
- var strTimeout = "timeout";
3521
4121
  var _fieldTypeEventPropMap = (_a$1 = {},
3522
4122
  _a$1[0 ] = 0 ,
3523
4123
  _a$1[2 ] = 6 ,
@@ -3686,39 +4286,11 @@
3686
4286
  function isChromium() {
3687
4287
  return !!getInst("chrome");
3688
4288
  }
3689
- function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {
3690
- if (disabled === void 0) { disabled = false; }
3691
- if (isSync === void 0) { isSync = false; }
3692
- function _wrapSetXhrProp(xhr, prop, value) {
3693
- try {
3694
- xhr[prop] = value;
3695
- }
3696
- catch (e) {
3697
- }
3698
- }
3699
- var xhr = new XMLHttpRequest();
3700
- if (disabled) {
3701
- _wrapSetXhrProp(xhr, strDisabledPropertyName, disabled);
3702
- }
3703
- if (withCredentials) {
3704
- _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
3705
- }
3706
- xhr.open(method, urlString, !isSync);
3707
- if (withCredentials) {
3708
- _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
3709
- }
3710
- if (!isSync && timeout) {
3711
- _wrapSetXhrProp(xhr, strTimeout, timeout);
3712
- }
3713
- return xhr;
3714
- }
3715
4289
  function isGreaterThanZero(value) {
3716
4290
  return value > 0;
3717
4291
  }
3718
4292
 
3719
4293
  var STR_EMPTY = "";
3720
- var STR_POST_METHOD = "POST";
3721
- var STR_DISABLED_PROPERTY_NAME = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
3722
4294
  var STR_DROPPED = "drop";
3723
4295
  var STR_SENDING = "send";
3724
4296
  var STR_REQUEUE = "requeue";
@@ -3730,7 +4302,6 @@
3730
4302
  var STR_CONTENT_TYPE_HEADER = "content-type";
3731
4303
  var STR_KILL_TOKENS_HEADER = "kill-tokens";
3732
4304
  var STR_KILL_DURATION_HEADER = "kill-duration";
3733
- var STR_KILL_DURATION_SECONDS_HEADER = "kill-duration-seconds";
3734
4305
  var STR_TIME_DELTA_HEADER = "time-delta-millis";
3735
4306
  var STR_CLIENT_VERSION = "client-version";
3736
4307
  var STR_CLIENT_ID = "client-id";
@@ -3772,6 +4343,7 @@
3772
4343
  var _DYN_ENABLE_COMPOUND_KEY = "enableCompoundKey";
3773
4344
  var _DYN_DISABLE_XHR_SYNC = "disableXhrSync";
3774
4345
  var _DYN_DISABLE_FETCH_KEEP_A6 = "disableFetchKeepAlive";
4346
+ var _DYN_ADD_NO_RESPONSE = "addNoResponse";
3775
4347
  var _DYN_EXCLUDE_CS_META_DATA = "excludeCsMetaData";
3776
4348
  var _DYN_USE_SEND_BEACON = "useSendBeacon";
3777
4349
  var _DYN_ALWAYS_USE_XHR_OVERR7 = "alwaysUseXhrOverride";
@@ -3779,15 +4351,9 @@
3779
4351
  var _DYN_SERIALIZE_OFFLINE_EV8 = "serializeOfflineEvt";
3780
4352
  var _DYN_GET_OFFLINE_REQUEST_9 = "getOfflineRequestDetails";
3781
4353
  var _DYN_CREATE_PAYLOAD = "createPayload";
3782
- var _DYN_URL_STRING = "urlString";
3783
- var _DYN_TIMEOUT = "timeout";
3784
- var _DYN_ONTIMEOUT = "ontimeout";
3785
- var _DYN_DATA = "data";
3786
- var _DYN__SEND_REASON = "_sendReason";
3787
4354
  var _DYN_HEADERS = "headers";
3788
- var _DYN_GET_RESPONSE_HEADER = "getResponseHeader";
3789
- var _DYN_GET_ALL_RESPONSE_HEA10 = "getAllResponseHeaders";
3790
4355
  var _DYN__THE_PAYLOAD = "_thePayload";
4356
+ var _DYN_URL_STRING = "urlString";
3791
4357
  var _DYN_BATCHES = "batches";
3792
4358
  var _DYN_SEND_TYPE = "sendType";
3793
4359
  var _DYN_ADD_HEADER = "addHeader";
@@ -3796,23 +4362,24 @@
3796
4362
  var _DYN_IS_COMPLETELY_IDLE = "isCompletelyIdle";
3797
4363
  var _DYN_SET_UNLOADING = "setUnloading";
3798
4364
  var _DYN_IS_TENANT_KILLED = "isTenantKilled";
3799
- var _DYN_SEND_SYNCHRONOUS_BAT11 = "sendSynchronousBatch";
4365
+ var _DYN_SEND_SYNCHRONOUS_BAT10 = "sendSynchronousBatch";
3800
4366
  var _DYN__TRANSPORT = "_transport";
3801
4367
  var _DYN_GET_WPARAM = "getWParam";
3802
4368
  var _DYN_IS_BEACON = "isBeacon";
3803
4369
  var _DYN_TIMINGS = "timings";
3804
4370
  var _DYN_IS_TEARDOWN = "isTeardown";
3805
4371
  var _DYN_IS_SYNC = "isSync";
3806
- var _DYN_SEND_POST = "sendPOST";
3807
- var _DYN_SET_KILL_SWITCH_TENA12 = "setKillSwitchTenants";
3808
- var _DYN__BACK_OFF_TRANSMISSI13 = "_backOffTransmission";
4372
+ var _DYN_DATA = "data";
4373
+ var _DYN__SEND_REASON = "_sendReason";
4374
+ var _DYN_SET_KILL_SWITCH_TENA11 = "setKillSwitchTenants";
4375
+ var _DYN__BACK_OFF_TRANSMISSI12 = "_backOffTransmission";
3809
4376
  var _DYN_IDENTIFIER = "identifier";
3810
4377
  var _DYN_DISABLE_OPTIMIZE_OBJ = "disableOptimizeObj";
3811
- var _DYN_IGNORE_MC1_MS0_COOKI14 = "ignoreMc1Ms0CookieProcessing";
4378
+ var _DYN_IGNORE_MC1_MS0_COOKI13 = "ignoreMc1Ms0CookieProcessing";
3812
4379
  var _DYN_EVENTS_LIMIT_IN_MEM = "eventsLimitInMem";
3813
- var _DYN_AUTO_FLUSH_EVENTS_LI15 = "autoFlushEventsLimit";
3814
- var _DYN_DISABLE_AUTO_BATCH_F16 = "disableAutoBatchFlushLimit";
3815
- var _DYN_OVERRIDE_INSTRUMENTA17 = "overrideInstrumentationKey";
4380
+ var _DYN_AUTO_FLUSH_EVENTS_LI14 = "autoFlushEventsLimit";
4381
+ var _DYN_DISABLE_AUTO_BATCH_F15 = "disableAutoBatchFlushLimit";
4382
+ var _DYN_OVERRIDE_INSTRUMENTA16 = "overrideInstrumentationKey";
3816
4383
  var _DYN_DISABLE_TELEMETRY = "disableTelemetry";
3817
4384
  var _DYN_BASE_DATA = "baseData";
3818
4385
  var _DYN_SEND_ATTEMPT = "sendAttempt";
@@ -3937,7 +4504,7 @@
3937
4504
  return result;
3938
4505
  }
3939
4506
  dynamicProto(KillSwitch, this, function (_self) {
3940
- _self[_DYN_SET_KILL_SWITCH_TENA12 ] = function (killTokens, killDuration) {
4507
+ _self[_DYN_SET_KILL_SWITCH_TENA11 ] = function (killTokens, killDuration) {
3941
4508
  if (killTokens && killDuration) {
3942
4509
  try {
3943
4510
  var killedTokens = _normalizeTenants(killTokens[_DYN_SPLIT ](","));
@@ -4276,14 +4843,6 @@
4276
4843
  _addCollectorHeaderQsMapping(STR_TIME_DELTA_TO_APPLY, STR_TIME_DELTA_TO_APPLY);
4277
4844
  _addCollectorHeaderQsMapping(STR_UPLOAD_TIME, STR_UPLOAD_TIME);
4278
4845
  _addCollectorHeaderQsMapping(STR_AUTH_XTOKEN, STR_AUTH_XTOKEN);
4279
- function _getResponseText(xhr) {
4280
- try {
4281
- return xhr.responseText;
4282
- }
4283
- catch (e) {
4284
- }
4285
- return STR_EMPTY;
4286
- }
4287
4846
  function _hasHeader(headers, header) {
4288
4847
  var hasHeader = false;
4289
4848
  if (headers && header) {
@@ -4313,17 +4872,6 @@
4313
4872
  }
4314
4873
  }
4315
4874
  }
4316
- function _prependTransports(theTransports, newTransports) {
4317
- if (newTransports) {
4318
- if (isNumber(newTransports)) {
4319
- theTransports = [newTransports][_DYN_CONCAT ](theTransports);
4320
- }
4321
- else if (isArray(newTransports)) {
4322
- theTransports = newTransports[_DYN_CONCAT ](theTransports);
4323
- }
4324
- }
4325
- return theTransports;
4326
- }
4327
4875
  function _addQueryStringParameter(qsParams, name, value) {
4328
4876
  for (var i = 0; i < qsParams[_DYN_LENGTH ]; i++) {
4329
4877
  if (qsParams[i].name === name) {
@@ -4374,6 +4922,7 @@
4374
4922
  var _isInitialized;
4375
4923
  var _timeoutWrapper;
4376
4924
  var _excludeCsMetaData;
4925
+ var _sendPostMgr;
4377
4926
  dynamicProto(HttpManager, this, function (_self) {
4378
4927
  _initDefaults();
4379
4928
  var _sendCredentials = true;
@@ -4410,7 +4959,7 @@
4410
4959
  _xhrTimeout = channelConfig.xhrTimeout;
4411
4960
  _disableXhrSync = !!channelConfig[_DYN_DISABLE_XHR_SYNC ];
4412
4961
  _disableFetchKeepAlive = !!channelConfig[_DYN_DISABLE_FETCH_KEEP_A6 ];
4413
- _addNoResponse = channelConfig.addNoResponse !== false;
4962
+ _addNoResponse = channelConfig[_DYN_ADD_NO_RESPONSE ] !== false;
4414
4963
  _excludeCsMetaData = !!channelConfig[_DYN_EXCLUDE_CS_META_DATA ];
4415
4964
  if (!!core.getPlugin("LocalStorage")) {
4416
4965
  _disableFetchKeepAlive = true;
@@ -4420,16 +4969,20 @@
4420
4969
  if (!isNullOrUndefined(channelConfig[_DYN_USE_SEND_BEACON ])) {
4421
4970
  _useBeacons = !!channelConfig[_DYN_USE_SEND_BEACON ];
4422
4971
  }
4972
+ var sendPostConfig = _getSendPostMgrConfig();
4973
+ if (!_sendPostMgr) {
4974
+ _sendPostMgr = new SenderPostManager();
4975
+ _sendPostMgr[_DYN_INITIALIZE ](sendPostConfig, _logger);
4976
+ }
4977
+ else {
4978
+ _sendPostMgr.SetConfig(sendPostConfig);
4979
+ }
4423
4980
  var syncHttpInterface = httpInterface;
4424
4981
  var beaconHttpInterface = channelConfig[_DYN_ALWAYS_USE_XHR_OVERR7 ] ? httpInterface : null;
4425
4982
  var fetchSyncHttpInterface = channelConfig[_DYN_ALWAYS_USE_XHR_OVERR7 ] ? httpInterface : null;
4426
4983
  var beaconUnloadTransports = [3 , 2 ];
4427
4984
  if (!httpInterface) {
4428
4985
  _customHttpInterface = false;
4429
- var location_1 = getLocation();
4430
- if (location_1 && location_1.protocol && location_1.protocol[_DYN_TO_LOWER_CASE ]() === "file:") {
4431
- _sendCredentials = false;
4432
- }
4433
4986
  var theTransports = [];
4434
4987
  if (isReactNative()) {
4435
4988
  theTransports = [2 , 1 ];
@@ -4438,7 +4991,7 @@
4438
4991
  else {
4439
4992
  theTransports = [1 , 2 , 3 ];
4440
4993
  }
4441
- theTransports = _prependTransports(theTransports, channelConfig.transports);
4994
+ theTransports = prependTransports(theTransports, channelConfig.transports);
4442
4995
  httpInterface = _getSenderInterface(theTransports, false);
4443
4996
  if (!httpInterface) {
4444
4997
  _warnToConsole(_logger, "No available transport to send events");
@@ -4446,7 +4999,7 @@
4446
4999
  syncHttpInterface = _getSenderInterface(theTransports, true);
4447
5000
  }
4448
5001
  if (!beaconHttpInterface) {
4449
- beaconUnloadTransports = _prependTransports(beaconUnloadTransports, channelConfig[_DYN_UNLOAD_TRANSPORTS ]);
5002
+ beaconUnloadTransports = prependTransports(beaconUnloadTransports, channelConfig[_DYN_UNLOAD_TRANSPORTS ]);
4450
5003
  beaconHttpInterface = _getSenderInterface(beaconUnloadTransports, true);
4451
5004
  }
4452
5005
  _canHaveReducedPayload = !_customHttpInterface && ((_useBeacons && isBeaconsSupported()) || (!_disableFetchKeepAlive && isFetchSupported(true)));
@@ -4472,72 +5025,65 @@
4472
5025
  };
4473
5026
  };
4474
5027
  _self[_DYN_SERIALIZE_OFFLINE_EV8 ] = function (evt) {
4475
- return _serializer.getEventBlob(evt);
5028
+ try {
5029
+ if (_serializer) {
5030
+ return _serializer.getEventBlob(evt);
5031
+ }
5032
+ }
5033
+ catch (e) {
5034
+ }
5035
+ return STR_EMPTY;
4476
5036
  };
4477
5037
  _self[_DYN_GET_OFFLINE_REQUEST_9 ] = function () {
4478
- var payload = _serializer[_DYN_CREATE_PAYLOAD ](0, false, false, false, 1 , 0 );
4479
- return _buildRequestDetails(payload, _useHeaders);
5038
+ try {
5039
+ var payload = _serializer && _serializer[_DYN_CREATE_PAYLOAD ](0, false, false, false, 1 , 0 );
5040
+ return _buildRequestDetails(payload, _useHeaders);
5041
+ }
5042
+ catch (e) {
5043
+ }
5044
+ return null;
4480
5045
  };
4481
5046
  function _getSenderInterface(transports, syncSupport) {
4482
- var transportType = 0 ;
4483
- var sendPostFunc = null;
4484
- var lp = 0;
4485
- while (sendPostFunc == null && lp < transports[_DYN_LENGTH ]) {
4486
- transportType = transports[lp];
4487
- if (transportType === 1 ) {
4488
- if (useXDomainRequest()) {
4489
- sendPostFunc = _xdrSendPost;
4490
- }
4491
- else if (isXhrSupported()) {
4492
- sendPostFunc = _xhrSendPost;
4493
- }
4494
- }
4495
- else if (transportType === 2 && isFetchSupported(syncSupport) && (!syncSupport || (syncSupport && !_disableFetchKeepAlive))) {
4496
- sendPostFunc = _fetchSendPost;
4497
- }
4498
- else if (_useBeacons && transportType === 3 && isBeaconsSupported()) {
4499
- sendPostFunc = _beaconSendPost;
4500
- }
4501
- lp++;
5047
+ try {
5048
+ return _sendPostMgr && _sendPostMgr.getSenderInst(transports, syncSupport);
4502
5049
  }
4503
- if (sendPostFunc) {
4504
- return {
4505
- _transport: transportType,
4506
- _isSync: syncSupport,
4507
- sendPOST: sendPostFunc
4508
- };
5050
+ catch (e) {
4509
5051
  }
4510
5052
  return null;
4511
5053
  }
4512
5054
  _self["_getDbgPlgTargets"] = function () {
4513
5055
  return [_sendInterfaces[0 ], _killSwitch, _serializer, _sendInterfaces];
4514
5056
  };
4515
- function _xdrSendPost(payload, oncomplete, sync) {
4516
- var xdr = new XDomainRequest();
4517
- xdr.open(STR_POST_METHOD, payload[_DYN_URL_STRING ]);
4518
- if (payload[_DYN_TIMEOUT ]) {
4519
- xdr[_DYN_TIMEOUT ] = payload[_DYN_TIMEOUT ];
4520
- }
4521
- xdr.onload = function () {
4522
- var response = _getResponseText(xdr);
4523
- _doOnComplete(oncomplete, 200, {}, response);
4524
- _handleCollectorResponse(response);
4525
- };
4526
- xdr.onerror = function () {
4527
- _doOnComplete(oncomplete, 400, {});
4528
- };
4529
- xdr[_DYN_ONTIMEOUT ] = function () {
4530
- _doOnComplete(oncomplete, 500, {});
4531
- };
4532
- xdr.onprogress = function () { };
4533
- if (sync) {
4534
- xdr.send(payload[_DYN_DATA ]);
5057
+ function _getSendPostMgrConfig() {
5058
+ try {
5059
+ var onCompleteFuncs = {
5060
+ xdrOnComplete: _xdrOncomplete,
5061
+ fetchOnComplete: _fetchOnComplete,
5062
+ xhrOnComplete: _xhrOnComplete,
5063
+ beaconOnRetry: _onBeaconRetry
5064
+ };
5065
+ var config = {
5066
+ enableSendPromise: false,
5067
+ isOneDs: true,
5068
+ disableCredentials: !_sendCredentials,
5069
+ disableXhr: false,
5070
+ disableBeacon: !_useBeacons,
5071
+ disableBeaconSync: !_useBeacons,
5072
+ disableFetchKeepAlive: _disableFetchKeepAlive,
5073
+ timeWrapper: _timeoutWrapper,
5074
+ addNoResponse: _addNoResponse,
5075
+ senderOnCompleteCallBack: onCompleteFuncs
5076
+ };
5077
+ return config;
4535
5078
  }
4536
- else {
4537
- _timeoutWrapper.set(function () {
4538
- xdr.send(payload[_DYN_DATA ]);
4539
- }, 0);
5079
+ catch (e) {
4540
5080
  }
5081
+ return null;
5082
+ }
5083
+ function _xdrOncomplete(xdr, oncomplete, payload) {
5084
+ var response = getResponseText(xdr);
5085
+ _doOnComplete(oncomplete, 200, {}, response);
5086
+ _handleCollectorResponse(response);
4541
5087
  }
4542
5088
  function _initDefaults() {
4543
5089
  var undefValue;
@@ -4572,123 +5118,26 @@
4572
5118
  _isInitialized = false;
4573
5119
  _timeoutWrapper = createTimeoutWrapper();
4574
5120
  _excludeCsMetaData = false;
5121
+ _sendPostMgr = null;
4575
5122
  }
4576
- function _fetchSendPost(payload, oncomplete, sync) {
4577
- var _a;
4578
- var theUrl = payload[_DYN_URL_STRING ];
4579
- var ignoreResponse = false;
4580
- var responseHandled = false;
4581
- var requestInit = (_a = {
4582
- body: payload[_DYN_DATA ],
4583
- method: STR_POST_METHOD
4584
- },
4585
- _a[STR_DISABLED_PROPERTY_NAME] = true,
4586
- _a);
4587
- if (sync) {
4588
- requestInit.keepalive = true;
4589
- if (payload[_DYN__SEND_REASON ] === 2 ) {
4590
- ignoreResponse = true;
4591
- if (_addNoResponse) {
4592
- theUrl += _noResponseQs;
4593
- }
4594
- }
4595
- }
4596
- if (_sendCredentials) {
4597
- requestInit.credentials = "include";
4598
- }
4599
- if (payload.headers && objKeys(payload.headers)[_DYN_LENGTH ] > 0) {
4600
- requestInit[_DYN_HEADERS ] = payload[_DYN_HEADERS ];
4601
- }
5123
+ function _fetchOnComplete(response, onComplete, resValue, payload) {
4602
5124
  var handleResponse = function (status, headerMap, responseText) {
4603
- if (!responseHandled) {
4604
- responseHandled = true;
4605
- _doOnComplete(oncomplete, status, headerMap, responseText);
4606
- _handleCollectorResponse(responseText);
4607
- }
5125
+ _doOnComplete(onComplete, status, headerMap, responseText);
5126
+ _handleCollectorResponse(responseText);
4608
5127
  };
4609
- var handleError = function () {
4610
- if (!responseHandled) {
4611
- responseHandled = true;
4612
- _doOnComplete(oncomplete, 0, {});
4613
- }
4614
- };
4615
- fetch(theUrl, requestInit).then(function (response) {
4616
- var headerMap = {};
4617
- var responseText = STR_EMPTY;
4618
- var headers = response[_DYN_HEADERS ];
4619
- if (headers) {
4620
- headers["forEach"](function (value, name) {
4621
- headerMap[name] = value;
4622
- });
4623
- }
4624
- if (response.body) {
4625
- response.text().then(function (text) {
4626
- responseText = text;
4627
- handleResponse(response.status, headerMap, responseText);
4628
- }, handleError);
4629
- }
4630
- else {
4631
- handleResponse(response.status, headerMap, "");
4632
- }
4633
- }).catch(handleError);
4634
- if (ignoreResponse && !responseHandled) {
4635
- responseHandled = true;
4636
- _doOnComplete(oncomplete, 200, {});
4637
- }
4638
- if (!responseHandled && payload[_DYN_TIMEOUT ] > 0) {
4639
- _timeoutWrapper.set(function () {
4640
- if (!responseHandled) {
4641
- responseHandled = true;
4642
- _doOnComplete(oncomplete, 500, {});
4643
- }
4644
- }, payload[_DYN_TIMEOUT ]);
5128
+ var headerMap = {};
5129
+ var headers = response[_DYN_HEADERS ];
5130
+ if (headers) {
5131
+ headers["forEach"](function (value, name) {
5132
+ headerMap[name] = value;
5133
+ });
4645
5134
  }
5135
+ handleResponse(response.status, headerMap, resValue || STR_EMPTY);
4646
5136
  }
4647
- function _xhrSendPost(payload, oncomplete, sync) {
4648
- var theUrl = payload[_DYN_URL_STRING ];
4649
- function _appendHeader(theHeaders, xhr, name) {
4650
- if (!theHeaders[name] && xhr && xhr[_DYN_GET_RESPONSE_HEADER ]) {
4651
- var value = xhr[_DYN_GET_RESPONSE_HEADER ](name);
4652
- if (value) {
4653
- theHeaders[name] = strTrim(value);
4654
- }
4655
- }
4656
- return theHeaders;
4657
- }
4658
- function _getAllResponseHeaders(xhr) {
4659
- var theHeaders = {};
4660
- if (!xhr[_DYN_GET_ALL_RESPONSE_HEA10 ]) {
4661
- theHeaders = _appendHeader(theHeaders, xhr, STR_TIME_DELTA_HEADER);
4662
- theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_HEADER);
4663
- theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_SECONDS_HEADER);
4664
- }
4665
- else {
4666
- theHeaders = _convertAllHeadersToMap(xhr[_DYN_GET_ALL_RESPONSE_HEA10 ]());
4667
- }
4668
- return theHeaders;
4669
- }
4670
- function xhrComplete(xhr, responseTxt) {
4671
- _doOnComplete(oncomplete, xhr.status, _getAllResponseHeaders(xhr), responseTxt);
4672
- }
4673
- if (sync && payload[_DYN_DISABLE_XHR_SYNC ]) {
4674
- sync = false;
4675
- }
4676
- var xhrRequest = openXhr(STR_POST_METHOD, theUrl, _sendCredentials, true, sync, payload[_DYN_TIMEOUT ]);
4677
- objForEachKey(payload[_DYN_HEADERS ], function (name, value) {
4678
- xhrRequest.setRequestHeader(name, value);
4679
- });
4680
- xhrRequest.onload = function () {
4681
- var response = _getResponseText(xhrRequest);
4682
- xhrComplete(xhrRequest, response);
4683
- _handleCollectorResponse(response);
4684
- };
4685
- xhrRequest.onerror = function () {
4686
- xhrComplete(xhrRequest);
4687
- };
4688
- xhrRequest[_DYN_ONTIMEOUT ] = function () {
4689
- xhrComplete(xhrRequest);
4690
- };
4691
- xhrRequest.send(payload[_DYN_DATA ]);
5137
+ function _xhrOnComplete(request, oncomplete, payload) {
5138
+ var response = getResponseText(request);
5139
+ _doOnComplete(oncomplete, request.status, _getAllResponseHeaders(request, true), response);
5140
+ _handleCollectorResponse(response);
4692
5141
  }
4693
5142
  function _doOnComplete(oncomplete, status, headers, response) {
4694
5143
  try {
@@ -4698,53 +5147,51 @@
4698
5147
  _throwInternal(_logger, 2 , 518 , dumpObj(e));
4699
5148
  }
4700
5149
  }
4701
- function _beaconSendPost(payload, oncomplete, sync) {
5150
+ function _onBeaconRetry(payload, onComplete, canSend) {
4702
5151
  var internalPayloadData = payload;
4703
5152
  var status = 200;
4704
5153
  var thePayload = internalPayloadData[_DYN__THE_PAYLOAD ];
4705
5154
  var theUrl = payload[_DYN_URL_STRING ] + (_addNoResponse ? _noResponseQs : STR_EMPTY);
4706
5155
  try {
4707
5156
  var nav_1 = getNavigator();
4708
- if (!nav_1.sendBeacon(theUrl, payload[_DYN_DATA ])) {
4709
- if (thePayload) {
4710
- var persistStorage = !!_core.getPlugin("LocalStorage");
4711
- var droppedBatches_1 = [];
4712
- var sentBatches_1 = [];
4713
- arrForEach(thePayload[_DYN_BATCHES ], function (theBatch) {
4714
- if (droppedBatches_1 && theBatch && theBatch[_DYN_COUNT ]() > 0) {
4715
- var theEvents = theBatch[_DYN_EVENTS ]();
4716
- for (var lp = 0; lp < theEvents[_DYN_LENGTH ]; lp++) {
4717
- if (!nav_1.sendBeacon(theUrl, _serializer.getEventBlob(theEvents[lp]))) {
4718
- droppedBatches_1[_DYN_PUSH ](theBatch[_DYN_SPLIT ](lp));
4719
- break;
4720
- }
4721
- else {
4722
- sentBatches_1[_DYN_PUSH ](theBatch[lp]);
4723
- }
5157
+ if (thePayload) {
5158
+ var persistStorage = !!_core.getPlugin("LocalStorage");
5159
+ var droppedBatches_1 = [];
5160
+ var sentBatches_1 = [];
5161
+ arrForEach(thePayload[_DYN_BATCHES ], function (theBatch) {
5162
+ if (droppedBatches_1 && theBatch && theBatch[_DYN_COUNT ]() > 0) {
5163
+ var theEvents = theBatch[_DYN_EVENTS ]();
5164
+ for (var lp = 0; lp < theEvents[_DYN_LENGTH ]; lp++) {
5165
+ if (!nav_1.sendBeacon(theUrl, _serializer.getEventBlob(theEvents[lp]))) {
5166
+ droppedBatches_1[_DYN_PUSH ](theBatch[_DYN_SPLIT ](lp));
5167
+ break;
5168
+ }
5169
+ else {
5170
+ sentBatches_1[_DYN_PUSH ](theBatch[lp]);
4724
5171
  }
4725
5172
  }
4726
- else {
4727
- droppedBatches_1[_DYN_PUSH ](theBatch[_DYN_SPLIT ](0));
4728
- }
4729
- });
4730
- if (sentBatches_1[_DYN_LENGTH ] > 0) {
4731
- thePayload.sentEvts = sentBatches_1;
4732
5173
  }
4733
- if (!persistStorage) {
4734
- _sendBatchesNotification(droppedBatches_1, 8003 , thePayload[_DYN_SEND_TYPE ], true);
5174
+ else {
5175
+ droppedBatches_1[_DYN_PUSH ](theBatch[_DYN_SPLIT ](0));
4735
5176
  }
5177
+ });
5178
+ if (sentBatches_1[_DYN_LENGTH ] > 0) {
5179
+ thePayload.sentEvts = sentBatches_1;
4736
5180
  }
4737
- else {
4738
- status = 0;
5181
+ if (!persistStorage) {
5182
+ _sendBatchesNotification(droppedBatches_1, 8003 , thePayload[_DYN_SEND_TYPE ], true);
4739
5183
  }
4740
5184
  }
5185
+ else {
5186
+ status = 0;
5187
+ }
4741
5188
  }
4742
5189
  catch (ex) {
4743
5190
  _warnToConsole(_logger, "Failed to send telemetry using sendBeacon API. Ex:" + dumpObj(ex));
4744
5191
  status = 0;
4745
5192
  }
4746
5193
  finally {
4747
- _doOnComplete(oncomplete, status, {}, STR_EMPTY);
5194
+ _doOnComplete(onComplete, status, {}, STR_EMPTY);
4748
5195
  }
4749
5196
  }
4750
5197
  function _isBeaconPayload(sendType) {
@@ -4808,7 +5255,7 @@
4808
5255
  _paused = false;
4809
5256
  _self[_DYN_SEND_QUEUED_REQUESTS ](0 , 4 );
4810
5257
  };
4811
- _self[_DYN_SEND_SYNCHRONOUS_BAT11 ] = function (batch, sendType, sendReason) {
5258
+ _self[_DYN_SEND_SYNCHRONOUS_BAT10 ] = function (batch, sendType, sendReason) {
4812
5259
  if (batch && batch[_DYN_COUNT ]() > 0) {
4813
5260
  if (isNullOrUndefined(sendType)) {
4814
5261
  sendType = 1 ;
@@ -5017,7 +5464,7 @@
5017
5464
  };
5018
5465
  var isSync = thePayload[_DYN_IS_TEARDOWN ] || thePayload[_DYN_IS_SYNC ];
5019
5466
  try {
5020
- sendInterface_1[_DYN_SEND_POST ](payload, onComplete, isSync);
5467
+ sendInterface_1.sendPOST(payload, onComplete, isSync);
5021
5468
  if (_sendListener) {
5022
5469
  _sendListener(orgPayloadData, payload, isSync, thePayload[_DYN_IS_BEACON ]);
5023
5470
  }
@@ -5038,7 +5485,7 @@
5038
5485
  data: orgPayloadData[_DYN_DATA ],
5039
5486
  urlString: orgPayloadData[_DYN_URL_STRING ],
5040
5487
  headers: extend({}, orgPayloadData[_DYN_HEADERS ]),
5041
- timeout: orgPayloadData[_DYN_TIMEOUT ],
5488
+ timeout: orgPayloadData.timeout,
5042
5489
  disableXhrSync: orgPayloadData[_DYN_DISABLE_XHR_SYNC ],
5043
5490
  disableFetchKeepAlive: orgPayloadData[_DYN_DISABLE_FETCH_KEEP_A6 ]
5044
5491
  };
@@ -5094,7 +5541,7 @@
5094
5541
  if (headers) {
5095
5542
  _clockSkewManager[_DYN_SET_CLOCK_SKEW ](headers[STR_TIME_DELTA_HEADER]);
5096
5543
  var killDuration = headers[STR_KILL_DURATION_HEADER] || headers["kill-duration-seconds"];
5097
- arrForEach(_killSwitch[_DYN_SET_KILL_SWITCH_TENA12 ](headers[STR_KILL_TOKENS_HEADER], killDuration), function (killToken) {
5544
+ arrForEach(_killSwitch[_DYN_SET_KILL_SWITCH_TENA11 ](headers[STR_KILL_TOKENS_HEADER], killDuration), function (killToken) {
5098
5545
  arrForEach(thePayload[_DYN_BATCHES ], function (theBatch) {
5099
5546
  if (theBatch[_DYN_I_KEY ]() === killToken) {
5100
5547
  droppedBatches = droppedBatches || [];
@@ -5147,7 +5594,7 @@
5147
5594
  function _handleRequestFinished(thePayload, batchReason, sendReason, backOffTrans) {
5148
5595
  try {
5149
5596
  if (backOffTrans) {
5150
- _postManager[_DYN__BACK_OFF_TRANSMISSI13 ]();
5597
+ _postManager[_DYN__BACK_OFF_TRANSMISSI12 ]();
5151
5598
  }
5152
5599
  var theBatches = thePayload[_DYN_BATCHES ];
5153
5600
  if (batchReason === 200 ) {
@@ -5186,26 +5633,6 @@
5186
5633
  _timeoutWrapper.set(cb, interval);
5187
5634
  }
5188
5635
  }
5189
- function _convertAllHeadersToMap(headersString) {
5190
- var headers = {};
5191
- if (isString(headersString)) {
5192
- var headersArray = strTrim(headersString)[_DYN_SPLIT ](/[\r\n]+/);
5193
- arrForEach(headersArray, function (headerEntry) {
5194
- if (headerEntry) {
5195
- var idx = headerEntry.indexOf(": ");
5196
- if (idx !== -1) {
5197
- var header = strTrim(headerEntry.substring(0, idx))[_DYN_TO_LOWER_CASE ]();
5198
- var value = strTrim(headerEntry.substring(idx + 1));
5199
- headers[header] = value;
5200
- }
5201
- else {
5202
- headers[strTrim(headerEntry)] = 1;
5203
- }
5204
- }
5205
- });
5206
- }
5207
- return headers;
5208
- }
5209
5636
  function _getMsfpc(thePayload) {
5210
5637
  for (var lp = 0; lp < thePayload.batches[_DYN_LENGTH ]; lp++) {
5211
5638
  var msfpc = thePayload[_DYN_BATCHES ][lp].Msfpc();
@@ -5321,7 +5748,7 @@
5321
5748
  excludeCsMetaData: undefValue
5322
5749
  });
5323
5750
  function isOverrideFn(httpXHROverride) {
5324
- return httpXHROverride && httpXHROverride[_DYN_SEND_POST ];
5751
+ return httpXHROverride && httpXHROverride.sendPOST;
5325
5752
  }
5326
5753
  var PostChannel = /** @class */ (function (_super) {
5327
5754
  __extendsFn(PostChannel, _super);
@@ -5329,7 +5756,7 @@
5329
5756
  var _this = _super.call(this) || this;
5330
5757
  _this.identifier = "PostChannel";
5331
5758
  _this.priority = 1011;
5332
- _this.version = '4.1.1-nightly3.2403-02';
5759
+ _this.version = '4.1.1-nightly3.2403-04';
5333
5760
  var _postConfig;
5334
5761
  var _isTeardownCalled = false;
5335
5762
  var _flushCallbackQueue = [];
@@ -5380,16 +5807,16 @@
5380
5807
  _postConfig = ctx.getExtCfg(_self[_DYN_IDENTIFIER ], defaultPostChannelConfig);
5381
5808
  _timeoutWrapper = createTimeoutWrapper(_postConfig[_DYN_SET_TIMEOUT_OVERRIDE ], _postConfig[_DYN_CLEAR_TIMEOUT_OVERRI3 ]);
5382
5809
  _optimizeObject = !_postConfig[_DYN_DISABLE_OPTIMIZE_OBJ ] && isChromium();
5383
- _ignoreMc1Ms0CookieProcessing = _postConfig[_DYN_IGNORE_MC1_MS0_COOKI14 ];
5810
+ _ignoreMc1Ms0CookieProcessing = _postConfig[_DYN_IGNORE_MC1_MS0_COOKI13 ];
5384
5811
  _hookWParam(core);
5385
5812
  _queueSizeLimit = _postConfig[_DYN_EVENTS_LIMIT_IN_MEM ];
5386
5813
  _immediateQueueSizeLimit = _postConfig.immediateEventLimit;
5387
- _autoFlushEventsLimit = _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI15 ];
5814
+ _autoFlushEventsLimit = _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI14 ];
5388
5815
  _maxEventSendAttempts = _postConfig.maxEventRetryAttempts;
5389
5816
  _maxUnloadEventSendAttempts = _postConfig.maxUnloadEventRetryAttempts;
5390
- _disableAutoBatchFlushLimit = _postConfig[_DYN_DISABLE_AUTO_BATCH_F16 ];
5817
+ _disableAutoBatchFlushLimit = _postConfig[_DYN_DISABLE_AUTO_BATCH_F15 ];
5391
5818
  _setAutoLimits();
5392
- _overrideInstrumentationKey = _postConfig[_DYN_OVERRIDE_INSTRUMENTA17 ];
5819
+ _overrideInstrumentationKey = _postConfig[_DYN_OVERRIDE_INSTRUMENTA16 ];
5393
5820
  _disableTelemetry = !!_postConfig[_DYN_DISABLE_TELEMETRY ];
5394
5821
  if (_unloadHandlersAdded) {
5395
5822
  _removeUnloadHandlers();
@@ -5426,24 +5853,31 @@
5426
5853
  _self.processNext(event, itemCtx);
5427
5854
  };
5428
5855
  _self.getOfflineSupport = function () {
5429
- var details = _httpManager[_DYN_GET_OFFLINE_REQUEST_9 ]();
5430
- return {
5431
- getUrl: function () {
5432
- return details.url;
5433
- },
5434
- serialize: _serialize,
5435
- batch: _batch,
5436
- shouldProcess: function (evt) {
5437
- return !_disableTelemetry;
5438
- },
5439
- createPayload: function (evt) {
5856
+ try {
5857
+ var details_1 = _httpManager && _httpManager[_DYN_GET_OFFLINE_REQUEST_9 ]();
5858
+ if (details_1) {
5440
5859
  return {
5441
- urlString: details.url,
5442
- headers: details[_DYN_HDRS ],
5443
- data: evt
5860
+ getUrl: function () {
5861
+ return details_1.url;
5862
+ },
5863
+ serialize: _serialize,
5864
+ batch: _batch,
5865
+ shouldProcess: function (evt) {
5866
+ return !_disableTelemetry;
5867
+ },
5868
+ createPayload: function (evt) {
5869
+ return {
5870
+ urlString: details_1.url,
5871
+ headers: details_1[_DYN_HDRS ],
5872
+ data: evt
5873
+ };
5874
+ }
5444
5875
  };
5445
5876
  }
5446
- };
5877
+ }
5878
+ catch (e) {
5879
+ }
5880
+ return null;
5447
5881
  };
5448
5882
  _self._doTeardown = function (unloadCtx, unloadState) {
5449
5883
  _releaseAllQueues(2 , 2 );
@@ -5536,7 +5970,7 @@
5536
5970
  if (_optimizeObject) {
5537
5971
  event = optimizeObject(event);
5538
5972
  }
5539
- _httpManager[_DYN_SEND_SYNCHRONOUS_BAT11 ](EventBatch.create(event[_DYN_I_KEY ], [event]), event[_DYN_SYNC ] === true ? 1 : event[_DYN_SYNC ], 3 );
5973
+ _httpManager[_DYN_SEND_SYNCHRONOUS_BAT10 ](EventBatch.create(event[_DYN_I_KEY ], [event]), event[_DYN_SYNC ] === true ? 1 : event[_DYN_SYNC ], 3 );
5540
5974
  return;
5541
5975
  }
5542
5976
  }
@@ -5570,7 +6004,7 @@
5570
6004
  }
5571
6005
  _self.setEventQueueLimits = function (eventLimit, autoFlushLimit) {
5572
6006
  _postConfig[_DYN_EVENTS_LIMIT_IN_MEM ] = _queueSizeLimit = isGreaterThanZero(eventLimit) ? eventLimit : MaxEventsLimitInMem;
5573
- _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI15 ] = _autoFlushEventsLimit = isGreaterThanZero(autoFlushLimit) ? autoFlushLimit : 0;
6007
+ _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI14 ] = _autoFlushEventsLimit = isGreaterThanZero(autoFlushLimit) ? autoFlushLimit : 0;
5574
6008
  _setAutoLimits();
5575
6009
  var doFlush = _queueSize > eventLimit;
5576
6010
  if (!doFlush && _autoFlushBatchLimit > 0) {
@@ -5709,7 +6143,7 @@
5709
6143
  }
5710
6144
  }
5711
6145
  }
5712
- _self[_DYN__BACK_OFF_TRANSMISSI13 ] = function () {
6146
+ _self[_DYN__BACK_OFF_TRANSMISSI12 ] = function () {
5713
6147
  if (_currentBackoffCount < MaxBackoffCount) {
5714
6148
  _currentBackoffCount++;
5715
6149
  _clearScheduledTimer();