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

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-03.gbl.js → ms.post-4.1.1.gbl.js} +1145 -711
  2. package/bundle/es5/ms.post-4.1.1.gbl.js.map +1 -0
  3. package/bundle/es5/ms.post-4.1.1.gbl.min.js +7 -0
  4. package/bundle/es5/ms.post-4.1.1.gbl.min.js.map +1 -0
  5. package/bundle/es5/ms.post-4.1.1.integrity.json +46 -0
  6. package/bundle/es5/{ms.post-4.1.1-nightly3.2403-03.js → ms.post-4.1.1.js} +1145 -711
  7. package/bundle/es5/ms.post-4.1.1.js.map +1 -0
  8. package/bundle/es5/ms.post-4.1.1.min.js +7 -0
  9. package/bundle/es5/ms.post-4.1.1.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 +63 -66
  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-03.gbl.js.map +0 -1
  45. package/bundle/es5/ms.post-4.1.1-nightly3.2403-03.gbl.min.js +0 -7
  46. package/bundle/es5/ms.post-4.1.1-nightly3.2403-03.gbl.min.js.map +0 -1
  47. package/bundle/es5/ms.post-4.1.1-nightly3.2403-03.integrity.json +0 -46
  48. package/bundle/es5/ms.post-4.1.1-nightly3.2403-03.js.map +0 -1
  49. package/bundle/es5/ms.post-4.1.1-nightly3.2403-03.min.js +0 -7
  50. package/bundle/es5/ms.post-4.1.1-nightly3.2403-03.min.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * 1DS JS SDK POST plugin, 4.1.1-nightly3.2403-03
