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