@microsoft/applicationinsights-react-js 3.3.0-beta.2203-02 → 3.3.0-beta.2203-05
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-react-js.js +139 -12
- package/browser/applicationinsights-react-js.js.map +1 -1
- package/browser/applicationinsights-react-js.min.js +2 -2
- package/browser/applicationinsights-react-js.min.js.map +1 -1
- package/dist/applicationinsights-react-js.d.ts +1 -1
- package/dist/applicationinsights-react-js.js +139 -12
- package/dist/applicationinsights-react-js.js.map +1 -1
- package/dist/applicationinsights-react-js.min.js +2 -2
- package/dist/applicationinsights-react-js.min.js.map +1 -1
- package/dist/applicationinsights-react-js.rollup.d.ts +1 -1
- package/dist-esm/AppInsightsContext.js +1 -1
- package/dist-esm/AppInsightsErrorBoundary.js +1 -1
- package/dist-esm/Interfaces/IReactExtensionConfig.js +1 -1
- package/dist-esm/ReactPlugin.js +1 -1
- package/dist-esm/applicationinsights-react-js.js +1 -1
- package/dist-esm/useTrackEvent.js +1 -1
- package/dist-esm/useTrackMetric.js +1 -1
- package/dist-esm/withAITracking.js +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-
|
|
2
|
+
* Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-05
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -363,6 +363,7 @@
|
|
|
363
363
|
var strIsInitialized = "isInitialized";
|
|
364
364
|
var strTeardown = "teardown";
|
|
365
365
|
var strCore = "core";
|
|
366
|
+
var strUpdate = "update";
|
|
366
367
|
var strDisabled = "disabled";
|
|
367
368
|
var strDoTeardown = "_doTeardown";
|
|
368
369
|
|
|
@@ -706,18 +707,45 @@
|
|
|
706
707
|
function throwError(message) {
|
|
707
708
|
throw new Error(message);
|
|
708
709
|
}
|
|
710
|
+
function _createProxyFunction(source, funcName) {
|
|
711
|
+
var srcFunc = null;
|
|
712
|
+
var src = null;
|
|
713
|
+
if (isFunction(source)) {
|
|
714
|
+
srcFunc = source;
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
src = source;
|
|
718
|
+
}
|
|
719
|
+
return function () {
|
|
720
|
+
var originalArguments = arguments;
|
|
721
|
+
if (srcFunc) {
|
|
722
|
+
src = srcFunc();
|
|
723
|
+
}
|
|
724
|
+
if (src) {
|
|
725
|
+
return src[funcName].apply(src, originalArguments);
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
|
|
730
|
+
if (overwriteTarget === void 0) { overwriteTarget = true; }
|
|
731
|
+
if (target && name && source) {
|
|
732
|
+
if (overwriteTarget || isUndefined(target[name])) {
|
|
733
|
+
target[name] = _createProxyFunction(source, theFunc);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
709
737
|
function createEnumStyle(values) {
|
|
710
738
|
var enumClass = {};
|
|
711
739
|
objForEachKey(values, function (field, value) {
|
|
712
740
|
enumClass[field] = value;
|
|
713
741
|
if (!isUndefined(enumClass[value])) {
|
|
714
|
-
throwError("
|
|
742
|
+
throwError("[" + value + "] exists for " + field);
|
|
715
743
|
}
|
|
716
744
|
enumClass[value] = field;
|
|
717
745
|
});
|
|
718
746
|
return objFreeze(enumClass);
|
|
719
747
|
}
|
|
720
|
-
function objExtend(
|
|
748
|
+
function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
|
|
721
749
|
var theArgs = arguments;
|
|
722
750
|
var extended = theArgs[0] || {};
|
|
723
751
|
var argLen = theArgs.length;
|
|
@@ -1037,6 +1065,10 @@
|
|
|
1037
1065
|
}
|
|
1038
1066
|
return DiagnosticLogger;
|
|
1039
1067
|
}());
|
|
1068
|
+
function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
|
|
1069
|
+
if (isUserAct === void 0) { isUserAct = false; }
|
|
1070
|
+
(logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
|
|
1071
|
+
}
|
|
1040
1072
|
|
|
1041
1073
|
var strExecutionContextKey = "ctx";
|
|
1042
1074
|
var PerfEvent = /** @class */ (function () {
|
|
@@ -1323,8 +1355,11 @@
|
|
|
1323
1355
|
return createTelemetryProxyChain([startAt], config, core);
|
|
1324
1356
|
}
|
|
1325
1357
|
function _createInternalContext(telemetryChain, config, core, startAt) {
|
|
1326
|
-
var _nextProxy =
|
|
1358
|
+
var _nextProxy = null;
|
|
1327
1359
|
var _onComplete = [];
|
|
1360
|
+
if (startAt !== null) {
|
|
1361
|
+
_nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
|
|
1362
|
+
}
|
|
1328
1363
|
var context = {
|
|
1329
1364
|
_next: _moveNext,
|
|
1330
1365
|
ctx: {
|
|
@@ -1374,7 +1409,7 @@
|
|
|
1374
1409
|
completeDetails.func.call(completeDetails.self, completeDetails.args);
|
|
1375
1410
|
}
|
|
1376
1411
|
catch (e) {
|
|
1377
|
-
core.logger
|
|
1412
|
+
_throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
|
|
1378
1413
|
}
|
|
1379
1414
|
});
|
|
1380
1415
|
_onComplete = [];
|
|
@@ -1473,6 +1508,27 @@
|
|
|
1473
1508
|
context.createNew = _createNew;
|
|
1474
1509
|
return context;
|
|
1475
1510
|
}
|
|
1511
|
+
function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
|
|
1512
|
+
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
1513
|
+
var context = internalContext.ctx;
|
|
1514
|
+
function _processNext(updateState) {
|
|
1515
|
+
return context.iterate(function (plugin) {
|
|
1516
|
+
if (isFunction(plugin[strUpdate])) {
|
|
1517
|
+
plugin[strUpdate](context, updateState);
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
function _createNew(plugins, startAt) {
|
|
1522
|
+
if (plugins === void 0) { plugins = null; }
|
|
1523
|
+
if (isArray(plugins)) {
|
|
1524
|
+
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1525
|
+
}
|
|
1526
|
+
return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
|
|
1527
|
+
}
|
|
1528
|
+
context.processNext = _processNext;
|
|
1529
|
+
context.createNew = _createNew;
|
|
1530
|
+
return context;
|
|
1531
|
+
}
|
|
1476
1532
|
function createTelemetryProxyChain(plugins, config, core, startAt) {
|
|
1477
1533
|
var firstProxy = null;
|
|
1478
1534
|
var add = startAt ? false : true;
|
|
@@ -1519,6 +1575,7 @@
|
|
|
1519
1575
|
},
|
|
1520
1576
|
processTelemetry: _processTelemetry,
|
|
1521
1577
|
unload: _unloadPlugin,
|
|
1578
|
+
update: _updatePlugin,
|
|
1522
1579
|
_id: chainId,
|
|
1523
1580
|
_setNext: function (nextPlugin) {
|
|
1524
1581
|
nextProxy = nextPlugin;
|
|
@@ -1558,7 +1615,7 @@
|
|
|
1558
1615
|
hasRun = true;
|
|
1559
1616
|
}
|
|
1560
1617
|
if (!nextProxy || !hasNextRun) {
|
|
1561
|
-
itemCtx.diagLog()
|
|
1618
|
+
_throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
|
|
1562
1619
|
}
|
|
1563
1620
|
}
|
|
1564
1621
|
}, details, isAsync);
|
|
@@ -1606,6 +1663,24 @@
|
|
|
1606
1663
|
unloadCtx.processNext(unloadState);
|
|
1607
1664
|
}
|
|
1608
1665
|
}
|
|
1666
|
+
function _updatePlugin(updateCtx, updateState) {
|
|
1667
|
+
function _callUpdate() {
|
|
1668
|
+
var hasRun = false;
|
|
1669
|
+
if (plugin) {
|
|
1670
|
+
var pluginState = _getPluginState(plugin);
|
|
1671
|
+
var pluginCore = plugin[strCore] || pluginState.core;
|
|
1672
|
+
if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
|
|
1673
|
+
if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
|
|
1674
|
+
hasRun = true;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
return hasRun;
|
|
1679
|
+
}
|
|
1680
|
+
if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
|
|
1681
|
+
updateCtx.processNext(updateState);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1609
1684
|
return objFreeze(proxyChain);
|
|
1610
1685
|
}
|
|
1611
1686
|
|
|
@@ -1775,7 +1850,7 @@
|
|
|
1775
1850
|
_supportsCookies = doc[strCookie] !== undefined;
|
|
1776
1851
|
}
|
|
1777
1852
|
catch (e) {
|
|
1778
|
-
logger
|
|
1853
|
+
_throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
|
|
1779
1854
|
}
|
|
1780
1855
|
}
|
|
1781
1856
|
return _supportsCookies;
|
|
@@ -1856,6 +1931,30 @@
|
|
|
1856
1931
|
|
|
1857
1932
|
var strExtensionConfig = "extensionConfig";
|
|
1858
1933
|
|
|
1934
|
+
function createUnloadHandlerContainer() {
|
|
1935
|
+
var handlers = [];
|
|
1936
|
+
function _addHandler(handler) {
|
|
1937
|
+
if (handler) {
|
|
1938
|
+
handlers.push(handler);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
function _runHandlers(unloadCtx, unloadState) {
|
|
1942
|
+
arrForEach(handlers, function (handler) {
|
|
1943
|
+
try {
|
|
1944
|
+
handler(unloadCtx, unloadState);
|
|
1945
|
+
}
|
|
1946
|
+
catch (e) {
|
|
1947
|
+
_throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
|
|
1948
|
+
}
|
|
1949
|
+
});
|
|
1950
|
+
handlers = [];
|
|
1951
|
+
}
|
|
1952
|
+
return {
|
|
1953
|
+
add: _addHandler,
|
|
1954
|
+
run: _runHandlers
|
|
1955
|
+
};
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1859
1958
|
var strGetPlugin = "getPlugin";
|
|
1860
1959
|
var BaseTelemetryPlugin = /** @class */ (function () {
|
|
1861
1960
|
function BaseTelemetryPlugin() {
|
|
@@ -1863,6 +1962,7 @@
|
|
|
1863
1962
|
var _isinitialized;
|
|
1864
1963
|
var _rootCtx;
|
|
1865
1964
|
var _nextPlugin;
|
|
1965
|
+
var _unloadHandlerContainer;
|
|
1866
1966
|
var _hooks;
|
|
1867
1967
|
_initDefaults();
|
|
1868
1968
|
dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
|
|
@@ -1884,6 +1984,7 @@
|
|
|
1884
1984
|
function _unloadCallback() {
|
|
1885
1985
|
if (!unloadDone) {
|
|
1886
1986
|
unloadDone = true;
|
|
1987
|
+
_unloadHandlerContainer.run(theUnloadCtx, unloadState);
|
|
1887
1988
|
arrForEach(_hooks, function (fn) {
|
|
1888
1989
|
fn.rm();
|
|
1889
1990
|
});
|
|
@@ -1902,6 +2003,30 @@
|
|
|
1902
2003
|
}
|
|
1903
2004
|
return result;
|
|
1904
2005
|
};
|
|
2006
|
+
_self.update = function (updateCtx, updateState) {
|
|
2007
|
+
if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
var result;
|
|
2011
|
+
var updateDone = false;
|
|
2012
|
+
var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
|
|
2013
|
+
var theUpdateState = updateState || {
|
|
2014
|
+
reason: 0
|
|
2015
|
+
};
|
|
2016
|
+
function _updateCallback() {
|
|
2017
|
+
if (!updateDone) {
|
|
2018
|
+
updateDone = true;
|
|
2019
|
+
_setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
|
|
2023
|
+
_updateCallback();
|
|
2024
|
+
}
|
|
2025
|
+
else {
|
|
2026
|
+
result = true;
|
|
2027
|
+
}
|
|
2028
|
+
return result;
|
|
2029
|
+
};
|
|
1905
2030
|
_self._addHook = function (hooks) {
|
|
1906
2031
|
if (hooks) {
|
|
1907
2032
|
if (isArray(hooks)) {
|
|
@@ -1912,6 +2037,7 @@
|
|
|
1912
2037
|
}
|
|
1913
2038
|
}
|
|
1914
2039
|
};
|
|
2040
|
+
proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
|
|
1915
2041
|
});
|
|
1916
2042
|
_self.diagLog = function (itemCtx) {
|
|
1917
2043
|
return _getTelCtx(itemCtx).diagLog();
|
|
@@ -1968,6 +2094,7 @@
|
|
|
1968
2094
|
_rootCtx = null;
|
|
1969
2095
|
_nextPlugin = null;
|
|
1970
2096
|
_hooks = [];
|
|
2097
|
+
_unloadHandlerContainer = createUnloadHandlerContainer();
|
|
1971
2098
|
}
|
|
1972
2099
|
}
|
|
1973
2100
|
return BaseTelemetryPlugin;
|
|
@@ -1988,12 +2115,12 @@
|
|
|
1988
2115
|
}
|
|
1989
2116
|
return name;
|
|
1990
2117
|
}
|
|
1991
|
-
function _getEvtNamespace(eventName,
|
|
1992
|
-
if (
|
|
2118
|
+
function _getEvtNamespace(eventName, evtNamespace) {
|
|
2119
|
+
if (evtNamespace) {
|
|
1993
2120
|
var theNamespace_1 = "";
|
|
1994
|
-
if (isArray(
|
|
2121
|
+
if (isArray(evtNamespace)) {
|
|
1995
2122
|
theNamespace_1 = "";
|
|
1996
|
-
arrForEach(
|
|
2123
|
+
arrForEach(evtNamespace, function (name) {
|
|
1997
2124
|
name = _normalizeNamespace(name);
|
|
1998
2125
|
if (name) {
|
|
1999
2126
|
if (name[0] !== ".") {
|
|
@@ -2004,7 +2131,7 @@
|
|
|
2004
2131
|
});
|
|
2005
2132
|
}
|
|
2006
2133
|
else {
|
|
2007
|
-
theNamespace_1 = _normalizeNamespace(
|
|
2134
|
+
theNamespace_1 = _normalizeNamespace(evtNamespace);
|
|
2008
2135
|
}
|
|
2009
2136
|
if (theNamespace_1) {
|
|
2010
2137
|
if (theNamespace_1[0] !== ".") {
|