2
+ * 1DS JS SDK POST plugin, 4.1.1
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
6
6
  (function (global, factory) {
7
7
  var undef = "undefined";
8
- var nsKey, key, nm, theExports = {}, modName = "es5_ms_post_4_1_1_nightly3_2403_03", msMod="__ms$mod__";
9
- var mods={}, modDetail=mods[modName]={}, ver="4.1.1-nightly3.2403-03";
8
+ var nsKey, key, nm, theExports = {}, modName = "es5_ms_post_4_1_1", msMod="__ms$mod__";
9
+ var mods={}, modDetail=mods[modName]={}, ver="4.1.1";
10
10
  // Versioned namespace "oneDS4"
11
11
  var exportNs=global, nsKey="oneDS4", exportNs=exportNs[nsKey]=(exportNs[nsKey]||{});
12
12
  // Global namespace "oneDS"
@@ -1151,6 +1151,7 @@ var _DYN__DO_TEARDOWN = "_doTeardown";
1151
1151
  var _DYN_UPDATE = "update";
1152
1152
  var _DYN_GET_NEXT = "getNext";
1153
1153
  var _DYN_SET_NEXT_PLUGIN = "setNextPlugin";
1154
+ var _DYN_PROTOCOL = "protocol";
1154
1155
  var _DYN_USER_AGENT = "userAgent";
1155
1156
  var _DYN_SPLIT$1 = "split";
1156
1157
  var _DYN_NODE_TYPE = "nodeType";
@@ -1158,10 +1159,19 @@ var _DYN_REPLACE = "replace";
1158
1159
  var _DYN_LOG_INTERNAL_MESSAGE = "logInternalMessage";
1159
1160
  var _DYN_TYPE = "type";
1160
1161
  var _DYN_HANDLER = "handler";
1162
+ var _DYN_STATUS = "status";
1163
+ var _DYN_GET_RESPONSE_HEADER = "getResponseHeader";
1164
+ var _DYN_GET_ALL_RESPONSE_HEA5 = "getAllResponseHeaders";
1161
1165
  var _DYN_IS_CHILD_EVT = "isChildEvt";
1166
+ var _DYN_DATA$1 = "data";
1162
1167
  var _DYN_GET_CTX = "getCtx";
1163
1168
  var _DYN_SET_CTX = "setCtx";
1164
1169
  var _DYN_COMPLETE = "complete";
1170
+ var _DYN_URL_STRING$1 = "urlString";
1171
+ var _DYN_SEND_POST = "sendPOST";
1172
+ var _DYN_HEADERS$1 = "headers";
1173
+ var _DYN_TIMEOUT = "timeout";
1174
+ var _DYN_SET_REQUEST_HEADER = "setRequestHeader";
1165
1175
 
1166
1176
  var aggregationErrorType;
1167
1177
  function throwAggregationError(message, sourceErrors) {
@@ -1179,6 +1189,60 @@ function throwAggregationError(message, sourceErrors) {
1179
1189
  throw new aggregationErrorType(theMessage, sourceErrors || []);
1180
1190
  }
1181
1191
 
1192
+ function doAwaitResponse(value, cb) {
1193
+ return doAwait(value, function (value) {
1194
+ return cb ? cb({
1195
+ value: value,
1196
+ rejected: false
1197
+ }) : value;
1198
+ }, function (reason) {
1199
+ return cb ? cb({
1200
+ rejected: true,
1201
+ reason: reason
1202
+ }) : reason;
1203
+ });
1204
+ }
1205
+ function doAwait(value, resolveFn, rejectFn, finallyFn) {
1206
+ var result = value;
1207
+ if (isPromiseLike(value)) {
1208
+ if (resolveFn || rejectFn) {
1209
+ result = value.then(resolveFn, rejectFn);
1210
+ }
1211
+ }
1212
+ else {
1213
+ if (resolveFn) {
1214
+ result = resolveFn(value);
1215
+ }
1216
+ }
1217
+ if (finallyFn) {
1218
+ doFinally(result, finallyFn);
1219
+ }
1220
+ return result;
1221
+ }
1222
+ function doFinally(value, finallyFn) {
1223
+ var result = value;
1224
+ if (finallyFn) {
1225
+ if (isPromiseLike(value)) {
1226
+ if (value.finally) {
1227
+ result = value.finally(finallyFn);
1228
+ }
1229
+ else {
1230
+ result = value.then(function (value) {
1231
+ finallyFn();
1232
+ return value;
1233
+ }, function (reason) {
1234
+ finallyFn();
1235
+ throw reason;
1236
+ });
1237
+ }
1238
+ }
1239
+ else {
1240
+ finallyFn();
1241
+ }
1242
+ }
1243
+ return result;
1244
+ }
1245
+
1182
1246
  var STRING_STATES = [
1183
1247
  "pending", "resolving", "resolved", "rejected"
1184
1248
  ];
@@ -1426,7 +1490,7 @@ function createPromise(executor, timeout) {
1426
1490
  }
1427
1491
 
1428
1492
  var UNDEFINED_VALUE = undefined;
1429
- var STR_EMPTY$2 = "";
1493
+ var STR_EMPTY$3 = "";
1430
1494
  var STR_CORE = "core";
1431
1495
  var STR_DISABLED = "disabled";
1432
1496
  var STR_EXTENSION_CONFIG = "extensionConfig";
@@ -1435,72 +1499,20 @@ var STR_PRIORITY = "priority";
1435
1499
  var STR_GET_PERF_MGR = "getPerfMgr";
1436
1500
  var STR_NOT_DYNAMIC_ERROR = "Not dynamic - ";
1437
1501
 
1438
- var rCamelCase = /-([a-z])/g;
1439
- var rNormalizeInvalid = /([^\w\d_$])/g;
1440
- var rLeadingNumeric = /^(\d+[\w\d_$])/;
1441
- function isNotNullOrUndefined(value) {
1442
- return !isNullOrUndefined(value);
1443
- }
1444
- function normalizeJsName(name) {
1445
- var value = name;
1446
- if (value && isString(value)) {
1447
- value = value[_DYN_REPLACE ](rCamelCase, function (_all, letter) {
1448
- return letter.toUpperCase();
1449
- });
1450
- value = value[_DYN_REPLACE ](rNormalizeInvalid, "_");
1451
- value = value[_DYN_REPLACE ](rLeadingNumeric, function (_all, match) {
1452
- return "_" + match;
1453
- });
1454
- }
1455
- return value;
1456
- }
1457
- function strContains(value, search) {
1458
- if (value && search) {
1459
- return strIndexOf(value, search) !== -1;
1460
- }
1461
- return false;
1462
- }
1463
- function _createProxyFunction(source, funcName) {
1464
- var srcFunc = null;
1465
- var src = null;
1466
- if (isFunction(source)) {
1467
- srcFunc = source;
1468
- }
1469
- else {
1470
- src = source;
1471
- }
1472
- return function () {
1473
- var originalArguments = arguments;
1474
- if (srcFunc) {
1475
- src = srcFunc();
1476
- }
1477
- if (src) {
1478
- return src[funcName][_DYN_APPLY ](src, originalArguments);
1479
- }
1480
- };
1481
- }
1482
- function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
1483
- if (target && name && source) {
1484
- if (overwriteTarget !== false || isUndefined(target[name])) {
1485
- target[name] = _createProxyFunction(source, theFunc);
1486
- }
1487
- }
1488
- }
1489
- function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
1490
- if (target && source && isObject(target) && isArray(functionsToProxy)) {
1491
- arrForEach(functionsToProxy, function (theFuncName) {
1492
- if (isString(theFuncName)) {
1493
- proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
1494
- }
1495
- });
1502
+ var _aiNamespace = null;
1503
+ function _getExtensionNamespace() {
1504
+ var target = getInst("Microsoft");
1505
+ if (target) {
1506
+ _aiNamespace = target["ApplicationInsights"];
1496
1507
  }
1497
- return target;
1508
+ return _aiNamespace;
1498
1509
  }
1499
- function optimizeObject(theObject) {
1500
- if (theObject && objAssign) {
1501
- theObject = ObjClass$1(objAssign({}, theObject));
1510
+ function getDebugExt(config) {
1511
+ var ns = _aiNamespace;
1512
+ if (!ns && config.disableDbgExt !== true) {
1513
+ ns = _aiNamespace || _getExtensionNamespace();
1502
1514
  }
1503
- return theObject;
1515
+ return ns ? ns["ChromeDbgExt"] : null;
1504
1516
  }
1505
1517
 
1506
1518
  var strLocation = "location";
@@ -1580,54 +1592,413 @@ function isReactNative() {
1580
1592
  if (nav && nav.product) {
1581
1593
  return nav.product === strReactNative;
1582
1594
  }
1583
- return false;
1584
- }
1585
- function isIE() {
1586
- var nav = getNavigator();
1587
- if (nav && (nav[_DYN_USER_AGENT ] !== _navUserAgentCheck || _isTrident === null)) {
1588
- _navUserAgentCheck = nav[_DYN_USER_AGENT ];
1589
- var userAgent = (_navUserAgentCheck || STR_EMPTY$2)[_DYN_TO_LOWER_CASE$1 ]();
1590
- _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1595
+ return false;
1596
+ }
1597
+ function isIE() {
1598
+ var nav = getNavigator();
1599
+ if (nav && (nav[_DYN_USER_AGENT ] !== _navUserAgentCheck || _isTrident === null)) {
1600
+ _navUserAgentCheck = nav[_DYN_USER_AGENT ];
1601
+ var userAgent = (_navUserAgentCheck || STR_EMPTY$3)[_DYN_TO_LOWER_CASE$1 ]();
1602
+ _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
1603
+ }
1604
+ return _isTrident;
1605
+ }
1606
+ function isBeaconsSupported(useCached) {
1607
+ if (_beaconsSupported === null || useCached === false) {
1608
+ _beaconsSupported = hasNavigator() && Boolean(getNavigator().sendBeacon);
1609
+ }
1610
+ return _beaconsSupported;
1611
+ }
1612
+ function isFetchSupported(withKeepAlive) {
1613
+ var isSupported = false;
1614
+ try {
1615
+ isSupported = !!getInst("fetch");
1616
+ var request = getInst("Request");
1617
+ if (isSupported && withKeepAlive && request) {
1618
+ isSupported = _hasProperty(request, "keepalive");
1619
+ }
1620
+ }
1621
+ catch (e) {
1622
+ }
1623
+ return isSupported;
1624
+ }
1625
+ function useXDomainRequest() {
1626
+ if (_useXDomainRequest === null) {
1627
+ _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
1628
+ if (_useXDomainRequest && isXhrSupported()) {
1629
+ _useXDomainRequest = _useXDomainRequest && !_hasProperty(getInst(strXMLHttpRequest), "withCredentials");
1630
+ }
1631
+ }
1632
+ return _useXDomainRequest;
1633
+ }
1634
+ function isXhrSupported() {
1635
+ var isSupported = false;
1636
+ try {
1637
+ var xmlHttpRequest = getInst(strXMLHttpRequest);
1638
+ isSupported = !!xmlHttpRequest;
1639
+ }
1640
+ catch (e) {
1641
+ }
1642
+ return isSupported;
1643
+ }
1644
+
1645
+ var _a$3;
1646
+ var STR_WARN_TO_CONSOLE = "warnToConsole";
1647
+ var AiNonUserActionablePrefix = "AI (Internal): ";
1648
+ var AiUserActionablePrefix = "AI: ";
1649
+ var AIInternalMessagePrefix = "AITR_";
1650
+ var defaultValues$1 = {
1651
+ loggingLevelConsole: 0,
1652
+ loggingLevelTelemetry: 1,
1653
+ maxMessageLimit: 25,
1654
+ enableDebug: false
1655
+ };
1656
+ var _logFuncs = (_a$3 = {},
1657
+ _a$3[0 ] = null,
1658
+ _a$3[1 ] = "errorToConsole",
1659
+ _a$3[2 ] = STR_WARN_TO_CONSOLE,
1660
+ _a$3[3 ] = "debugToConsole",
1661
+ _a$3);
1662
+ function _sanitizeDiagnosticText(text) {
1663
+ if (text) {
1664
+ return "\"" + text[_DYN_REPLACE ](/\"/g, STR_EMPTY$3) + "\"";
1665
+ }
1666
+ return STR_EMPTY$3;
1667
+ }
1668
+ function _logToConsole(func, message) {
1669
+ var theConsole = getConsole();
1670
+ if (!!theConsole) {
1671
+ var logFunc = "log";
1672
+ if (theConsole[func]) {
1673
+ logFunc = func;
1674
+ }
1675
+ if (isFunction(theConsole[logFunc])) {
1676
+ theConsole[logFunc](message);
1677
+ }
1678
+ }
1679
+ }
1680
+ var _InternalLogMessage = /** @class */ (function () {
1681
+ function _InternalLogMessage(msgId, msg, isUserAct, properties) {
1682
+ if (isUserAct === void 0) { isUserAct = false; }
1683
+ var _self = this;
1684
+ _self[_DYN_MESSAGE_ID ] = msgId;
1685
+ _self[_DYN_MESSAGE ] =
1686
+ (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
1687
+ msgId;
1688
+ var strProps = STR_EMPTY$3;
1689
+ if (hasJSON()) {
1690
+ strProps = getJSON().stringify(properties);
1691
+ }
1692
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : STR_EMPTY$3) +
1693
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : STR_EMPTY$3);
1694
+ _self[_DYN_MESSAGE ] += diagnosticText;
1695
+ }
1696
+ _InternalLogMessage.dataType = "MessageData";
1697
+ return _InternalLogMessage;
1698
+ }());
1699
+ function safeGetLogger(core, config) {
1700
+ return (core || {})[_DYN_LOGGER ] || new DiagnosticLogger(config);
1701
+ }
1702
+ var DiagnosticLogger = /** @class */ (function () {
1703
+ function DiagnosticLogger(config) {
1704
+ this.identifier = "DiagnosticLogger";
1705
+ this.queue = [];
1706
+ var _messageCount = 0;
1707
+ var _messageLogged = {};
1708
+ var _loggingLevelConsole;
1709
+ var _loggingLevelTelemetry;
1710
+ var _maxInternalMessageLimit;
1711
+ var _enableDebug;
1712
+ var _unloadHandler;
1713
+ dynamicProto(DiagnosticLogger, this, function (_self) {
1714
+ _unloadHandler = _setDefaultsFromConfig(config || {});
1715
+ _self.consoleLoggingLevel = function () { return _loggingLevelConsole; };
1716
+ _self[_DYN_THROW_INTERNAL ] = function (severity, msgId, msg, properties, isUserAct) {
1717
+ if (isUserAct === void 0) { isUserAct = false; }
1718
+ var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
1719
+ if (_enableDebug) {
1720
+ throw dumpObj(message);
1721
+ }
1722
+ else {
1723
+ var logFunc = _logFuncs[severity] || STR_WARN_TO_CONSOLE;
1724
+ if (!isUndefined(message[_DYN_MESSAGE ])) {
1725
+ if (isUserAct) {
1726
+ var messageKey = +message[_DYN_MESSAGE_ID ];
1727
+ if (!_messageLogged[messageKey] && _loggingLevelConsole >= severity) {
1728
+ _self[logFunc](message[_DYN_MESSAGE ]);
1729
+ _messageLogged[messageKey] = true;
1730
+ }
1731
+ }
1732
+ else {
1733
+ if (_loggingLevelConsole >= severity) {
1734
+ _self[logFunc](message[_DYN_MESSAGE ]);
1735
+ }
1736
+ }
1737
+ _logInternalMessage(severity, message);
1738
+ }
1739
+ else {
1740
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
1741
+ }
1742
+ }
1743
+ };
1744
+ _self.debugToConsole = function (message) {
1745
+ _logToConsole("debug", message);
1746
+ _debugExtMsg("warning", message);
1747
+ };
1748
+ _self[_DYN_WARN_TO_CONSOLE ] = function (message) {
1749
+ _logToConsole("warn", message);
1750
+ _debugExtMsg("warning", message);
1751
+ };
1752
+ _self.errorToConsole = function (message) {
1753
+ _logToConsole("error", message);
1754
+ _debugExtMsg("error", message);
1755
+ };
1756
+ _self.resetInternalMessageCount = function () {
1757
+ _messageCount = 0;
1758
+ _messageLogged = {};
1759
+ };
1760
+ _self[_DYN_LOG_INTERNAL_MESSAGE ] = _logInternalMessage;
1761
+ _self[_DYN_UNLOAD ] = function (isAsync) {
1762
+ _unloadHandler && _unloadHandler.rm();
1763
+ _unloadHandler = null;
1764
+ };
1765
+ function _logInternalMessage(severity, message) {
1766
+ if (_areInternalMessagesThrottled()) {
1767
+ return;
1768
+ }
1769
+ var logMessage = true;
1770
+ var messageKey = AIInternalMessagePrefix + message[_DYN_MESSAGE_ID ];
1771
+ if (_messageLogged[messageKey]) {
1772
+ logMessage = false;
1773
+ }
1774
+ else {
1775
+ _messageLogged[messageKey] = true;
1776
+ }
1777
+ if (logMessage) {
1778
+ if (severity <= _loggingLevelTelemetry) {
1779
+ _self.queue[_DYN_PUSH$1 ](message);
1780
+ _messageCount++;
1781
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
1782
+ }
1783
+ if (_messageCount === _maxInternalMessageLimit) {
1784
+ var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
1785
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
1786
+ _self.queue[_DYN_PUSH$1 ](throttleMessage);
1787
+ if (severity === 1 ) {
1788
+ _self.errorToConsole(throttleLimitMessage);
1789
+ }
1790
+ else {
1791
+ _self[_DYN_WARN_TO_CONSOLE ](throttleLimitMessage);
1792
+ }
1793
+ }
1794
+ }
1795
+ }
1796
+ function _setDefaultsFromConfig(config) {
1797
+ return onConfigChange(createDynamicConfig(config, defaultValues$1, _self).cfg, function (details) {
1798
+ var config = details.cfg;
1799
+ _loggingLevelConsole = config[_DYN_LOGGING_LEVEL_CONSOL4 ];
1800
+ _loggingLevelTelemetry = config.loggingLevelTelemetry;
1801
+ _maxInternalMessageLimit = config.maxMessageLimit;
1802
+ _enableDebug = config.enableDebug;
1803
+ });
1804
+ }
1805
+ function _areInternalMessagesThrottled() {
1806
+ return _messageCount >= _maxInternalMessageLimit;
1807
+ }
1808
+ function _debugExtMsg(name, data) {
1809
+ var dbgExt = getDebugExt(config || {});
1810
+ if (dbgExt && dbgExt[_DYN_DIAG_LOG ]) {
1811
+ dbgExt[_DYN_DIAG_LOG ](name, data);
1812
+ }
1813
+ }
1814
+ });
1815
+ }
1816
+ DiagnosticLogger.__ieDyn=1;
1817
+ return DiagnosticLogger;
1818
+ }());
1819
+ function _getLogger(logger) {
1820
+ return (logger || new DiagnosticLogger());
1821
+ }
1822
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1823
+ if (isUserAct === void 0) { isUserAct = false; }
1824
+ _getLogger(logger)[_DYN_THROW_INTERNAL ](severity, msgId, msg, properties, isUserAct);
1825
+ }
1826
+ function _warnToConsole(logger, message) {
1827
+ _getLogger(logger)[_DYN_WARN_TO_CONSOLE ](message);
1828
+ }
1829
+
1830
+ var rCamelCase = /-([a-z])/g;
1831
+ var rNormalizeInvalid = /([^\w\d_$])/g;
1832
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
1833
+ function isNotNullOrUndefined(value) {
1834
+ return !isNullOrUndefined(value);
1835
+ }
1836
+ function normalizeJsName(name) {
1837
+ var value = name;
1838
+ if (value && isString(value)) {
1839
+ value = value[_DYN_REPLACE ](rCamelCase, function (_all, letter) {
1840
+ return letter.toUpperCase();
1841
+ });
1842
+ value = value[_DYN_REPLACE ](rNormalizeInvalid, "_");
1843
+ value = value[_DYN_REPLACE ](rLeadingNumeric, function (_all, match) {
1844
+ return "_" + match;
1845
+ });
1846
+ }
1847
+ return value;
1848
+ }
1849
+ function strContains(value, search) {
1850
+ if (value && search) {
1851
+ return strIndexOf(value, search) !== -1;
1852
+ }
1853
+ return false;
1854
+ }
1855
+ function _createProxyFunction(source, funcName) {
1856
+ var srcFunc = null;
1857
+ var src = null;
1858
+ if (isFunction(source)) {
1859
+ srcFunc = source;
1860
+ }
1861
+ else {
1862
+ src = source;
1863
+ }
1864
+ return function () {
1865
+ var originalArguments = arguments;
1866
+ if (srcFunc) {
1867
+ src = srcFunc();
1868
+ }
1869
+ if (src) {
1870
+ return src[funcName][_DYN_APPLY ](src, originalArguments);
1871
+ }
1872
+ };
1873
+ }
1874
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
1875
+ if (target && name && source) {
1876
+ if (overwriteTarget !== false || isUndefined(target[name])) {
1877
+ target[name] = _createProxyFunction(source, theFunc);
1878
+ }
1879
+ }
1880
+ }
1881
+ function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
1882
+ if (target && source && isObject(target) && isArray(functionsToProxy)) {
1883
+ arrForEach(functionsToProxy, function (theFuncName) {
1884
+ if (isString(theFuncName)) {
1885
+ proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
1886
+ }
1887
+ });
1888
+ }
1889
+ return target;
1890
+ }
1891
+ function optimizeObject(theObject) {
1892
+ if (theObject && objAssign) {
1893
+ theObject = ObjClass$1(objAssign({}, theObject));
1894
+ }
1895
+ return theObject;
1896
+ }
1897
+ function getResponseText(xhr) {
1898
+ try {
1899
+ return xhr.responseText;
1900
+ }
1901
+ catch (e) {
1902
+ }
1903
+ return null;
1904
+ }
1905
+ function formatErrorMessageXdr(xdr, message) {
1906
+ if (xdr) {
1907
+ return "XDomainRequest,Response:" + getResponseText(xdr) || "";
1908
+ }
1909
+ return message;
1910
+ }
1911
+ function formatErrorMessageXhr(xhr, message) {
1912
+ if (xhr) {
1913
+ return "XMLHttpRequest,Status:" + xhr[_DYN_STATUS ] + ",Response:" + getResponseText(xhr) || xhr.response || "";
1914
+ }
1915
+ return message;
1916
+ }
1917
+ function prependTransports(theTransports, newTransports) {
1918
+ if (newTransports) {
1919
+ if (isNumber(newTransports)) {
1920
+ theTransports = [newTransports].concat(theTransports);
1921
+ }
1922
+ else if (isArray(newTransports)) {
1923
+ theTransports = newTransports.concat(theTransports);
1924
+ }
1925
+ }
1926
+ return theTransports;
1927
+ }
1928
+ var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
1929
+ var strWithCredentials = "withCredentials";
1930
+ var strTimeout = "timeout";
1931
+ function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {
1932
+ if (disabled === void 0) { disabled = false; }
1933
+ if (isSync === void 0) { isSync = false; }
1934
+ function _wrapSetXhrProp(xhr, prop, value) {
1935
+ try {
1936
+ xhr[prop] = value;
1937
+ }
1938
+ catch (e) {
1939
+ }
1940
+ }
1941
+ var xhr = new XMLHttpRequest();
1942
+ if (disabled) {
1943
+ _wrapSetXhrProp(xhr, strDisabledPropertyName, disabled);
1944
+ }
1945
+ if (withCredentials) {
1946
+ _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
1947
+ }
1948
+ xhr.open(method, urlString, !isSync);
1949
+ if (withCredentials) {
1950
+ _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
1951
+ }
1952
+ if (!isSync && timeout) {
1953
+ _wrapSetXhrProp(xhr, strTimeout, timeout);
1591
1954
  }
1592
- return _isTrident;
1955
+ return xhr;
1593
1956
  }
1594
- function isBeaconsSupported(useCached) {
1595
- if (_beaconsSupported === null || useCached === false) {
1596
- _beaconsSupported = hasNavigator() && Boolean(getNavigator().sendBeacon);
1957
+ function convertAllHeadersToMap(headersString) {
1958
+ var headers = {};
1959
+ if (isString(headersString)) {
1960
+ var headersArray = strTrim(headersString)[_DYN_SPLIT$1 ](/[\r\n]+/);
1961
+ arrForEach(headersArray, function (headerEntry) {
1962
+ if (headerEntry) {
1963
+ var idx = headerEntry.indexOf(": ");
1964
+ if (idx !== -1) {
1965
+ var header = strTrim(headerEntry.substring(0, idx))[_DYN_TO_LOWER_CASE$1 ]();
1966
+ var value = strTrim(headerEntry.substring(idx + 1));
1967
+ headers[header] = value;
1968
+ }
1969
+ else {
1970
+ headers[strTrim(headerEntry)] = 1;
1971
+ }
1972
+ }
1973
+ });
1597
1974
  }
1598
- return _beaconsSupported;
1975
+ return headers;
1599
1976
  }
1600
- function isFetchSupported(withKeepAlive) {
1601
- var isSupported = false;
1602
- try {
1603
- isSupported = !!getInst("fetch");
1604
- var request = getInst("Request");
1605
- if (isSupported && withKeepAlive && request) {
1606
- isSupported = _hasProperty(request, "keepalive");
1977
+ function _appendHeader(theHeaders, xhr, name) {
1978
+ if (!theHeaders[name] && xhr && xhr[_DYN_GET_RESPONSE_HEADER ]) {
1979
+ var value = xhr[_DYN_GET_RESPONSE_HEADER ](name);
1980
+ if (value) {
1981
+ theHeaders[name] = strTrim(value);
1607
1982
  }
1608
1983
  }
1609
- catch (e) {
1610
- }
1611
- return isSupported;
1984
+ return theHeaders;
1612
1985
  }
1613
- function useXDomainRequest() {
1614
- if (_useXDomainRequest === null) {
1615
- _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined);
1616
- if (_useXDomainRequest && isXhrSupported()) {
1617
- _useXDomainRequest = _useXDomainRequest && !_hasProperty(getInst(strXMLHttpRequest), "withCredentials");
1986
+ var STR_KILL_DURATION_HEADER$1 = "kill-duration";
1987
+ var STR_KILL_DURATION_SECONDS_HEADER = "kill-duration-seconds";
1988
+ var STR_TIME_DELTA_HEADER$1 = "time-delta-millis";
1989
+ function _getAllResponseHeaders(xhr, isOneDs) {
1990
+ var theHeaders = {};
1991
+ if (!xhr[_DYN_GET_ALL_RESPONSE_HEA5 ]) {
1992
+ if (!!isOneDs) {
1993
+ theHeaders = _appendHeader(theHeaders, xhr, STR_TIME_DELTA_HEADER$1);
1994
+ theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_HEADER$1);
1995
+ theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_SECONDS_HEADER);
1618
1996
  }
1619
1997
  }
1620
- return _useXDomainRequest;
1621
- }
1622
- function isXhrSupported() {
1623
- var isSupported = false;
1624
- try {
1625
- var xmlHttpRequest = getInst(strXMLHttpRequest);
1626
- isSupported = !!xmlHttpRequest;
1627
- }
1628
- catch (e) {
1998
+ else {
1999
+ theHeaders = convertAllHeadersToMap(xhr[_DYN_GET_ALL_RESPONSE_HEA5 ]());
1629
2000
  }
1630
- return isSupported;
2001
+ return theHeaders;
1631
2002
  }
1632
2003
 
1633
2004
  var UInt32Mask = 0x100000000;
@@ -1687,7 +2058,7 @@ function newId(maxLength) {
1687
2058
  var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1688
2059
  var number = random32() >>> 0;
1689
2060
  var chars = 0;
1690
- var result = STR_EMPTY$2;
2061
+ var result = STR_EMPTY$3;
1691
2062
  while (result[_DYN_LENGTH$2 ] < maxLength) {
1692
2063
  chars++;
1693
2064
  result += base64chars.charAt(number & 0x3F);
@@ -1725,11 +2096,11 @@ function _getCache(data, target) {
1725
2096
  }
1726
2097
  function createUniqueNamespace(name, includeVersion) {
1727
2098
  if (includeVersion === void 0) { includeVersion = false; }
1728
- return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : STR_EMPTY$2) + instanceName);
2099
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : STR_EMPTY$3) + instanceName);
1729
2100
  }
1730
2101
  function createElmNodeData(name) {
1731
2102
  var data = {
1732
- id: createUniqueNamespace("_aiData-" + (name || STR_EMPTY$2) + "." + version),
2103
+ id: createUniqueNamespace("_aiData-" + (name || STR_EMPTY$3) + "." + version),
1733
2104
  accept: function (target) {
1734
2105
  return _canAcceptData(target);
1735
2106
  },
@@ -2350,226 +2721,27 @@ function _logInvalidAccess(logger, message) {
2350
2721
  logger[_DYN_THROW_INTERNAL ](2 , 108 , message);
2351
2722
  }
2352
2723
  else {
2353
- throwInvalidAccess(message);
2354
- }
2355
- }
2356
- function createDynamicConfig(config, defaultConfig, logger, inPlace) {
2357
- var dynamicHandler = _createDynamicHandler(logger, config || {}, inPlace);
2358
- if (defaultConfig) {
2359
- dynamicHandler[_DYN_SET_DF ](dynamicHandler.cfg, defaultConfig);
2360
- }
2361
- return dynamicHandler;
2362
- }
2363
- function onConfigChange(config, configHandler, logger) {
2364
- var handler = config[CFG_HANDLER_LINK] || config;
2365
- if (handler.cfg && (handler.cfg === config || handler.cfg[CFG_HANDLER_LINK] === handler)) {
2366
- return handler[_DYN_WATCH ](configHandler);
2367
- }
2368
- _logInvalidAccess(logger, STR_NOT_DYNAMIC_ERROR + dumpObj(config));
2369
- return createDynamicConfig(config, null, logger)[_DYN_WATCH ](configHandler);
2370
- }
2371
-
2372
- var _aiNamespace = null;
2373
- function _getExtensionNamespace() {
2374
- var target = getInst("Microsoft");
2375
- if (target) {
2376
- _aiNamespace = target["ApplicationInsights"];
2377
- }
2378
- return _aiNamespace;
2379
- }
2380
- function getDebugExt(config) {
2381
- var ns = _aiNamespace;
2382
- if (!ns && config.disableDbgExt !== true) {
2383
- ns = _aiNamespace || _getExtensionNamespace();
2384
- }
2385
- return ns ? ns["ChromeDbgExt"] : null;
2386
- }
2387
-
2388
- var _a$3;
2389
- var STR_WARN_TO_CONSOLE = "warnToConsole";
2390
- var AiNonUserActionablePrefix = "AI (Internal): ";
2391
- var AiUserActionablePrefix = "AI: ";
2392
- var AIInternalMessagePrefix = "AITR_";
2393
- var defaultValues$1 = {
2394
- loggingLevelConsole: 0,
2395
- loggingLevelTelemetry: 1,
2396
- maxMessageLimit: 25,
2397
- enableDebug: false
2398
- };
2399
- var _logFuncs = (_a$3 = {},
2400
- _a$3[0 ] = null,
2401
- _a$3[1 ] = "errorToConsole",
2402
- _a$3[2 ] = STR_WARN_TO_CONSOLE,
2403
- _a$3[3 ] = "debugToConsole",
2404
- _a$3);
2405
- function _sanitizeDiagnosticText(text) {
2406
- if (text) {
2407
- return "\"" + text[_DYN_REPLACE ](/\"/g, STR_EMPTY$2) + "\"";
2408
- }
2409
- return STR_EMPTY$2;
2410
- }
2411
- function _logToConsole(func, message) {
2412
- var theConsole = getConsole();
2413
- if (!!theConsole) {
2414
- var logFunc = "log";
2415
- if (theConsole[func]) {
2416
- logFunc = func;
2417
- }
2418
- if (isFunction(theConsole[logFunc])) {
2419
- theConsole[logFunc](message);
2420
- }
2421
- }
2422
- }
2423
- var _InternalLogMessage = /** @class */ (function () {
2424
- function _InternalLogMessage(msgId, msg, isUserAct, properties) {
2425
- if (isUserAct === void 0) { isUserAct = false; }
2426
- var _self = this;
2427
- _self[_DYN_MESSAGE_ID ] = msgId;
2428
- _self[_DYN_MESSAGE ] =
2429
- (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
2430
- msgId;
2431
- var strProps = STR_EMPTY$2;
2432
- if (hasJSON()) {
2433
- strProps = getJSON().stringify(properties);
2434
- }
2435
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : STR_EMPTY$2) +
2436
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : STR_EMPTY$2);
2437
- _self[_DYN_MESSAGE ] += diagnosticText;
2438
- }
2439
- _InternalLogMessage.dataType = "MessageData";
2440
- return _InternalLogMessage;
2441
- }());
2442
- function safeGetLogger(core, config) {
2443
- return (core || {})[_DYN_LOGGER ] || new DiagnosticLogger(config);
2444
- }
2445
- var DiagnosticLogger = /** @class */ (function () {
2446
- function DiagnosticLogger(config) {
2447
- this.identifier = "DiagnosticLogger";
2448
- this.queue = [];
2449
- var _messageCount = 0;
2450
- var _messageLogged = {};
2451
- var _loggingLevelConsole;
2452
- var _loggingLevelTelemetry;
2453
- var _maxInternalMessageLimit;
2454
- var _enableDebug;
2455
- var _unloadHandler;
2456
- dynamicProto(DiagnosticLogger, this, function (_self) {
2457
- _unloadHandler = _setDefaultsFromConfig(config || {});
2458
- _self.consoleLoggingLevel = function () { return _loggingLevelConsole; };
2459
- _self[_DYN_THROW_INTERNAL ] = function (severity, msgId, msg, properties, isUserAct) {
2460
- if (isUserAct === void 0) { isUserAct = false; }
2461
- var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
2462
- if (_enableDebug) {
2463
- throw dumpObj(message);
2464
- }
2465
- else {
2466
- var logFunc = _logFuncs[severity] || STR_WARN_TO_CONSOLE;
2467
- if (!isUndefined(message[_DYN_MESSAGE ])) {
2468
- if (isUserAct) {
2469
- var messageKey = +message[_DYN_MESSAGE_ID ];
2470
- if (!_messageLogged[messageKey] && _loggingLevelConsole >= severity) {
2471
- _self[logFunc](message[_DYN_MESSAGE ]);
2472
- _messageLogged[messageKey] = true;
2473
- }
2474
- }
2475
- else {
2476
- if (_loggingLevelConsole >= severity) {
2477
- _self[logFunc](message[_DYN_MESSAGE ]);
2478
- }
2479
- }
2480
- _logInternalMessage(severity, message);
2481
- }
2482
- else {
2483
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
2484
- }
2485
- }
2486
- };
2487
- _self.debugToConsole = function (message) {
2488
- _logToConsole("debug", message);
2489
- _debugExtMsg("warning", message);
2490
- };
2491
- _self[_DYN_WARN_TO_CONSOLE ] = function (message) {
2492
- _logToConsole("warn", message);
2493
- _debugExtMsg("warning", message);
2494
- };
2495
- _self.errorToConsole = function (message) {
2496
- _logToConsole("error", message);
2497
- _debugExtMsg("error", message);
2498
- };
2499
- _self.resetInternalMessageCount = function () {
2500
- _messageCount = 0;
2501
- _messageLogged = {};
2502
- };
2503
- _self[_DYN_LOG_INTERNAL_MESSAGE ] = _logInternalMessage;
2504
- _self[_DYN_UNLOAD ] = function (isAsync) {
2505
- _unloadHandler && _unloadHandler.rm();
2506
- _unloadHandler = null;
2507
- };
2508
- function _logInternalMessage(severity, message) {
2509
- if (_areInternalMessagesThrottled()) {
2510
- return;
2511
- }
2512
- var logMessage = true;
2513
- var messageKey = AIInternalMessagePrefix + message[_DYN_MESSAGE_ID ];
2514
- if (_messageLogged[messageKey]) {
2515
- logMessage = false;
2516
- }
2517
- else {
2518
- _messageLogged[messageKey] = true;
2519
- }
2520
- if (logMessage) {
2521
- if (severity <= _loggingLevelTelemetry) {
2522
- _self.queue[_DYN_PUSH$1 ](message);
2523
- _messageCount++;
2524
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
2525
- }
2526
- if (_messageCount === _maxInternalMessageLimit) {
2527
- var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
2528
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
2529
- _self.queue[_DYN_PUSH$1 ](throttleMessage);
2530
- if (severity === 1 ) {
2531
- _self.errorToConsole(throttleLimitMessage);
2532
- }
2533
- else {
2534
- _self[_DYN_WARN_TO_CONSOLE ](throttleLimitMessage);
2535
- }
2536
- }
2537
- }
2538
- }
2539
- function _setDefaultsFromConfig(config) {
2540
- return onConfigChange(createDynamicConfig(config, defaultValues$1, _self).cfg, function (details) {
2541
- var config = details.cfg;
2542
- _loggingLevelConsole = config[_DYN_LOGGING_LEVEL_CONSOL4 ];
2543
- _loggingLevelTelemetry = config.loggingLevelTelemetry;
2544
- _maxInternalMessageLimit = config.maxMessageLimit;
2545
- _enableDebug = config.enableDebug;
2546
- });
2547
- }
2548
- function _areInternalMessagesThrottled() {
2549
- return _messageCount >= _maxInternalMessageLimit;
2550
- }
2551
- function _debugExtMsg(name, data) {
2552
- var dbgExt = getDebugExt(config || {});
2553
- if (dbgExt && dbgExt[_DYN_DIAG_LOG ]) {
2554
- dbgExt[_DYN_DIAG_LOG ](name, data);
2555
- }
2556
- }
2557
- });
2558
- }
2559
- DiagnosticLogger.__ieDyn=1;
2560
- return DiagnosticLogger;
2561
- }());
2562
- function _getLogger(logger) {
2563
- return (logger || new DiagnosticLogger());
2724
+ throwInvalidAccess(message);
2725
+ }
2564
2726
  }
2565
- function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
2566
- if (isUserAct === void 0) { isUserAct = false; }
2567
- _getLogger(logger)[_DYN_THROW_INTERNAL ](severity, msgId, msg, properties, isUserAct);
2727
+ function createDynamicConfig(config, defaultConfig, logger, inPlace) {
2728
+ var dynamicHandler = _createDynamicHandler(logger, config || {}, inPlace);
2729
+ if (defaultConfig) {
2730
+ dynamicHandler[_DYN_SET_DF ](dynamicHandler.cfg, defaultConfig);
2731
+ }
2732
+ return dynamicHandler;
2568
2733
  }
2569
- function _warnToConsole(logger, message) {
2570
- _getLogger(logger)[_DYN_WARN_TO_CONSOLE ](message);
2734
+ function onConfigChange(config, configHandler, logger) {
2735
+ var handler = config[CFG_HANDLER_LINK] || config;
2736
+ if (handler.cfg && (handler.cfg === config || handler.cfg[CFG_HANDLER_LINK] === handler)) {
2737
+ return handler[_DYN_WATCH ](configHandler);
2738
+ }
2739
+ _logInvalidAccess(logger, STR_NOT_DYNAMIC_ERROR + dumpObj(config));
2740
+ return createDynamicConfig(config, null, logger)[_DYN_WATCH ](configHandler);
2571
2741
  }
2572
2742
 
2743
+ var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
2744
+
2573
2745
  var strExecutionContextKey = "ctx";
2574
2746
  var strParentContextKey = "ParentContextKey";
2575
2747
  var strChildrenContextKey = "ChildrenContextKey";
@@ -2966,7 +3138,7 @@ function createTelemetryPluginProxy(plugin, config, core) {
2966
3138
  doPerf(itemCtx[STR_CORE ](), function () { return identifier + ":" + name; }, function () {
2967
3139
  hasRunContext[chainId] = true;
2968
3140
  try {
2969
- var nextId = nextProxy ? nextProxy._id : STR_EMPTY$2;
3141
+ var nextId = nextProxy ? nextProxy._id : STR_EMPTY$3;
2970
3142
  if (nextId) {
2971
3143
  hasRunContext[nextId] = false;
2972
3144
  }
@@ -3165,76 +3337,507 @@ var BaseTelemetryPlugin = /** @class */ (function () {
3165
3337
  _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx[_DYN_GET_NEXT ]());
3166
3338
  }
3167
3339
  }
3168
- if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
3169
- _updateCallback();
3340
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
3341
+ _updateCallback();
3342
+ }
3343
+ else {
3344
+ result = true;
3345
+ }
3346
+ return result;
3347
+ };
3348
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
3349
+ proxyFunctionAs(_self, "_addHook", function () { return _hookContainer; }, "add");
3350
+ objDefine(_self, "_unloadHooks", { g: function () { return _hookContainer; } });
3351
+ });
3352
+ _self[_DYN_DIAG_LOG ] = function (itemCtx) {
3353
+ return _getTelCtx(itemCtx)[_DYN_DIAG_LOG ]();
3354
+ };
3355
+ _self[_DYN_IS_INITIALIZED ] = function () {
3356
+ return _isinitialized;
3357
+ };
3358
+ _self.setInitialized = function (isInitialized) {
3359
+ _isinitialized = isInitialized;
3360
+ };
3361
+ _self[_DYN_SET_NEXT_PLUGIN ] = function (next) {
3362
+ _nextPlugin = next;
3363
+ };
3364
+ _self[_DYN_PROCESS_NEXT ] = function (env, itemCtx) {
3365
+ if (itemCtx) {
3366
+ itemCtx[_DYN_PROCESS_NEXT ](env);
3367
+ }
3368
+ else if (_nextPlugin && isFunction(_nextPlugin[STR_PROCESS_TELEMETRY ])) {
3369
+ _nextPlugin[STR_PROCESS_TELEMETRY ](env, null);
3370
+ }
3371
+ };
3372
+ _self._getTelCtx = _getTelCtx;
3373
+ function _getTelCtx(currentCtx) {
3374
+ if (currentCtx === void 0) { currentCtx = null; }
3375
+ var itemCtx = currentCtx;
3376
+ if (!itemCtx) {
3377
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self[STR_CORE ]);
3378
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
3379
+ itemCtx = rootCtx[_DYN_CREATE_NEW ](null, _nextPlugin[strGetPlugin]);
3380
+ }
3381
+ else {
3382
+ itemCtx = rootCtx[_DYN_CREATE_NEW ](null, _nextPlugin);
3383
+ }
3384
+ }
3385
+ return itemCtx;
3386
+ }
3387
+ function _setDefaults(config, core, pluginChain) {
3388
+ createDynamicConfig(config, defaultValues, safeGetLogger(core));
3389
+ if (!pluginChain && core) {
3390
+ pluginChain = core[_DYN_GET_PROCESS_TEL_CONT0 ]()[_DYN_GET_NEXT ]();
3391
+ }
3392
+ var nextPlugin = _nextPlugin;
3393
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
3394
+ nextPlugin = _nextPlugin[strGetPlugin]();
3395
+ }
3396
+ _self[STR_CORE ] = core;
3397
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
3398
+ }
3399
+ function _initDefaults() {
3400
+ _isinitialized = false;
3401
+ _self[STR_CORE ] = null;
3402
+ _rootCtx = null;
3403
+ _nextPlugin = null;
3404
+ _hookContainer = createUnloadHookContainer();
3405
+ _unloadHandlerContainer = createUnloadHandlerContainer();
3406
+ }
3407
+ }
3408
+ BaseTelemetryPlugin.__ieDyn=1;
3409
+ return BaseTelemetryPlugin;
3410
+ }());
3411
+
3412
+ var STR_EMPTY$2 = "";
3413
+ var STR_NO_RESPONSE_BODY$1 = "NoResponseBody";
3414
+ var _noResponseQs$1 = "&" + STR_NO_RESPONSE_BODY$1 + "=true";
3415
+ var STR_POST_METHOD = "POST";
3416
+ var SenderPostManager = /** @class */ (function () {
3417
+ function SenderPostManager() {
3418
+ var _syncFetchPayload = 0;
3419
+ var _enableSendPromise;
3420
+ var _isInitialized;
3421
+ var _diagLog;
3422
+ var _isOneDs;
3423
+ var _onCompleteFuncs;
3424
+ var _disableCredentials;
3425
+ var _fallbackInst;
3426
+ var _disableXhr;
3427
+ var _disableBeacon;
3428
+ var _disableBeaconSync;
3429
+ var _disableFetchKeepAlive;
3430
+ var _addNoResponse;
3431
+ var _timeoutWrapper;
3432
+ dynamicProto(SenderPostManager, this, function (_self, _base) {
3433
+ var _sendCredentials = true;
3434
+ _initDefaults();
3435
+ _self[_DYN_INITIALIZE$1 ] = function (config, diagLog) {
3436
+ _diagLog = diagLog;
3437
+ if (_isInitialized) {
3438
+ _throwInternal(_diagLog, 1 , 28 , "Sender is already initialized");
3439
+ }
3440
+ _self.SetConfig(config);
3441
+ _isInitialized = true;
3442
+ };
3443
+ _self["_getDbgPlgTargets"] = function () {
3444
+ return [_isInitialized, _isOneDs, _disableCredentials, _enableSendPromise];
3445
+ };
3446
+ _self.SetConfig = function (config) {
3447
+ try {
3448
+ _onCompleteFuncs = config.senderOnCompleteCallBack || {};
3449
+ _disableCredentials = !!config.disableCredentials;
3450
+ _isOneDs = !!config.isOneDs;
3451
+ _enableSendPromise = !!config.enableSendPromise;
3452
+ _disableXhr = !!config.disableXhr;
3453
+ _disableBeacon = !!config.disableBeacon;
3454
+ _disableBeaconSync = !!config.disableBeaconSync;
3455
+ _timeoutWrapper = config.timeWrapper;
3456
+ _addNoResponse = !!config.addNoResponse;
3457
+ _disableFetchKeepAlive = !!config.disableFetchKeepAlive;
3458
+ _fallbackInst = { sendPOST: _xhrSender };
3459
+ if (!_isOneDs) {
3460
+ _sendCredentials = false;
3461
+ }
3462
+ if (_disableCredentials) {
3463
+ var location_1 = getLocation();
3464
+ if (location_1 && location_1.protocol && location_1.protocol[_DYN_TO_LOWER_CASE$1 ]() === "file:") {
3465
+ _sendCredentials = false;
3466
+ }
3467
+ }
3468
+ return true;
3469
+ }
3470
+ catch (e) {
3471
+ }
3472
+ return false;
3473
+ };
3474
+ _self.getSyncFetchPayload = function () {
3475
+ return _syncFetchPayload;
3476
+ };
3477
+ _self.getSenderInst = function (transports, sync) {
3478
+ if (transports && transports[_DYN_LENGTH$2 ]) {
3479
+ return _getSenderInterface(transports, sync);
3480
+ }
3481
+ return null;
3482
+ };
3483
+ _self.getFallbackInst = function () {
3484
+ return _fallbackInst;
3485
+ };
3486
+ _self[_DYN__DO_TEARDOWN ] = function (unloadCtx, unloadState) {
3487
+ _initDefaults();
3488
+ };
3489
+ function _onSuccess(res, onComplete) {
3490
+ _doOnComplete(onComplete, 200, {}, res);
3491
+ }
3492
+ function _onError(message, onComplete) {
3493
+ _throwInternal(_diagLog, 2 , 26 , "Failed to send telemetry.", { message: message });
3494
+ _doOnComplete(onComplete, 400, {});
3495
+ }
3496
+ function _onNoPayloadUrl(onComplete) {
3497
+ _onError("No endpoint url is provided for the batch", onComplete);
3498
+ }
3499
+ function _getSenderInterface(transports, syncSupport) {
3500
+ var _a;
3501
+ var transportType = 0 ;
3502
+ var sendPostFunc = null;
3503
+ var lp = 0;
3504
+ while (sendPostFunc == null && lp < transports[_DYN_LENGTH$2 ]) {
3505
+ transportType = transports[lp];
3506
+ if (!_disableXhr && transportType === 1 ) {
3507
+ if (useXDomainRequest()) {
3508
+ sendPostFunc = _xdrSender;
3509
+ }
3510
+ else if (isXhrSupported()) {
3511
+ sendPostFunc = _xhrSender;
3512
+ }
3513
+ }
3514
+ else if (transportType === 2 && isFetchSupported(syncSupport) && (!syncSupport || !_disableFetchKeepAlive)) {
3515
+ sendPostFunc = _doFetchSender;
3516
+ }
3517
+ else if (transportType === 3 && isBeaconsSupported() && (syncSupport ? !_disableBeaconSync : !_disableBeacon)) {
3518
+ sendPostFunc = _beaconSender;
3519
+ }
3520
+ lp++;
3521
+ }
3522
+ if (sendPostFunc) {
3523
+ return _a = {
3524
+ _transport: transportType,
3525
+ _isSync: syncSupport
3526
+ },
3527
+ _a[_DYN_SEND_POST ] = sendPostFunc,
3528
+ _a;
3529
+ }
3530
+ return null;
3531
+ }
3532
+ function _doOnComplete(oncomplete, status, headers, response) {
3533
+ try {
3534
+ oncomplete && oncomplete(status, headers, response);
3535
+ }
3536
+ catch (e) {
3537
+ }
3538
+ }
3539
+ function _doBeaconSend(payload, oncomplete) {
3540
+ var nav = getNavigator();
3541
+ var url = payload[_DYN_URL_STRING$1 ];
3542
+ if (!url) {
3543
+ _onNoPayloadUrl(oncomplete);
3544
+ return true;
3545
+ }
3546
+ url = payload[_DYN_URL_STRING$1 ] + (_addNoResponse ? _noResponseQs$1 : STR_EMPTY$2);
3547
+ var data = payload[_DYN_DATA$1 ];
3548
+ var plainTextBatch = _isOneDs ? data : new Blob([data], { type: "text/plain;charset=UTF-8" });
3549
+ var queued = nav.sendBeacon(url, plainTextBatch);
3550
+ return queued;
3551
+ }
3552
+ function _beaconSender(payload, oncomplete, sync) {
3553
+ var data = payload[_DYN_DATA$1 ];
3554
+ try {
3555
+ if (data) {
3556
+ if (!_doBeaconSend(payload, oncomplete)) {
3557
+ var onRetry = _onCompleteFuncs && _onCompleteFuncs.beaconOnRetry;
3558
+ if (onRetry && isFunction(onRetry)) {
3559
+ onRetry(payload, oncomplete, _doBeaconSend);
3560
+ }
3561
+ else {
3562
+ _fallbackInst && _fallbackInst[_DYN_SEND_POST ](payload, oncomplete, true);
3563
+ _throwInternal(_diagLog, 2 , 40 , ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
3564
+ }
3565
+ }
3566
+ else {
3567
+ _onSuccess(STR_EMPTY$2, oncomplete);
3568
+ }
3569
+ }
3570
+ }
3571
+ catch (e) {
3572
+ _isOneDs && _warnToConsole(_diagLog, "Failed to send telemetry using sendBeacon API. Ex:" + dumpObj(e));
3573
+ _doOnComplete(oncomplete, _isOneDs ? 0 : 400, {}, STR_EMPTY$2);
3574
+ }
3575
+ return;
3576
+ }
3577
+ function _xhrSender(payload, oncomplete, sync) {
3578
+ var thePromise;
3579
+ var resolveFunc;
3580
+ var rejectFunc;
3581
+ var headers = payload[_DYN_HEADERS$1 ] || {};
3582
+ if (!sync && _enableSendPromise) {
3583
+ thePromise = createPromise(function (resolve, reject) {
3584
+ resolveFunc = resolve;
3585
+ rejectFunc = reject;
3586
+ });
3587
+ }
3588
+ if (_isOneDs && sync && payload.disableXhrSync) {
3589
+ sync = false;
3590
+ }
3591
+ var endPointUrl = payload[_DYN_URL_STRING$1 ];
3592
+ if (!endPointUrl) {
3593
+ _onNoPayloadUrl(oncomplete);
3594
+ resolveFunc && resolveFunc(false);
3595
+ return;
3596
+ }
3597
+ var xhr = openXhr(STR_POST_METHOD, endPointUrl, _sendCredentials, true, sync, payload[_DYN_TIMEOUT ]);
3598
+ xhr[_DYN_SET_REQUEST_HEADER ]("Content-type", "application/json");
3599
+ arrForEach(objKeys(headers), function (headerName) {
3600
+ xhr[_DYN_SET_REQUEST_HEADER ](headerName, headers[headerName]);
3601
+ });
3602
+ xhr.onreadystatechange = function () {
3603
+ if (!_isOneDs) {
3604
+ _doOnReadyFunc(xhr);
3605
+ if (xhr.readyState === 4) {
3606
+ resolveFunc && resolveFunc(true);
3607
+ }
3608
+ }
3609
+ };
3610
+ xhr.onload = function () {
3611
+ if (_isOneDs) {
3612
+ _doOnReadyFunc(xhr);
3613
+ }
3614
+ };
3615
+ function _doOnReadyFunc(xhr) {
3616
+ var onReadyFunc = _onCompleteFuncs && _onCompleteFuncs.xhrOnComplete;
3617
+ var onReadyFuncExist = onReadyFunc && isFunction(onReadyFunc);
3618
+ if (onReadyFuncExist) {
3619
+ onReadyFunc(xhr, oncomplete, payload);
3620
+ }
3621
+ else {
3622
+ var response = getResponseText(xhr);
3623
+ _doOnComplete(oncomplete, xhr[_DYN_STATUS ], _getAllResponseHeaders(xhr, _isOneDs), response);
3624
+ }
3625
+ }
3626
+ xhr.onerror = function (event) {
3627
+ _doOnComplete(oncomplete, _isOneDs ? xhr[_DYN_STATUS ] : 400, _getAllResponseHeaders(xhr, _isOneDs), _isOneDs ? STR_EMPTY$2 : formatErrorMessageXhr(xhr));
3628
+ rejectFunc && rejectFunc(event);
3629
+ };
3630
+ xhr.ontimeout = function () {
3631
+ _doOnComplete(oncomplete, _isOneDs ? xhr[_DYN_STATUS ] : 500, _getAllResponseHeaders(xhr, _isOneDs), _isOneDs ? STR_EMPTY$2 : formatErrorMessageXhr(xhr));
3632
+ resolveFunc && resolveFunc(false);
3633
+ };
3634
+ xhr.send(payload[_DYN_DATA$1 ]);
3635
+ return thePromise;
3636
+ }
3637
+ function _doFetchSender(payload, oncomplete, sync) {
3638
+ var _a;
3639
+ var endPointUrl = payload[_DYN_URL_STRING$1 ];
3640
+ var batch = payload[_DYN_DATA$1 ];
3641
+ var plainTextBatch = _isOneDs ? batch : new Blob([batch], { type: "application/json" });
3642
+ var thePromise;
3643
+ var resolveFunc;
3644
+ var rejectFunc;
3645
+ var requestHeaders = new Headers();
3646
+ var batchLength = batch[_DYN_LENGTH$2 ];
3647
+ var ignoreResponse = false;
3648
+ var responseHandled = false;
3649
+ var headers = payload[_DYN_HEADERS$1 ] || {};
3650
+ var init = (_a = {
3651
+ method: STR_POST_METHOD,
3652
+ body: plainTextBatch
3653
+ },
3654
+ _a[DisabledPropertyName] = true
3655
+ ,
3656
+ _a);
3657
+ if (payload.headers && objKeys(payload.headers)[_DYN_LENGTH$2 ] > 0) {
3658
+ arrForEach(objKeys(headers), function (headerName) {
3659
+ requestHeaders.append(headerName, headers[headerName]);
3660
+ });
3661
+ init[_DYN_HEADERS$1 ] = requestHeaders;
3662
+ }
3663
+ if (_sendCredentials && _isOneDs) {
3664
+ init.credentials = "include";
3665
+ }
3666
+ if (sync) {
3667
+ init.keepalive = true;
3668
+ _syncFetchPayload += batchLength;
3669
+ if (_isOneDs) {
3670
+ if (payload["_sendReason"] === 2 ) {
3671
+ ignoreResponse = true;
3672
+ if (_addNoResponse) {
3673
+ endPointUrl += _noResponseQs$1;
3674
+ }
3675
+ }
3676
+ }
3677
+ else {
3678
+ ignoreResponse = true;
3679
+ }
3680
+ }
3681
+ var request = new Request(endPointUrl, init);
3682
+ try {
3683
+ request[DisabledPropertyName] = true;
3684
+ }
3685
+ catch (e) {
3686
+ }
3687
+ if (!sync && _enableSendPromise) {
3688
+ thePromise = createPromise(function (resolve, reject) {
3689
+ resolveFunc = resolve;
3690
+ rejectFunc = reject;
3691
+ });
3692
+ }
3693
+ if (!endPointUrl) {
3694
+ _onNoPayloadUrl(oncomplete);
3695
+ resolveFunc && resolveFunc(false);
3696
+ return;
3697
+ }
3698
+ function _handleError(res) {
3699
+ _doOnComplete(oncomplete, _isOneDs ? 0 : 400, {}, _isOneDs ? STR_EMPTY$2 : res);
3700
+ }
3701
+ function _onFetchComplete(response, payload, value) {
3702
+ var status = response[_DYN_STATUS ];
3703
+ var onCompleteFunc = _onCompleteFuncs.fetchOnComplete;
3704
+ if (onCompleteFunc && isFunction(onCompleteFunc)) {
3705
+ onCompleteFunc(response, oncomplete, value || STR_EMPTY$2, payload);
3706
+ }
3707
+ else {
3708
+ _doOnComplete(oncomplete, status, {}, value || STR_EMPTY$2);
3709
+ }
3710
+ }
3711
+ try {
3712
+ doAwaitResponse(fetch(_isOneDs ? endPointUrl : request, _isOneDs ? init : null), function (result) {
3713
+ if (sync) {
3714
+ _syncFetchPayload -= batchLength;
3715
+ batchLength = 0;
3716
+ }
3717
+ if (!responseHandled) {
3718
+ responseHandled = true;
3719
+ if (!result.rejected) {
3720
+ var response_1 = result.value;
3721
+ try {
3722
+ if (!_isOneDs && !response_1.ok) {
3723
+ _handleError(response_1.statusText);
3724
+ resolveFunc && resolveFunc(false);
3725
+ }
3726
+ else {
3727
+ if (_isOneDs && !response_1.body) {
3728
+ _onFetchComplete(response_1, null, STR_EMPTY$2);
3729
+ resolveFunc && resolveFunc(true);
3730
+ }
3731
+ else {
3732
+ doAwaitResponse(response_1.text(), function (resp) {
3733
+ _onFetchComplete(response_1, payload, resp.value);
3734
+ resolveFunc && resolveFunc(true);
3735
+ });
3736
+ }
3737
+ }
3738
+ }
3739
+ catch (e) {
3740
+ _handleError(dumpObj(e));
3741
+ rejectFunc && rejectFunc(e);
3742
+ }
3743
+ }
3744
+ else {
3745
+ _handleError(result.reason && result.reason[_DYN_MESSAGE ]);
3746
+ rejectFunc && rejectFunc(result.reason);
3747
+ }
3748
+ }
3749
+ });
3750
+ }
3751
+ catch (e) {
3752
+ if (!responseHandled) {
3753
+ _handleError(dumpObj(e));
3754
+ rejectFunc && rejectFunc(e);
3755
+ }
3756
+ }
3757
+ if (ignoreResponse && !responseHandled) {
3758
+ responseHandled = true;
3759
+ _doOnComplete(oncomplete, 200, {});
3760
+ resolveFunc && resolveFunc(true);
3761
+ }
3762
+ if (_isOneDs && !responseHandled && payload[_DYN_TIMEOUT ] > 0) {
3763
+ _timeoutWrapper && _timeoutWrapper.set(function () {
3764
+ if (!responseHandled) {
3765
+ responseHandled = true;
3766
+ _doOnComplete(oncomplete, 500, {});
3767
+ resolveFunc && resolveFunc(true);
3768
+ }
3769
+ }, payload[_DYN_TIMEOUT ]);
3770
+ }
3771
+ return thePromise;
3772
+ }
3773
+ function _xdrSender(payload, oncomplete, sync) {
3774
+ var _window = getWindow();
3775
+ var xdr = new XDomainRequest();
3776
+ var data = payload[_DYN_DATA$1 ];
3777
+ xdr.onload = function () {
3778
+ var response = getResponseText(xdr);
3779
+ var onloadFunc = _onCompleteFuncs && _onCompleteFuncs.xdrOnComplete;
3780
+ if (onloadFunc && isFunction(onloadFunc)) {
3781
+ onloadFunc(xdr, oncomplete, payload);
3782
+ }
3783
+ else {
3784
+ _doOnComplete(oncomplete, 200, {}, response);
3785
+ }
3786
+ };
3787
+ xdr.onerror = function () {
3788
+ _doOnComplete(oncomplete, 400, {}, _isOneDs ? STR_EMPTY$2 : formatErrorMessageXdr(xdr));
3789
+ };
3790
+ xdr.ontimeout = function () {
3791
+ _doOnComplete(oncomplete, 500, {});
3792
+ };
3793
+ xdr.onprogress = function () { };
3794
+ var hostingProtocol = _window && _window.location && _window.location[_DYN_PROTOCOL ] || "";
3795
+ var endpoint = payload[_DYN_URL_STRING$1 ];
3796
+ if (!endpoint) {
3797
+ _onNoPayloadUrl(oncomplete);
3798
+ return;
3799
+ }
3800
+ if (!_isOneDs && endpoint.lastIndexOf(hostingProtocol, 0) !== 0) {
3801
+ var msg = "Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.";
3802
+ _throwInternal(_diagLog, 2 , 40 , ". " + msg);
3803
+ _onError(msg, oncomplete);
3804
+ return;
3170
3805
  }
3171
- else {
3172
- result = true;
3806
+ var endpointUrl = _isOneDs ? endpoint : endpoint[_DYN_REPLACE ](/^(https?:)/, "");
3807
+ xdr.open(STR_POST_METHOD, endpointUrl);
3808
+ if (payload[_DYN_TIMEOUT ]) {
3809
+ xdr[_DYN_TIMEOUT ] = payload[_DYN_TIMEOUT ];
3173
3810
  }
3174
- return result;
3175
- };
3176
- proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
3177
- proxyFunctionAs(_self, "_addHook", function () { return _hookContainer; }, "add");
3178
- objDefine(_self, "_unloadHooks", { g: function () { return _hookContainer; } });
3179
- });
3180
- _self[_DYN_DIAG_LOG ] = function (itemCtx) {
3181
- return _getTelCtx(itemCtx)[_DYN_DIAG_LOG ]();
3182
- };
3183
- _self[_DYN_IS_INITIALIZED ] = function () {
3184
- return _isinitialized;
3185
- };
3186
- _self.setInitialized = function (isInitialized) {
3187
- _isinitialized = isInitialized;
3188
- };
3189
- _self[_DYN_SET_NEXT_PLUGIN ] = function (next) {
3190
- _nextPlugin = next;
3191
- };
3192
- _self[_DYN_PROCESS_NEXT ] = function (env, itemCtx) {
3193
- if (itemCtx) {
3194
- itemCtx[_DYN_PROCESS_NEXT ](env);
3195
- }
3196
- else if (_nextPlugin && isFunction(_nextPlugin[STR_PROCESS_TELEMETRY ])) {
3197
- _nextPlugin[STR_PROCESS_TELEMETRY ](env, null);
3198
- }
3199
- };
3200
- _self._getTelCtx = _getTelCtx;
3201
- function _getTelCtx(currentCtx) {
3202
- if (currentCtx === void 0) { currentCtx = null; }
3203
- var itemCtx = currentCtx;
3204
- if (!itemCtx) {
3205
- var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self[STR_CORE ]);
3206
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
3207
- itemCtx = rootCtx[_DYN_CREATE_NEW ](null, _nextPlugin[strGetPlugin]);
3811
+ xdr.send(data);
3812
+ if (_isOneDs && sync) {
3813
+ _timeoutWrapper && _timeoutWrapper.set(function () {
3814
+ xdr.send(data);
3815
+ }, 0);
3208
3816
  }
3209
3817
  else {
3210
- itemCtx = rootCtx[_DYN_CREATE_NEW ](null, _nextPlugin);
3818
+ xdr.send(data);
3211
3819
  }
3212
3820
  }
3213
- return itemCtx;
3214
- }
3215
- function _setDefaults(config, core, pluginChain) {
3216
- createDynamicConfig(config, defaultValues, safeGetLogger(core));
3217
- if (!pluginChain && core) {
3218
- pluginChain = core[_DYN_GET_PROCESS_TEL_CONT0 ]()[_DYN_GET_NEXT ]();
3219
- }
3220
- var nextPlugin = _nextPlugin;
3221
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
3222
- nextPlugin = _nextPlugin[strGetPlugin]();
3821
+ function _initDefaults() {
3822
+ _syncFetchPayload = 0;
3823
+ _isInitialized = false;
3824
+ _enableSendPromise = false;
3825
+ _diagLog = null;
3826
+ _isOneDs = null;
3827
+ _onCompleteFuncs = null;
3828
+ _disableCredentials = null;
3829
+ _fallbackInst = null;
3830
+ _disableXhr = false;
3831
+ _disableBeacon = false;
3832
+ _disableBeaconSync = false;
3833
+ _disableFetchKeepAlive = false;
3834
+ _addNoResponse = false;
3835
+ _timeoutWrapper = null;
3223
3836
  }
3224
- _self[STR_CORE ] = core;
3225
- _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
3226
- }
3227
- function _initDefaults() {
3228
- _isinitialized = false;
3229
- _self[STR_CORE ] = null;
3230
- _rootCtx = null;
3231
- _nextPlugin = null;
3232
- _hookContainer = createUnloadHookContainer();
3233
- _unloadHandlerContainer = createUnloadHandlerContainer();
3234
- }
3837
+ });
3235
3838
  }
3236
- BaseTelemetryPlugin.__ieDyn=1;
3237
- return BaseTelemetryPlugin;
3839
+ SenderPostManager.__ieDyn=1;
3840
+ return SenderPostManager;
3238
3841
  }());
