@microsoft/applicationinsights-core-js 2.8.4-nightly.2205-07 → 2.8.4-nightly.2205-10
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.
- package/browser/applicationinsights-core-js.integrity.json +9 -9
- package/browser/applicationinsights-core-js.js +2008 -1811
- package/browser/applicationinsights-core-js.js.map +1 -1
- package/browser/applicationinsights-core-js.min.js +2 -2
- package/browser/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.api.json +1302 -199
- package/dist/applicationinsights-core-js.api.md +54 -0
- package/dist/applicationinsights-core-js.d.ts +174 -1
- package/dist/applicationinsights-core-js.js +2008 -1811
- package/dist/applicationinsights-core-js.js.map +1 -1
- package/dist/applicationinsights-core-js.min.js +2 -2
- package/dist/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.rollup.d.ts +174 -1
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +2 -2
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +25 -12
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +3 -3
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +3 -3
- package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +2 -2
- package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js +2 -2
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +6 -6
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +40 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EventHelpers.js +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +6 -6
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
- package/dist-esm/JavaScriptSDK/InternalConstants.js +1 -1
- package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +6 -6
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +54 -6
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +2 -2
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +2 -2
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -1
- package/dist-esm/JavaScriptSDK/W3cTraceParent.js +172 -0
- package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +7 -7
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js.map +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +86 -86
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +8 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +8 -0
- package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
- package/dist-esm/applicationinsights-core-js.js +3 -2
- package/dist-esm/applicationinsights-core-js.js.map +1 -1
- package/package.json +2 -2
- package/src/JavaScriptSDK/BaseCore.ts +32 -1
- package/src/JavaScriptSDK/DataCacheHelper.ts +1 -1
- package/src/JavaScriptSDK/EnvUtils.ts +45 -0
- package/src/JavaScriptSDK/TelemetryHelpers.ts +57 -5
- package/src/JavaScriptSDK/W3cTraceParent.ts +196 -0
- package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +12 -0
- package/src/JavaScriptSDK.Interfaces/IDistributedTraceContext.ts +54 -0
- package/src/JavaScriptSDK.Interfaces/ITraceParent.ts +38 -0
- package/tsconfig.json +1 -2
- package/types/JavaScriptSDK/BaseCore.d.ts +10 -0
- package/types/JavaScriptSDK/EnvUtils.d.ts +10 -0
- package/types/JavaScriptSDK/TelemetryHelpers.d.ts +7 -0
- package/types/JavaScriptSDK/W3cTraceParent.d.ts +59 -0
- package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +10 -0
- package/types/JavaScriptSDK.Interfaces/IDistributedTraceContext.d.ts +43 -0
- package/types/JavaScriptSDK.Interfaces/ITraceParent.d.ts +32 -0
- package/types/applicationinsights-core-js.d.ts +4 -1
- package/types/tsdoc-metadata.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Application Insights JavaScript SDK - Core, 2.8.4-nightly.2205-
|
|
2
|
+
* Application Insights JavaScript SDK - Core, 2.8.4-nightly.2205-10
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -1149,6 +1149,35 @@
|
|
|
1149
1149
|
}
|
|
1150
1150
|
return isSupported;
|
|
1151
1151
|
}
|
|
1152
|
+
function _getNamedValue(values, name) {
|
|
1153
|
+
if (values) {
|
|
1154
|
+
for (var i = 0; i < values.length; i++) {
|
|
1155
|
+
var value = values[i];
|
|
1156
|
+
if (value.name) {
|
|
1157
|
+
if (value.name === name) {
|
|
1158
|
+
return value;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
return {};
|
|
1164
|
+
}
|
|
1165
|
+
function findMetaTag(name) {
|
|
1166
|
+
var doc = getDocument();
|
|
1167
|
+
if (doc && name) {
|
|
1168
|
+
return _getNamedValue(doc.querySelectorAll("meta"), name).content;
|
|
1169
|
+
}
|
|
1170
|
+
return null;
|
|
1171
|
+
}
|
|
1172
|
+
function findNamedServerTiming(name) {
|
|
1173
|
+
var value;
|
|
1174
|
+
var perf = getPerformance();
|
|
1175
|
+
if (perf) {
|
|
1176
|
+
var navPerf = perf.getEntriesByType("navigation") || [];
|
|
1177
|
+
value = _getNamedValue((navPerf.length > 0 ? navPerf[0] : {}).serverTiming, name).description;
|
|
1178
|
+
}
|
|
1179
|
+
return value;
|
|
1180
|
+
}
|
|
1152
1181
|
|
|
1153
1182
|
var listenerFuncs = ["eventsSent", "eventsDiscarded", "eventsSendRequest", "perfEvent"];
|
|
1154
1183
|
var _aiNamespace = null;
|
|
@@ -1584,7 +1613,7 @@
|
|
|
1584
1613
|
}
|
|
1585
1614
|
|
|
1586
1615
|
var _objDefineProperty = ObjDefineProperty;
|
|
1587
|
-
var version = "2.8.4-nightly.2205-
|
|
1616
|
+
var version = "2.8.4-nightly.2205-10";
|
|
1588
1617
|
var instanceName = "." + newId(6);
|
|
1589
1618
|
var _dataUid = 0;
|
|
1590
1619
|
function _createAccessor(target, prop, value) {
|
|
@@ -1655,1221 +1684,1797 @@
|
|
|
1655
1684
|
return data;
|
|
1656
1685
|
}
|
|
1657
1686
|
|
|
1658
|
-
var
|
|
1659
|
-
var
|
|
1660
|
-
|
|
1661
|
-
|
|
1687
|
+
var strToGMTString = "toGMTString";
|
|
1688
|
+
var strToUTCString = "toUTCString";
|
|
1689
|
+
var strCookie = "cookie";
|
|
1690
|
+
var strExpires = "expires";
|
|
1691
|
+
var strEnabled = "enabled";
|
|
1692
|
+
var strIsCookieUseDisabled = "isCookieUseDisabled";
|
|
1693
|
+
var strDisableCookiesUsage = "disableCookiesUsage";
|
|
1694
|
+
var strConfigCookieMgr = "_ckMgr";
|
|
1695
|
+
var _supportsCookies = null;
|
|
1696
|
+
var _allowUaSameSite = null;
|
|
1697
|
+
var _parsedCookieValue = null;
|
|
1698
|
+
var _doc = getDocument();
|
|
1699
|
+
var _cookieCache = {};
|
|
1700
|
+
var _globalCookieConfig = {};
|
|
1701
|
+
function _gblCookieMgr(config, logger) {
|
|
1702
|
+
var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
|
|
1703
|
+
if (!inst) {
|
|
1704
|
+
inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
|
|
1705
|
+
_globalCookieConfig[strConfigCookieMgr] = inst;
|
|
1706
|
+
}
|
|
1707
|
+
return inst;
|
|
1662
1708
|
}
|
|
1663
|
-
function
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
var proxy = processContext.getNext();
|
|
1667
|
-
var pluginState;
|
|
1668
|
-
while (proxy) {
|
|
1669
|
-
var thePlugin = proxy.getPlugin();
|
|
1670
|
-
if (thePlugin) {
|
|
1671
|
-
if (lastPlugin &&
|
|
1672
|
-
isFunction(lastPlugin[strSetNextPlugin]) &&
|
|
1673
|
-
isFunction(thePlugin[strProcessTelemetry])) {
|
|
1674
|
-
lastPlugin[strSetNextPlugin](thePlugin);
|
|
1675
|
-
}
|
|
1676
|
-
var isInitialized = false;
|
|
1677
|
-
if (isFunction(thePlugin[strIsInitialized])) {
|
|
1678
|
-
isInitialized = thePlugin[strIsInitialized]();
|
|
1679
|
-
}
|
|
1680
|
-
else {
|
|
1681
|
-
pluginState = _getPluginState(thePlugin);
|
|
1682
|
-
isInitialized = pluginState[strIsInitialized];
|
|
1683
|
-
}
|
|
1684
|
-
if (!isInitialized) {
|
|
1685
|
-
initPlugins.push(thePlugin);
|
|
1686
|
-
}
|
|
1687
|
-
lastPlugin = thePlugin;
|
|
1688
|
-
proxy = proxy.getNext();
|
|
1689
|
-
}
|
|
1709
|
+
function _isMgrEnabled(cookieMgr) {
|
|
1710
|
+
if (cookieMgr) {
|
|
1711
|
+
return cookieMgr.isEnabled();
|
|
1690
1712
|
}
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1713
|
+
return true;
|
|
1714
|
+
}
|
|
1715
|
+
function _createCookieMgrConfig(rootConfig) {
|
|
1716
|
+
var cookieMgrCfg = rootConfig.cookieCfg = rootConfig.cookieCfg || {};
|
|
1717
|
+
setValue(cookieMgrCfg, "domain", rootConfig.cookieDomain, isNotNullOrUndefined, isNullOrUndefined);
|
|
1718
|
+
setValue(cookieMgrCfg, "path", rootConfig.cookiePath || "/", null, isNullOrUndefined);
|
|
1719
|
+
if (isNullOrUndefined(cookieMgrCfg[strEnabled])) {
|
|
1720
|
+
var cookieEnabled = void 0;
|
|
1721
|
+
if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
|
|
1722
|
+
cookieEnabled = !rootConfig[strIsCookieUseDisabled];
|
|
1697
1723
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1724
|
+
if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
|
|
1725
|
+
cookieEnabled = !rootConfig[strDisableCookiesUsage];
|
|
1726
|
+
}
|
|
1727
|
+
cookieMgrCfg[strEnabled] = cookieEnabled;
|
|
1728
|
+
}
|
|
1729
|
+
return cookieMgrCfg;
|
|
1701
1730
|
}
|
|
1702
|
-
function
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1731
|
+
function safeGetCookieMgr(core, config) {
|
|
1732
|
+
var cookieMgr;
|
|
1733
|
+
if (core) {
|
|
1734
|
+
cookieMgr = core.getCookieMgr();
|
|
1735
|
+
}
|
|
1736
|
+
else if (config) {
|
|
1737
|
+
var cookieCfg = config.cookieCfg;
|
|
1738
|
+
if (cookieCfg[strConfigCookieMgr]) {
|
|
1739
|
+
cookieMgr = cookieCfg[strConfigCookieMgr];
|
|
1708
1740
|
}
|
|
1709
|
-
else
|
|
1710
|
-
|
|
1741
|
+
else {
|
|
1742
|
+
cookieMgr = createCookieMgr(config);
|
|
1711
1743
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1744
|
+
}
|
|
1745
|
+
if (!cookieMgr) {
|
|
1746
|
+
cookieMgr = _gblCookieMgr(config, (core || {}).logger);
|
|
1747
|
+
}
|
|
1748
|
+
return cookieMgr;
|
|
1714
1749
|
}
|
|
1715
|
-
function
|
|
1716
|
-
var
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1750
|
+
function createCookieMgr(rootConfig, logger) {
|
|
1751
|
+
var cookieMgrConfig = _createCookieMgrConfig(rootConfig || _globalCookieConfig);
|
|
1752
|
+
var _path = cookieMgrConfig.path || "/";
|
|
1753
|
+
var _domain = cookieMgrConfig.domain;
|
|
1754
|
+
var _enabled = cookieMgrConfig[strEnabled] !== false;
|
|
1755
|
+
var cookieMgr = {
|
|
1756
|
+
isEnabled: function () {
|
|
1757
|
+
var enabled = _enabled && areCookiesSupported(logger);
|
|
1758
|
+
var gblManager = _globalCookieConfig[strConfigCookieMgr];
|
|
1759
|
+
if (enabled && gblManager && cookieMgr !== gblManager) {
|
|
1760
|
+
enabled = _isMgrEnabled(gblManager);
|
|
1761
|
+
}
|
|
1762
|
+
return enabled;
|
|
1763
|
+
},
|
|
1764
|
+
setEnabled: function (value) {
|
|
1765
|
+
_enabled = value !== false;
|
|
1766
|
+
},
|
|
1767
|
+
set: function (name, value, maxAgeSec, domain, path) {
|
|
1768
|
+
var result = false;
|
|
1769
|
+
if (_isMgrEnabled(cookieMgr)) {
|
|
1770
|
+
var values = {};
|
|
1771
|
+
var theValue = strTrim(value || strEmpty);
|
|
1772
|
+
var idx = theValue.indexOf(";");
|
|
1773
|
+
if (idx !== -1) {
|
|
1774
|
+
theValue = strTrim(value.substring(0, idx));
|
|
1775
|
+
values = _extractParts(value.substring(idx + 1));
|
|
1776
|
+
}
|
|
1777
|
+
setValue(values, "domain", domain || _domain, isTruthy, isUndefined);
|
|
1778
|
+
if (!isNullOrUndefined(maxAgeSec)) {
|
|
1779
|
+
var _isIE = isIE();
|
|
1780
|
+
if (isUndefined(values[strExpires])) {
|
|
1781
|
+
var nowMs = dateNow();
|
|
1782
|
+
var expireMs = nowMs + (maxAgeSec * 1000);
|
|
1783
|
+
if (expireMs > 0) {
|
|
1784
|
+
var expiry = new Date();
|
|
1785
|
+
expiry.setTime(expireMs);
|
|
1786
|
+
setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
if (!_isIE) {
|
|
1790
|
+
setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
var location_1 = getLocation();
|
|
1794
|
+
if (location_1 && location_1.protocol === "https:") {
|
|
1795
|
+
setValue(values, "secure", null, null, isUndefined);
|
|
1796
|
+
if (_allowUaSameSite === null) {
|
|
1797
|
+
_allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {}).userAgent);
|
|
1798
|
+
}
|
|
1799
|
+
if (_allowUaSameSite) {
|
|
1800
|
+
setValue(values, "SameSite", "None", null, isUndefined);
|
|
1725
1801
|
}
|
|
1726
1802
|
}
|
|
1803
|
+
setValue(values, "path", path || _path, null, isUndefined);
|
|
1804
|
+
var setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
|
|
1805
|
+
setCookieFn(name, _formatCookieValue(theValue, values));
|
|
1806
|
+
result = true;
|
|
1807
|
+
}
|
|
1808
|
+
return result;
|
|
1809
|
+
},
|
|
1810
|
+
get: function (name) {
|
|
1811
|
+
var value = strEmpty;
|
|
1812
|
+
if (_isMgrEnabled(cookieMgr)) {
|
|
1813
|
+
value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
|
|
1814
|
+
}
|
|
1815
|
+
return value;
|
|
1816
|
+
},
|
|
1817
|
+
del: function (name, path) {
|
|
1818
|
+
var result = false;
|
|
1819
|
+
if (_isMgrEnabled(cookieMgr)) {
|
|
1820
|
+
result = cookieMgr.purge(name, path);
|
|
1821
|
+
}
|
|
1822
|
+
return result;
|
|
1823
|
+
},
|
|
1824
|
+
purge: function (name, path) {
|
|
1825
|
+
var _a;
|
|
1826
|
+
var result = false;
|
|
1827
|
+
if (areCookiesSupported(logger)) {
|
|
1828
|
+
var values = (_a = {},
|
|
1829
|
+
_a["path"] = path ? path : "/",
|
|
1830
|
+
_a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
|
|
1831
|
+
_a);
|
|
1832
|
+
if (!isIE()) {
|
|
1833
|
+
values["max-age"] = "0";
|
|
1834
|
+
}
|
|
1835
|
+
var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
|
|
1836
|
+
delCookie(name, _formatCookieValue(strEmpty, values));
|
|
1837
|
+
result = true;
|
|
1727
1838
|
}
|
|
1839
|
+
return result;
|
|
1728
1840
|
}
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1841
|
+
};
|
|
1842
|
+
cookieMgr[strConfigCookieMgr] = cookieMgr;
|
|
1843
|
+
return cookieMgr;
|
|
1731
1844
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1845
|
+
function areCookiesSupported(logger) {
|
|
1846
|
+
if (_supportsCookies === null) {
|
|
1847
|
+
_supportsCookies = false;
|
|
1848
|
+
try {
|
|
1849
|
+
var doc = _doc || {};
|
|
1850
|
+
_supportsCookies = doc[strCookie] !== undefined;
|
|
1851
|
+
}
|
|
1852
|
+
catch (e) {
|
|
1853
|
+
_throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
|
|
1741
1854
|
}
|
|
1742
|
-
proxy = proxy.getNext();
|
|
1743
1855
|
}
|
|
1744
|
-
return
|
|
1856
|
+
return _supportsCookies;
|
|
1745
1857
|
}
|
|
1746
|
-
function
|
|
1747
|
-
var
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
return safeGetLogger(core, config);
|
|
1760
|
-
},
|
|
1761
|
-
getCfg: function () {
|
|
1762
|
-
return config;
|
|
1763
|
-
},
|
|
1764
|
-
getExtCfg: _getExtCfg,
|
|
1765
|
-
getConfig: _getConfig,
|
|
1766
|
-
hasNext: function () {
|
|
1767
|
-
return !!_nextProxy;
|
|
1768
|
-
},
|
|
1769
|
-
getNext: function () {
|
|
1770
|
-
return _nextProxy;
|
|
1771
|
-
},
|
|
1772
|
-
setNext: function (nextPlugin) {
|
|
1773
|
-
_nextProxy = nextPlugin;
|
|
1774
|
-
},
|
|
1775
|
-
iterate: _iterateChain,
|
|
1776
|
-
onComplete: _addOnComplete
|
|
1777
|
-
}
|
|
1778
|
-
};
|
|
1779
|
-
function _addOnComplete(onComplete, that) {
|
|
1780
|
-
var args = [];
|
|
1781
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1782
|
-
args[_i - 2] = arguments[_i];
|
|
1783
|
-
}
|
|
1784
|
-
if (onComplete) {
|
|
1785
|
-
_onComplete.push({
|
|
1786
|
-
func: onComplete,
|
|
1787
|
-
self: !isUndefined(that) ? that : context.ctx,
|
|
1788
|
-
args: args
|
|
1789
|
-
});
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
function _moveNext() {
|
|
1793
|
-
var nextProxy = _nextProxy;
|
|
1794
|
-
_nextProxy = nextProxy ? nextProxy.getNext() : null;
|
|
1795
|
-
if (!nextProxy) {
|
|
1796
|
-
var onComplete = _onComplete;
|
|
1797
|
-
if (onComplete && onComplete.length > 0) {
|
|
1798
|
-
arrForEach(onComplete, function (completeDetails) {
|
|
1799
|
-
try {
|
|
1800
|
-
completeDetails.func.call(completeDetails.self, completeDetails.args);
|
|
1801
|
-
}
|
|
1802
|
-
catch (e) {
|
|
1803
|
-
_throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
|
|
1804
|
-
}
|
|
1805
|
-
});
|
|
1806
|
-
_onComplete = [];
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
return nextProxy;
|
|
1810
|
-
}
|
|
1811
|
-
function _getExtCfg(identifier, defaultValue, mergeDefault) {
|
|
1812
|
-
if (defaultValue === void 0) { defaultValue = {}; }
|
|
1813
|
-
if (mergeDefault === void 0) { mergeDefault = 0 ; }
|
|
1814
|
-
var theConfig;
|
|
1815
|
-
if (config) {
|
|
1816
|
-
var extConfig = config.extensionConfig;
|
|
1817
|
-
if (extConfig && identifier) {
|
|
1818
|
-
theConfig = extConfig[identifier];
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
if (!theConfig) {
|
|
1822
|
-
theConfig = defaultValue;
|
|
1823
|
-
}
|
|
1824
|
-
else if (isObject(defaultValue)) {
|
|
1825
|
-
if (mergeDefault !== 0 ) {
|
|
1826
|
-
var newConfig_1 = objExtend(true, defaultValue, theConfig);
|
|
1827
|
-
if (config && mergeDefault === 2 ) {
|
|
1828
|
-
objForEachKey(defaultValue, function (field) {
|
|
1829
|
-
if (isNullOrUndefined(newConfig_1[field])) {
|
|
1830
|
-
var cfgValue = config[field];
|
|
1831
|
-
if (!isNullOrUndefined(cfgValue)) {
|
|
1832
|
-
newConfig_1[field] = cfgValue;
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
});
|
|
1858
|
+
function _extractParts(theValue) {
|
|
1859
|
+
var values = {};
|
|
1860
|
+
if (theValue && theValue.length) {
|
|
1861
|
+
var parts = strTrim(theValue).split(";");
|
|
1862
|
+
arrForEach(parts, function (thePart) {
|
|
1863
|
+
thePart = strTrim(thePart || strEmpty);
|
|
1864
|
+
if (thePart) {
|
|
1865
|
+
var idx = thePart.indexOf("=");
|
|
1866
|
+
if (idx === -1) {
|
|
1867
|
+
values[thePart] = null;
|
|
1868
|
+
}
|
|
1869
|
+
else {
|
|
1870
|
+
values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));
|
|
1836
1871
|
}
|
|
1837
|
-
theConfig = newConfig_1;
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
return theConfig;
|
|
1841
|
-
}
|
|
1842
|
-
function _getConfig(identifier, field, defaultValue) {
|
|
1843
|
-
if (defaultValue === void 0) { defaultValue = false; }
|
|
1844
|
-
var theValue;
|
|
1845
|
-
var extConfig = _getExtCfg(identifier, null);
|
|
1846
|
-
if (extConfig && !isNullOrUndefined(extConfig[field])) {
|
|
1847
|
-
theValue = extConfig[field];
|
|
1848
|
-
}
|
|
1849
|
-
else if (config && !isNullOrUndefined(config[field])) {
|
|
1850
|
-
theValue = config[field];
|
|
1851
|
-
}
|
|
1852
|
-
return !isNullOrUndefined(theValue) ? theValue : defaultValue;
|
|
1853
|
-
}
|
|
1854
|
-
function _iterateChain(cb) {
|
|
1855
|
-
var nextPlugin;
|
|
1856
|
-
while (!!(nextPlugin = context._next())) {
|
|
1857
|
-
var plugin = nextPlugin.getPlugin();
|
|
1858
|
-
if (plugin) {
|
|
1859
|
-
cb(plugin);
|
|
1860
1872
|
}
|
|
1861
|
-
}
|
|
1873
|
+
});
|
|
1862
1874
|
}
|
|
1863
|
-
return
|
|
1875
|
+
return values;
|
|
1864
1876
|
}
|
|
1865
|
-
function
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
function _processNext(env) {
|
|
1869
|
-
var nextPlugin = internalContext._next();
|
|
1870
|
-
nextPlugin && nextPlugin.processTelemetry(env, context);
|
|
1871
|
-
return !nextPlugin;
|
|
1877
|
+
function _formatDate(theDate, func) {
|
|
1878
|
+
if (isFunction(theDate[func])) {
|
|
1879
|
+
return theDate[func]();
|
|
1872
1880
|
}
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1881
|
+
return null;
|
|
1882
|
+
}
|
|
1883
|
+
function _formatCookieValue(value, values) {
|
|
1884
|
+
var cookieValue = value || strEmpty;
|
|
1885
|
+
objForEachKey(values, function (name, theValue) {
|
|
1886
|
+
cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
|
|
1887
|
+
});
|
|
1888
|
+
return cookieValue;
|
|
1889
|
+
}
|
|
1890
|
+
function _getCookieValue(name) {
|
|
1891
|
+
var cookieValue = strEmpty;
|
|
1892
|
+
if (_doc) {
|
|
1893
|
+
var theCookie = _doc[strCookie] || strEmpty;
|
|
1894
|
+
if (_parsedCookieValue !== theCookie) {
|
|
1895
|
+
_cookieCache = _extractParts(theCookie);
|
|
1896
|
+
_parsedCookieValue = theCookie;
|
|
1877
1897
|
}
|
|
1878
|
-
|
|
1898
|
+
cookieValue = strTrim(_cookieCache[name] || strEmpty);
|
|
1879
1899
|
}
|
|
1880
|
-
|
|
1881
|
-
context.createNew = _createNew;
|
|
1882
|
-
return context;
|
|
1900
|
+
return cookieValue;
|
|
1883
1901
|
}
|
|
1884
|
-
function
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
var context = internalContext.ctx;
|
|
1888
|
-
function _processNext(unloadState) {
|
|
1889
|
-
var nextPlugin = internalContext._next();
|
|
1890
|
-
nextPlugin && nextPlugin.unload(context, unloadState);
|
|
1891
|
-
return !nextPlugin;
|
|
1892
|
-
}
|
|
1893
|
-
function _createNew(plugins, startAt) {
|
|
1894
|
-
if (plugins === void 0) { plugins = null; }
|
|
1895
|
-
if (isArray(plugins)) {
|
|
1896
|
-
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1897
|
-
}
|
|
1898
|
-
return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
|
|
1902
|
+
function _setCookieValue(name, cookieValue) {
|
|
1903
|
+
if (_doc) {
|
|
1904
|
+
_doc[strCookie] = name + "=" + cookieValue;
|
|
1899
1905
|
}
|
|
1900
|
-
context.processNext = _processNext;
|
|
1901
|
-
context.createNew = _createNew;
|
|
1902
|
-
return context;
|
|
1903
1906
|
}
|
|
1904
|
-
function
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
var context = internalContext.ctx;
|
|
1908
|
-
function _processNext(updateState) {
|
|
1909
|
-
return context.iterate(function (plugin) {
|
|
1910
|
-
if (isFunction(plugin.update)) {
|
|
1911
|
-
plugin.update(context, updateState);
|
|
1912
|
-
}
|
|
1913
|
-
});
|
|
1907
|
+
function uaDisallowsSameSiteNone(userAgent) {
|
|
1908
|
+
if (!isString(userAgent)) {
|
|
1909
|
+
return false;
|
|
1914
1910
|
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
if (isArray(plugins)) {
|
|
1918
|
-
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1919
|
-
}
|
|
1920
|
-
return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
|
|
1911
|
+
if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
|
|
1912
|
+
return true;
|
|
1921
1913
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
return context;
|
|
1925
|
-
}
|
|
1926
|
-
function createTelemetryProxyChain(plugins, config, core, startAt) {
|
|
1927
|
-
var firstProxy = null;
|
|
1928
|
-
var add = startAt ? false : true;
|
|
1929
|
-
if (isArray(plugins) && plugins.length > 0) {
|
|
1930
|
-
var lastProxy_1 = null;
|
|
1931
|
-
arrForEach(plugins, function (thePlugin) {
|
|
1932
|
-
if (!add && startAt === thePlugin) {
|
|
1933
|
-
add = true;
|
|
1934
|
-
}
|
|
1935
|
-
if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
|
|
1936
|
-
var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
|
|
1937
|
-
if (!firstProxy) {
|
|
1938
|
-
firstProxy = newProxy;
|
|
1939
|
-
}
|
|
1940
|
-
if (lastProxy_1) {
|
|
1941
|
-
lastProxy_1._setNext(newProxy);
|
|
1942
|
-
}
|
|
1943
|
-
lastProxy_1 = newProxy;
|
|
1944
|
-
}
|
|
1945
|
-
});
|
|
1914
|
+
if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
|
|
1915
|
+
return true;
|
|
1946
1916
|
}
|
|
1947
|
-
if (
|
|
1948
|
-
return
|
|
1917
|
+
if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
|
|
1918
|
+
return true;
|
|
1949
1919
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
function createTelemetryPluginProxy(plugin, config, core) {
|
|
1953
|
-
var nextProxy = null;
|
|
1954
|
-
var hasProcessTelemetry = isFunction(plugin.processTelemetry);
|
|
1955
|
-
var hasSetNext = isFunction(plugin.setNextPlugin);
|
|
1956
|
-
var chainId;
|
|
1957
|
-
if (plugin) {
|
|
1958
|
-
chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
|
|
1920
|
+
if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
|
|
1921
|
+
return true;
|
|
1959
1922
|
}
|
|
1960
|
-
|
|
1961
|
-
|
|
1923
|
+
if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
|
|
1924
|
+
return true;
|
|
1962
1925
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
return plugin;
|
|
1966
|
-
},
|
|
1967
|
-
getNext: function () {
|
|
1968
|
-
return nextProxy;
|
|
1969
|
-
},
|
|
1970
|
-
processTelemetry: _processTelemetry,
|
|
1971
|
-
unload: _unloadPlugin,
|
|
1972
|
-
update: _updatePlugin,
|
|
1973
|
-
_id: chainId,
|
|
1974
|
-
_setNext: function (nextPlugin) {
|
|
1975
|
-
nextProxy = nextPlugin;
|
|
1976
|
-
}
|
|
1977
|
-
};
|
|
1978
|
-
function _getTelCtx() {
|
|
1979
|
-
var itemCtx;
|
|
1980
|
-
if (plugin && isFunction(plugin[strGetTelCtx])) {
|
|
1981
|
-
itemCtx = plugin[strGetTelCtx]();
|
|
1982
|
-
}
|
|
1983
|
-
if (!itemCtx) {
|
|
1984
|
-
itemCtx = createProcessTelemetryContext(proxyChain, config, core);
|
|
1985
|
-
}
|
|
1986
|
-
return itemCtx;
|
|
1926
|
+
if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
|
|
1927
|
+
return true;
|
|
1987
1928
|
}
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
1929
|
+
return false;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
var strOnPrefix = "on";
|
|
1933
|
+
var strAttachEvent = "attachEvent";
|
|
1934
|
+
var strAddEventHelper = "addEventListener";
|
|
1935
|
+
var strDetachEvent = "detachEvent";
|
|
1936
|
+
var strRemoveEventListener = "removeEventListener";
|
|
1937
|
+
var strEvents = "events";
|
|
1938
|
+
var strVisibilityChangeEvt = "visibilitychange";
|
|
1939
|
+
var strPageHide = "pagehide";
|
|
1940
|
+
var strPageShow = "pageshow";
|
|
1941
|
+
var strUnload = "unload";
|
|
1942
|
+
var strBeforeUnload = "beforeunload";
|
|
1943
|
+
var strPageHideNamespace = createUniqueNamespace("aiEvtPageHide");
|
|
1944
|
+
var strPageShowNamespace = createUniqueNamespace("aiEvtPageShow");
|
|
1945
|
+
var rRemoveEmptyNs = /\.[\.]+/g;
|
|
1946
|
+
var rRemoveTrailingEmptyNs = /[\.]+$/;
|
|
1947
|
+
var _guid = 1;
|
|
1948
|
+
var elmNodeData = createElmNodeData("events");
|
|
1949
|
+
var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
|
|
1950
|
+
function _normalizeNamespace(name) {
|
|
1951
|
+
if (name && name.replace) {
|
|
1952
|
+
return name.replace(/^\s*\.*|\.*\s*$/g, "");
|
|
1953
|
+
}
|
|
1954
|
+
return name;
|
|
1955
|
+
}
|
|
1956
|
+
function _getEvtNamespace(eventName, evtNamespace) {
|
|
1957
|
+
if (evtNamespace) {
|
|
1958
|
+
var theNamespace_1 = "";
|
|
1959
|
+
if (isArray(evtNamespace)) {
|
|
1960
|
+
theNamespace_1 = "";
|
|
1961
|
+
arrForEach(evtNamespace, function (name) {
|
|
1962
|
+
name = _normalizeNamespace(name);
|
|
1963
|
+
if (name) {
|
|
1964
|
+
if (name[0] !== ".") {
|
|
1965
|
+
name = "." + name;
|
|
2013
1966
|
}
|
|
1967
|
+
theNamespace_1 += name;
|
|
2014
1968
|
}
|
|
2015
|
-
}
|
|
1969
|
+
});
|
|
2016
1970
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
function _processTelemetry(env, itemCtx) {
|
|
2020
|
-
itemCtx = itemCtx || _getTelCtx();
|
|
2021
|
-
function _callProcessTelemetry(itemCtx) {
|
|
2022
|
-
if (!plugin || !hasProcessTelemetry) {
|
|
2023
|
-
return false;
|
|
2024
|
-
}
|
|
2025
|
-
var pluginState = _getPluginState(plugin);
|
|
2026
|
-
if (pluginState.teardown || pluginState[strDisabled]) {
|
|
2027
|
-
return false;
|
|
2028
|
-
}
|
|
2029
|
-
if (hasSetNext) {
|
|
2030
|
-
plugin.setNextPlugin(nextProxy);
|
|
2031
|
-
}
|
|
2032
|
-
plugin.processTelemetry(env, itemCtx);
|
|
2033
|
-
return true;
|
|
1971
|
+
else {
|
|
1972
|
+
theNamespace_1 = _normalizeNamespace(evtNamespace);
|
|
2034
1973
|
}
|
|
2035
|
-
if (
|
|
2036
|
-
|
|
1974
|
+
if (theNamespace_1) {
|
|
1975
|
+
if (theNamespace_1[0] !== ".") {
|
|
1976
|
+
theNamespace_1 = "." + theNamespace_1;
|
|
1977
|
+
}
|
|
1978
|
+
eventName = (eventName || "") + theNamespace_1;
|
|
2037
1979
|
}
|
|
2038
1980
|
}
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
1981
|
+
var parsedEvent = (eventNamespace.exec(eventName || "") || []);
|
|
1982
|
+
return {
|
|
1983
|
+
type: parsedEvent[1],
|
|
1984
|
+
ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
|
|
1985
|
+
};
|
|
1986
|
+
}
|
|
1987
|
+
function __getRegisteredEvents(target, eventName, evtNamespace) {
|
|
1988
|
+
var theEvents = [];
|
|
1989
|
+
var eventCache = elmNodeData.get(target, strEvents, {}, false);
|
|
1990
|
+
var evtName = _getEvtNamespace(eventName, evtNamespace);
|
|
1991
|
+
objForEachKey(eventCache, function (evtType, registeredEvents) {
|
|
1992
|
+
arrForEach(registeredEvents, function (value) {
|
|
1993
|
+
if (!evtName.type || evtName.type === value.evtName.type) {
|
|
1994
|
+
if (!evtName.ns || evtName.ns === evtName.ns) {
|
|
1995
|
+
theEvents.push({
|
|
1996
|
+
name: value.evtName.type + (value.evtName.ns ? "." + value.evtName.ns : ""),
|
|
1997
|
+
handler: value.handler
|
|
1998
|
+
});
|
|
2052
1999
|
}
|
|
2053
2000
|
}
|
|
2054
|
-
|
|
2001
|
+
});
|
|
2002
|
+
});
|
|
2003
|
+
return theEvents;
|
|
2004
|
+
}
|
|
2005
|
+
function _getRegisteredEvents(target, evtName, addDefault) {
|
|
2006
|
+
if (addDefault === void 0) { addDefault = true; }
|
|
2007
|
+
var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
|
|
2008
|
+
var registeredEvents = aiEvts[evtName];
|
|
2009
|
+
if (!registeredEvents) {
|
|
2010
|
+
registeredEvents = aiEvts[evtName] = [];
|
|
2011
|
+
}
|
|
2012
|
+
return registeredEvents;
|
|
2013
|
+
}
|
|
2014
|
+
function _doDetach(obj, evtName, handlerRef, useCapture) {
|
|
2015
|
+
if (obj && evtName && evtName.type) {
|
|
2016
|
+
if (obj[strRemoveEventListener]) {
|
|
2017
|
+
obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
|
|
2055
2018
|
}
|
|
2056
|
-
if (
|
|
2057
|
-
|
|
2019
|
+
else if (obj[strDetachEvent]) {
|
|
2020
|
+
obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
|
|
2058
2021
|
}
|
|
2059
2022
|
}
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
|
|
2068
|
-
hasRun = true;
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
return hasRun;
|
|
2023
|
+
}
|
|
2024
|
+
function _doAttach(obj, evtName, handlerRef, useCapture) {
|
|
2025
|
+
var result = false;
|
|
2026
|
+
if (obj && evtName && evtName.type && handlerRef) {
|
|
2027
|
+
if (obj[strAddEventHelper]) {
|
|
2028
|
+
obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
|
|
2029
|
+
result = true;
|
|
2073
2030
|
}
|
|
2074
|
-
if (
|
|
2075
|
-
|
|
2031
|
+
else if (obj[strAttachEvent]) {
|
|
2032
|
+
obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
|
|
2033
|
+
result = true;
|
|
2076
2034
|
}
|
|
2077
2035
|
}
|
|
2078
|
-
return
|
|
2036
|
+
return result;
|
|
2079
2037
|
}
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
var
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
var strExpires = "expires";
|
|
2093
|
-
var strEnabled = "enabled";
|
|
2094
|
-
var strIsCookieUseDisabled = "isCookieUseDisabled";
|
|
2095
|
-
var strDisableCookiesUsage = "disableCookiesUsage";
|
|
2096
|
-
var strConfigCookieMgr = "_ckMgr";
|
|
2097
|
-
var _supportsCookies = null;
|
|
2098
|
-
var _allowUaSameSite = null;
|
|
2099
|
-
var _parsedCookieValue = null;
|
|
2100
|
-
var _doc = getDocument();
|
|
2101
|
-
var _cookieCache = {};
|
|
2102
|
-
var _globalCookieConfig = {};
|
|
2103
|
-
function _gblCookieMgr(config, logger) {
|
|
2104
|
-
var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
|
|
2105
|
-
if (!inst) {
|
|
2106
|
-
inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
|
|
2107
|
-
_globalCookieConfig[strConfigCookieMgr] = inst;
|
|
2038
|
+
function _doUnregister(target, events, evtName, unRegFn) {
|
|
2039
|
+
var idx = events.length;
|
|
2040
|
+
while (idx--) {
|
|
2041
|
+
var theEvent = events[idx];
|
|
2042
|
+
if (theEvent) {
|
|
2043
|
+
if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
|
|
2044
|
+
if (!unRegFn || unRegFn(theEvent)) {
|
|
2045
|
+
_doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
|
|
2046
|
+
events.splice(idx, 1);
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2108
2050
|
}
|
|
2109
|
-
return inst;
|
|
2110
2051
|
}
|
|
2111
|
-
function
|
|
2112
|
-
if (
|
|
2113
|
-
|
|
2052
|
+
function _unregisterEvents(target, evtName, unRegFn) {
|
|
2053
|
+
if (evtName.type) {
|
|
2054
|
+
_doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
|
|
2055
|
+
}
|
|
2056
|
+
else {
|
|
2057
|
+
var eventCache = elmNodeData.get(target, strEvents, {});
|
|
2058
|
+
objForEachKey(eventCache, function (evtType, events) {
|
|
2059
|
+
_doUnregister(target, events, evtName, unRegFn);
|
|
2060
|
+
});
|
|
2061
|
+
if (objKeys(eventCache).length === 0) {
|
|
2062
|
+
elmNodeData.kill(target, strEvents);
|
|
2063
|
+
}
|
|
2114
2064
|
}
|
|
2115
|
-
return true;
|
|
2116
2065
|
}
|
|
2117
|
-
function
|
|
2118
|
-
var
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
var cookieEnabled = void 0;
|
|
2123
|
-
if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
|
|
2124
|
-
cookieEnabled = !rootConfig[strIsCookieUseDisabled];
|
|
2066
|
+
function mergeEvtNamespace(theNamespace, namespaces) {
|
|
2067
|
+
var newNamespaces;
|
|
2068
|
+
if (namespaces) {
|
|
2069
|
+
if (isArray(namespaces)) {
|
|
2070
|
+
newNamespaces = [theNamespace].concat(namespaces);
|
|
2125
2071
|
}
|
|
2126
|
-
|
|
2127
|
-
|
|
2072
|
+
else {
|
|
2073
|
+
newNamespaces = [theNamespace, namespaces];
|
|
2128
2074
|
}
|
|
2129
|
-
|
|
2075
|
+
newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
|
|
2130
2076
|
}
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
function safeGetCookieMgr(core, config) {
|
|
2134
|
-
var cookieMgr;
|
|
2135
|
-
if (core) {
|
|
2136
|
-
cookieMgr = core.getCookieMgr();
|
|
2077
|
+
else {
|
|
2078
|
+
newNamespaces = theNamespace;
|
|
2137
2079
|
}
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2080
|
+
return newNamespaces;
|
|
2081
|
+
}
|
|
2082
|
+
function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
|
|
2083
|
+
if (useCapture === void 0) { useCapture = false; }
|
|
2084
|
+
var result = false;
|
|
2085
|
+
if (target) {
|
|
2086
|
+
try {
|
|
2087
|
+
var evtName = _getEvtNamespace(eventName, evtNamespace);
|
|
2088
|
+
result = _doAttach(target, evtName, handlerRef, useCapture);
|
|
2089
|
+
if (result && elmNodeData.accept(target)) {
|
|
2090
|
+
var registeredEvent = {
|
|
2091
|
+
guid: _guid++,
|
|
2092
|
+
evtName: evtName,
|
|
2093
|
+
handler: handlerRef,
|
|
2094
|
+
capture: useCapture
|
|
2095
|
+
};
|
|
2096
|
+
_getRegisteredEvents(target, evtName.type).push(registeredEvent);
|
|
2097
|
+
}
|
|
2142
2098
|
}
|
|
2143
|
-
|
|
2144
|
-
cookieMgr = createCookieMgr(config);
|
|
2099
|
+
catch (e) {
|
|
2145
2100
|
}
|
|
2146
2101
|
}
|
|
2147
|
-
|
|
2148
|
-
cookieMgr = _gblCookieMgr(config, (core || {}).logger);
|
|
2149
|
-
}
|
|
2150
|
-
return cookieMgr;
|
|
2102
|
+
return result;
|
|
2151
2103
|
}
|
|
2152
|
-
function
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
enabled = _isMgrEnabled(gblManager);
|
|
2163
|
-
}
|
|
2164
|
-
return enabled;
|
|
2165
|
-
},
|
|
2166
|
-
setEnabled: function (value) {
|
|
2167
|
-
_enabled = value !== false;
|
|
2168
|
-
},
|
|
2169
|
-
set: function (name, value, maxAgeSec, domain, path) {
|
|
2170
|
-
var result = false;
|
|
2171
|
-
if (_isMgrEnabled(cookieMgr)) {
|
|
2172
|
-
var values = {};
|
|
2173
|
-
var theValue = strTrim(value || strEmpty);
|
|
2174
|
-
var idx = theValue.indexOf(";");
|
|
2175
|
-
if (idx !== -1) {
|
|
2176
|
-
theValue = strTrim(value.substring(0, idx));
|
|
2177
|
-
values = _extractParts(value.substring(idx + 1));
|
|
2178
|
-
}
|
|
2179
|
-
setValue(values, "domain", domain || _domain, isTruthy, isUndefined);
|
|
2180
|
-
if (!isNullOrUndefined(maxAgeSec)) {
|
|
2181
|
-
var _isIE = isIE();
|
|
2182
|
-
if (isUndefined(values[strExpires])) {
|
|
2183
|
-
var nowMs = dateNow();
|
|
2184
|
-
var expireMs = nowMs + (maxAgeSec * 1000);
|
|
2185
|
-
if (expireMs > 0) {
|
|
2186
|
-
var expiry = new Date();
|
|
2187
|
-
expiry.setTime(expireMs);
|
|
2188
|
-
setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
|
-
if (!_isIE) {
|
|
2192
|
-
setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
var location_1 = getLocation();
|
|
2196
|
-
if (location_1 && location_1.protocol === "https:") {
|
|
2197
|
-
setValue(values, "secure", null, null, isUndefined);
|
|
2198
|
-
if (_allowUaSameSite === null) {
|
|
2199
|
-
_allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {}).userAgent);
|
|
2200
|
-
}
|
|
2201
|
-
if (_allowUaSameSite) {
|
|
2202
|
-
setValue(values, "SameSite", "None", null, isUndefined);
|
|
2203
|
-
}
|
|
2204
|
-
}
|
|
2205
|
-
setValue(values, "path", path || _path, null, isUndefined);
|
|
2206
|
-
var setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
|
|
2207
|
-
setCookieFn(name, _formatCookieValue(theValue, values));
|
|
2208
|
-
result = true;
|
|
2209
|
-
}
|
|
2210
|
-
return result;
|
|
2211
|
-
},
|
|
2212
|
-
get: function (name) {
|
|
2213
|
-
var value = strEmpty;
|
|
2214
|
-
if (_isMgrEnabled(cookieMgr)) {
|
|
2215
|
-
value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
|
|
2216
|
-
}
|
|
2217
|
-
return value;
|
|
2218
|
-
},
|
|
2219
|
-
del: function (name, path) {
|
|
2220
|
-
var result = false;
|
|
2221
|
-
if (_isMgrEnabled(cookieMgr)) {
|
|
2222
|
-
result = cookieMgr.purge(name, path);
|
|
2223
|
-
}
|
|
2224
|
-
return result;
|
|
2225
|
-
},
|
|
2226
|
-
purge: function (name, path) {
|
|
2227
|
-
var _a;
|
|
2228
|
-
var result = false;
|
|
2229
|
-
if (areCookiesSupported(logger)) {
|
|
2230
|
-
var values = (_a = {},
|
|
2231
|
-
_a["path"] = path ? path : "/",
|
|
2232
|
-
_a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
|
|
2233
|
-
_a);
|
|
2234
|
-
if (!isIE()) {
|
|
2235
|
-
values["max-age"] = "0";
|
|
2104
|
+
function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
|
|
2105
|
+
if (useCapture === void 0) { useCapture = false; }
|
|
2106
|
+
if (target) {
|
|
2107
|
+
try {
|
|
2108
|
+
var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
|
|
2109
|
+
var found_1 = false;
|
|
2110
|
+
_unregisterEvents(target, evtName_1, function (regEvent) {
|
|
2111
|
+
if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
|
|
2112
|
+
found_1 = true;
|
|
2113
|
+
return true;
|
|
2236
2114
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2115
|
+
return false;
|
|
2116
|
+
});
|
|
2117
|
+
if (!found_1) {
|
|
2118
|
+
_doDetach(target, evtName_1, handlerRef, useCapture);
|
|
2240
2119
|
}
|
|
2241
|
-
return result;
|
|
2242
|
-
}
|
|
2243
|
-
};
|
|
2244
|
-
cookieMgr[strConfigCookieMgr] = cookieMgr;
|
|
2245
|
-
return cookieMgr;
|
|
2246
|
-
}
|
|
2247
|
-
function areCookiesSupported(logger) {
|
|
2248
|
-
if (_supportsCookies === null) {
|
|
2249
|
-
_supportsCookies = false;
|
|
2250
|
-
try {
|
|
2251
|
-
var doc = _doc || {};
|
|
2252
|
-
_supportsCookies = doc[strCookie] !== undefined;
|
|
2253
2120
|
}
|
|
2254
2121
|
catch (e) {
|
|
2255
|
-
_throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
|
|
2256
2122
|
}
|
|
2257
2123
|
}
|
|
2258
|
-
return _supportsCookies;
|
|
2259
2124
|
}
|
|
2260
|
-
function
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
}
|
|
2275
|
-
});
|
|
2125
|
+
function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
|
|
2126
|
+
if (useCapture === void 0) { useCapture = false; }
|
|
2127
|
+
return eventOn(obj, eventNameWithoutOn, handlerRef, null, useCapture);
|
|
2128
|
+
}
|
|
2129
|
+
function detachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
|
|
2130
|
+
if (useCapture === void 0) { useCapture = false; }
|
|
2131
|
+
eventOff(obj, eventNameWithoutOn, handlerRef, null, useCapture);
|
|
2132
|
+
}
|
|
2133
|
+
function addEventHandler(eventName, callback, evtNamespace) {
|
|
2134
|
+
var result = false;
|
|
2135
|
+
var w = getWindow();
|
|
2136
|
+
if (w) {
|
|
2137
|
+
result = eventOn(w, eventName, callback, evtNamespace);
|
|
2138
|
+
result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
|
|
2276
2139
|
}
|
|
2277
|
-
|
|
2140
|
+
var doc = getDocument();
|
|
2141
|
+
if (doc) {
|
|
2142
|
+
result = eventOn(doc, eventName, callback, evtNamespace) || result;
|
|
2143
|
+
}
|
|
2144
|
+
return result;
|
|
2278
2145
|
}
|
|
2279
|
-
function
|
|
2280
|
-
|
|
2281
|
-
|
|
2146
|
+
function removeEventHandler(eventName, callback, evtNamespace) {
|
|
2147
|
+
var w = getWindow();
|
|
2148
|
+
if (w) {
|
|
2149
|
+
eventOff(w, eventName, callback, evtNamespace);
|
|
2150
|
+
eventOff(w["body"], eventName, callback, evtNamespace);
|
|
2151
|
+
}
|
|
2152
|
+
var doc = getDocument();
|
|
2153
|
+
if (doc) {
|
|
2154
|
+
eventOff(doc, eventName, callback, evtNamespace);
|
|
2282
2155
|
}
|
|
2283
|
-
return null;
|
|
2284
2156
|
}
|
|
2285
|
-
function
|
|
2286
|
-
var
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2157
|
+
function _addEventListeners(events, listener, excludeEvents, evtNamespace) {
|
|
2158
|
+
var added = false;
|
|
2159
|
+
if (listener && events && events.length > 0) {
|
|
2160
|
+
arrForEach(events, function (name) {
|
|
2161
|
+
if (name) {
|
|
2162
|
+
if (!excludeEvents || arrIndexOf(excludeEvents, name) === -1) {
|
|
2163
|
+
added = addEventHandler(name, listener, evtNamespace) || added;
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
return added;
|
|
2291
2169
|
}
|
|
2292
|
-
function
|
|
2293
|
-
var
|
|
2294
|
-
if (
|
|
2295
|
-
|
|
2296
|
-
if (
|
|
2297
|
-
|
|
2298
|
-
_parsedCookieValue = theCookie;
|
|
2170
|
+
function addEventListeners(events, listener, excludeEvents, evtNamespace) {
|
|
2171
|
+
var added = false;
|
|
2172
|
+
if (listener && events && isArray(events)) {
|
|
2173
|
+
added = _addEventListeners(events, listener, excludeEvents, evtNamespace);
|
|
2174
|
+
if (!added && excludeEvents && excludeEvents.length > 0) {
|
|
2175
|
+
added = _addEventListeners(events, listener, null, evtNamespace);
|
|
2299
2176
|
}
|
|
2300
|
-
cookieValue = strTrim(_cookieCache[name] || strEmpty);
|
|
2301
2177
|
}
|
|
2302
|
-
return
|
|
2178
|
+
return added;
|
|
2303
2179
|
}
|
|
2304
|
-
function
|
|
2305
|
-
if (
|
|
2306
|
-
|
|
2180
|
+
function removeEventListeners(events, listener, evtNamespace) {
|
|
2181
|
+
if (events && isArray(events)) {
|
|
2182
|
+
arrForEach(events, function (name) {
|
|
2183
|
+
if (name) {
|
|
2184
|
+
removeEventHandler(name, listener, evtNamespace);
|
|
2185
|
+
}
|
|
2186
|
+
});
|
|
2307
2187
|
}
|
|
2308
2188
|
}
|
|
2309
|
-
function
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
}
|
|
2322
|
-
if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
|
|
2323
|
-
return true;
|
|
2189
|
+
function addPageUnloadEventListener(listener, excludeEvents, evtNamespace) {
|
|
2190
|
+
return addEventListeners([strBeforeUnload, strUnload, strPageHide], listener, excludeEvents, evtNamespace);
|
|
2191
|
+
}
|
|
2192
|
+
function removePageUnloadEventListener(listener, evtNamespace) {
|
|
2193
|
+
removeEventListeners([strBeforeUnload, strUnload, strPageHide], listener, evtNamespace);
|
|
2194
|
+
}
|
|
2195
|
+
function addPageHideEventListener(listener, excludeEvents, evtNamespace) {
|
|
2196
|
+
function _handlePageVisibility(evt) {
|
|
2197
|
+
var doc = getDocument();
|
|
2198
|
+
if (listener && doc && doc.visibilityState === "hidden") {
|
|
2199
|
+
listener(evt);
|
|
2200
|
+
}
|
|
2324
2201
|
}
|
|
2325
|
-
|
|
2326
|
-
|
|
2202
|
+
var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
|
|
2203
|
+
var pageUnloadAdded = _addEventListeners([strPageHide], listener, excludeEvents, newNamespaces);
|
|
2204
|
+
if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
|
|
2205
|
+
pageUnloadAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageUnloadAdded;
|
|
2327
2206
|
}
|
|
2328
|
-
if (
|
|
2329
|
-
|
|
2207
|
+
if (!pageUnloadAdded && excludeEvents) {
|
|
2208
|
+
pageUnloadAdded = addPageHideEventListener(listener, null, evtNamespace);
|
|
2330
2209
|
}
|
|
2331
|
-
return
|
|
2210
|
+
return pageUnloadAdded;
|
|
2211
|
+
}
|
|
2212
|
+
function removePageHideEventListener(listener, evtNamespace) {
|
|
2213
|
+
var newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace);
|
|
2214
|
+
removeEventListeners([strPageHide], listener, newNamespaces);
|
|
2215
|
+
removeEventListeners([strVisibilityChangeEvt], null, newNamespaces);
|
|
2216
|
+
}
|
|
2217
|
+
function addPageShowEventListener(listener, excludeEvents, evtNamespace) {
|
|
2218
|
+
function _handlePageVisibility(evt) {
|
|
2219
|
+
var doc = getDocument();
|
|
2220
|
+
if (listener && doc && doc.visibilityState === "visible") {
|
|
2221
|
+
listener(evt);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
|
|
2225
|
+
var pageShowAdded = _addEventListeners([strPageShow], listener, excludeEvents, newNamespaces);
|
|
2226
|
+
pageShowAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageShowAdded;
|
|
2227
|
+
if (!pageShowAdded && excludeEvents) {
|
|
2228
|
+
pageShowAdded = addPageShowEventListener(listener, null, evtNamespace);
|
|
2229
|
+
}
|
|
2230
|
+
return pageShowAdded;
|
|
2231
|
+
}
|
|
2232
|
+
function removePageShowEventListener(listener, evtNamespace) {
|
|
2233
|
+
var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
|
|
2234
|
+
removeEventListeners([strPageShow], listener, newNamespaces);
|
|
2235
|
+
removeEventListeners([strVisibilityChangeEvt], null, newNamespaces);
|
|
2332
2236
|
}
|
|
2333
2237
|
|
|
2334
|
-
var
|
|
2335
|
-
var
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
if (queue && isArray(queue) && queue.length > 0) {
|
|
2341
|
-
queue = queue.sort(function (a, b) {
|
|
2342
|
-
return a.priority - b.priority;
|
|
2343
|
-
});
|
|
2344
|
-
arrForEach(queue, function (queueItem) {
|
|
2345
|
-
if (queueItem.priority < ChannelControllerPriority) {
|
|
2346
|
-
throwError(ChannelValidationMessage + queueItem.identifier);
|
|
2347
|
-
}
|
|
2348
|
-
});
|
|
2349
|
-
channelQueue.push({
|
|
2350
|
-
queue: objFreeze(queue),
|
|
2351
|
-
chain: createTelemetryProxyChain(queue, config, core)
|
|
2352
|
-
});
|
|
2238
|
+
var _cookieMgrs = null;
|
|
2239
|
+
var _canUseCookies;
|
|
2240
|
+
var Undefined = strShimUndefined;
|
|
2241
|
+
function newGuid() {
|
|
2242
|
+
function randomHexDigit() {
|
|
2243
|
+
return randomValue(15);
|
|
2353
2244
|
}
|
|
2245
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(GuidRegex, function (c) {
|
|
2246
|
+
var r = (randomHexDigit() | 0), v = (c === "x" ? r : r & 0x3 | 0x8);
|
|
2247
|
+
return v.toString(16);
|
|
2248
|
+
});
|
|
2354
2249
|
}
|
|
2355
|
-
function
|
|
2356
|
-
var
|
|
2357
|
-
|
|
2358
|
-
return
|
|
2250
|
+
function perfNow() {
|
|
2251
|
+
var perf = getPerformance();
|
|
2252
|
+
if (perf && perf.now) {
|
|
2253
|
+
return perf.now();
|
|
2359
2254
|
}
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
}
|
|
2377
|
-
else {
|
|
2378
|
-
waiting--;
|
|
2379
|
-
}
|
|
2380
|
-
});
|
|
2381
|
-
}
|
|
2382
|
-
_runChainOnComplete();
|
|
2255
|
+
return dateNow();
|
|
2256
|
+
}
|
|
2257
|
+
function generateW3CId() {
|
|
2258
|
+
var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
|
|
2259
|
+
var oct = strEmpty, tmp;
|
|
2260
|
+
for (var a = 0; a < 4; a++) {
|
|
2261
|
+
tmp = random32();
|
|
2262
|
+
oct +=
|
|
2263
|
+
hexValues[tmp & 0xF] +
|
|
2264
|
+
hexValues[tmp >> 4 & 0xF] +
|
|
2265
|
+
hexValues[tmp >> 8 & 0xF] +
|
|
2266
|
+
hexValues[tmp >> 12 & 0xF] +
|
|
2267
|
+
hexValues[tmp >> 16 & 0xF] +
|
|
2268
|
+
hexValues[tmp >> 20 & 0xF] +
|
|
2269
|
+
hexValues[tmp >> 24 & 0xF] +
|
|
2270
|
+
hexValues[tmp >> 28 & 0xF];
|
|
2383
2271
|
}
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2272
|
+
var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
|
|
2273
|
+
return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
|
|
2274
|
+
}
|
|
2275
|
+
var CoreUtils = {
|
|
2276
|
+
_canUseCookies: undefined,
|
|
2277
|
+
isTypeof: isTypeof,
|
|
2278
|
+
isUndefined: isUndefined,
|
|
2279
|
+
isNullOrUndefined: isNullOrUndefined,
|
|
2280
|
+
hasOwnProperty: hasOwnProperty,
|
|
2281
|
+
isFunction: isFunction,
|
|
2282
|
+
isObject: isObject,
|
|
2283
|
+
isDate: isDate,
|
|
2284
|
+
isArray: isArray,
|
|
2285
|
+
isError: isError,
|
|
2286
|
+
isString: isString,
|
|
2287
|
+
isNumber: isNumber,
|
|
2288
|
+
isBoolean: isBoolean,
|
|
2289
|
+
toISOString: toISOString,
|
|
2290
|
+
arrForEach: arrForEach,
|
|
2291
|
+
arrIndexOf: arrIndexOf,
|
|
2292
|
+
arrMap: arrMap,
|
|
2293
|
+
arrReduce: arrReduce,
|
|
2294
|
+
strTrim: strTrim,
|
|
2295
|
+
objCreate: objCreateFn,
|
|
2296
|
+
objKeys: objKeys,
|
|
2297
|
+
objDefineAccessors: objDefineAccessors,
|
|
2298
|
+
addEventHandler: addEventHandler,
|
|
2299
|
+
dateNow: dateNow,
|
|
2300
|
+
isIE: isIE,
|
|
2301
|
+
disableCookies: disableCookies,
|
|
2302
|
+
newGuid: newGuid,
|
|
2303
|
+
perfNow: perfNow,
|
|
2304
|
+
newId: newId,
|
|
2305
|
+
randomValue: randomValue,
|
|
2306
|
+
random32: random32,
|
|
2307
|
+
mwcRandomSeed: mwcRandomSeed,
|
|
2308
|
+
mwcRandom32: mwcRandom32,
|
|
2309
|
+
generateW3CId: generateW3CId
|
|
2310
|
+
};
|
|
2311
|
+
var GuidRegex = /[xy]/g;
|
|
2312
|
+
var EventHelper = {
|
|
2313
|
+
Attach: attachEvent,
|
|
2314
|
+
AttachEvent: attachEvent,
|
|
2315
|
+
Detach: detachEvent,
|
|
2316
|
+
DetachEvent: detachEvent
|
|
2317
|
+
};
|
|
2318
|
+
function _legacyCookieMgr(config, logger) {
|
|
2319
|
+
var cookieMgr = _gblCookieMgr(config, logger);
|
|
2320
|
+
var legacyCanUseCookies = CoreUtils._canUseCookies;
|
|
2321
|
+
if (_cookieMgrs === null) {
|
|
2322
|
+
_cookieMgrs = [];
|
|
2323
|
+
_canUseCookies = legacyCanUseCookies;
|
|
2324
|
+
objDefineAccessors(CoreUtils, "_canUseCookies", function () {
|
|
2325
|
+
return _canUseCookies;
|
|
2326
|
+
}, function (value) {
|
|
2327
|
+
_canUseCookies = value;
|
|
2328
|
+
arrForEach(_cookieMgrs, function (mgr) {
|
|
2329
|
+
mgr.setEnabled(value);
|
|
2330
|
+
});
|
|
2392
2331
|
});
|
|
2393
|
-
return true;
|
|
2394
2332
|
}
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
reason: 0 ,
|
|
2398
|
-
isAsync: false
|
|
2399
|
-
};
|
|
2400
|
-
_processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {
|
|
2401
|
-
chainCtx[strProcessNext](theUnloadState);
|
|
2402
|
-
}, function () {
|
|
2403
|
-
unloadCtx[strProcessNext](theUnloadState);
|
|
2404
|
-
isInitialized = false;
|
|
2405
|
-
});
|
|
2406
|
-
return true;
|
|
2333
|
+
if (arrIndexOf(_cookieMgrs, cookieMgr) === -1) {
|
|
2334
|
+
_cookieMgrs.push(cookieMgr);
|
|
2407
2335
|
}
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
if (channelQueue && channelQueue.length > 0) {
|
|
2411
|
-
arrForEach(channelQueue, function (channels) {
|
|
2412
|
-
if (channels && channels.queue.length > 0) {
|
|
2413
|
-
arrForEach(channels.queue, function (ext) {
|
|
2414
|
-
if (ext.identifier === pluginIdentifier) {
|
|
2415
|
-
thePlugin = ext;
|
|
2416
|
-
return -1;
|
|
2417
|
-
}
|
|
2418
|
-
});
|
|
2419
|
-
if (thePlugin) {
|
|
2420
|
-
return -1;
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
});
|
|
2424
|
-
}
|
|
2425
|
-
return thePlugin;
|
|
2336
|
+
if (isBoolean(legacyCanUseCookies)) {
|
|
2337
|
+
cookieMgr.setEnabled(legacyCanUseCookies);
|
|
2426
2338
|
}
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
initialize: function (config, core, extensions, pluginChain) {
|
|
2432
|
-
isInitialized = true;
|
|
2433
|
-
arrForEach(channelQueue, function (channels) {
|
|
2434
|
-
if (channels && channels.queue.length > 0) {
|
|
2435
|
-
initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
|
|
2436
|
-
}
|
|
2437
|
-
});
|
|
2438
|
-
},
|
|
2439
|
-
isInitialized: function () {
|
|
2440
|
-
return isInitialized;
|
|
2441
|
-
},
|
|
2442
|
-
processTelemetry: function (item, itemCtx) {
|
|
2443
|
-
_processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {
|
|
2444
|
-
chainCtx[strProcessNext](item);
|
|
2445
|
-
}, function () {
|
|
2446
|
-
itemCtx[strProcessNext](item);
|
|
2447
|
-
});
|
|
2448
|
-
},
|
|
2449
|
-
update: _doUpdate
|
|
2450
|
-
},
|
|
2451
|
-
_a[strPause] = function () {
|
|
2452
|
-
_processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
|
|
2453
|
-
chainCtx.iterate(function (plugin) {
|
|
2454
|
-
plugin[strPause] && plugin[strPause]();
|
|
2455
|
-
});
|
|
2456
|
-
}, null);
|
|
2457
|
-
},
|
|
2458
|
-
_a[strResume] = function () {
|
|
2459
|
-
_processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
|
|
2460
|
-
chainCtx.iterate(function (plugin) {
|
|
2461
|
-
plugin[strResume] && plugin[strResume]();
|
|
2462
|
-
});
|
|
2463
|
-
}, null);
|
|
2464
|
-
},
|
|
2465
|
-
_a[strTeardown] = _doTeardown,
|
|
2466
|
-
_a.getChannel = _getChannel,
|
|
2467
|
-
_a.flush = function (isAsync, callBack, sendReason, cbTimeout) {
|
|
2468
|
-
var waiting = 1;
|
|
2469
|
-
var doneIterating = false;
|
|
2470
|
-
var cbTimer = null;
|
|
2471
|
-
cbTimeout = cbTimeout || 5000;
|
|
2472
|
-
function doCallback() {
|
|
2473
|
-
waiting--;
|
|
2474
|
-
if (doneIterating && waiting === 0) {
|
|
2475
|
-
if (cbTimer) {
|
|
2476
|
-
clearTimeout(cbTimer);
|
|
2477
|
-
cbTimer = null;
|
|
2478
|
-
}
|
|
2479
|
-
callBack && callBack(doneIterating);
|
|
2480
|
-
callBack = null;
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
_processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
|
|
2484
|
-
chainCtx.iterate(function (plugin) {
|
|
2485
|
-
if (plugin.flush) {
|
|
2486
|
-
waiting++;
|
|
2487
|
-
var handled_1 = false;
|
|
2488
|
-
if (!plugin.flush(isAsync, function () {
|
|
2489
|
-
handled_1 = true;
|
|
2490
|
-
doCallback();
|
|
2491
|
-
}, sendReason)) {
|
|
2492
|
-
if (!handled_1) {
|
|
2493
|
-
if (isAsync && cbTimer == null) {
|
|
2494
|
-
cbTimer = setTimeout(function () {
|
|
2495
|
-
cbTimer = null;
|
|
2496
|
-
doCallback();
|
|
2497
|
-
}, cbTimeout);
|
|
2498
|
-
}
|
|
2499
|
-
else {
|
|
2500
|
-
doCallback();
|
|
2501
|
-
}
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
});
|
|
2506
|
-
}, function () {
|
|
2507
|
-
doneIterating = true;
|
|
2508
|
-
doCallback();
|
|
2509
|
-
});
|
|
2510
|
-
return true;
|
|
2511
|
-
},
|
|
2512
|
-
_a._setQueue = function (queue) {
|
|
2513
|
-
channelQueue = queue;
|
|
2514
|
-
},
|
|
2515
|
-
_a);
|
|
2516
|
-
return channelController;
|
|
2339
|
+
if (isBoolean(_canUseCookies)) {
|
|
2340
|
+
cookieMgr.setEnabled(_canUseCookies);
|
|
2341
|
+
}
|
|
2342
|
+
return cookieMgr;
|
|
2517
2343
|
}
|
|
2518
|
-
function
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2344
|
+
function disableCookies() {
|
|
2345
|
+
_legacyCookieMgr().setEnabled(false);
|
|
2346
|
+
}
|
|
2347
|
+
function canUseCookies(logger) {
|
|
2348
|
+
return _legacyCookieMgr(null, logger).isEnabled();
|
|
2349
|
+
}
|
|
2350
|
+
function getCookie(logger, name) {
|
|
2351
|
+
return _legacyCookieMgr(null, logger).get(name);
|
|
2352
|
+
}
|
|
2353
|
+
function setCookie(logger, name, value, domain) {
|
|
2354
|
+
_legacyCookieMgr(null, logger).set(name, value, null, domain);
|
|
2355
|
+
}
|
|
2356
|
+
function deleteCookie(logger, name) {
|
|
2357
|
+
return _legacyCookieMgr(null, logger).del(name);
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
var TRACE_PARENT_REGEX = /^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-[^\s]*)?$/;
|
|
2361
|
+
var DEFAULT_VERSION = "00";
|
|
2362
|
+
var INVALID_VERSION = "ff";
|
|
2363
|
+
var INVALID_TRACE_ID = "00000000000000000000000000000000";
|
|
2364
|
+
var INVALID_SPAN_ID = "0000000000000000";
|
|
2365
|
+
var SAMPLED_FLAG = 0x01;
|
|
2366
|
+
function _isValid(value, len, invalidValue) {
|
|
2367
|
+
if (value && value.length === len && value !== invalidValue) {
|
|
2368
|
+
return !!value.match(/^[\da-f]*$/);
|
|
2522
2369
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
}
|
|
2529
|
-
});
|
|
2530
|
-
_addChannelQueue(channelQueue, extensionQueue_1, config, core);
|
|
2370
|
+
return false;
|
|
2371
|
+
}
|
|
2372
|
+
function _formatValue(value, len, defValue) {
|
|
2373
|
+
if (_isValid(value, len)) {
|
|
2374
|
+
return value;
|
|
2531
2375
|
}
|
|
2532
|
-
return
|
|
2376
|
+
return defValue;
|
|
2377
|
+
}
|
|
2378
|
+
function _formatFlags(value) {
|
|
2379
|
+
if (isNaN(value) || value < 0 || value > 255) {
|
|
2380
|
+
value = 0x01;
|
|
2381
|
+
}
|
|
2382
|
+
var result = value.toString(16);
|
|
2383
|
+
while (result.length < 2) {
|
|
2384
|
+
result = "0" + result;
|
|
2385
|
+
}
|
|
2386
|
+
return result;
|
|
2387
|
+
}
|
|
2388
|
+
function createTraceParent(traceId, spanId, flags, version) {
|
|
2389
|
+
return {
|
|
2390
|
+
version: _isValid(version, 2, INVALID_VERSION) ? version : DEFAULT_VERSION,
|
|
2391
|
+
traceId: isValidTraceId(traceId) ? traceId : generateW3CId(),
|
|
2392
|
+
spanId: isValidSpanId(spanId) ? spanId : generateW3CId().substr(0, 16),
|
|
2393
|
+
traceFlags: flags >= 0 && flags <= 0xFF ? flags : 1
|
|
2394
|
+
};
|
|
2395
|
+
}
|
|
2396
|
+
function parseTraceParent(value) {
|
|
2397
|
+
if (!value) {
|
|
2398
|
+
return null;
|
|
2399
|
+
}
|
|
2400
|
+
if (isArray(value)) {
|
|
2401
|
+
value = value[0] || "";
|
|
2402
|
+
}
|
|
2403
|
+
if (!value || !isString(value) || value.length > 8192) {
|
|
2404
|
+
return null;
|
|
2405
|
+
}
|
|
2406
|
+
var match = TRACE_PARENT_REGEX.exec(strTrim(value));
|
|
2407
|
+
if (!match ||
|
|
2408
|
+
match[1] === INVALID_VERSION ||
|
|
2409
|
+
match[2] === INVALID_TRACE_ID ||
|
|
2410
|
+
match[3] === INVALID_SPAN_ID) {
|
|
2411
|
+
return null;
|
|
2412
|
+
}
|
|
2413
|
+
return {
|
|
2414
|
+
version: match[1],
|
|
2415
|
+
traceId: match[2],
|
|
2416
|
+
spanId: match[3],
|
|
2417
|
+
traceFlags: parseInt(match[4], 16)
|
|
2418
|
+
};
|
|
2419
|
+
}
|
|
2420
|
+
function isValidTraceId(value) {
|
|
2421
|
+
return _isValid(value, 32, INVALID_TRACE_ID);
|
|
2422
|
+
}
|
|
2423
|
+
function isValidSpanId(value) {
|
|
2424
|
+
return _isValid(value, 16, INVALID_SPAN_ID);
|
|
2425
|
+
}
|
|
2426
|
+
function isValidTraceParent(value) {
|
|
2427
|
+
if (!value ||
|
|
2428
|
+
!_isValid(value.version, 2, INVALID_VERSION) ||
|
|
2429
|
+
!_isValid(value.traceId, 32, INVALID_TRACE_ID) ||
|
|
2430
|
+
!_isValid(value.spanId, 16, INVALID_SPAN_ID) ||
|
|
2431
|
+
!_isValid(_formatFlags(value.traceFlags), 2)) {
|
|
2432
|
+
return false;
|
|
2433
|
+
}
|
|
2434
|
+
return true;
|
|
2435
|
+
}
|
|
2436
|
+
function isSampledFlag(value) {
|
|
2437
|
+
if (isValidTraceParent(value)) {
|
|
2438
|
+
return (value.traceFlags & SAMPLED_FLAG) === SAMPLED_FLAG;
|
|
2439
|
+
}
|
|
2440
|
+
return false;
|
|
2441
|
+
}
|
|
2442
|
+
function formatTraceParent(value) {
|
|
2443
|
+
if (value) {
|
|
2444
|
+
var flags = _formatFlags(value.traceFlags);
|
|
2445
|
+
if (!_isValid(flags, 2)) {
|
|
2446
|
+
flags = "01";
|
|
2447
|
+
}
|
|
2448
|
+
var version = value.version || DEFAULT_VERSION;
|
|
2449
|
+
if (version !== "00" && version !== "ff") {
|
|
2450
|
+
version = DEFAULT_VERSION;
|
|
2451
|
+
}
|
|
2452
|
+
return "".concat(version, "-").concat(_formatValue(value.traceId, 32, INVALID_TRACE_ID), "-").concat(_formatValue(value.spanId, 16, INVALID_SPAN_ID), "-").concat(flags);
|
|
2453
|
+
}
|
|
2454
|
+
return "";
|
|
2455
|
+
}
|
|
2456
|
+
function findW3cTraceParent() {
|
|
2457
|
+
var name = "traceparent";
|
|
2458
|
+
var traceParent = parseTraceParent(findMetaTag(name));
|
|
2459
|
+
if (!traceParent) {
|
|
2460
|
+
traceParent = parseTraceParent(findNamedServerTiming(name));
|
|
2461
|
+
}
|
|
2462
|
+
return traceParent;
|
|
2533
2463
|
}
|
|
2534
2464
|
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2465
|
+
var strDoUnload = "_doUnload";
|
|
2466
|
+
var pluginStateData = createElmNodeData("plugin");
|
|
2467
|
+
function _getPluginState(plugin) {
|
|
2468
|
+
return pluginStateData.get(plugin, "state", {}, true);
|
|
2469
|
+
}
|
|
2470
|
+
function initializePlugins(processContext, extensions) {
|
|
2471
|
+
var initPlugins = [];
|
|
2472
|
+
var lastPlugin = null;
|
|
2473
|
+
var proxy = processContext.getNext();
|
|
2474
|
+
var pluginState;
|
|
2475
|
+
while (proxy) {
|
|
2476
|
+
var thePlugin = proxy.getPlugin();
|
|
2477
|
+
if (thePlugin) {
|
|
2478
|
+
if (lastPlugin &&
|
|
2479
|
+
isFunction(lastPlugin[strSetNextPlugin]) &&
|
|
2480
|
+
isFunction(thePlugin[strProcessTelemetry])) {
|
|
2481
|
+
lastPlugin[strSetNextPlugin](thePlugin);
|
|
2482
|
+
}
|
|
2483
|
+
var isInitialized = false;
|
|
2484
|
+
if (isFunction(thePlugin[strIsInitialized])) {
|
|
2485
|
+
isInitialized = thePlugin[strIsInitialized]();
|
|
2486
|
+
}
|
|
2487
|
+
else {
|
|
2488
|
+
pluginState = _getPluginState(thePlugin);
|
|
2489
|
+
isInitialized = pluginState[strIsInitialized];
|
|
2490
|
+
}
|
|
2491
|
+
if (!isInitialized) {
|
|
2492
|
+
initPlugins.push(thePlugin);
|
|
2493
|
+
}
|
|
2494
|
+
lastPlugin = thePlugin;
|
|
2495
|
+
proxy = proxy.getNext();
|
|
2540
2496
|
}
|
|
2541
2497
|
}
|
|
2542
|
-
function
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2498
|
+
arrForEach(initPlugins, function (thePlugin) {
|
|
2499
|
+
var core = processContext.core();
|
|
2500
|
+
thePlugin.initialize(processContext.getCfg(), core, extensions, processContext.getNext());
|
|
2501
|
+
pluginState = _getPluginState(thePlugin);
|
|
2502
|
+
if (!thePlugin[strCore] && !pluginState[strCore]) {
|
|
2503
|
+
pluginState[strCore] = core;
|
|
2504
|
+
}
|
|
2505
|
+
pluginState[strIsInitialized] = true;
|
|
2506
|
+
delete pluginState[strTeardown];
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2509
|
+
function sortPlugins(plugins) {
|
|
2510
|
+
return plugins.sort(function (extA, extB) {
|
|
2511
|
+
var result = 0;
|
|
2512
|
+
if (extB) {
|
|
2513
|
+
var bHasProcess = isFunction(extB[strProcessTelemetry]);
|
|
2514
|
+
if (isFunction(extA[strProcessTelemetry])) {
|
|
2515
|
+
result = bHasProcess ? extA[strPriority] - extB[strPriority] : 1;
|
|
2546
2516
|
}
|
|
2547
|
-
|
|
2548
|
-
|
|
2517
|
+
else if (bHasProcess) {
|
|
2518
|
+
result = -1;
|
|
2549
2519
|
}
|
|
2550
|
-
}
|
|
2551
|
-
|
|
2520
|
+
}
|
|
2521
|
+
else {
|
|
2522
|
+
result = extA ? 1 : -1;
|
|
2523
|
+
}
|
|
2524
|
+
return result;
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
function unloadComponents(components, unloadCtx, unloadState, asyncCallback) {
|
|
2528
|
+
var idx = 0;
|
|
2529
|
+
function _doUnload() {
|
|
2530
|
+
while (idx < components.length) {
|
|
2531
|
+
var component = components[idx++];
|
|
2532
|
+
if (component) {
|
|
2533
|
+
var func = component[strDoUnload] || component[strDoTeardown];
|
|
2534
|
+
if (isFunction(func)) {
|
|
2535
|
+
if (func.call(component, unloadCtx, unloadState, _doUnload) === true) {
|
|
2536
|
+
return true;
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2552
2541
|
}
|
|
2542
|
+
return _doUnload();
|
|
2543
|
+
}
|
|
2544
|
+
function createDistributedTraceContext(parentCtx) {
|
|
2545
|
+
var trace = {};
|
|
2553
2546
|
return {
|
|
2554
|
-
|
|
2555
|
-
|
|
2547
|
+
getName: function () {
|
|
2548
|
+
return trace.name;
|
|
2549
|
+
},
|
|
2550
|
+
setName: function (newValue) {
|
|
2551
|
+
parentCtx && parentCtx.setName(newValue);
|
|
2552
|
+
trace.name = newValue;
|
|
2553
|
+
},
|
|
2554
|
+
getTraceId: function () {
|
|
2555
|
+
return trace.traceId;
|
|
2556
|
+
},
|
|
2557
|
+
setTraceId: function (newValue) {
|
|
2558
|
+
parentCtx && parentCtx.setTraceId(newValue);
|
|
2559
|
+
if (isValidTraceId(newValue)) {
|
|
2560
|
+
trace.traceId = newValue;
|
|
2561
|
+
}
|
|
2562
|
+
},
|
|
2563
|
+
getSpanId: function () {
|
|
2564
|
+
return trace.spanId;
|
|
2565
|
+
},
|
|
2566
|
+
setSpanId: function (newValue) {
|
|
2567
|
+
parentCtx && parentCtx.setSpanId(newValue);
|
|
2568
|
+
if (isValidSpanId(newValue)) {
|
|
2569
|
+
trace.spanId = newValue;
|
|
2570
|
+
}
|
|
2571
|
+
},
|
|
2572
|
+
getTraceFlags: function () {
|
|
2573
|
+
return trace.traceFlags;
|
|
2574
|
+
},
|
|
2575
|
+
setTraceFlags: function (newTraceFlags) {
|
|
2576
|
+
parentCtx && parentCtx.setTraceFlags(newTraceFlags);
|
|
2577
|
+
trace.traceFlags = newTraceFlags;
|
|
2578
|
+
}
|
|
2556
2579
|
};
|
|
2557
2580
|
}
|
|
2558
2581
|
|
|
2559
|
-
var
|
|
2560
|
-
var
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
}
|
|
2628
|
-
else {
|
|
2629
|
-
result = true;
|
|
2630
|
-
}
|
|
2631
|
-
return result;
|
|
2632
|
-
};
|
|
2633
|
-
_self._addHook = function (hooks) {
|
|
2634
|
-
if (hooks) {
|
|
2635
|
-
if (isArray(hooks)) {
|
|
2636
|
-
_hooks = _hooks.concat(hooks);
|
|
2582
|
+
var strTelemetryPluginChain = "TelemetryPluginChain";
|
|
2583
|
+
var strHasRunFlags = "_hasRun";
|
|
2584
|
+
var strGetTelCtx = "_getTelCtx";
|
|
2585
|
+
var _chainId = 0;
|
|
2586
|
+
function _getNextProxyStart(proxy, core, startAt) {
|
|
2587
|
+
while (proxy) {
|
|
2588
|
+
if (proxy.getPlugin() === startAt) {
|
|
2589
|
+
return proxy;
|
|
2590
|
+
}
|
|
2591
|
+
proxy = proxy.getNext();
|
|
2592
|
+
}
|
|
2593
|
+
return createTelemetryProxyChain([startAt], core.config || {}, core);
|
|
2594
|
+
}
|
|
2595
|
+
function _createInternalContext(telemetryChain, config, core, startAt) {
|
|
2596
|
+
var _nextProxy = null;
|
|
2597
|
+
var _onComplete = [];
|
|
2598
|
+
if (startAt !== null) {
|
|
2599
|
+
_nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
|
|
2600
|
+
}
|
|
2601
|
+
var context = {
|
|
2602
|
+
_next: _moveNext,
|
|
2603
|
+
ctx: {
|
|
2604
|
+
core: function () {
|
|
2605
|
+
return core;
|
|
2606
|
+
},
|
|
2607
|
+
diagLog: function () {
|
|
2608
|
+
return safeGetLogger(core, config);
|
|
2609
|
+
},
|
|
2610
|
+
getCfg: function () {
|
|
2611
|
+
return config;
|
|
2612
|
+
},
|
|
2613
|
+
getExtCfg: _getExtCfg,
|
|
2614
|
+
getConfig: _getConfig,
|
|
2615
|
+
hasNext: function () {
|
|
2616
|
+
return !!_nextProxy;
|
|
2617
|
+
},
|
|
2618
|
+
getNext: function () {
|
|
2619
|
+
return _nextProxy;
|
|
2620
|
+
},
|
|
2621
|
+
setNext: function (nextPlugin) {
|
|
2622
|
+
_nextProxy = nextPlugin;
|
|
2623
|
+
},
|
|
2624
|
+
iterate: _iterateChain,
|
|
2625
|
+
onComplete: _addOnComplete
|
|
2626
|
+
}
|
|
2627
|
+
};
|
|
2628
|
+
function _addOnComplete(onComplete, that) {
|
|
2629
|
+
var args = [];
|
|
2630
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
2631
|
+
args[_i - 2] = arguments[_i];
|
|
2632
|
+
}
|
|
2633
|
+
if (onComplete) {
|
|
2634
|
+
_onComplete.push({
|
|
2635
|
+
func: onComplete,
|
|
2636
|
+
self: !isUndefined(that) ? that : context.ctx,
|
|
2637
|
+
args: args
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
function _moveNext() {
|
|
2642
|
+
var nextProxy = _nextProxy;
|
|
2643
|
+
_nextProxy = nextProxy ? nextProxy.getNext() : null;
|
|
2644
|
+
if (!nextProxy) {
|
|
2645
|
+
var onComplete = _onComplete;
|
|
2646
|
+
if (onComplete && onComplete.length > 0) {
|
|
2647
|
+
arrForEach(onComplete, function (completeDetails) {
|
|
2648
|
+
try {
|
|
2649
|
+
completeDetails.func.call(completeDetails.self, completeDetails.args);
|
|
2637
2650
|
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2651
|
+
catch (e) {
|
|
2652
|
+
_throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
|
|
2640
2653
|
}
|
|
2641
|
-
}
|
|
2642
|
-
|
|
2643
|
-
proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
|
|
2644
|
-
});
|
|
2645
|
-
_self.diagLog = function (itemCtx) {
|
|
2646
|
-
return _getTelCtx(itemCtx).diagLog();
|
|
2647
|
-
};
|
|
2648
|
-
_self[strIsInitialized] = function () {
|
|
2649
|
-
return _isinitialized;
|
|
2650
|
-
};
|
|
2651
|
-
_self.setInitialized = function (isInitialized) {
|
|
2652
|
-
_isinitialized = isInitialized;
|
|
2653
|
-
};
|
|
2654
|
-
_self[strSetNextPlugin] = function (next) {
|
|
2655
|
-
_nextPlugin = next;
|
|
2656
|
-
};
|
|
2657
|
-
_self.processNext = function (env, itemCtx) {
|
|
2658
|
-
if (itemCtx) {
|
|
2659
|
-
itemCtx.processNext(env);
|
|
2660
|
-
}
|
|
2661
|
-
else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
|
|
2662
|
-
_nextPlugin.processTelemetry(env, null);
|
|
2663
|
-
}
|
|
2664
|
-
};
|
|
2665
|
-
_self._getTelCtx = _getTelCtx;
|
|
2666
|
-
function _getTelCtx(currentCtx) {
|
|
2667
|
-
if (currentCtx === void 0) { currentCtx = null; }
|
|
2668
|
-
var itemCtx = currentCtx;
|
|
2669
|
-
if (!itemCtx) {
|
|
2670
|
-
var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
|
|
2671
|
-
if (_nextPlugin && _nextPlugin[strGetPlugin]) {
|
|
2672
|
-
itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
|
|
2673
|
-
}
|
|
2674
|
-
else {
|
|
2675
|
-
itemCtx = rootCtx.createNew(null, _nextPlugin);
|
|
2676
|
-
}
|
|
2654
|
+
});
|
|
2655
|
+
_onComplete = [];
|
|
2677
2656
|
}
|
|
2678
|
-
return itemCtx;
|
|
2679
2657
|
}
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
var
|
|
2688
|
-
if (
|
|
2689
|
-
|
|
2658
|
+
return nextProxy;
|
|
2659
|
+
}
|
|
2660
|
+
function _getExtCfg(identifier, defaultValue, mergeDefault) {
|
|
2661
|
+
if (defaultValue === void 0) { defaultValue = {}; }
|
|
2662
|
+
if (mergeDefault === void 0) { mergeDefault = 0 ; }
|
|
2663
|
+
var theConfig;
|
|
2664
|
+
if (config) {
|
|
2665
|
+
var extConfig = config.extensionConfig;
|
|
2666
|
+
if (extConfig && identifier) {
|
|
2667
|
+
theConfig = extConfig[identifier];
|
|
2690
2668
|
}
|
|
2691
|
-
_self.core = core;
|
|
2692
|
-
_rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
|
|
2693
2669
|
}
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
_self.core = null;
|
|
2697
|
-
_rootCtx = null;
|
|
2698
|
-
_nextPlugin = null;
|
|
2699
|
-
_hooks = [];
|
|
2700
|
-
_unloadHandlerContainer = createUnloadHandlerContainer();
|
|
2670
|
+
if (!theConfig) {
|
|
2671
|
+
theConfig = defaultValue;
|
|
2701
2672
|
}
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
_this.priority = 199;
|
|
2712
|
-
var _id;
|
|
2713
|
-
var _initializers;
|
|
2714
|
-
_initDefaults();
|
|
2715
|
-
dynamicProto(TelemetryInitializerPlugin, _this, function (_self, _base) {
|
|
2716
|
-
_self.addTelemetryInitializer = function (telemetryInitializer) {
|
|
2717
|
-
var theInitializer = {
|
|
2718
|
-
id: _id++,
|
|
2719
|
-
fn: telemetryInitializer
|
|
2720
|
-
};
|
|
2721
|
-
_initializers.push(theInitializer);
|
|
2722
|
-
var handler = {
|
|
2723
|
-
remove: function () {
|
|
2724
|
-
arrForEach(_initializers, function (initializer, idx) {
|
|
2725
|
-
if (initializer.id === theInitializer.id) {
|
|
2726
|
-
_initializers.splice(idx, 1);
|
|
2727
|
-
return -1;
|
|
2728
|
-
}
|
|
2729
|
-
});
|
|
2730
|
-
}
|
|
2731
|
-
};
|
|
2732
|
-
return handler;
|
|
2733
|
-
};
|
|
2734
|
-
_self.processTelemetry = function (item, itemCtx) {
|
|
2735
|
-
var doNotSendItem = false;
|
|
2736
|
-
var telemetryInitializersCount = _initializers.length;
|
|
2737
|
-
for (var i = 0; i < telemetryInitializersCount; ++i) {
|
|
2738
|
-
var telemetryInitializer = _initializers[i];
|
|
2739
|
-
if (telemetryInitializer) {
|
|
2740
|
-
try {
|
|
2741
|
-
if (telemetryInitializer.fn.apply(null, [item]) === false) {
|
|
2742
|
-
doNotSendItem = true;
|
|
2743
|
-
break;
|
|
2673
|
+
else if (isObject(defaultValue)) {
|
|
2674
|
+
if (mergeDefault !== 0 ) {
|
|
2675
|
+
var newConfig_1 = objExtend(true, defaultValue, theConfig);
|
|
2676
|
+
if (config && mergeDefault === 2 ) {
|
|
2677
|
+
objForEachKey(defaultValue, function (field) {
|
|
2678
|
+
if (isNullOrUndefined(newConfig_1[field])) {
|
|
2679
|
+
var cfgValue = config[field];
|
|
2680
|
+
if (!isNullOrUndefined(cfgValue)) {
|
|
2681
|
+
newConfig_1[field] = cfgValue;
|
|
2744
2682
|
}
|
|
2745
2683
|
}
|
|
2746
|
-
|
|
2747
|
-
_throwInternal(itemCtx.diagLog(), 1 , 64 , "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
|
|
2748
|
-
}
|
|
2749
|
-
}
|
|
2750
|
-
}
|
|
2751
|
-
if (!doNotSendItem) {
|
|
2752
|
-
_self.processNext(item, itemCtx);
|
|
2684
|
+
});
|
|
2753
2685
|
}
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
_initDefaults();
|
|
2757
|
-
};
|
|
2758
|
-
});
|
|
2759
|
-
function _initDefaults() {
|
|
2760
|
-
_id = 0;
|
|
2761
|
-
_initializers = [];
|
|
2686
|
+
theConfig = newConfig_1;
|
|
2687
|
+
}
|
|
2762
2688
|
}
|
|
2763
|
-
return
|
|
2689
|
+
return theConfig;
|
|
2764
2690
|
}
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
var strSdkNotInitialized = "SDK is not initialized";
|
|
2772
|
-
var defaultInitConfig = {
|
|
2773
|
-
loggingLevelConsole: 1
|
|
2774
|
-
};
|
|
2775
|
-
function _createPerfManager(core, notificationMgr) {
|
|
2776
|
-
return new PerfManager(notificationMgr);
|
|
2777
|
-
}
|
|
2778
|
-
function _validateExtensions(logger, channelPriority, allExtensions) {
|
|
2779
|
-
var coreExtensions = [];
|
|
2780
|
-
var extPriorities = {};
|
|
2781
|
-
arrForEach(allExtensions, function (ext) {
|
|
2782
|
-
if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
|
|
2783
|
-
throwError(strValidationError);
|
|
2691
|
+
function _getConfig(identifier, field, defaultValue) {
|
|
2692
|
+
if (defaultValue === void 0) { defaultValue = false; }
|
|
2693
|
+
var theValue;
|
|
2694
|
+
var extConfig = _getExtCfg(identifier, null);
|
|
2695
|
+
if (extConfig && !isNullOrUndefined(extConfig[field])) {
|
|
2696
|
+
theValue = extConfig[field];
|
|
2784
2697
|
}
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2698
|
+
else if (config && !isNullOrUndefined(config[field])) {
|
|
2699
|
+
theValue = config[field];
|
|
2700
|
+
}
|
|
2701
|
+
return !isNullOrUndefined(theValue) ? theValue : defaultValue;
|
|
2702
|
+
}
|
|
2703
|
+
function _iterateChain(cb) {
|
|
2704
|
+
var nextPlugin;
|
|
2705
|
+
while (!!(nextPlugin = context._next())) {
|
|
2706
|
+
var plugin = nextPlugin.getPlugin();
|
|
2707
|
+
if (plugin) {
|
|
2708
|
+
cb(plugin);
|
|
2793
2709
|
}
|
|
2794
2710
|
}
|
|
2795
|
-
|
|
2796
|
-
|
|
2711
|
+
}
|
|
2712
|
+
return context;
|
|
2713
|
+
}
|
|
2714
|
+
function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
|
|
2715
|
+
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
2716
|
+
var context = internalContext.ctx;
|
|
2717
|
+
function _processNext(env) {
|
|
2718
|
+
var nextPlugin = internalContext._next();
|
|
2719
|
+
nextPlugin && nextPlugin.processTelemetry(env, context);
|
|
2720
|
+
return !nextPlugin;
|
|
2721
|
+
}
|
|
2722
|
+
function _createNew(plugins, startAt) {
|
|
2723
|
+
if (plugins === void 0) { plugins = null; }
|
|
2724
|
+
if (isArray(plugins)) {
|
|
2725
|
+
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
2797
2726
|
}
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2727
|
+
return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
|
|
2728
|
+
}
|
|
2729
|
+
context.processNext = _processNext;
|
|
2730
|
+
context.createNew = _createNew;
|
|
2731
|
+
return context;
|
|
2803
2732
|
}
|
|
2804
|
-
function
|
|
2805
|
-
var
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2733
|
+
function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
|
|
2734
|
+
var config = core.config || {};
|
|
2735
|
+
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
2736
|
+
var context = internalContext.ctx;
|
|
2737
|
+
function _processNext(unloadState) {
|
|
2738
|
+
var nextPlugin = internalContext._next();
|
|
2739
|
+
nextPlugin && nextPlugin.unload(context, unloadState);
|
|
2740
|
+
return !nextPlugin;
|
|
2741
|
+
}
|
|
2742
|
+
function _createNew(plugins, startAt) {
|
|
2743
|
+
if (plugins === void 0) { plugins = null; }
|
|
2744
|
+
if (isArray(plugins)) {
|
|
2745
|
+
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
2810
2746
|
}
|
|
2811
|
-
|
|
2812
|
-
|
|
2747
|
+
return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
|
|
2748
|
+
}
|
|
2749
|
+
context.processNext = _processNext;
|
|
2750
|
+
context.createNew = _createNew;
|
|
2751
|
+
return context;
|
|
2813
2752
|
}
|
|
2814
|
-
function
|
|
2815
|
-
var
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2753
|
+
function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
|
|
2754
|
+
var config = core.config || {};
|
|
2755
|
+
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
2756
|
+
var context = internalContext.ctx;
|
|
2757
|
+
function _processNext(updateState) {
|
|
2758
|
+
return context.iterate(function (plugin) {
|
|
2759
|
+
if (isFunction(plugin.update)) {
|
|
2760
|
+
plugin.update(context, updateState);
|
|
2761
|
+
}
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
function _createNew(plugins, startAt) {
|
|
2765
|
+
if (plugins === void 0) { plugins = null; }
|
|
2766
|
+
if (isArray(plugins)) {
|
|
2767
|
+
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
2768
|
+
}
|
|
2769
|
+
return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
|
|
2770
|
+
}
|
|
2771
|
+
context.processNext = _processNext;
|
|
2772
|
+
context.createNew = _createNew;
|
|
2773
|
+
return context;
|
|
2823
2774
|
}
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
var
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
var _channelQueue;
|
|
2838
|
-
var _isUnloading;
|
|
2839
|
-
var _telemetryInitializerPlugin;
|
|
2840
|
-
var _internalLogsEventName;
|
|
2841
|
-
var _evtNamespace;
|
|
2842
|
-
var _unloadHandlers;
|
|
2843
|
-
var _debugListener;
|
|
2844
|
-
var _internalLogPoller = 0;
|
|
2845
|
-
dynamicProto(BaseCore, this, function (_self) {
|
|
2846
|
-
_initDefaults();
|
|
2847
|
-
_self.isInitialized = function () { return _isInitialized; };
|
|
2848
|
-
_self.initialize = function (config, extensions, logger, notificationManager) {
|
|
2849
|
-
if (_isUnloading) {
|
|
2850
|
-
throwError(strSdkUnloadingError);
|
|
2775
|
+
function createTelemetryProxyChain(plugins, config, core, startAt) {
|
|
2776
|
+
var firstProxy = null;
|
|
2777
|
+
var add = startAt ? false : true;
|
|
2778
|
+
if (isArray(plugins) && plugins.length > 0) {
|
|
2779
|
+
var lastProxy_1 = null;
|
|
2780
|
+
arrForEach(plugins, function (thePlugin) {
|
|
2781
|
+
if (!add && startAt === thePlugin) {
|
|
2782
|
+
add = true;
|
|
2783
|
+
}
|
|
2784
|
+
if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
|
|
2785
|
+
var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
|
|
2786
|
+
if (!firstProxy) {
|
|
2787
|
+
firstProxy = newProxy;
|
|
2851
2788
|
}
|
|
2852
|
-
if (
|
|
2853
|
-
|
|
2789
|
+
if (lastProxy_1) {
|
|
2790
|
+
lastProxy_1._setNext(newProxy);
|
|
2854
2791
|
}
|
|
2855
|
-
|
|
2856
|
-
|
|
2792
|
+
lastProxy_1 = newProxy;
|
|
2793
|
+
}
|
|
2794
|
+
});
|
|
2795
|
+
}
|
|
2796
|
+
if (startAt && !firstProxy) {
|
|
2797
|
+
return createTelemetryProxyChain([startAt], config, core);
|
|
2798
|
+
}
|
|
2799
|
+
return firstProxy;
|
|
2800
|
+
}
|
|
2801
|
+
function createTelemetryPluginProxy(plugin, config, core) {
|
|
2802
|
+
var nextProxy = null;
|
|
2803
|
+
var hasProcessTelemetry = isFunction(plugin.processTelemetry);
|
|
2804
|
+
var hasSetNext = isFunction(plugin.setNextPlugin);
|
|
2805
|
+
var chainId;
|
|
2806
|
+
if (plugin) {
|
|
2807
|
+
chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
|
|
2808
|
+
}
|
|
2809
|
+
else {
|
|
2810
|
+
chainId = "Unknown-0-" + _chainId++;
|
|
2811
|
+
}
|
|
2812
|
+
var proxyChain = {
|
|
2813
|
+
getPlugin: function () {
|
|
2814
|
+
return plugin;
|
|
2815
|
+
},
|
|
2816
|
+
getNext: function () {
|
|
2817
|
+
return nextProxy;
|
|
2818
|
+
},
|
|
2819
|
+
processTelemetry: _processTelemetry,
|
|
2820
|
+
unload: _unloadPlugin,
|
|
2821
|
+
update: _updatePlugin,
|
|
2822
|
+
_id: chainId,
|
|
2823
|
+
_setNext: function (nextPlugin) {
|
|
2824
|
+
nextProxy = nextPlugin;
|
|
2825
|
+
}
|
|
2826
|
+
};
|
|
2827
|
+
function _getTelCtx() {
|
|
2828
|
+
var itemCtx;
|
|
2829
|
+
if (plugin && isFunction(plugin[strGetTelCtx])) {
|
|
2830
|
+
itemCtx = plugin[strGetTelCtx]();
|
|
2831
|
+
}
|
|
2832
|
+
if (!itemCtx) {
|
|
2833
|
+
itemCtx = createProcessTelemetryContext(proxyChain, config, core);
|
|
2834
|
+
}
|
|
2835
|
+
return itemCtx;
|
|
2836
|
+
}
|
|
2837
|
+
function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
|
|
2838
|
+
var hasRun = false;
|
|
2839
|
+
var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
|
|
2840
|
+
var hasRunContext = itemCtx[strHasRunFlags];
|
|
2841
|
+
if (!hasRunContext) {
|
|
2842
|
+
hasRunContext = itemCtx[strHasRunFlags] = {};
|
|
2843
|
+
}
|
|
2844
|
+
itemCtx.setNext(nextProxy);
|
|
2845
|
+
if (plugin) {
|
|
2846
|
+
doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
|
|
2847
|
+
hasRunContext[chainId] = true;
|
|
2848
|
+
try {
|
|
2849
|
+
var nextId = nextProxy ? nextProxy._id : strEmpty;
|
|
2850
|
+
if (nextId) {
|
|
2851
|
+
hasRunContext[nextId] = false;
|
|
2852
|
+
}
|
|
2853
|
+
hasRun = processPluginFn(itemCtx);
|
|
2857
2854
|
}
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
_self.logger = logger;
|
|
2855
|
+
catch (error) {
|
|
2856
|
+
var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
|
|
2857
|
+
if (hasNextRun) {
|
|
2858
|
+
hasRun = true;
|
|
2859
|
+
}
|
|
2860
|
+
if (!nextProxy || !hasNextRun) {
|
|
2861
|
+
_throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
|
|
2862
|
+
}
|
|
2867
2863
|
}
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2864
|
+
}, details, isAsync);
|
|
2865
|
+
}
|
|
2866
|
+
return hasRun;
|
|
2867
|
+
}
|
|
2868
|
+
function _processTelemetry(env, itemCtx) {
|
|
2869
|
+
itemCtx = itemCtx || _getTelCtx();
|
|
2870
|
+
function _callProcessTelemetry(itemCtx) {
|
|
2871
|
+
if (!plugin || !hasProcessTelemetry) {
|
|
2872
|
+
return false;
|
|
2873
|
+
}
|
|
2874
|
+
var pluginState = _getPluginState(plugin);
|
|
2875
|
+
if (pluginState.teardown || pluginState[strDisabled]) {
|
|
2876
|
+
return false;
|
|
2877
|
+
}
|
|
2878
|
+
if (hasSetNext) {
|
|
2879
|
+
plugin.setNextPlugin(nextProxy);
|
|
2880
|
+
}
|
|
2881
|
+
plugin.processTelemetry(env, itemCtx);
|
|
2882
|
+
return true;
|
|
2883
|
+
}
|
|
2884
|
+
if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
|
|
2885
|
+
itemCtx.processNext(env);
|
|
2886
|
+
}
|
|
2887
|
+
}
|
|
2888
|
+
function _unloadPlugin(unloadCtx, unloadState) {
|
|
2889
|
+
function _callTeardown() {
|
|
2890
|
+
var hasRun = false;
|
|
2891
|
+
if (plugin) {
|
|
2892
|
+
var pluginState = _getPluginState(plugin);
|
|
2893
|
+
var pluginCore = plugin[strCore] || pluginState.core;
|
|
2894
|
+
if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
|
|
2895
|
+
pluginState[strCore] = null;
|
|
2896
|
+
pluginState[strTeardown] = true;
|
|
2897
|
+
pluginState[strIsInitialized] = false;
|
|
2898
|
+
if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
|
|
2899
|
+
hasRun = true;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
return hasRun;
|
|
2904
|
+
}
|
|
2905
|
+
if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
|
|
2906
|
+
unloadCtx.processNext(unloadState);
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
function _updatePlugin(updateCtx, updateState) {
|
|
2910
|
+
function _callUpdate() {
|
|
2911
|
+
var hasRun = false;
|
|
2912
|
+
if (plugin) {
|
|
2913
|
+
var pluginState = _getPluginState(plugin);
|
|
2914
|
+
var pluginCore = plugin[strCore] || pluginState.core;
|
|
2915
|
+
if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
|
|
2916
|
+
if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
|
|
2917
|
+
hasRun = true;
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
return hasRun;
|
|
2922
|
+
}
|
|
2923
|
+
if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
|
|
2924
|
+
updateCtx.processNext(updateState);
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
return objFreeze(proxyChain);
|
|
2928
|
+
}
|
|
2929
|
+
var ProcessTelemetryContext = /** @class */ (function () {
|
|
2930
|
+
function ProcessTelemetryContext(pluginChain, config, core, startAt) {
|
|
2931
|
+
var _self = this;
|
|
2932
|
+
var context = createProcessTelemetryContext(pluginChain, config, core, startAt);
|
|
2933
|
+
proxyFunctions(_self, context, objKeys(context));
|
|
2934
|
+
}
|
|
2935
|
+
return ProcessTelemetryContext;
|
|
2936
|
+
}());
|
|
2937
|
+
|
|
2938
|
+
var strIKey = "iKey";
|
|
2939
|
+
var strExtensionConfig = "extensionConfig";
|
|
2940
|
+
|
|
2941
|
+
var ChannelControllerPriority = 500;
|
|
2942
|
+
var ChannelValidationMessage = "Channel has invalid priority - ";
|
|
2943
|
+
function _addChannelQueue(channelQueue, queue, config, core) {
|
|
2944
|
+
if (queue && isArray(queue) && queue.length > 0) {
|
|
2945
|
+
queue = queue.sort(function (a, b) {
|
|
2946
|
+
return a.priority - b.priority;
|
|
2947
|
+
});
|
|
2948
|
+
arrForEach(queue, function (queueItem) {
|
|
2949
|
+
if (queueItem.priority < ChannelControllerPriority) {
|
|
2950
|
+
throwError(ChannelValidationMessage + queueItem.identifier);
|
|
2951
|
+
}
|
|
2952
|
+
});
|
|
2953
|
+
channelQueue.push({
|
|
2954
|
+
queue: objFreeze(queue),
|
|
2955
|
+
chain: createTelemetryProxyChain(queue, config, core)
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2959
|
+
function createChannelControllerPlugin(channelQueue, core) {
|
|
2960
|
+
var _a;
|
|
2961
|
+
function _getTelCtx() {
|
|
2962
|
+
return createProcessTelemetryContext(null, core.config, core, null);
|
|
2963
|
+
}
|
|
2964
|
+
function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {
|
|
2965
|
+
var waiting = theChannels ? (theChannels.length + 1) : 1;
|
|
2966
|
+
function _runChainOnComplete() {
|
|
2967
|
+
waiting--;
|
|
2968
|
+
if (waiting === 0) {
|
|
2969
|
+
onComplete && onComplete();
|
|
2970
|
+
onComplete = null;
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
if (waiting > 0) {
|
|
2974
|
+
arrForEach(theChannels, function (channels) {
|
|
2975
|
+
if (channels && channels.queue.length > 0) {
|
|
2976
|
+
var channelChain = channels.chain;
|
|
2977
|
+
var chainCtx = itemCtx.createNew(channelChain);
|
|
2978
|
+
chainCtx.onComplete(_runChainOnComplete);
|
|
2979
|
+
processFn(chainCtx);
|
|
2980
|
+
}
|
|
2981
|
+
else {
|
|
2982
|
+
waiting--;
|
|
2983
|
+
}
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
_runChainOnComplete();
|
|
2987
|
+
}
|
|
2988
|
+
function _doUpdate(updateCtx, updateState) {
|
|
2989
|
+
var theUpdateState = updateState || {
|
|
2990
|
+
reason: 0
|
|
2991
|
+
};
|
|
2992
|
+
_processChannelQueue(channelQueue, updateCtx, function (chainCtx) {
|
|
2993
|
+
chainCtx[strProcessNext](theUpdateState);
|
|
2994
|
+
}, function () {
|
|
2995
|
+
updateCtx[strProcessNext](theUpdateState);
|
|
2996
|
+
});
|
|
2997
|
+
return true;
|
|
2998
|
+
}
|
|
2999
|
+
function _doTeardown(unloadCtx, unloadState) {
|
|
3000
|
+
var theUnloadState = unloadState || {
|
|
3001
|
+
reason: 0 ,
|
|
3002
|
+
isAsync: false
|
|
3003
|
+
};
|
|
3004
|
+
_processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {
|
|
3005
|
+
chainCtx[strProcessNext](theUnloadState);
|
|
3006
|
+
}, function () {
|
|
3007
|
+
unloadCtx[strProcessNext](theUnloadState);
|
|
3008
|
+
isInitialized = false;
|
|
3009
|
+
});
|
|
3010
|
+
return true;
|
|
3011
|
+
}
|
|
3012
|
+
function _getChannel(pluginIdentifier) {
|
|
3013
|
+
var thePlugin = null;
|
|
3014
|
+
if (channelQueue && channelQueue.length > 0) {
|
|
3015
|
+
arrForEach(channelQueue, function (channels) {
|
|
3016
|
+
if (channels && channels.queue.length > 0) {
|
|
3017
|
+
arrForEach(channels.queue, function (ext) {
|
|
3018
|
+
if (ext.identifier === pluginIdentifier) {
|
|
3019
|
+
thePlugin = ext;
|
|
3020
|
+
return -1;
|
|
3021
|
+
}
|
|
3022
|
+
});
|
|
3023
|
+
if (thePlugin) {
|
|
3024
|
+
return -1;
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
3029
|
+
return thePlugin;
|
|
3030
|
+
}
|
|
3031
|
+
var isInitialized = false;
|
|
3032
|
+
var channelController = (_a = {
|
|
3033
|
+
identifier: "ChannelControllerPlugin",
|
|
3034
|
+
priority: ChannelControllerPriority,
|
|
3035
|
+
initialize: function (config, core, extensions, pluginChain) {
|
|
3036
|
+
isInitialized = true;
|
|
3037
|
+
arrForEach(channelQueue, function (channels) {
|
|
3038
|
+
if (channels && channels.queue.length > 0) {
|
|
3039
|
+
initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
|
|
3040
|
+
}
|
|
3041
|
+
});
|
|
3042
|
+
},
|
|
3043
|
+
isInitialized: function () {
|
|
3044
|
+
return isInitialized;
|
|
3045
|
+
},
|
|
3046
|
+
processTelemetry: function (item, itemCtx) {
|
|
3047
|
+
_processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {
|
|
3048
|
+
chainCtx[strProcessNext](item);
|
|
3049
|
+
}, function () {
|
|
3050
|
+
itemCtx[strProcessNext](item);
|
|
3051
|
+
});
|
|
3052
|
+
},
|
|
3053
|
+
update: _doUpdate
|
|
3054
|
+
},
|
|
3055
|
+
_a[strPause] = function () {
|
|
3056
|
+
_processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
|
|
3057
|
+
chainCtx.iterate(function (plugin) {
|
|
3058
|
+
plugin[strPause] && plugin[strPause]();
|
|
3059
|
+
});
|
|
3060
|
+
}, null);
|
|
3061
|
+
},
|
|
3062
|
+
_a[strResume] = function () {
|
|
3063
|
+
_processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
|
|
3064
|
+
chainCtx.iterate(function (plugin) {
|
|
3065
|
+
plugin[strResume] && plugin[strResume]();
|
|
3066
|
+
});
|
|
3067
|
+
}, null);
|
|
3068
|
+
},
|
|
3069
|
+
_a[strTeardown] = _doTeardown,
|
|
3070
|
+
_a.getChannel = _getChannel,
|
|
3071
|
+
_a.flush = function (isAsync, callBack, sendReason, cbTimeout) {
|
|
3072
|
+
var waiting = 1;
|
|
3073
|
+
var doneIterating = false;
|
|
3074
|
+
var cbTimer = null;
|
|
3075
|
+
cbTimeout = cbTimeout || 5000;
|
|
3076
|
+
function doCallback() {
|
|
3077
|
+
waiting--;
|
|
3078
|
+
if (doneIterating && waiting === 0) {
|
|
3079
|
+
if (cbTimer) {
|
|
3080
|
+
clearTimeout(cbTimer);
|
|
3081
|
+
cbTimer = null;
|
|
3082
|
+
}
|
|
3083
|
+
callBack && callBack(doneIterating);
|
|
3084
|
+
callBack = null;
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
_processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
|
|
3088
|
+
chainCtx.iterate(function (plugin) {
|
|
3089
|
+
if (plugin.flush) {
|
|
3090
|
+
waiting++;
|
|
3091
|
+
var handled_1 = false;
|
|
3092
|
+
if (!plugin.flush(isAsync, function () {
|
|
3093
|
+
handled_1 = true;
|
|
3094
|
+
doCallback();
|
|
3095
|
+
}, sendReason)) {
|
|
3096
|
+
if (!handled_1) {
|
|
3097
|
+
if (isAsync && cbTimer == null) {
|
|
3098
|
+
cbTimer = setTimeout(function () {
|
|
3099
|
+
cbTimer = null;
|
|
3100
|
+
doCallback();
|
|
3101
|
+
}, cbTimeout);
|
|
3102
|
+
}
|
|
3103
|
+
else {
|
|
3104
|
+
doCallback();
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
});
|
|
3110
|
+
}, function () {
|
|
3111
|
+
doneIterating = true;
|
|
3112
|
+
doCallback();
|
|
3113
|
+
});
|
|
3114
|
+
return true;
|
|
3115
|
+
},
|
|
3116
|
+
_a._setQueue = function (queue) {
|
|
3117
|
+
channelQueue = queue;
|
|
3118
|
+
},
|
|
3119
|
+
_a);
|
|
3120
|
+
return channelController;
|
|
3121
|
+
}
|
|
3122
|
+
function createChannelQueues(channels, extensions, config, core) {
|
|
3123
|
+
var channelQueue = [];
|
|
3124
|
+
if (channels) {
|
|
3125
|
+
arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, config, core); });
|
|
3126
|
+
}
|
|
3127
|
+
if (extensions) {
|
|
3128
|
+
var extensionQueue_1 = [];
|
|
3129
|
+
arrForEach(extensions, function (plugin) {
|
|
3130
|
+
if (plugin.priority > ChannelControllerPriority) {
|
|
3131
|
+
extensionQueue_1.push(plugin);
|
|
3132
|
+
}
|
|
3133
|
+
});
|
|
3134
|
+
_addChannelQueue(channelQueue, extensionQueue_1, config, core);
|
|
3135
|
+
}
|
|
3136
|
+
return channelQueue;
|
|
3137
|
+
}
|
|
3138
|
+
|
|
3139
|
+
function createUnloadHandlerContainer() {
|
|
3140
|
+
var handlers = [];
|
|
3141
|
+
function _addHandler(handler) {
|
|
3142
|
+
if (handler) {
|
|
3143
|
+
handlers.push(handler);
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
function _runHandlers(unloadCtx, unloadState) {
|
|
3147
|
+
arrForEach(handlers, function (handler) {
|
|
3148
|
+
try {
|
|
3149
|
+
handler(unloadCtx, unloadState);
|
|
3150
|
+
}
|
|
3151
|
+
catch (e) {
|
|
3152
|
+
_throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
|
|
3153
|
+
}
|
|
3154
|
+
});
|
|
3155
|
+
handlers = [];
|
|
3156
|
+
}
|
|
3157
|
+
return {
|
|
3158
|
+
add: _addHandler,
|
|
3159
|
+
run: _runHandlers
|
|
3160
|
+
};
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
var strGetPlugin = "getPlugin";
|
|
3164
|
+
var BaseTelemetryPlugin = /** @class */ (function () {
|
|
3165
|
+
function BaseTelemetryPlugin() {
|
|
3166
|
+
var _self = this;
|
|
3167
|
+
var _isinitialized;
|
|
3168
|
+
var _rootCtx;
|
|
3169
|
+
var _nextPlugin;
|
|
3170
|
+
var _unloadHandlerContainer;
|
|
3171
|
+
var _hooks;
|
|
3172
|
+
_initDefaults();
|
|
3173
|
+
dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
|
|
3174
|
+
_self.initialize = function (config, core, extensions, pluginChain) {
|
|
3175
|
+
_setDefaults(config, core, pluginChain);
|
|
3176
|
+
_isinitialized = true;
|
|
3177
|
+
};
|
|
3178
|
+
_self.teardown = function (unloadCtx, unloadState) {
|
|
3179
|
+
var core = _self.core;
|
|
3180
|
+
if (!core || (unloadCtx && core !== unloadCtx.core())) {
|
|
3181
|
+
return;
|
|
3182
|
+
}
|
|
3183
|
+
var result;
|
|
3184
|
+
var unloadDone = false;
|
|
3185
|
+
var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
|
|
3186
|
+
var theUnloadState = unloadState || {
|
|
3187
|
+
reason: 0 ,
|
|
3188
|
+
isAsync: false
|
|
3189
|
+
};
|
|
3190
|
+
function _unloadCallback() {
|
|
3191
|
+
if (!unloadDone) {
|
|
3192
|
+
unloadDone = true;
|
|
3193
|
+
_unloadHandlerContainer.run(theUnloadCtx, unloadState);
|
|
3194
|
+
arrForEach(_hooks, function (fn) {
|
|
3195
|
+
fn.rm();
|
|
3196
|
+
});
|
|
3197
|
+
_hooks = [];
|
|
3198
|
+
if (result === true) {
|
|
3199
|
+
theUnloadCtx.processNext(theUnloadState);
|
|
3200
|
+
}
|
|
3201
|
+
_initDefaults();
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
|
|
3205
|
+
_unloadCallback();
|
|
3206
|
+
}
|
|
3207
|
+
else {
|
|
3208
|
+
result = true;
|
|
3209
|
+
}
|
|
3210
|
+
return result;
|
|
3211
|
+
};
|
|
3212
|
+
_self.update = function (updateCtx, updateState) {
|
|
3213
|
+
var core = _self.core;
|
|
3214
|
+
if (!core || (updateCtx && core !== updateCtx.core())) {
|
|
3215
|
+
return;
|
|
3216
|
+
}
|
|
3217
|
+
var result;
|
|
3218
|
+
var updateDone = false;
|
|
3219
|
+
var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
|
|
3220
|
+
var theUpdateState = updateState || {
|
|
3221
|
+
reason: 0
|
|
3222
|
+
};
|
|
3223
|
+
function _updateCallback() {
|
|
3224
|
+
if (!updateDone) {
|
|
3225
|
+
updateDone = true;
|
|
3226
|
+
_setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
|
|
3230
|
+
_updateCallback();
|
|
3231
|
+
}
|
|
3232
|
+
else {
|
|
3233
|
+
result = true;
|
|
3234
|
+
}
|
|
3235
|
+
return result;
|
|
3236
|
+
};
|
|
3237
|
+
_self._addHook = function (hooks) {
|
|
3238
|
+
if (hooks) {
|
|
3239
|
+
if (isArray(hooks)) {
|
|
3240
|
+
_hooks = _hooks.concat(hooks);
|
|
3241
|
+
}
|
|
3242
|
+
else {
|
|
3243
|
+
_hooks.push(hooks);
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
};
|
|
3247
|
+
proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
|
|
3248
|
+
});
|
|
3249
|
+
_self.diagLog = function (itemCtx) {
|
|
3250
|
+
return _getTelCtx(itemCtx).diagLog();
|
|
3251
|
+
};
|
|
3252
|
+
_self[strIsInitialized] = function () {
|
|
3253
|
+
return _isinitialized;
|
|
3254
|
+
};
|
|
3255
|
+
_self.setInitialized = function (isInitialized) {
|
|
3256
|
+
_isinitialized = isInitialized;
|
|
3257
|
+
};
|
|
3258
|
+
_self[strSetNextPlugin] = function (next) {
|
|
3259
|
+
_nextPlugin = next;
|
|
3260
|
+
};
|
|
3261
|
+
_self.processNext = function (env, itemCtx) {
|
|
3262
|
+
if (itemCtx) {
|
|
3263
|
+
itemCtx.processNext(env);
|
|
3264
|
+
}
|
|
3265
|
+
else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
|
|
3266
|
+
_nextPlugin.processTelemetry(env, null);
|
|
3267
|
+
}
|
|
3268
|
+
};
|
|
3269
|
+
_self._getTelCtx = _getTelCtx;
|
|
3270
|
+
function _getTelCtx(currentCtx) {
|
|
3271
|
+
if (currentCtx === void 0) { currentCtx = null; }
|
|
3272
|
+
var itemCtx = currentCtx;
|
|
3273
|
+
if (!itemCtx) {
|
|
3274
|
+
var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
|
|
3275
|
+
if (_nextPlugin && _nextPlugin[strGetPlugin]) {
|
|
3276
|
+
itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
|
|
3277
|
+
}
|
|
3278
|
+
else {
|
|
3279
|
+
itemCtx = rootCtx.createNew(null, _nextPlugin);
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
return itemCtx;
|
|
3283
|
+
}
|
|
3284
|
+
function _setDefaults(config, core, pluginChain) {
|
|
3285
|
+
if (config) {
|
|
3286
|
+
setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
|
|
3287
|
+
}
|
|
3288
|
+
if (!pluginChain && core) {
|
|
3289
|
+
pluginChain = core.getProcessTelContext().getNext();
|
|
3290
|
+
}
|
|
3291
|
+
var nextPlugin = _nextPlugin;
|
|
3292
|
+
if (_nextPlugin && _nextPlugin[strGetPlugin]) {
|
|
3293
|
+
nextPlugin = _nextPlugin[strGetPlugin]();
|
|
3294
|
+
}
|
|
3295
|
+
_self.core = core;
|
|
3296
|
+
_rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
|
|
3297
|
+
}
|
|
3298
|
+
function _initDefaults() {
|
|
3299
|
+
_isinitialized = false;
|
|
3300
|
+
_self.core = null;
|
|
3301
|
+
_rootCtx = null;
|
|
3302
|
+
_nextPlugin = null;
|
|
3303
|
+
_hooks = [];
|
|
3304
|
+
_unloadHandlerContainer = createUnloadHandlerContainer();
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
return BaseTelemetryPlugin;
|
|
3308
|
+
}());
|
|
3309
|
+
|
|
3310
|
+
var TelemetryInitializerPlugin = /** @class */ (function (_super) {
|
|
3311
|
+
__extendsFn(TelemetryInitializerPlugin, _super);
|
|
3312
|
+
function TelemetryInitializerPlugin() {
|
|
3313
|
+
var _this = _super.call(this) || this;
|
|
3314
|
+
_this.identifier = "TelemetryInitializerPlugin";
|
|
3315
|
+
_this.priority = 199;
|
|
3316
|
+
var _id;
|
|
3317
|
+
var _initializers;
|
|
3318
|
+
_initDefaults();
|
|
3319
|
+
dynamicProto(TelemetryInitializerPlugin, _this, function (_self, _base) {
|
|
3320
|
+
_self.addTelemetryInitializer = function (telemetryInitializer) {
|
|
3321
|
+
var theInitializer = {
|
|
3322
|
+
id: _id++,
|
|
3323
|
+
fn: telemetryInitializer
|
|
3324
|
+
};
|
|
3325
|
+
_initializers.push(theInitializer);
|
|
3326
|
+
var handler = {
|
|
3327
|
+
remove: function () {
|
|
3328
|
+
arrForEach(_initializers, function (initializer, idx) {
|
|
3329
|
+
if (initializer.id === theInitializer.id) {
|
|
3330
|
+
_initializers.splice(idx, 1);
|
|
3331
|
+
return -1;
|
|
3332
|
+
}
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
};
|
|
3336
|
+
return handler;
|
|
3337
|
+
};
|
|
3338
|
+
_self.processTelemetry = function (item, itemCtx) {
|
|
3339
|
+
var doNotSendItem = false;
|
|
3340
|
+
var telemetryInitializersCount = _initializers.length;
|
|
3341
|
+
for (var i = 0; i < telemetryInitializersCount; ++i) {
|
|
3342
|
+
var telemetryInitializer = _initializers[i];
|
|
3343
|
+
if (telemetryInitializer) {
|
|
3344
|
+
try {
|
|
3345
|
+
if (telemetryInitializer.fn.apply(null, [item]) === false) {
|
|
3346
|
+
doNotSendItem = true;
|
|
3347
|
+
break;
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
catch (e) {
|
|
3351
|
+
_throwInternal(itemCtx.diagLog(), 1 , 64 , "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
if (!doNotSendItem) {
|
|
3356
|
+
_self.processNext(item, itemCtx);
|
|
3357
|
+
}
|
|
3358
|
+
};
|
|
3359
|
+
_self[strDoTeardown] = function () {
|
|
3360
|
+
_initDefaults();
|
|
3361
|
+
};
|
|
3362
|
+
});
|
|
3363
|
+
function _initDefaults() {
|
|
3364
|
+
_id = 0;
|
|
3365
|
+
_initializers = [];
|
|
3366
|
+
}
|
|
3367
|
+
return _this;
|
|
3368
|
+
}
|
|
3369
|
+
return TelemetryInitializerPlugin;
|
|
3370
|
+
}(BaseTelemetryPlugin));
|
|
3371
|
+
|
|
3372
|
+
var strValidationError = "Plugins must provide initialize method";
|
|
3373
|
+
var strNotificationManager = "_notificationManager";
|
|
3374
|
+
var strSdkUnloadingError = "SDK is still unloading...";
|
|
3375
|
+
var strSdkNotInitialized = "SDK is not initialized";
|
|
3376
|
+
var defaultInitConfig = {
|
|
3377
|
+
loggingLevelConsole: 1
|
|
3378
|
+
};
|
|
3379
|
+
function _createPerfManager(core, notificationMgr) {
|
|
3380
|
+
return new PerfManager(notificationMgr);
|
|
3381
|
+
}
|
|
3382
|
+
function _validateExtensions(logger, channelPriority, allExtensions) {
|
|
3383
|
+
var coreExtensions = [];
|
|
3384
|
+
var extPriorities = {};
|
|
3385
|
+
arrForEach(allExtensions, function (ext) {
|
|
3386
|
+
if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
|
|
3387
|
+
throwError(strValidationError);
|
|
3388
|
+
}
|
|
3389
|
+
var extPriority = ext.priority;
|
|
3390
|
+
var identifier = ext.identifier;
|
|
3391
|
+
if (ext && extPriority) {
|
|
3392
|
+
if (!isNullOrUndefined(extPriorities[extPriority])) {
|
|
3393
|
+
_warnToConsole(logger, "Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
|
|
3394
|
+
}
|
|
3395
|
+
else {
|
|
3396
|
+
extPriorities[extPriority] = identifier;
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
if (!extPriority || extPriority < channelPriority) {
|
|
3400
|
+
coreExtensions.push(ext);
|
|
3401
|
+
}
|
|
3402
|
+
});
|
|
3403
|
+
return {
|
|
3404
|
+
all: allExtensions,
|
|
3405
|
+
core: coreExtensions
|
|
3406
|
+
};
|
|
3407
|
+
}
|
|
3408
|
+
function _isPluginPresent(thePlugin, plugins) {
|
|
3409
|
+
var exists = false;
|
|
3410
|
+
arrForEach(plugins, function (plugin) {
|
|
3411
|
+
if (plugin === thePlugin) {
|
|
3412
|
+
exists = true;
|
|
3413
|
+
return -1;
|
|
3414
|
+
}
|
|
3415
|
+
});
|
|
3416
|
+
return exists;
|
|
3417
|
+
}
|
|
3418
|
+
function _createDummyNotificationManager() {
|
|
3419
|
+
var _a;
|
|
3420
|
+
return objCreateFn((_a = {},
|
|
3421
|
+
_a[strAddNotificationListener] = function (listener) { },
|
|
3422
|
+
_a[strRemoveNotificationListener] = function (listener) { },
|
|
3423
|
+
_a[strEventsSent] = function (events) { },
|
|
3424
|
+
_a[strEventsDiscarded] = function (events, reason) { },
|
|
3425
|
+
_a[strEventsSendRequest] = function (sendReason, isAsync) { },
|
|
3426
|
+
_a));
|
|
3427
|
+
}
|
|
3428
|
+
var BaseCore = /** @class */ (function () {
|
|
3429
|
+
function BaseCore() {
|
|
3430
|
+
var _isInitialized;
|
|
3431
|
+
var _eventQueue;
|
|
3432
|
+
var _notificationManager;
|
|
3433
|
+
var _perfManager;
|
|
3434
|
+
var _cfgPerfManager;
|
|
3435
|
+
var _cookieManager;
|
|
3436
|
+
var _pluginChain;
|
|
3437
|
+
var _configExtensions;
|
|
3438
|
+
var _coreExtensions;
|
|
3439
|
+
var _channelControl;
|
|
3440
|
+
var _channelConfig;
|
|
3441
|
+
var _channelQueue;
|
|
3442
|
+
var _isUnloading;
|
|
3443
|
+
var _telemetryInitializerPlugin;
|
|
3444
|
+
var _internalLogsEventName;
|
|
3445
|
+
var _evtNamespace;
|
|
3446
|
+
var _unloadHandlers;
|
|
3447
|
+
var _debugListener;
|
|
3448
|
+
var _traceCtx;
|
|
3449
|
+
var _internalLogPoller = 0;
|
|
3450
|
+
dynamicProto(BaseCore, this, function (_self) {
|
|
3451
|
+
_initDefaults();
|
|
3452
|
+
_self.isInitialized = function () { return _isInitialized; };
|
|
3453
|
+
_self.initialize = function (config, extensions, logger, notificationManager) {
|
|
3454
|
+
if (_isUnloading) {
|
|
3455
|
+
throwError(strSdkUnloadingError);
|
|
3456
|
+
}
|
|
3457
|
+
if (_self.isInitialized()) {
|
|
3458
|
+
throwError("Core should not be initialized more than once");
|
|
3459
|
+
}
|
|
3460
|
+
if (!config || isNullOrUndefined(config.instrumentationKey)) {
|
|
3461
|
+
throwError("Please provide instrumentation key");
|
|
3462
|
+
}
|
|
3463
|
+
_notificationManager = notificationManager;
|
|
3464
|
+
_self[strNotificationManager] = notificationManager;
|
|
3465
|
+
_self.config = config || {};
|
|
3466
|
+
_initDebugListener(config);
|
|
3467
|
+
_initPerfManager(config);
|
|
3468
|
+
config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
|
|
3469
|
+
_initExtConfig(config);
|
|
3470
|
+
if (logger) {
|
|
3471
|
+
_self.logger = logger;
|
|
3472
|
+
}
|
|
3473
|
+
_configExtensions = [];
|
|
3474
|
+
_configExtensions.push.apply(_configExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
|
|
3475
|
+
_channelConfig = (config || {}).channels;
|
|
3476
|
+
_initPluginChain(config, null);
|
|
3477
|
+
if (!_channelQueue || _channelQueue.length === 0) {
|
|
2873
3478
|
throwError("No channels available");
|
|
2874
3479
|
}
|
|
2875
3480
|
_isInitialized = true;
|
|
@@ -3039,752 +3644,334 @@
|
|
|
3039
3644
|
_addPlugin();
|
|
3040
3645
|
}
|
|
3041
3646
|
};
|
|
3042
|
-
_self.evtNamespace = function () {
|
|
3043
|
-
return _evtNamespace;
|
|
3044
|
-
};
|
|
3045
|
-
_self.flush = _flushChannels;
|
|
3046
|
-
proxyFunctionAs(_self, "addUnloadCb", function () { return _unloadHandlers; }, "add");
|
|
3047
|
-
function _initDefaults() {
|
|
3048
|
-
_isInitialized = false;
|
|
3049
|
-
_self.config = objExtend(true, {}, defaultInitConfig);
|
|
3050
|
-
_self.logger = new DiagnosticLogger(_self.config);
|
|
3051
|
-
_self._extensions = [];
|
|
3052
|
-
_telemetryInitializerPlugin = new TelemetryInitializerPlugin();
|
|
3053
|
-
_eventQueue = [];
|
|
3054
|
-
_notificationManager = null;
|
|
3055
|
-
_perfManager = null;
|
|
3056
|
-
_cfgPerfManager = null;
|
|
3057
|
-
_cookieManager = null;
|
|
3058
|
-
_pluginChain = null;
|
|
3059
|
-
_coreExtensions = null;
|
|
3060
|
-
_configExtensions = [];
|
|
3061
|
-
_channelControl = null;
|
|
3062
|
-
_channelConfig = null;
|
|
3063
|
-
_channelQueue = null;
|
|
3064
|
-
_isUnloading = false;
|
|
3065
|
-
_internalLogsEventName = null;
|
|
3066
|
-
_evtNamespace = createUniqueNamespace("AIBaseCore", true);
|
|
3067
|
-
_unloadHandlers = createUnloadHandlerContainer();
|
|
3068
|
-
}
|
|
3069
|
-
function _createTelCtx() {
|
|
3070
|
-
return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
|
|
3071
|
-
}
|
|
3072
|
-
function _initPluginChain(config, updateState) {
|
|
3073
|
-
var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
|
|
3074
|
-
_coreExtensions = theExtensions.core;
|
|
3075
|
-
_pluginChain = null;
|
|
3076
|
-
var allExtensions = theExtensions.all;
|
|
3077
|
-
_channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));
|
|
3078
|
-
if (_channelControl) {
|
|
3079
|
-
var idx = arrIndexOf(allExtensions, _channelControl);
|
|
3080
|
-
if (idx !== -1) {
|
|
3081
|
-
allExtensions.splice(idx, 1);
|
|
3082
|
-
}
|
|
3083
|
-
idx = arrIndexOf(_coreExtensions, _channelControl);
|
|
3084
|
-
if (idx !== -1) {
|
|
3085
|
-
_coreExtensions.splice(idx, 1);
|
|
3086
|
-
}
|
|
3087
|
-
_channelControl._setQueue(_channelQueue);
|
|
3088
|
-
}
|
|
3089
|
-
else {
|
|
3090
|
-
_channelControl = createChannelControllerPlugin(_channelQueue, _self);
|
|
3091
|
-
}
|
|
3092
|
-
allExtensions.push(_channelControl);
|
|
3093
|
-
_coreExtensions.push(_channelControl);
|
|
3094
|
-
_self._extensions = sortPlugins(allExtensions);
|
|
3095
|
-
_channelControl.initialize(config, _self, allExtensions);
|
|
3096
|
-
initializePlugins(_createTelCtx(), allExtensions);
|
|
3097
|
-
_self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
|
|
3098
|
-
if (updateState) {
|
|
3099
|
-
_doUpdate(updateState);
|
|
3100
|
-
}
|
|
3101
|
-
}
|
|
3102
|
-
function _getPlugin(pluginIdentifier) {
|
|
3103
|
-
var theExt = null;
|
|
3104
|
-
var thePlugin = null;
|
|
3105
|
-
arrForEach(_self._extensions, function (ext) {
|
|
3106
|
-
if (ext.identifier === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
|
|
3107
|
-
thePlugin = ext;
|
|
3108
|
-
return -1;
|
|
3109
|
-
}
|
|
3110
|
-
});
|
|
3111
|
-
if (!thePlugin && _channelControl) {
|
|
3112
|
-
thePlugin = _channelControl.getChannel(pluginIdentifier);
|
|
3113
|
-
}
|
|
3114
|
-
if (thePlugin) {
|
|
3115
|
-
theExt = {
|
|
3116
|
-
plugin: thePlugin,
|
|
3117
|
-
setEnabled: function (enabled) {
|
|
3118
|
-
_getPluginState(thePlugin)[strDisabled] = !enabled;
|
|
3119
|
-
},
|
|
3120
|
-
isEnabled: function () {
|
|
3121
|
-
var pluginState = _getPluginState(thePlugin);
|
|
3122
|
-
return !pluginState[strTeardown] && !pluginState[strDisabled];
|
|
3123
|
-
},
|
|
3124
|
-
remove: function (isAsync, removeCb) {
|
|
3125
|
-
if (isAsync === void 0) { isAsync = true; }
|
|
3126
|
-
var pluginsToRemove = [thePlugin];
|
|
3127
|
-
var unloadState = {
|
|
3128
|
-
reason: 1 ,
|
|
3129
|
-
isAsync: isAsync
|
|
3130
|
-
};
|
|
3131
|
-
_removePlugins(pluginsToRemove, unloadState, function (removed) {
|
|
3132
|
-
if (removed) {
|
|
3133
|
-
_initPluginChain(_self.config, {
|
|
3134
|
-
reason: 32 ,
|
|
3135
|
-
removed: pluginsToRemove
|
|
3136
|
-
});
|
|
3137
|
-
}
|
|
3138
|
-
removeCb && removeCb(removed);
|
|
3139
|
-
});
|
|
3140
|
-
}
|
|
3141
|
-
};
|
|
3142
|
-
}
|
|
3143
|
-
return theExt;
|
|
3144
|
-
}
|
|
3145
|
-
function _getPluginChain() {
|
|
3146
|
-
if (!_pluginChain) {
|
|
3147
|
-
var extensions = (_coreExtensions || []).slice();
|
|
3148
|
-
if (arrIndexOf(extensions, _telemetryInitializerPlugin) === -1) {
|
|
3149
|
-
extensions.push(_telemetryInitializerPlugin);
|
|
3150
|
-
}
|
|
3151
|
-
_pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);
|
|
3152
|
-
}
|
|
3153
|
-
return _pluginChain;
|
|
3154
|
-
}
|
|
3155
|
-
function _removePlugins(thePlugins, unloadState, removeComplete) {
|
|
3156
|
-
if (thePlugins && thePlugins.length > 0) {
|
|
3157
|
-
var unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);
|
|
3158
|
-
var unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self);
|
|
3159
|
-
unloadCtx.onComplete(function () {
|
|
3160
|
-
var removed = false;
|
|
3161
|
-
var newConfigExtensions = [];
|
|
3162
|
-
arrForEach(_configExtensions, function (plugin, idx) {
|
|
3163
|
-
if (!_isPluginPresent(plugin, thePlugins)) {
|
|
3164
|
-
newConfigExtensions.push(plugin);
|
|
3165
|
-
}
|
|
3166
|
-
else {
|
|
3167
|
-
removed = true;
|
|
3168
|
-
}
|
|
3169
|
-
});
|
|
3170
|
-
_configExtensions = newConfigExtensions;
|
|
3171
|
-
var newChannelConfig = [];
|
|
3172
|
-
if (_channelConfig) {
|
|
3173
|
-
arrForEach(_channelConfig, function (queue, idx) {
|
|
3174
|
-
var newQueue = [];
|
|
3175
|
-
arrForEach(queue, function (channel) {
|
|
3176
|
-
if (!_isPluginPresent(channel, thePlugins)) {
|
|
3177
|
-
newQueue.push(channel);
|
|
3178
|
-
}
|
|
3179
|
-
else {
|
|
3180
|
-
removed = true;
|
|
3181
|
-
}
|
|
3182
|
-
});
|
|
3183
|
-
newChannelConfig.push(newQueue);
|
|
3184
|
-
});
|
|
3185
|
-
_channelConfig = newChannelConfig;
|
|
3186
|
-
}
|
|
3187
|
-
removeComplete && removeComplete(removed);
|
|
3188
|
-
});
|
|
3189
|
-
unloadCtx.processNext(unloadState);
|
|
3190
|
-
}
|
|
3191
|
-
else {
|
|
3192
|
-
removeComplete(false);
|
|
3193
|
-
}
|
|
3194
|
-
}
|
|
3195
|
-
function _flushInternalLogs() {
|
|
3196
|
-
var queue = _self.logger ? _self.logger.queue : [];
|
|
3197
|
-
if (queue) {
|
|
3198
|
-
arrForEach(queue, function (logMessage) {
|
|
3199
|
-
var item = {
|
|
3200
|
-
name: _internalLogsEventName ? _internalLogsEventName : "InternalMessageId: " + logMessage.messageId,
|
|
3201
|
-
iKey: _self.config.instrumentationKey,
|
|
3202
|
-
time: toISOString(new Date()),
|
|
3203
|
-
baseType: _InternalLogMessage.dataType,
|
|
3204
|
-
baseData: { message: logMessage.message }
|
|
3205
|
-
};
|
|
3206
|
-
_self.track(item);
|
|
3207
|
-
});
|
|
3208
|
-
queue.length = 0;
|
|
3209
|
-
}
|
|
3210
|
-
}
|
|
3211
|
-
function _flushChannels(isAsync, callBack, sendReason, cbTimeout) {
|
|
3212
|
-
if (_channelControl) {
|
|
3213
|
-
return _channelControl.flush(isAsync, callBack, sendReason || 6 , cbTimeout);
|
|
3214
|
-
}
|
|
3215
|
-
callBack && callBack(false);
|
|
3216
|
-
return true;
|
|
3217
|
-
}
|
|
3218
|
-
function _initDebugListener(config) {
|
|
3219
|
-
if (config.disableDbgExt === true && _debugListener) {
|
|
3220
|
-
_notificationManager[strRemoveNotificationListener](_debugListener);
|
|
3221
|
-
_debugListener = null;
|
|
3222
|
-
}
|
|
3223
|
-
if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {
|
|
3224
|
-
_debugListener = getDebugListener(config);
|
|
3225
|
-
_notificationManager[strAddNotificationListener](_debugListener);
|
|
3226
|
-
}
|
|
3227
|
-
}
|
|
3228
|
-
function _initPerfManager(config) {
|
|
3229
|
-
if (!config.enablePerfMgr && _cfgPerfManager) {
|
|
3230
|
-
_cfgPerfManager = null;
|
|
3231
|
-
}
|
|
3232
|
-
if (config.enablePerfMgr) {
|
|
3233
|
-
setValue(_self.config, "createPerfMgr", _createPerfManager);
|
|
3234
|
-
}
|
|
3235
|
-
}
|
|
3236
|
-
function _initExtConfig(config) {
|
|
3237
|
-
var extConfig = getSetValue(config, strExtensionConfig);
|
|
3238
|
-
extConfig.NotificationManager = _notificationManager;
|
|
3239
|
-
}
|
|
3240
|
-
function _doUpdate(updateState) {
|
|
3241
|
-
var updateCtx = createProcessTelemetryUpdateContext(_getPluginChain(), _self);
|
|
3242
|
-
if (!_self._updateHook || _self._updateHook(updateCtx, updateState) !== true) {
|
|
3243
|
-
updateCtx.processNext(updateState);
|
|
3244
|
-
}
|
|
3245
|
-
}
|
|
3246
|
-
function _logOrThrowError(message) {
|
|
3247
|
-
var logger = _self.logger;
|
|
3248
|
-
if (logger) {
|
|
3249
|
-
_throwInternal(logger, 2 , 73 , message);
|
|
3250
|
-
}
|
|
3251
|
-
else {
|
|
3252
|
-
throwError(message);
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
});
|
|
3256
|
-
}
|
|
3257
|
-
return BaseCore;
|
|
3258
|
-
}());
|
|
3259
|
-
|
|
3260
|
-
function _runListeners(listeners, name, isAsync, callback) {
|
|
3261
|
-
arrForEach(listeners, function (listener) {
|
|
3262
|
-
if (listener && listener[name]) {
|
|
3263
|
-
if (isAsync) {
|
|
3264
|
-
setTimeout(function () { return callback(listener); }, 0);
|
|
3265
|
-
}
|
|
3266
|
-
else {
|
|
3267
|
-
try {
|
|
3268
|
-
callback(listener);
|
|
3269
|
-
}
|
|
3270
|
-
catch (e) {
|
|
3271
|
-
}
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
});
|
|
3275
|
-
}
|
|
3276
|
-
var NotificationManager = /** @class */ (function () {
|
|
3277
|
-
function NotificationManager(config) {
|
|
3278
|
-
this.listeners = [];
|
|
3279
|
-
var perfEvtsSendAll = !!(config || {}).perfEvtsSendAll;
|
|
3280
|
-
dynamicProto(NotificationManager, this, function (_self) {
|
|
3281
|
-
_self[strAddNotificationListener] = function (listener) {
|
|
3282
|
-
_self.listeners.push(listener);
|
|
3283
|
-
};
|
|
3284
|
-
_self[strRemoveNotificationListener] = function (listener) {
|
|
3285
|
-
var index = arrIndexOf(_self.listeners, listener);
|
|
3286
|
-
while (index > -1) {
|
|
3287
|
-
_self.listeners.splice(index, 1);
|
|
3288
|
-
index = arrIndexOf(_self.listeners, listener);
|
|
3289
|
-
}
|
|
3290
|
-
};
|
|
3291
|
-
_self[strEventsSent] = function (events) {
|
|
3292
|
-
_runListeners(_self.listeners, strEventsSent, true, function (listener) {
|
|
3293
|
-
listener[strEventsSent](events);
|
|
3294
|
-
});
|
|
3295
|
-
};
|
|
3296
|
-
_self[strEventsDiscarded] = function (events, reason) {
|
|
3297
|
-
_runListeners(_self.listeners, strEventsDiscarded, true, function (listener) {
|
|
3298
|
-
listener[strEventsDiscarded](events, reason);
|
|
3299
|
-
});
|
|
3300
|
-
};
|
|
3301
|
-
_self[strEventsSendRequest] = function (sendReason, isAsync) {
|
|
3302
|
-
_runListeners(_self.listeners, strEventsSendRequest, isAsync, function (listener) {
|
|
3303
|
-
listener[strEventsSendRequest](sendReason, isAsync);
|
|
3304
|
-
});
|
|
3647
|
+
_self.evtNamespace = function () {
|
|
3648
|
+
return _evtNamespace;
|
|
3305
3649
|
};
|
|
3306
|
-
_self
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
if (perfEvent.isAsync) {
|
|
3311
|
-
setTimeout(function () { return listener[strPerfEvent](perfEvent); }, 0);
|
|
3312
|
-
}
|
|
3313
|
-
else {
|
|
3314
|
-
listener[strPerfEvent](perfEvent);
|
|
3315
|
-
}
|
|
3316
|
-
});
|
|
3317
|
-
}
|
|
3650
|
+
_self.flush = _flushChannels;
|
|
3651
|
+
_self.getTraceCtx = function (createNew) {
|
|
3652
|
+
if (!_traceCtx) {
|
|
3653
|
+
_traceCtx = createDistributedTraceContext();
|
|
3318
3654
|
}
|
|
3655
|
+
return _traceCtx;
|
|
3319
3656
|
};
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
return NotificationManager;
|
|
3323
|
-
}());
|
|
3324
|
-
|
|
3325
|
-
var AppInsightsCore = /** @class */ (function (_super) {
|
|
3326
|
-
__extendsFn(AppInsightsCore, _super);
|
|
3327
|
-
function AppInsightsCore() {
|
|
3328
|
-
var _this = _super.call(this) || this;
|
|
3329
|
-
dynamicProto(AppInsightsCore, _this, function (_self, _base) {
|
|
3330
|
-
_self.initialize = function (config, extensions, logger, notificationManager) {
|
|
3331
|
-
_base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));
|
|
3332
|
-
};
|
|
3333
|
-
_self.track = function (telemetryItem) {
|
|
3334
|
-
doPerf(_self.getPerfMgr(), function () { return "AppInsightsCore:track"; }, function () {
|
|
3335
|
-
if (telemetryItem === null) {
|
|
3336
|
-
_notifyInvalidEvent(telemetryItem);
|
|
3337
|
-
throwError("Invalid telemetry item");
|
|
3338
|
-
}
|
|
3339
|
-
_validateTelemetryItem(telemetryItem);
|
|
3340
|
-
_base.track(telemetryItem);
|
|
3341
|
-
}, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));
|
|
3657
|
+
_self.setTraceCtx = function (traceCtx) {
|
|
3658
|
+
_traceCtx = traceCtx || null;
|
|
3342
3659
|
};
|
|
3343
|
-
function
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3660
|
+
proxyFunctionAs(_self, "addUnloadCb", function () { return _unloadHandlers; }, "add");
|
|
3661
|
+
function _initDefaults() {
|
|
3662
|
+
_isInitialized = false;
|
|
3663
|
+
_self.config = objExtend(true, {}, defaultInitConfig);
|
|
3664
|
+
_self.logger = new DiagnosticLogger(_self.config);
|
|
3665
|
+
_self._extensions = [];
|
|
3666
|
+
_telemetryInitializerPlugin = new TelemetryInitializerPlugin();
|
|
3667
|
+
_eventQueue = [];
|
|
3668
|
+
_notificationManager = null;
|
|
3669
|
+
_perfManager = null;
|
|
3670
|
+
_cfgPerfManager = null;
|
|
3671
|
+
_cookieManager = null;
|
|
3672
|
+
_pluginChain = null;
|
|
3673
|
+
_coreExtensions = null;
|
|
3674
|
+
_configExtensions = [];
|
|
3675
|
+
_channelControl = null;
|
|
3676
|
+
_channelConfig = null;
|
|
3677
|
+
_channelQueue = null;
|
|
3678
|
+
_isUnloading = false;
|
|
3679
|
+
_internalLogsEventName = null;
|
|
3680
|
+
_evtNamespace = createUniqueNamespace("AIBaseCore", true);
|
|
3681
|
+
_unloadHandlers = createUnloadHandlerContainer();
|
|
3682
|
+
_traceCtx = null;
|
|
3348
3683
|
}
|
|
3349
|
-
function
|
|
3350
|
-
|
|
3351
|
-
if (manager) {
|
|
3352
|
-
manager.eventsDiscarded([telemetryItem], 2 );
|
|
3353
|
-
}
|
|
3684
|
+
function _createTelCtx() {
|
|
3685
|
+
return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
|
|
3354
3686
|
}
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
var strRemoveEventListener = "removeEventListener";
|
|
3366
|
-
var strEvents = "events";
|
|
3367
|
-
var strVisibilityChangeEvt = "visibilitychange";
|
|
3368
|
-
var strPageHide = "pagehide";
|
|
3369
|
-
var strPageShow = "pageshow";
|
|
3370
|
-
var strUnload = "unload";
|
|
3371
|
-
var strBeforeUnload = "beforeunload";
|
|
3372
|
-
var strPageHideNamespace = createUniqueNamespace("aiEvtPageHide");
|
|
3373
|
-
var strPageShowNamespace = createUniqueNamespace("aiEvtPageShow");
|
|
3374
|
-
var rRemoveEmptyNs = /\.[\.]+/g;
|
|
3375
|
-
var rRemoveTrailingEmptyNs = /[\.]+$/;
|
|
3376
|
-
var _guid = 1;
|
|
3377
|
-
var elmNodeData = createElmNodeData("events");
|
|
3378
|
-
var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
|
|
3379
|
-
function _normalizeNamespace(name) {
|
|
3380
|
-
if (name && name.replace) {
|
|
3381
|
-
return name.replace(/^\s*\.*|\.*\s*$/g, "");
|
|
3382
|
-
}
|
|
3383
|
-
return name;
|
|
3384
|
-
}
|
|
3385
|
-
function _getEvtNamespace(eventName, evtNamespace) {
|
|
3386
|
-
if (evtNamespace) {
|
|
3387
|
-
var theNamespace_1 = "";
|
|
3388
|
-
if (isArray(evtNamespace)) {
|
|
3389
|
-
theNamespace_1 = "";
|
|
3390
|
-
arrForEach(evtNamespace, function (name) {
|
|
3391
|
-
name = _normalizeNamespace(name);
|
|
3392
|
-
if (name) {
|
|
3393
|
-
if (name[0] !== ".") {
|
|
3394
|
-
name = "." + name;
|
|
3687
|
+
function _initPluginChain(config, updateState) {
|
|
3688
|
+
var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
|
|
3689
|
+
_coreExtensions = theExtensions.core;
|
|
3690
|
+
_pluginChain = null;
|
|
3691
|
+
var allExtensions = theExtensions.all;
|
|
3692
|
+
_channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));
|
|
3693
|
+
if (_channelControl) {
|
|
3694
|
+
var idx = arrIndexOf(allExtensions, _channelControl);
|
|
3695
|
+
if (idx !== -1) {
|
|
3696
|
+
allExtensions.splice(idx, 1);
|
|
3395
3697
|
}
|
|
3396
|
-
|
|
3698
|
+
idx = arrIndexOf(_coreExtensions, _channelControl);
|
|
3699
|
+
if (idx !== -1) {
|
|
3700
|
+
_coreExtensions.splice(idx, 1);
|
|
3701
|
+
}
|
|
3702
|
+
_channelControl._setQueue(_channelQueue);
|
|
3397
3703
|
}
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
}
|
|
3410
|
-
var parsedEvent = (eventNamespace.exec(eventName || "") || []);
|
|
3411
|
-
return {
|
|
3412
|
-
type: parsedEvent[1],
|
|
3413
|
-
ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
|
|
3414
|
-
};
|
|
3415
|
-
}
|
|
3416
|
-
function __getRegisteredEvents(target, eventName, evtNamespace) {
|
|
3417
|
-
var theEvents = [];
|
|
3418
|
-
var eventCache = elmNodeData.get(target, strEvents, {}, false);
|
|
3419
|
-
var evtName = _getEvtNamespace(eventName, evtNamespace);
|
|
3420
|
-
objForEachKey(eventCache, function (evtType, registeredEvents) {
|
|
3421
|
-
arrForEach(registeredEvents, function (value) {
|
|
3422
|
-
if (!evtName.type || evtName.type === value.evtName.type) {
|
|
3423
|
-
if (!evtName.ns || evtName.ns === evtName.ns) {
|
|
3424
|
-
theEvents.push({
|
|
3425
|
-
name: value.evtName.type + (value.evtName.ns ? "." + value.evtName.ns : ""),
|
|
3426
|
-
handler: value.handler
|
|
3427
|
-
});
|
|
3704
|
+
else {
|
|
3705
|
+
_channelControl = createChannelControllerPlugin(_channelQueue, _self);
|
|
3706
|
+
}
|
|
3707
|
+
allExtensions.push(_channelControl);
|
|
3708
|
+
_coreExtensions.push(_channelControl);
|
|
3709
|
+
_self._extensions = sortPlugins(allExtensions);
|
|
3710
|
+
_channelControl.initialize(config, _self, allExtensions);
|
|
3711
|
+
initializePlugins(_createTelCtx(), allExtensions);
|
|
3712
|
+
_self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
|
|
3713
|
+
if (updateState) {
|
|
3714
|
+
_doUpdate(updateState);
|
|
3428
3715
|
}
|
|
3429
3716
|
}
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
var theEvent = events[idx];
|
|
3471
|
-
if (theEvent) {
|
|
3472
|
-
if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
|
|
3473
|
-
if (!unRegFn || unRegFn(theEvent)) {
|
|
3474
|
-
_doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
|
|
3475
|
-
events.splice(idx, 1);
|
|
3717
|
+
function _getPlugin(pluginIdentifier) {
|
|
3718
|
+
var theExt = null;
|
|
3719
|
+
var thePlugin = null;
|
|
3720
|
+
arrForEach(_self._extensions, function (ext) {
|
|
3721
|
+
if (ext.identifier === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
|
|
3722
|
+
thePlugin = ext;
|
|
3723
|
+
return -1;
|
|
3724
|
+
}
|
|
3725
|
+
});
|
|
3726
|
+
if (!thePlugin && _channelControl) {
|
|
3727
|
+
thePlugin = _channelControl.getChannel(pluginIdentifier);
|
|
3728
|
+
}
|
|
3729
|
+
if (thePlugin) {
|
|
3730
|
+
theExt = {
|
|
3731
|
+
plugin: thePlugin,
|
|
3732
|
+
setEnabled: function (enabled) {
|
|
3733
|
+
_getPluginState(thePlugin)[strDisabled] = !enabled;
|
|
3734
|
+
},
|
|
3735
|
+
isEnabled: function () {
|
|
3736
|
+
var pluginState = _getPluginState(thePlugin);
|
|
3737
|
+
return !pluginState[strTeardown] && !pluginState[strDisabled];
|
|
3738
|
+
},
|
|
3739
|
+
remove: function (isAsync, removeCb) {
|
|
3740
|
+
if (isAsync === void 0) { isAsync = true; }
|
|
3741
|
+
var pluginsToRemove = [thePlugin];
|
|
3742
|
+
var unloadState = {
|
|
3743
|
+
reason: 1 ,
|
|
3744
|
+
isAsync: isAsync
|
|
3745
|
+
};
|
|
3746
|
+
_removePlugins(pluginsToRemove, unloadState, function (removed) {
|
|
3747
|
+
if (removed) {
|
|
3748
|
+
_initPluginChain(_self.config, {
|
|
3749
|
+
reason: 32 ,
|
|
3750
|
+
removed: pluginsToRemove
|
|
3751
|
+
});
|
|
3752
|
+
}
|
|
3753
|
+
removeCb && removeCb(removed);
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
};
|
|
3476
3757
|
}
|
|
3758
|
+
return theExt;
|
|
3477
3759
|
}
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
objForEachKey(eventCache, function (evtType, events) {
|
|
3488
|
-
_doUnregister(target, events, evtName, unRegFn);
|
|
3489
|
-
});
|
|
3490
|
-
if (objKeys(eventCache).length === 0) {
|
|
3491
|
-
elmNodeData.kill(target, strEvents);
|
|
3492
|
-
}
|
|
3493
|
-
}
|
|
3494
|
-
}
|
|
3495
|
-
function mergeEvtNamespace(theNamespace, namespaces) {
|
|
3496
|
-
var newNamespaces;
|
|
3497
|
-
if (namespaces) {
|
|
3498
|
-
if (isArray(namespaces)) {
|
|
3499
|
-
newNamespaces = [theNamespace].concat(namespaces);
|
|
3500
|
-
}
|
|
3501
|
-
else {
|
|
3502
|
-
newNamespaces = [theNamespace, namespaces];
|
|
3503
|
-
}
|
|
3504
|
-
newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
|
|
3505
|
-
}
|
|
3506
|
-
else {
|
|
3507
|
-
newNamespaces = theNamespace;
|
|
3508
|
-
}
|
|
3509
|
-
return newNamespaces;
|
|
3510
|
-
}
|
|
3511
|
-
function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
|
|
3512
|
-
if (useCapture === void 0) { useCapture = false; }
|
|
3513
|
-
var result = false;
|
|
3514
|
-
if (target) {
|
|
3515
|
-
try {
|
|
3516
|
-
var evtName = _getEvtNamespace(eventName, evtNamespace);
|
|
3517
|
-
result = _doAttach(target, evtName, handlerRef, useCapture);
|
|
3518
|
-
if (result && elmNodeData.accept(target)) {
|
|
3519
|
-
var registeredEvent = {
|
|
3520
|
-
guid: _guid++,
|
|
3521
|
-
evtName: evtName,
|
|
3522
|
-
handler: handlerRef,
|
|
3523
|
-
capture: useCapture
|
|
3524
|
-
};
|
|
3525
|
-
_getRegisteredEvents(target, evtName.type).push(registeredEvent);
|
|
3760
|
+
function _getPluginChain() {
|
|
3761
|
+
if (!_pluginChain) {
|
|
3762
|
+
var extensions = (_coreExtensions || []).slice();
|
|
3763
|
+
if (arrIndexOf(extensions, _telemetryInitializerPlugin) === -1) {
|
|
3764
|
+
extensions.push(_telemetryInitializerPlugin);
|
|
3765
|
+
}
|
|
3766
|
+
_pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);
|
|
3767
|
+
}
|
|
3768
|
+
return _pluginChain;
|
|
3526
3769
|
}
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3770
|
+
function _removePlugins(thePlugins, unloadState, removeComplete) {
|
|
3771
|
+
if (thePlugins && thePlugins.length > 0) {
|
|
3772
|
+
var unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);
|
|
3773
|
+
var unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self);
|
|
3774
|
+
unloadCtx.onComplete(function () {
|
|
3775
|
+
var removed = false;
|
|
3776
|
+
var newConfigExtensions = [];
|
|
3777
|
+
arrForEach(_configExtensions, function (plugin, idx) {
|
|
3778
|
+
if (!_isPluginPresent(plugin, thePlugins)) {
|
|
3779
|
+
newConfigExtensions.push(plugin);
|
|
3780
|
+
}
|
|
3781
|
+
else {
|
|
3782
|
+
removed = true;
|
|
3783
|
+
}
|
|
3784
|
+
});
|
|
3785
|
+
_configExtensions = newConfigExtensions;
|
|
3786
|
+
var newChannelConfig = [];
|
|
3787
|
+
if (_channelConfig) {
|
|
3788
|
+
arrForEach(_channelConfig, function (queue, idx) {
|
|
3789
|
+
var newQueue = [];
|
|
3790
|
+
arrForEach(queue, function (channel) {
|
|
3791
|
+
if (!_isPluginPresent(channel, thePlugins)) {
|
|
3792
|
+
newQueue.push(channel);
|
|
3793
|
+
}
|
|
3794
|
+
else {
|
|
3795
|
+
removed = true;
|
|
3796
|
+
}
|
|
3797
|
+
});
|
|
3798
|
+
newChannelConfig.push(newQueue);
|
|
3799
|
+
});
|
|
3800
|
+
_channelConfig = newChannelConfig;
|
|
3801
|
+
}
|
|
3802
|
+
removeComplete && removeComplete(removed);
|
|
3803
|
+
});
|
|
3804
|
+
unloadCtx.processNext(unloadState);
|
|
3805
|
+
}
|
|
3806
|
+
else {
|
|
3807
|
+
removeComplete(false);
|
|
3543
3808
|
}
|
|
3544
|
-
return false;
|
|
3545
|
-
});
|
|
3546
|
-
if (!found_1) {
|
|
3547
|
-
_doDetach(target, evtName_1, handlerRef, useCapture);
|
|
3548
3809
|
}
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
var result = false;
|
|
3564
|
-
var w = getWindow();
|
|
3565
|
-
if (w) {
|
|
3566
|
-
result = eventOn(w, eventName, callback, evtNamespace);
|
|
3567
|
-
result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
|
|
3568
|
-
}
|
|
3569
|
-
var doc = getDocument();
|
|
3570
|
-
if (doc) {
|
|
3571
|
-
result = eventOn(doc, eventName, callback, evtNamespace) || result;
|
|
3572
|
-
}
|
|
3573
|
-
return result;
|
|
3574
|
-
}
|
|
3575
|
-
function removeEventHandler(eventName, callback, evtNamespace) {
|
|
3576
|
-
var w = getWindow();
|
|
3577
|
-
if (w) {
|
|
3578
|
-
eventOff(w, eventName, callback, evtNamespace);
|
|
3579
|
-
eventOff(w["body"], eventName, callback, evtNamespace);
|
|
3580
|
-
}
|
|
3581
|
-
var doc = getDocument();
|
|
3582
|
-
if (doc) {
|
|
3583
|
-
eventOff(doc, eventName, callback, evtNamespace);
|
|
3584
|
-
}
|
|
3585
|
-
}
|
|
3586
|
-
function _addEventListeners(events, listener, excludeEvents, evtNamespace) {
|
|
3587
|
-
var added = false;
|
|
3588
|
-
if (listener && events && events.length > 0) {
|
|
3589
|
-
arrForEach(events, function (name) {
|
|
3590
|
-
if (name) {
|
|
3591
|
-
if (!excludeEvents || arrIndexOf(excludeEvents, name) === -1) {
|
|
3592
|
-
added = addEventHandler(name, listener, evtNamespace) || added;
|
|
3810
|
+
function _flushInternalLogs() {
|
|
3811
|
+
var queue = _self.logger ? _self.logger.queue : [];
|
|
3812
|
+
if (queue) {
|
|
3813
|
+
arrForEach(queue, function (logMessage) {
|
|
3814
|
+
var item = {
|
|
3815
|
+
name: _internalLogsEventName ? _internalLogsEventName : "InternalMessageId: " + logMessage.messageId,
|
|
3816
|
+
iKey: _self.config.instrumentationKey,
|
|
3817
|
+
time: toISOString(new Date()),
|
|
3818
|
+
baseType: _InternalLogMessage.dataType,
|
|
3819
|
+
baseData: { message: logMessage.message }
|
|
3820
|
+
};
|
|
3821
|
+
_self.track(item);
|
|
3822
|
+
});
|
|
3823
|
+
queue.length = 0;
|
|
3593
3824
|
}
|
|
3594
3825
|
}
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
if (listener && events && isArray(events)) {
|
|
3602
|
-
added = _addEventListeners(events, listener, excludeEvents, evtNamespace);
|
|
3603
|
-
if (!added && excludeEvents && excludeEvents.length > 0) {
|
|
3604
|
-
added = _addEventListeners(events, listener, null, evtNamespace);
|
|
3605
|
-
}
|
|
3606
|
-
}
|
|
3607
|
-
return added;
|
|
3608
|
-
}
|
|
3609
|
-
function removeEventListeners(events, listener, evtNamespace) {
|
|
3610
|
-
if (events && isArray(events)) {
|
|
3611
|
-
arrForEach(events, function (name) {
|
|
3612
|
-
if (name) {
|
|
3613
|
-
removeEventHandler(name, listener, evtNamespace);
|
|
3826
|
+
function _flushChannels(isAsync, callBack, sendReason, cbTimeout) {
|
|
3827
|
+
if (_channelControl) {
|
|
3828
|
+
return _channelControl.flush(isAsync, callBack, sendReason || 6 , cbTimeout);
|
|
3829
|
+
}
|
|
3830
|
+
callBack && callBack(false);
|
|
3831
|
+
return true;
|
|
3614
3832
|
}
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
|
|
3654
|
-
var pageShowAdded = _addEventListeners([strPageShow], listener, excludeEvents, newNamespaces);
|
|
3655
|
-
pageShowAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageShowAdded;
|
|
3656
|
-
if (!pageShowAdded && excludeEvents) {
|
|
3657
|
-
pageShowAdded = addPageShowEventListener(listener, null, evtNamespace);
|
|
3833
|
+
function _initDebugListener(config) {
|
|
3834
|
+
if (config.disableDbgExt === true && _debugListener) {
|
|
3835
|
+
_notificationManager[strRemoveNotificationListener](_debugListener);
|
|
3836
|
+
_debugListener = null;
|
|
3837
|
+
}
|
|
3838
|
+
if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {
|
|
3839
|
+
_debugListener = getDebugListener(config);
|
|
3840
|
+
_notificationManager[strAddNotificationListener](_debugListener);
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
function _initPerfManager(config) {
|
|
3844
|
+
if (!config.enablePerfMgr && _cfgPerfManager) {
|
|
3845
|
+
_cfgPerfManager = null;
|
|
3846
|
+
}
|
|
3847
|
+
if (config.enablePerfMgr) {
|
|
3848
|
+
setValue(_self.config, "createPerfMgr", _createPerfManager);
|
|
3849
|
+
}
|
|
3850
|
+
}
|
|
3851
|
+
function _initExtConfig(config) {
|
|
3852
|
+
var extConfig = getSetValue(config, strExtensionConfig);
|
|
3853
|
+
extConfig.NotificationManager = _notificationManager;
|
|
3854
|
+
}
|
|
3855
|
+
function _doUpdate(updateState) {
|
|
3856
|
+
var updateCtx = createProcessTelemetryUpdateContext(_getPluginChain(), _self);
|
|
3857
|
+
if (!_self._updateHook || _self._updateHook(updateCtx, updateState) !== true) {
|
|
3858
|
+
updateCtx.processNext(updateState);
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
function _logOrThrowError(message) {
|
|
3862
|
+
var logger = _self.logger;
|
|
3863
|
+
if (logger) {
|
|
3864
|
+
_throwInternal(logger, 2 , 73 , message);
|
|
3865
|
+
}
|
|
3866
|
+
else {
|
|
3867
|
+
throwError(message);
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
});
|
|
3658
3871
|
}
|
|
3659
|
-
return
|
|
3660
|
-
}
|
|
3661
|
-
function removePageShowEventListener(listener, evtNamespace) {
|
|
3662
|
-
var newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace);
|
|
3663
|
-
removeEventListeners([strPageShow], listener, newNamespaces);
|
|
3664
|
-
removeEventListeners([strVisibilityChangeEvt], null, newNamespaces);
|
|
3665
|
-
}
|
|
3872
|
+
return BaseCore;
|
|
3873
|
+
}());
|
|
3666
3874
|
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3875
|
+
function _runListeners(listeners, name, isAsync, callback) {
|
|
3876
|
+
arrForEach(listeners, function (listener) {
|
|
3877
|
+
if (listener && listener[name]) {
|
|
3878
|
+
if (isAsync) {
|
|
3879
|
+
setTimeout(function () { return callback(listener); }, 0);
|
|
3880
|
+
}
|
|
3881
|
+
else {
|
|
3882
|
+
try {
|
|
3883
|
+
callback(listener);
|
|
3884
|
+
}
|
|
3885
|
+
catch (e) {
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3677
3889
|
});
|
|
3678
3890
|
}
|
|
3679
|
-
function
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
strTrim: strTrim,
|
|
3724
|
-
objCreate: objCreateFn,
|
|
3725
|
-
objKeys: objKeys,
|
|
3726
|
-
objDefineAccessors: objDefineAccessors,
|
|
3727
|
-
addEventHandler: addEventHandler,
|
|
3728
|
-
dateNow: dateNow,
|
|
3729
|
-
isIE: isIE,
|
|
3730
|
-
disableCookies: disableCookies,
|
|
3731
|
-
newGuid: newGuid,
|
|
3732
|
-
perfNow: perfNow,
|
|
3733
|
-
newId: newId,
|
|
3734
|
-
randomValue: randomValue,
|
|
3735
|
-
random32: random32,
|
|
3736
|
-
mwcRandomSeed: mwcRandomSeed,
|
|
3737
|
-
mwcRandom32: mwcRandom32,
|
|
3738
|
-
generateW3CId: generateW3CId
|
|
3739
|
-
};
|
|
3740
|
-
var GuidRegex = /[xy]/g;
|
|
3741
|
-
var EventHelper = {
|
|
3742
|
-
Attach: attachEvent,
|
|
3743
|
-
AttachEvent: attachEvent,
|
|
3744
|
-
Detach: detachEvent,
|
|
3745
|
-
DetachEvent: detachEvent
|
|
3746
|
-
};
|
|
3747
|
-
function _legacyCookieMgr(config, logger) {
|
|
3748
|
-
var cookieMgr = _gblCookieMgr(config, logger);
|
|
3749
|
-
var legacyCanUseCookies = CoreUtils._canUseCookies;
|
|
3750
|
-
if (_cookieMgrs === null) {
|
|
3751
|
-
_cookieMgrs = [];
|
|
3752
|
-
_canUseCookies = legacyCanUseCookies;
|
|
3753
|
-
objDefineAccessors(CoreUtils, "_canUseCookies", function () {
|
|
3754
|
-
return _canUseCookies;
|
|
3755
|
-
}, function (value) {
|
|
3756
|
-
_canUseCookies = value;
|
|
3757
|
-
arrForEach(_cookieMgrs, function (mgr) {
|
|
3758
|
-
mgr.setEnabled(value);
|
|
3759
|
-
});
|
|
3891
|
+
var NotificationManager = /** @class */ (function () {
|
|
3892
|
+
function NotificationManager(config) {
|
|
3893
|
+
this.listeners = [];
|
|
3894
|
+
var perfEvtsSendAll = !!(config || {}).perfEvtsSendAll;
|
|
3895
|
+
dynamicProto(NotificationManager, this, function (_self) {
|
|
3896
|
+
_self[strAddNotificationListener] = function (listener) {
|
|
3897
|
+
_self.listeners.push(listener);
|
|
3898
|
+
};
|
|
3899
|
+
_self[strRemoveNotificationListener] = function (listener) {
|
|
3900
|
+
var index = arrIndexOf(_self.listeners, listener);
|
|
3901
|
+
while (index > -1) {
|
|
3902
|
+
_self.listeners.splice(index, 1);
|
|
3903
|
+
index = arrIndexOf(_self.listeners, listener);
|
|
3904
|
+
}
|
|
3905
|
+
};
|
|
3906
|
+
_self[strEventsSent] = function (events) {
|
|
3907
|
+
_runListeners(_self.listeners, strEventsSent, true, function (listener) {
|
|
3908
|
+
listener[strEventsSent](events);
|
|
3909
|
+
});
|
|
3910
|
+
};
|
|
3911
|
+
_self[strEventsDiscarded] = function (events, reason) {
|
|
3912
|
+
_runListeners(_self.listeners, strEventsDiscarded, true, function (listener) {
|
|
3913
|
+
listener[strEventsDiscarded](events, reason);
|
|
3914
|
+
});
|
|
3915
|
+
};
|
|
3916
|
+
_self[strEventsSendRequest] = function (sendReason, isAsync) {
|
|
3917
|
+
_runListeners(_self.listeners, strEventsSendRequest, isAsync, function (listener) {
|
|
3918
|
+
listener[strEventsSendRequest](sendReason, isAsync);
|
|
3919
|
+
});
|
|
3920
|
+
};
|
|
3921
|
+
_self[strPerfEvent] = function (perfEvent) {
|
|
3922
|
+
if (perfEvent) {
|
|
3923
|
+
if (perfEvtsSendAll || !perfEvent.isChildEvt()) {
|
|
3924
|
+
_runListeners(_self.listeners, strPerfEvent, false, function (listener) {
|
|
3925
|
+
if (perfEvent.isAsync) {
|
|
3926
|
+
setTimeout(function () { return listener[strPerfEvent](perfEvent); }, 0);
|
|
3927
|
+
}
|
|
3928
|
+
else {
|
|
3929
|
+
listener[strPerfEvent](perfEvent);
|
|
3930
|
+
}
|
|
3931
|
+
});
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
};
|
|
3760
3935
|
});
|
|
3761
3936
|
}
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3937
|
+
return NotificationManager;
|
|
3938
|
+
}());
|
|
3939
|
+
|
|
3940
|
+
var AppInsightsCore = /** @class */ (function (_super) {
|
|
3941
|
+
__extendsFn(AppInsightsCore, _super);
|
|
3942
|
+
function AppInsightsCore() {
|
|
3943
|
+
var _this = _super.call(this) || this;
|
|
3944
|
+
dynamicProto(AppInsightsCore, _this, function (_self, _base) {
|
|
3945
|
+
_self.initialize = function (config, extensions, logger, notificationManager) {
|
|
3946
|
+
_base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));
|
|
3947
|
+
};
|
|
3948
|
+
_self.track = function (telemetryItem) {
|
|
3949
|
+
doPerf(_self.getPerfMgr(), function () { return "AppInsightsCore:track"; }, function () {
|
|
3950
|
+
if (telemetryItem === null) {
|
|
3951
|
+
_notifyInvalidEvent(telemetryItem);
|
|
3952
|
+
throwError("Invalid telemetry item");
|
|
3953
|
+
}
|
|
3954
|
+
_validateTelemetryItem(telemetryItem);
|
|
3955
|
+
_base.track(telemetryItem);
|
|
3956
|
+
}, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));
|
|
3957
|
+
};
|
|
3958
|
+
function _validateTelemetryItem(telemetryItem) {
|
|
3959
|
+
if (isNullOrUndefined(telemetryItem.name)) {
|
|
3960
|
+
_notifyInvalidEvent(telemetryItem);
|
|
3961
|
+
throwError("telemetry name required");
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
function _notifyInvalidEvent(telemetryItem) {
|
|
3965
|
+
var manager = _self.getNotifyMgr();
|
|
3966
|
+
if (manager) {
|
|
3967
|
+
manager.eventsDiscarded([telemetryItem], 2 );
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
});
|
|
3971
|
+
return _this;
|
|
3770
3972
|
}
|
|
3771
|
-
return
|
|
3772
|
-
}
|
|
3773
|
-
function disableCookies() {
|
|
3774
|
-
_legacyCookieMgr().setEnabled(false);
|
|
3775
|
-
}
|
|
3776
|
-
function canUseCookies(logger) {
|
|
3777
|
-
return _legacyCookieMgr(null, logger).isEnabled();
|
|
3778
|
-
}
|
|
3779
|
-
function getCookie(logger, name) {
|
|
3780
|
-
return _legacyCookieMgr(null, logger).get(name);
|
|
3781
|
-
}
|
|
3782
|
-
function setCookie(logger, name, value, domain) {
|
|
3783
|
-
_legacyCookieMgr(null, logger).set(name, value, null, domain);
|
|
3784
|
-
}
|
|
3785
|
-
function deleteCookie(logger, name) {
|
|
3786
|
-
return _legacyCookieMgr(null, logger).del(name);
|
|
3787
|
-
}
|
|
3973
|
+
return AppInsightsCore;
|
|
3974
|
+
}(BaseCore));
|
|
3788
3975
|
|
|
3789
3976
|
var LoggingSeverity = createEnumStyle({
|
|
3790
3977
|
CRITICAL: 1 ,
|
|
@@ -4096,6 +4283,7 @@
|
|
|
4096
4283
|
exports.createEnumMap = createEnumMap;
|
|
4097
4284
|
exports.createEnumStyle = createEnumStyle;
|
|
4098
4285
|
exports.createProcessTelemetryContext = createProcessTelemetryContext;
|
|
4286
|
+
exports.createTraceParent = createTraceParent;
|
|
4099
4287
|
exports.createUniqueNamespace = createUniqueNamespace;
|
|
4100
4288
|
exports.createUnloadHandlerContainer = createUnloadHandlerContainer;
|
|
4101
4289
|
exports.createValueMap = createValueMap;
|
|
@@ -4108,6 +4296,10 @@
|
|
|
4108
4296
|
exports.dumpObj = dumpObj;
|
|
4109
4297
|
exports.eventOff = eventOff;
|
|
4110
4298
|
exports.eventOn = eventOn;
|
|
4299
|
+
exports.findMetaTag = findMetaTag;
|
|
4300
|
+
exports.findNamedServerTiming = findNamedServerTiming;
|
|
4301
|
+
exports.findW3cTraceParent = findW3cTraceParent;
|
|
4302
|
+
exports.formatTraceParent = formatTraceParent;
|
|
4111
4303
|
exports.generateW3CId = generateW3CId;
|
|
4112
4304
|
exports.getConsole = getConsole;
|
|
4113
4305
|
exports.getCookie = getCookie;
|
|
@@ -4151,11 +4343,15 @@
|
|
|
4151
4343
|
exports.isObject = isObject;
|
|
4152
4344
|
exports.isReactNative = isReactNative;
|
|
4153
4345
|
exports.isSafari = isSafari;
|
|
4346
|
+
exports.isSampledFlag = isSampledFlag;
|
|
4154
4347
|
exports.isString = isString;
|
|
4155
4348
|
exports.isSymbol = isSymbol;
|
|
4156
4349
|
exports.isTruthy = isTruthy;
|
|
4157
4350
|
exports.isTypeof = isTypeof;
|
|
4158
4351
|
exports.isUndefined = isUndefined;
|
|
4352
|
+
exports.isValidSpanId = isValidSpanId;
|
|
4353
|
+
exports.isValidTraceId = isValidTraceId;
|
|
4354
|
+
exports.isValidTraceParent = isValidTraceParent;
|
|
4159
4355
|
exports.isXhrSupported = isXhrSupported;
|
|
4160
4356
|
exports.mergeEvtNamespace = mergeEvtNamespace;
|
|
4161
4357
|
exports.mwcRandom32 = mwcRandom32;
|
|
@@ -4172,6 +4368,7 @@
|
|
|
4172
4368
|
exports.objSeal = objSeal;
|
|
4173
4369
|
exports.objToString = objToString;
|
|
4174
4370
|
exports.optimizeObject = optimizeObject;
|
|
4371
|
+
exports.parseTraceParent = parseTraceParent;
|
|
4175
4372
|
exports.perfNow = perfNow;
|
|
4176
4373
|
exports.proxyAssign = proxyAssign;
|
|
4177
4374
|
exports.proxyFunctionAs = proxyFunctionAs;
|