3239
3842
 
3240
3843
  var strOnPrefix = "on";
@@ -3257,16 +3860,16 @@ var elmNodeData = createElmNodeData("events");
3257
3860
  var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
3258
3861
  function _normalizeNamespace(name) {
3259
3862
  if (name && name[_DYN_REPLACE ]) {
3260
- return name[_DYN_REPLACE ](/^[\s\.]+|(?=[\s\.])[\.\s]+$/g, STR_EMPTY$2);
3863
+ return name[_DYN_REPLACE ](/^[\s\.]+|(?=[\s\.])[\.\s]+$/g, STR_EMPTY$3);
3261
3864
  }
3262
3865
  return name;
3263
3866
  }
3264
3867
  function _getEvtNamespace(eventName, evtNamespace) {
3265
3868
  var _a;
3266
3869
  if (evtNamespace) {
3267
- var theNamespace_1 = STR_EMPTY$2;
3870
+ var theNamespace_1 = STR_EMPTY$3;
3268
3871
  if (isArray(evtNamespace)) {
3269
- theNamespace_1 = STR_EMPTY$2;
3872
+ theNamespace_1 = STR_EMPTY$3;
3270
3873
  arrForEach(evtNamespace, function (name) {
3271
3874
  name = _normalizeNamespace(name);
3272
3875
  if (name) {
@@ -3284,13 +3887,13 @@ function _getEvtNamespace(eventName, evtNamespace) {
3284
3887
  if (theNamespace_1[0] !== ".") {
3285
3888
  theNamespace_1 = "." + theNamespace_1;
3286
3889
  }
3287
- eventName = (eventName || STR_EMPTY$2) + theNamespace_1;
3890
+ eventName = (eventName || STR_EMPTY$3) + theNamespace_1;
3288
3891
  }
3289
3892
  }
3290
- var parsedEvent = (eventNamespace.exec(eventName || STR_EMPTY$2) || []);
3893
+ var parsedEvent = (eventNamespace.exec(eventName || STR_EMPTY$3) || []);
3291
3894
  return _a = {},
3292
3895
  _a[_DYN_TYPE ] = parsedEvent[1],
3293
- _a.ns = ((parsedEvent[2] || STR_EMPTY$2).replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, STR_EMPTY$2)[_DYN_SPLIT$1 ](".").sort()).join("."),
3896
+ _a.ns = ((parsedEvent[2] || STR_EMPTY$3).replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, STR_EMPTY$3)[_DYN_SPLIT$1 ](".").sort()).join("."),
3294
3897
  _a;
3295
3898
  }
3296
3899
  function _getRegisteredEvents(target, evtName, addDefault) {
@@ -3529,12 +4132,9 @@ var _DYN_LENGTH$1 = "length";
3529
4132
  var _DYN_PROCESS_TELEMETRY_ST0 = "processTelemetryStart";
3530
4133
 
3531
4134
  var _a$1;
3532
- var Version = '4.1.1-nightly3.2403-03';
4135
+ var Version = '4.1.1';
3533
4136
  var FullVersionString = "1DS-Web-JS-" + Version;
3534
4137
  var ObjHasOwnProperty = ObjProto$1.hasOwnProperty;
3535
- var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
3536
- var strWithCredentials = "withCredentials";
3537
- var strTimeout = "timeout";
3538
4138
  var _fieldTypeEventPropMap = (_a$1 = {},
3539
4139
  _a$1[0 ] = 0 ,
3540
4140
  _a$1[2 ] = 6 ,
@@ -3703,39 +4303,11 @@ function getFieldValueType(value) {
3703
4303
  function isChromium() {
3704
4304
  return !!getInst("chrome");
3705
4305
  }
3706
- function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {
3707
- if (disabled === void 0) { disabled = false; }
3708
- if (isSync === void 0) { isSync = false; }
3709
- function _wrapSetXhrProp(xhr, prop, value) {
3710
- try {
3711
- xhr[prop] = value;
3712
- }
3713
- catch (e) {
3714
- }
3715
- }
3716
- var xhr = new XMLHttpRequest();
3717
- if (disabled) {
3718
- _wrapSetXhrProp(xhr, strDisabledPropertyName, disabled);
3719
- }
3720
- if (withCredentials) {
3721
- _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
3722
- }
3723
- xhr.open(method, urlString, !isSync);
3724
- if (withCredentials) {
3725
- _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
3726
- }
3727
- if (!isSync && timeout) {
3728
- _wrapSetXhrProp(xhr, strTimeout, timeout);
3729
- }
3730
- return xhr;
3731
- }
3732
4306
  function isGreaterThanZero(value) {
3733
4307
  return value > 0;
3734
4308
  }
3735
4309
 
3736
4310
  var STR_EMPTY = "";
3737
- var STR_POST_METHOD = "POST";
3738
- var STR_DISABLED_PROPERTY_NAME = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
3739
4311
  var STR_DROPPED = "drop";
3740
4312
  var STR_SENDING = "send";
3741
4313
  var STR_REQUEUE = "requeue";
@@ -3747,7 +4319,6 @@ var STR_CACHE_CONTROL = "cache-control";
3747
4319
  var STR_CONTENT_TYPE_HEADER = "content-type";
3748
4320
  var STR_KILL_TOKENS_HEADER = "kill-tokens";
3749
4321
  var STR_KILL_DURATION_HEADER = "kill-duration";
3750
- var STR_KILL_DURATION_SECONDS_HEADER = "kill-duration-seconds";
3751
4322
  var STR_TIME_DELTA_HEADER = "time-delta-millis";
3752
4323
  var STR_CLIENT_VERSION = "client-version";
3753
4324
  var STR_CLIENT_ID = "client-id";
@@ -3789,6 +4360,7 @@ var _DYN_STRINGIFY_OBJECTS = "stringifyObjects";
3789
4360
  var _DYN_ENABLE_COMPOUND_KEY = "enableCompoundKey";
3790
4361
  var _DYN_DISABLE_XHR_SYNC = "disableXhrSync";
3791
4362
  var _DYN_DISABLE_FETCH_KEEP_A6 = "disableFetchKeepAlive";
4363
+ var _DYN_ADD_NO_RESPONSE = "addNoResponse";
3792
4364
  var _DYN_EXCLUDE_CS_META_DATA = "excludeCsMetaData";
3793
4365
  var _DYN_USE_SEND_BEACON = "useSendBeacon";
3794
4366
  var _DYN_ALWAYS_USE_XHR_OVERR7 = "alwaysUseXhrOverride";
@@ -3796,15 +4368,9 @@ var _DYN_UNLOAD_TRANSPORTS = "unloadTransports";
3796
4368
  var _DYN_SERIALIZE_OFFLINE_EV8 = "serializeOfflineEvt";
3797
4369
  var _DYN_GET_OFFLINE_REQUEST_9 = "getOfflineRequestDetails";
3798
4370
  var _DYN_CREATE_PAYLOAD = "createPayload";
3799
- var _DYN_URL_STRING = "urlString";
3800
- var _DYN_TIMEOUT = "timeout";
3801
- var _DYN_ONTIMEOUT = "ontimeout";
3802
- var _DYN_DATA = "data";
3803
- var _DYN__SEND_REASON = "_sendReason";
3804
4371
  var _DYN_HEADERS = "headers";
3805
- var _DYN_GET_RESPONSE_HEADER = "getResponseHeader";
3806
- var _DYN_GET_ALL_RESPONSE_HEA10 = "getAllResponseHeaders";
3807
4372
  var _DYN__THE_PAYLOAD = "_thePayload";
4373
+ var _DYN_URL_STRING = "urlString";
3808
4374
  var _DYN_BATCHES = "batches";
3809
4375
  var _DYN_SEND_TYPE = "sendType";
3810
4376
  var _DYN_ADD_HEADER = "addHeader";
@@ -3813,23 +4379,24 @@ var _DYN_SEND_QUEUED_REQUESTS = "sendQueuedRequests";
3813
4379
  var _DYN_IS_COMPLETELY_IDLE = "isCompletelyIdle";
3814
4380
  var _DYN_SET_UNLOADING = "setUnloading";
3815
4381
  var _DYN_IS_TENANT_KILLED = "isTenantKilled";
3816
- var _DYN_SEND_SYNCHRONOUS_BAT11 = "sendSynchronousBatch";
4382
+ var _DYN_SEND_SYNCHRONOUS_BAT10 = "sendSynchronousBatch";
3817
4383
  var _DYN__TRANSPORT = "_transport";
3818
4384
  var _DYN_GET_WPARAM = "getWParam";
3819
4385
  var _DYN_IS_BEACON = "isBeacon";
3820
4386
  var _DYN_TIMINGS = "timings";
3821
4387
  var _DYN_IS_TEARDOWN = "isTeardown";
3822
4388
  var _DYN_IS_SYNC = "isSync";
3823
- var _DYN_SEND_POST = "sendPOST";
3824
- var _DYN_SET_KILL_SWITCH_TENA12 = "setKillSwitchTenants";
3825
- var _DYN__BACK_OFF_TRANSMISSI13 = "_backOffTransmission";
4389
+ var _DYN_DATA = "data";
4390
+ var _DYN__SEND_REASON = "_sendReason";
4391
+ var _DYN_SET_KILL_SWITCH_TENA11 = "setKillSwitchTenants";
4392
+ var _DYN__BACK_OFF_TRANSMISSI12 = "_backOffTransmission";
3826
4393
  var _DYN_IDENTIFIER = "identifier";
3827
4394
  var _DYN_DISABLE_OPTIMIZE_OBJ = "disableOptimizeObj";
3828
- var _DYN_IGNORE_MC1_MS0_COOKI14 = "ignoreMc1Ms0CookieProcessing";
4395
+ var _DYN_IGNORE_MC1_MS0_COOKI13 = "ignoreMc1Ms0CookieProcessing";
3829
4396
  var _DYN_EVENTS_LIMIT_IN_MEM = "eventsLimitInMem";
3830
- var _DYN_AUTO_FLUSH_EVENTS_LI15 = "autoFlushEventsLimit";
3831
- var _DYN_DISABLE_AUTO_BATCH_F16 = "disableAutoBatchFlushLimit";
3832
- var _DYN_OVERRIDE_INSTRUMENTA17 = "overrideInstrumentationKey";
4397
+ var _DYN_AUTO_FLUSH_EVENTS_LI14 = "autoFlushEventsLimit";
4398
+ var _DYN_DISABLE_AUTO_BATCH_F15 = "disableAutoBatchFlushLimit";
4399
+ var _DYN_OVERRIDE_INSTRUMENTA16 = "overrideInstrumentationKey";
3833
4400
  var _DYN_DISABLE_TELEMETRY = "disableTelemetry";
3834
4401
  var _DYN_BASE_DATA = "baseData";
3835
4402
  var _DYN_SEND_ATTEMPT = "sendAttempt";
@@ -3954,7 +4521,7 @@ var KillSwitch = /** @class */ (function () {
3954
4521
  return result;
3955
4522
  }
3956
4523
  dynamicProto(KillSwitch, this, function (_self) {
3957
- _self[_DYN_SET_KILL_SWITCH_TENA12 ] = function (killTokens, killDuration) {
4524
+ _self[_DYN_SET_KILL_SWITCH_TENA11 ] = function (killTokens, killDuration) {
3958
4525
  if (killTokens && killDuration) {
3959
4526
  try {
3960
4527
  var killedTokens = _normalizeTenants(killTokens[_DYN_SPLIT ](","));
@@ -4293,14 +4860,6 @@ _addCollectorHeaderQsMapping(STR_API_KEY, STR_API_KEY);
4293
4860
  _addCollectorHeaderQsMapping(STR_TIME_DELTA_TO_APPLY, STR_TIME_DELTA_TO_APPLY);
4294
4861
  _addCollectorHeaderQsMapping(STR_UPLOAD_TIME, STR_UPLOAD_TIME);
4295
4862
  _addCollectorHeaderQsMapping(STR_AUTH_XTOKEN, STR_AUTH_XTOKEN);
4296
- function _getResponseText(xhr) {
4297
- try {
4298
- return xhr.responseText;
4299
- }
4300
- catch (e) {
4301
- }
4302
- return STR_EMPTY;
4303
- }
4304
4863
  function _hasHeader(headers, header) {
4305
4864
  var hasHeader = false;
4306
4865
  if (headers && header) {
@@ -4330,17 +4889,6 @@ function _addRequestDetails(details, name, value, useHeaders) {
4330
4889
  }
4331
4890
  }
4332
4891
  }
4333
- function _prependTransports(theTransports, newTransports) {
4334
- if (newTransports) {
4335
- if (isNumber(newTransports)) {
4336
- theTransports = [newTransports][_DYN_CONCAT ](theTransports);
4337
- }
4338
- else if (isArray(newTransports)) {
4339
- theTransports = newTransports[_DYN_CONCAT ](theTransports);
4340
- }
4341
- }
4342
- return theTransports;
4343
- }
4344
4892
  function _addQueryStringParameter(qsParams, name, value) {
4345
4893
  for (var i = 0; i < qsParams[_DYN_LENGTH ]; i++) {
4346
4894
  if (qsParams[i].name === name) {
@@ -4391,6 +4939,7 @@ var HttpManager = /** @class */ (function () {
4391
4939
  var _isInitialized;
4392
4940
  var _timeoutWrapper;
4393
4941
  var _excludeCsMetaData;
4942
+ var _sendPostMgr;
4394
4943
  dynamicProto(HttpManager, this, function (_self) {
4395
4944
  _initDefaults();
4396
4945
  var _sendCredentials = true;
@@ -4427,7 +4976,7 @@ var HttpManager = /** @class */ (function () {
4427
4976
  _xhrTimeout = channelConfig.xhrTimeout;
4428
4977
  _disableXhrSync = !!channelConfig[_DYN_DISABLE_XHR_SYNC ];
4429
4978
  _disableFetchKeepAlive = !!channelConfig[_DYN_DISABLE_FETCH_KEEP_A6 ];
4430
- _addNoResponse = channelConfig.addNoResponse !== false;
4979
+ _addNoResponse = channelConfig[_DYN_ADD_NO_RESPONSE ] !== false;
4431
4980
  _excludeCsMetaData = !!channelConfig[_DYN_EXCLUDE_CS_META_DATA ];
4432
4981
  if (!!core.getPlugin("LocalStorage")) {
4433
4982
  _disableFetchKeepAlive = true;
@@ -4437,16 +4986,20 @@ var HttpManager = /** @class */ (function () {
4437
4986
  if (!isNullOrUndefined(channelConfig[_DYN_USE_SEND_BEACON ])) {
4438
4987
  _useBeacons = !!channelConfig[_DYN_USE_SEND_BEACON ];
4439
4988
  }
4989
+ var sendPostConfig = _getSendPostMgrConfig();
4990
+ if (!_sendPostMgr) {
4991
+ _sendPostMgr = new SenderPostManager();
4992
+ _sendPostMgr[_DYN_INITIALIZE ](sendPostConfig, _logger);
4993
+ }
4994
+ else {
4995
+ _sendPostMgr.SetConfig(sendPostConfig);
4996
+ }
4440
4997
  var syncHttpInterface = httpInterface;
4441
4998
  var beaconHttpInterface = channelConfig[_DYN_ALWAYS_USE_XHR_OVERR7 ] ? httpInterface : null;
4442
4999
  var fetchSyncHttpInterface = channelConfig[_DYN_ALWAYS_USE_XHR_OVERR7 ] ? httpInterface : null;
4443
5000
  var beaconUnloadTransports = [3 , 2 ];
4444
5001
  if (!httpInterface) {
4445
5002
  _customHttpInterface = false;
4446
- var location_1 = getLocation();
4447
- if (location_1 && location_1.protocol && location_1.protocol[_DYN_TO_LOWER_CASE ]() === "file:") {
4448
- _sendCredentials = false;
4449
- }
4450
5003
  var theTransports = [];
4451
5004
  if (isReactNative()) {
4452
5005
  theTransports = [2 , 1 ];
@@ -4455,7 +5008,7 @@ var HttpManager = /** @class */ (function () {
4455
5008
  else {
4456
5009
  theTransports = [1 , 2 , 3 ];
4457
5010
  }
4458
- theTransports = _prependTransports(theTransports, channelConfig.transports);
5011
+ theTransports = prependTransports(theTransports, channelConfig.transports);
4459
5012
  httpInterface = _getSenderInterface(theTransports, false);
4460
5013
  if (!httpInterface) {
4461
5014
  _warnToConsole(_logger, "No available transport to send events");
@@ -4463,7 +5016,7 @@ var HttpManager = /** @class */ (function () {
4463
5016
  syncHttpInterface = _getSenderInterface(theTransports, true);
4464
5017
  }
4465
5018
  if (!beaconHttpInterface) {
4466
- beaconUnloadTransports = _prependTransports(beaconUnloadTransports, channelConfig[_DYN_UNLOAD_TRANSPORTS ]);
5019
+ beaconUnloadTransports = prependTransports(beaconUnloadTransports, channelConfig[_DYN_UNLOAD_TRANSPORTS ]);
4467
5020
  beaconHttpInterface = _getSenderInterface(beaconUnloadTransports, true);
4468
5021
  }
4469
5022
  _canHaveReducedPayload = !_customHttpInterface && ((_useBeacons && isBeaconsSupported()) || (!_disableFetchKeepAlive && isFetchSupported(true)));
@@ -4489,72 +5042,65 @@ var HttpManager = /** @class */ (function () {
4489
5042
  };
4490
5043
  };
4491
5044
  _self[_DYN_SERIALIZE_OFFLINE_EV8 ] = function (evt) {
4492
- return _serializer.getEventBlob(evt);
5045
+ try {
5046
+ if (_serializer) {
5047
+ return _serializer.getEventBlob(evt);
5048
+ }
5049
+ }
5050
+ catch (e) {
5051
+ }
5052
+ return STR_EMPTY;
4493
5053
  };
4494
5054
  _self[_DYN_GET_OFFLINE_REQUEST_9 ] = function () {
4495
- var payload = _serializer[_DYN_CREATE_PAYLOAD ](0, false, false, false, 1 , 0 );
4496
- return _buildRequestDetails(payload, _useHeaders);
5055
+ try {
5056
+ var payload = _serializer && _serializer[_DYN_CREATE_PAYLOAD ](0, false, false, false, 1 , 0 );
5057
+ return _buildRequestDetails(payload, _useHeaders);
5058
+ }
5059
+ catch (e) {
5060
+ }
5061
+ return null;
4497
5062
  };
4498
5063
  function _getSenderInterface(transports, syncSupport) {
4499
- var transportType = 0 ;
4500
- var sendPostFunc = null;
4501
- var lp = 0;
4502
- while (sendPostFunc == null && lp < transports[_DYN_LENGTH ]) {
4503
- transportType = transports[lp];
4504
- if (transportType === 1 ) {
4505
- if (useXDomainRequest()) {
4506
- sendPostFunc = _xdrSendPost;
4507
- }
4508
- else if (isXhrSupported()) {
4509
- sendPostFunc = _xhrSendPost;
4510
- }
4511
- }
4512
- else if (transportType === 2 && isFetchSupported(syncSupport) && (!syncSupport || (syncSupport && !_disableFetchKeepAlive))) {
4513
- sendPostFunc = _fetchSendPost;
4514
- }
4515
- else if (_useBeacons && transportType === 3 && isBeaconsSupported()) {
4516
- sendPostFunc = _beaconSendPost;
4517
- }
4518
- lp++;
5064
+ try {
5065
+ return _sendPostMgr && _sendPostMgr.getSenderInst(transports, syncSupport);
4519
5066
  }
4520
- if (sendPostFunc) {
4521
- return {
4522
- _transport: transportType,
4523
- _isSync: syncSupport,
4524
- sendPOST: sendPostFunc
4525
- };
5067
+ catch (e) {
4526
5068
  }
4527
5069
  return null;
4528
5070
  }
4529
5071
  _self["_getDbgPlgTargets"] = function () {
4530
5072
  return [_sendInterfaces[0 ], _killSwitch, _serializer, _sendInterfaces];
4531
5073
  };
4532
- function _xdrSendPost(payload, oncomplete, sync) {
4533
- var xdr = new XDomainRequest();
4534
- xdr.open(STR_POST_METHOD, payload[_DYN_URL_STRING ]);
4535
- if (payload[_DYN_TIMEOUT ]) {
4536
- xdr[_DYN_TIMEOUT ] = payload[_DYN_TIMEOUT ];
4537
- }
4538
- xdr.onload = function () {
4539
- var response = _getResponseText(xdr);
4540
- _doOnComplete(oncomplete, 200, {}, response);
4541
- _handleCollectorResponse(response);
4542
- };
4543
- xdr.onerror = function () {
4544
- _doOnComplete(oncomplete, 400, {});
4545
- };
4546
- xdr[_DYN_ONTIMEOUT ] = function () {
4547
- _doOnComplete(oncomplete, 500, {});
4548
- };
4549
- xdr.onprogress = function () { };
4550
- if (sync) {
4551
- xdr.send(payload[_DYN_DATA ]);
5074
+ function _getSendPostMgrConfig() {
5075
+ try {
5076
+ var onCompleteFuncs = {
5077
+ xdrOnComplete: _xdrOncomplete,
5078
+ fetchOnComplete: _fetchOnComplete,
5079
+ xhrOnComplete: _xhrOnComplete,
5080
+ beaconOnRetry: _onBeaconRetry
5081
+ };
5082
+ var config = {
5083
+ enableSendPromise: false,
5084
+ isOneDs: true,
5085
+ disableCredentials: !_sendCredentials,
5086
+ disableXhr: false,
5087
+ disableBeacon: !_useBeacons,
5088
+ disableBeaconSync: !_useBeacons,
5089
+ disableFetchKeepAlive: _disableFetchKeepAlive,
5090
+ timeWrapper: _timeoutWrapper,
5091
+ addNoResponse: _addNoResponse,
5092
+ senderOnCompleteCallBack: onCompleteFuncs
5093
+ };
5094
+ return config;
4552
5095
  }
4553
- else {
4554
- _timeoutWrapper.set(function () {
4555
- xdr.send(payload[_DYN_DATA ]);
4556
- }, 0);
5096
+ catch (e) {
4557
5097
  }
5098
+ return null;
5099
+ }
5100
+ function _xdrOncomplete(xdr, oncomplete, payload) {
5101
+ var response = getResponseText(xdr);
5102
+ _doOnComplete(oncomplete, 200, {}, response);
5103
+ _handleCollectorResponse(response);
4558
5104
  }
4559
5105
  function _initDefaults() {
4560
5106
  var undefValue;
@@ -4589,123 +5135,26 @@ var HttpManager = /** @class */ (function () {
4589
5135
  _isInitialized = false;
4590
5136
  _timeoutWrapper = createTimeoutWrapper();
4591
5137
  _excludeCsMetaData = false;
5138
+ _sendPostMgr = null;
4592
5139
  }
4593
- function _fetchSendPost(payload, oncomplete, sync) {
4594
- var _a;
4595
- var theUrl = payload[_DYN_URL_STRING ];
4596
- var ignoreResponse = false;
4597
- var responseHandled = false;
4598
- var requestInit = (_a = {
4599
- body: payload[_DYN_DATA ],
4600
- method: STR_POST_METHOD
4601
- },
4602
- _a[STR_DISABLED_PROPERTY_NAME] = true,
4603
- _a);
4604
- if (sync) {
4605
- requestInit.keepalive = true;
4606
- if (payload[_DYN__SEND_REASON ] === 2 ) {
4607
- ignoreResponse = true;
4608
- if (_addNoResponse) {
4609
- theUrl += _noResponseQs;
4610
- }
4611
- }
4612
- }
4613
- if (_sendCredentials) {
4614
- requestInit.credentials = "include";
4615
- }
4616
- if (payload.headers && objKeys(payload.headers)[_DYN_LENGTH ] > 0) {
4617
- requestInit[_DYN_HEADERS ] = payload[_DYN_HEADERS ];
4618
- }
5140
+ function _fetchOnComplete(response, onComplete, resValue, payload) {
4619
5141
  var handleResponse = function (status, headerMap, responseText) {
4620
- if (!responseHandled) {
4621
- responseHandled = true;
4622
- _doOnComplete(oncomplete, status, headerMap, responseText);
4623
- _handleCollectorResponse(responseText);
4624
- }
5142
+ _doOnComplete(onComplete, status, headerMap, responseText);
5143
+ _handleCollectorResponse(responseText);
4625
5144
  };
4626
- var handleError = function () {
4627
- if (!responseHandled) {
4628
- responseHandled = true;
4629
- _doOnComplete(oncomplete, 0, {});
4630
- }
4631
- };
4632
- fetch(theUrl, requestInit).then(function (response) {
4633
- var headerMap = {};
4634
- var responseText = STR_EMPTY;
4635
- var headers = response[_DYN_HEADERS ];
4636
- if (headers) {
4637
- headers["forEach"](function (value, name) {
4638
- headerMap[name] = value;
4639
- });
4640
- }
4641
- if (response.body) {
4642
- response.text().then(function (text) {
4643
- responseText = text;
4644
- handleResponse(response.status, headerMap, responseText);
4645
- }, handleError);
4646
- }
4647
- else {
4648
- handleResponse(response.status, headerMap, "");
4649
- }
4650
- }).catch(handleError);
4651
- if (ignoreResponse && !responseHandled) {
4652
- responseHandled = true;
4653
- _doOnComplete(oncomplete, 200, {});
4654
- }
4655
- if (!responseHandled && payload[_DYN_TIMEOUT ] > 0) {
4656
- _timeoutWrapper.set(function () {
4657
- if (!responseHandled) {
4658
- responseHandled = true;
4659
- _doOnComplete(oncomplete, 500, {});
4660
- }
4661
- }, payload[_DYN_TIMEOUT ]);
5145
+ var headerMap = {};
5146
+ var headers = response[_DYN_HEADERS ];
5147
+ if (headers) {
5148
+ headers["forEach"](function (value, name) {
5149
+ headerMap[name] = value;
5150
+ });
4662
5151
  }
5152
+ handleResponse(response.status, headerMap, resValue || STR_EMPTY);
4663
5153
  }
4664
- function _xhrSendPost(payload, oncomplete, sync) {
4665
- var theUrl = payload[_DYN_URL_STRING ];
4666
- function _appendHeader(theHeaders, xhr, name) {
4667
- if (!theHeaders[name] && xhr && xhr[_DYN_GET_RESPONSE_HEADER ]) {
4668
- var value = xhr[_DYN_GET_RESPONSE_HEADER ](name);
4669
- if (value) {
4670
- theHeaders[name] = strTrim(value);
4671
- }
4672
- }
4673
- return theHeaders;
4674
- }
4675
- function _getAllResponseHeaders(xhr) {
4676
- var theHeaders = {};
4677
- if (!xhr[_DYN_GET_ALL_RESPONSE_HEA10 ]) {
4678
- theHeaders = _appendHeader(theHeaders, xhr, STR_TIME_DELTA_HEADER);
4679
- theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_HEADER);
4680
- theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_SECONDS_HEADER);
4681
- }
4682
- else {
4683
- theHeaders = _convertAllHeadersToMap(xhr[_DYN_GET_ALL_RESPONSE_HEA10 ]());
4684
- }
4685
- return theHeaders;
4686
- }
4687
- function xhrComplete(xhr, responseTxt) {
4688
- _doOnComplete(oncomplete, xhr.status, _getAllResponseHeaders(xhr), responseTxt);
4689
- }
4690
- if (sync && payload[_DYN_DISABLE_XHR_SYNC ]) {
4691
- sync = false;
4692
- }
4693
- var xhrRequest = openXhr(STR_POST_METHOD, theUrl, _sendCredentials, true, sync, payload[_DYN_TIMEOUT ]);
4694
- objForEachKey(payload[_DYN_HEADERS ], function (name, value) {
4695
- xhrRequest.setRequestHeader(name, value);
4696
- });
4697
- xhrRequest.onload = function () {
4698
- var response = _getResponseText(xhrRequest);
4699
- xhrComplete(xhrRequest, response);
4700
- _handleCollectorResponse(response);
4701
- };
4702
- xhrRequest.onerror = function () {
4703
- xhrComplete(xhrRequest);
4704
- };
4705
- xhrRequest[_DYN_ONTIMEOUT ] = function () {
4706
- xhrComplete(xhrRequest);
4707
- };
4708
- xhrRequest.send(payload[_DYN_DATA ]);
5154
+ function _xhrOnComplete(request, oncomplete, payload) {
5155
+ var response = getResponseText(request);
5156
+ _doOnComplete(oncomplete, request.status, _getAllResponseHeaders(request, true), response);
5157
+ _handleCollectorResponse(response);
4709
5158
  }
4710
5159
  function _doOnComplete(oncomplete, status, headers, response) {
4711
5160
  try {
@@ -4715,53 +5164,51 @@ var HttpManager = /** @class */ (function () {
4715
5164
  _throwInternal(_logger, 2 , 518 , dumpObj(e));
4716
5165
  }
4717
5166
  }
4718
- function _beaconSendPost(payload, oncomplete, sync) {
5167
+ function _onBeaconRetry(payload, onComplete, canSend) {
4719
5168
  var internalPayloadData = payload;
4720
5169
  var status = 200;
4721
5170
  var thePayload = internalPayloadData[_DYN__THE_PAYLOAD ];
4722
5171
  var theUrl = payload[_DYN_URL_STRING ] + (_addNoResponse ? _noResponseQs : STR_EMPTY);
4723
5172
  try {
4724
5173
  var nav_1 = getNavigator();
4725
- if (!nav_1.sendBeacon(theUrl, payload[_DYN_DATA ])) {
4726
- if (thePayload) {
4727
- var persistStorage = !!_core.getPlugin("LocalStorage");
4728
- var droppedBatches_1 = [];
4729
- var sentBatches_1 = [];
4730
- arrForEach(thePayload[_DYN_BATCHES ], function (theBatch) {
4731
- if (droppedBatches_1 && theBatch && theBatch[_DYN_COUNT ]() > 0) {
4732
- var theEvents = theBatch[_DYN_EVENTS ]();
4733
- for (var lp = 0; lp < theEvents[_DYN_LENGTH ]; lp++) {
4734
- if (!nav_1.sendBeacon(theUrl, _serializer.getEventBlob(theEvents[lp]))) {
4735
- droppedBatches_1[_DYN_PUSH ](theBatch[_DYN_SPLIT ](lp));
4736
- break;
4737
- }
4738
- else {
4739
- sentBatches_1[_DYN_PUSH ](theBatch[lp]);
4740
- }
5174
+ if (thePayload) {
5175
+ var persistStorage = !!_core.getPlugin("LocalStorage");
5176
+ var droppedBatches_1 = [];
5177
+ var sentBatches_1 = [];
5178
+ arrForEach(thePayload[_DYN_BATCHES ], function (theBatch) {
5179
+ if (droppedBatches_1 && theBatch && theBatch[_DYN_COUNT ]() > 0) {
5180
+ var theEvents = theBatch[_DYN_EVENTS ]();
5181
+ for (var lp = 0; lp < theEvents[_DYN_LENGTH ]; lp++) {
5182
+ if (!nav_1.sendBeacon(theUrl, _serializer.getEventBlob(theEvents[lp]))) {
5183
+ droppedBatches_1[_DYN_PUSH ](theBatch[_DYN_SPLIT ](lp));
5184
+ break;
5185
+ }
5186
+ else {
5187
+ sentBatches_1[_DYN_PUSH ](theBatch[lp]);
4741
5188
  }
4742
5189
  }
4743
- else {
4744
- droppedBatches_1[_DYN_PUSH ](theBatch[_DYN_SPLIT ](0));
4745
- }
4746
- });
4747
- if (sentBatches_1[_DYN_LENGTH ] > 0) {
4748
- thePayload.sentEvts = sentBatches_1;
4749
5190
  }
4750
- if (!persistStorage) {
4751
- _sendBatchesNotification(droppedBatches_1, 8003 , thePayload[_DYN_SEND_TYPE ], true);
5191
+ else {
5192
+ droppedBatches_1[_DYN_PUSH ](theBatch[_DYN_SPLIT ](0));
4752
5193
  }
5194
+ });
5195
+ if (sentBatches_1[_DYN_LENGTH ] > 0) {
5196
+ thePayload.sentEvts = sentBatches_1;
4753
5197
  }
4754
- else {
4755
- status = 0;
5198
+ if (!persistStorage) {
5199
+ _sendBatchesNotification(droppedBatches_1, 8003 , thePayload[_DYN_SEND_TYPE ], true);
4756
5200
  }
4757
5201
  }
5202
+ else {
5203
+ status = 0;
5204
+ }
4758
5205
  }
4759
5206
  catch (ex) {
4760
5207
  _warnToConsole(_logger, "Failed to send telemetry using sendBeacon API. Ex:" + dumpObj(ex));
4761
5208
  status = 0;
4762
5209
  }
4763
5210
  finally {
4764
- _doOnComplete(oncomplete, status, {}, STR_EMPTY);
5211
+ _doOnComplete(onComplete, status, {}, STR_EMPTY);
4765
5212
  }
4766
5213
  }
4767
5214
  function _isBeaconPayload(sendType) {
@@ -4825,7 +5272,7 @@ var HttpManager = /** @class */ (function () {
4825
5272
  _paused = false;
4826
5273
  _self[_DYN_SEND_QUEUED_REQUESTS ](0 , 4 );
4827
5274
  };
4828
- _self[_DYN_SEND_SYNCHRONOUS_BAT11 ] = function (batch, sendType, sendReason) {
5275
+ _self[_DYN_SEND_SYNCHRONOUS_BAT10 ] = function (batch, sendType, sendReason) {
4829
5276
  if (batch && batch[_DYN_COUNT ]() > 0) {
4830
5277
  if (isNullOrUndefined(sendType)) {
4831
5278
  sendType = 1 ;
@@ -5034,7 +5481,7 @@ var HttpManager = /** @class */ (function () {
5034
5481
  };
5035
5482
  var isSync = thePayload[_DYN_IS_TEARDOWN ] || thePayload[_DYN_IS_SYNC ];
5036
5483
  try {
5037
- sendInterface_1[_DYN_SEND_POST ](payload, onComplete, isSync);
5484
+ sendInterface_1.sendPOST(payload, onComplete, isSync);
5038
5485
  if (_sendListener) {
5039
5486
  _sendListener(orgPayloadData, payload, isSync, thePayload[_DYN_IS_BEACON ]);
5040
5487
  }
@@ -5055,7 +5502,7 @@ var HttpManager = /** @class */ (function () {
5055
5502
  data: orgPayloadData[_DYN_DATA ],
5056
5503
  urlString: orgPayloadData[_DYN_URL_STRING ],
5057
5504
  headers: extend({}, orgPayloadData[_DYN_HEADERS ]),
5058
- timeout: orgPayloadData[_DYN_TIMEOUT ],
5505
+ timeout: orgPayloadData.timeout,
5059
5506
  disableXhrSync: orgPayloadData[_DYN_DISABLE_XHR_SYNC ],
5060
5507
  disableFetchKeepAlive: orgPayloadData[_DYN_DISABLE_FETCH_KEEP_A6 ]
5061
5508
  };
@@ -5111,7 +5558,7 @@ var HttpManager = /** @class */ (function () {
5111
5558
  if (headers) {
5112
5559
  _clockSkewManager[_DYN_SET_CLOCK_SKEW ](headers[STR_TIME_DELTA_HEADER]);
5113
5560
  var killDuration = headers[STR_KILL_DURATION_HEADER] || headers["kill-duration-seconds"];
5114
- arrForEach(_killSwitch[_DYN_SET_KILL_SWITCH_TENA12 ](headers[STR_KILL_TOKENS_HEADER], killDuration), function (killToken) {
5561
+ arrForEach(_killSwitch[_DYN_SET_KILL_SWITCH_TENA11 ](headers[STR_KILL_TOKENS_HEADER], killDuration), function (killToken) {
5115
5562
  arrForEach(thePayload[_DYN_BATCHES ], function (theBatch) {
5116
5563
  if (theBatch[_DYN_I_KEY ]() === killToken) {
5117
5564
  droppedBatches = droppedBatches || [];
@@ -5164,7 +5611,7 @@ var HttpManager = /** @class */ (function () {
5164
5611
  function _handleRequestFinished(thePayload, batchReason, sendReason, backOffTrans) {
5165
5612
  try {
5166
5613
  if (backOffTrans) {
5167
- _postManager[_DYN__BACK_OFF_TRANSMISSI13 ]();
5614
+ _postManager[_DYN__BACK_OFF_TRANSMISSI12 ]();
5168
5615
  }
5169
5616
  var theBatches = thePayload[_DYN_BATCHES ];
5170
5617
  if (batchReason === 200 ) {
@@ -5203,26 +5650,6 @@ var HttpManager = /** @class */ (function () {
5203
5650
  _timeoutWrapper.set(cb, interval);
5204
5651
  }
5205
5652
  }
5206
- function _convertAllHeadersToMap(headersString) {
5207
- var headers = {};
5208
- if (isString(headersString)) {
5209
- var headersArray = strTrim(headersString)[_DYN_SPLIT ](/[\r\n]+/);
5210
- arrForEach(headersArray, function (headerEntry) {
5211
- if (headerEntry) {
5212
- var idx = headerEntry.indexOf(": ");
5213
- if (idx !== -1) {
5214
- var header = strTrim(headerEntry.substring(0, idx))[_DYN_TO_LOWER_CASE ]();
5215
- var value = strTrim(headerEntry.substring(idx + 1));
5216
- headers[header] = value;
5217
- }
5218
- else {
5219
- headers[strTrim(headerEntry)] = 1;
5220
- }
5221
- }
5222
- });
5223
- }
5224
- return headers;
5225
- }
5226
5653
  function _getMsfpc(thePayload) {
5227
5654
  for (var lp = 0; lp < thePayload.batches[_DYN_LENGTH ]; lp++) {
5228
5655
  var msfpc = thePayload[_DYN_BATCHES ][lp].Msfpc();
@@ -5338,7 +5765,7 @@ var defaultPostChannelConfig = objDeepFreeze({
5338
5765
  excludeCsMetaData: undefValue
5339
5766
  });
5340
5767
  function isOverrideFn(httpXHROverride) {
5341
- return httpXHROverride && httpXHROverride[_DYN_SEND_POST ];
5768
+ return httpXHROverride && httpXHROverride.sendPOST;
5342
5769
  }
5343
5770
  var PostChannel = /** @class */ (function (_super) {
5344
5771
  __extendsFn(PostChannel, _super);
@@ -5346,7 +5773,7 @@ var PostChannel = /** @class */ (function (_super) {
5346
5773
  var _this = _super.call(this) || this;
5347
5774
  _this.identifier = "PostChannel";
5348
5775
  _this.priority = 1011;
5349
- _this.version = '4.1.1-nightly3.2403-03';
5776
+ _this.version = '4.1.1';
5350
5777
  var _postConfig;
5351
5778
  var _isTeardownCalled = false;
5352
5779
  var _flushCallbackQueue = [];
@@ -5397,16 +5824,16 @@ var PostChannel = /** @class */ (function (_super) {
5397
5824
  _postConfig = ctx.getExtCfg(_self[_DYN_IDENTIFIER ], defaultPostChannelConfig);
5398
5825
  _timeoutWrapper = createTimeoutWrapper(_postConfig[_DYN_SET_TIMEOUT_OVERRIDE ], _postConfig[_DYN_CLEAR_TIMEOUT_OVERRI3 ]);
5399
5826
  _optimizeObject = !_postConfig[_DYN_DISABLE_OPTIMIZE_OBJ ] && isChromium();
5400
- _ignoreMc1Ms0CookieProcessing = _postConfig[_DYN_IGNORE_MC1_MS0_COOKI14 ];
5827
+ _ignoreMc1Ms0CookieProcessing = _postConfig[_DYN_IGNORE_MC1_MS0_COOKI13 ];
5401
5828
  _hookWParam(core);
5402
5829
  _queueSizeLimit = _postConfig[_DYN_EVENTS_LIMIT_IN_MEM ];
5403
5830
  _immediateQueueSizeLimit = _postConfig.immediateEventLimit;
5404
- _autoFlushEventsLimit = _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI15 ];
5831
+ _autoFlushEventsLimit = _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI14 ];
5405
5832
  _maxEventSendAttempts = _postConfig.maxEventRetryAttempts;
5406
5833
  _maxUnloadEventSendAttempts = _postConfig.maxUnloadEventRetryAttempts;
5407
- _disableAutoBatchFlushLimit = _postConfig[_DYN_DISABLE_AUTO_BATCH_F16 ];
5834
+ _disableAutoBatchFlushLimit = _postConfig[_DYN_DISABLE_AUTO_BATCH_F15 ];
5408
5835
  _setAutoLimits();
5409
- _overrideInstrumentationKey = _postConfig[_DYN_OVERRIDE_INSTRUMENTA17 ];
5836
+ _overrideInstrumentationKey = _postConfig[_DYN_OVERRIDE_INSTRUMENTA16 ];
5410
5837
  _disableTelemetry = !!_postConfig[_DYN_DISABLE_TELEMETRY ];
5411
5838
  if (_unloadHandlersAdded) {
5412
5839
  _removeUnloadHandlers();
@@ -5443,24 +5870,31 @@ var PostChannel = /** @class */ (function (_super) {
5443
5870
  _self.processNext(event, itemCtx);
5444
5871
  };
5445
5872
  _self.getOfflineSupport = function () {
5446
- var details = _httpManager[_DYN_GET_OFFLINE_REQUEST_9 ]();
5447
- return {
5448
- getUrl: function () {
5449
- return details.url;
5450
- },
5451
- serialize: _serialize,
5452
- batch: _batch,
5453
- shouldProcess: function (evt) {
5454
- return !_disableTelemetry;
5455
- },
5456
- createPayload: function (evt) {
5873
+ try {
5874
+ var details_1 = _httpManager && _httpManager[_DYN_GET_OFFLINE_REQUEST_9 ]();
5875
+ if (details_1) {
5457
5876
  return {
5458
- urlString: details.url,
5459
- headers: details[_DYN_HDRS ],
5460
- data: evt
5877
+ getUrl: function () {
5878
+ return details_1.url;
5879
+ },
5880
+ serialize: _serialize,
5881
+ batch: _batch,
5882
+ shouldProcess: function (evt) {
5883
+ return !_disableTelemetry;
5884
+ },
5885
+ createPayload: function (evt) {
5886
+ return {
5887
+ urlString: details_1.url,
5888
+ headers: details_1[_DYN_HDRS ],
5889
+ data: evt
5890
+ };
5891
+ }
5461
5892
  };
5462
5893
  }
5463
- };
5894
+ }
5895
+ catch (e) {
5896
+ }
5897
+ return null;
5464
5898
  };
5465
5899
  _self._doTeardown = function (unloadCtx, unloadState) {
5466
5900
  _releaseAllQueues(2 , 2 );
@@ -5553,7 +5987,7 @@ var PostChannel = /** @class */ (function (_super) {
5553
5987
  if (_optimizeObject) {
5554
5988
  event = optimizeObject(event);
5555
5989
  }
5556
- _httpManager[_DYN_SEND_SYNCHRONOUS_BAT11 ](EventBatch.create(event[_DYN_I_KEY ], [event]), event[_DYN_SYNC ] === true ? 1 : event[_DYN_SYNC ], 3 );
5990
+ _httpManager[_DYN_SEND_SYNCHRONOUS_BAT10 ](EventBatch.create(event[_DYN_I_KEY ], [event]), event[_DYN_SYNC ] === true ? 1 : event[_DYN_SYNC ], 3 );
5557
5991
  return;
5558
5992
  }
5559
5993
  }
@@ -5587,7 +6021,7 @@ var PostChannel = /** @class */ (function (_super) {
5587
6021
  }
5588
6022
  _self.setEventQueueLimits = function (eventLimit, autoFlushLimit) {
5589
6023
  _postConfig[_DYN_EVENTS_LIMIT_IN_MEM ] = _queueSizeLimit = isGreaterThanZero(eventLimit) ? eventLimit : MaxEventsLimitInMem;
5590
- _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI15 ] = _autoFlushEventsLimit = isGreaterThanZero(autoFlushLimit) ? autoFlushLimit : 0;
6024
+ _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI14 ] = _autoFlushEventsLimit = isGreaterThanZero(autoFlushLimit) ? autoFlushLimit : 0;
5591
6025
  _setAutoLimits();
5592
6026
  var doFlush = _queueSize > eventLimit;
5593
6027
  if (!doFlush && _autoFlushBatchLimit > 0) {
@@ -5726,7 +6160,7 @@ var PostChannel = /** @class */ (function (_super) {
5726
6160
  }
5727
6161
  }
5728
6162
  }
5729
- _self[_DYN__BACK_OFF_TRANSMISSI13 ] = function () {
6163
+ _self[_DYN__BACK_OFF_TRANSMISSI12 ] = function () {
5730
6164
  if (_currentBackoffCount < MaxBackoffCount) {
5731
6165
  _currentBackoffCount++;
5732
6166
  _clearScheduledTimer();
@@ -6114,4 +6548,4 @@ exports.PostChannel = PostChannel;
6114
6548
  exports.RT_PROFILE = RT_PROFILE;
6115
6549
 
6116
6550
  }));
6117
- //# sourceMappingURL=ms.post-4.1.1-nightly3.2403-03.gbl.js.map
6551
+ //# sourceMappingURL=ms.post-4.1.1.gbl.js.map