@microsoft/applicationinsights-analytics-js 2.8.0-beta.2203-02 → 2.8.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.
Files changed (32) hide show
  1. package/browser/applicationinsights-analytics-js.integrity.json +9 -9
  2. package/browser/applicationinsights-analytics-js.js +813 -252
  3. package/browser/applicationinsights-analytics-js.js.map +1 -1
  4. package/browser/applicationinsights-analytics-js.min.js +2 -2
  5. package/browser/applicationinsights-analytics-js.min.js.map +1 -1
  6. package/dist/applicationinsights-analytics-js.api.json +48 -183
  7. package/dist/applicationinsights-analytics-js.api.md +8 -18
  8. package/dist/applicationinsights-analytics-js.d.ts +9 -104
  9. package/dist/applicationinsights-analytics-js.js +813 -252
  10. package/dist/applicationinsights-analytics-js.js.map +1 -1
  11. package/dist/applicationinsights-analytics-js.min.js +2 -2
  12. package/dist/applicationinsights-analytics-js.min.js.map +1 -1
  13. package/dist/applicationinsights-analytics-js.rollup.d.ts +9 -104
  14. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js +673 -0
  15. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js.map +1 -0
  16. package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js +1 -1
  17. package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js +1 -1
  18. package/dist-esm/JavaScriptSDK/Telemetry/PageVisitTimeManager.js +1 -1
  19. package/dist-esm/JavaScriptSDK/Timing.js +39 -0
  20. package/dist-esm/JavaScriptSDK/Timing.js.map +1 -0
  21. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryConfig.js +1 -1
  22. package/dist-esm/applicationinsights-analytics-js.js +2 -2
  23. package/dist-esm/applicationinsights-analytics-js.js.map +1 -1
  24. package/package.json +5 -5
  25. package/src/JavaScriptSDK/{ApplicationInsights.ts → AnalyticsPlugin.ts} +401 -324
  26. package/src/JavaScriptSDK/Timing.ts +46 -0
  27. package/src/applicationinsights-analytics-js.ts +1 -1
  28. package/types/JavaScriptSDK/{ApplicationInsights.d.ts → AnalyticsPlugin.d.ts} +7 -11
  29. package/types/JavaScriptSDK/Timing.d.ts +18 -0
  30. package/types/applicationinsights-analytics-js.d.ts +1 -1
  31. package/dist-esm/JavaScriptSDK/ApplicationInsights.js +0 -606
  32. package/dist-esm/JavaScriptSDK/ApplicationInsights.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Web Analytics, 2.8.0-beta.2203-02
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.8.0-beta.2203-05
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -340,6 +340,7 @@
340
340
  var strIsInitialized = "isInitialized";
341
341
  var strTeardown = "teardown";
342
342
  var strCore = "core";
343
+ var strUpdate = "update";
343
344
  var strDisabled = "disabled";
344
345
  var strDoTeardown = "_doTeardown";
345
346
 
@@ -352,6 +353,7 @@
352
353
  var strConstructor = "constructor";
353
354
  var _objDefineProperty$1 = ObjDefineProperty;
354
355
  var _objFreeze = ObjClass.freeze;
356
+ var _objKeys = ObjClass.keys;
355
357
  var StringProto = String[strShimPrototype];
356
358
  var _strTrim = StringProto[cStrTrim];
357
359
  var _strEndsWith = StringProto[cStrEndsWith];
@@ -386,6 +388,9 @@
386
388
  function isNotNullOrUndefined(value) {
387
389
  return !isNullOrUndefined(value);
388
390
  }
391
+ function hasOwnProperty(obj, prop) {
392
+ return !!(obj && ObjHasOwnProperty.call(obj, prop));
393
+ }
389
394
  function isObject(value) {
390
395
  return !!(value && typeof value === strShimObject);
391
396
  }
@@ -537,6 +542,40 @@
537
542
  }
538
543
  return str;
539
544
  }
545
+ var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
546
+ var _objKeysDontEnums = [
547
+ "toString",
548
+ "toLocaleString",
549
+ "valueOf",
550
+ "hasOwnProperty",
551
+ "isPrototypeOf",
552
+ "propertyIsEnumerable",
553
+ "constructor"
554
+ ];
555
+ function objKeys(obj) {
556
+ var objType = typeof obj;
557
+ if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
558
+ throwTypeError("objKeys called on non-object");
559
+ }
560
+ if (!_objKeysHasDontEnumBug && _objKeys) {
561
+ return _objKeys(obj);
562
+ }
563
+ var result = [];
564
+ for (var prop in obj) {
565
+ if (obj && ObjHasOwnProperty.call(obj, prop)) {
566
+ result.push(prop);
567
+ }
568
+ }
569
+ if (_objKeysHasDontEnumBug) {
570
+ var dontEnumsLength = _objKeysDontEnums.length;
571
+ for (var lp = 0; lp < dontEnumsLength; lp++) {
572
+ if (obj && ObjHasOwnProperty.call(obj, _objKeysDontEnums[lp])) {
573
+ result.push(_objKeysDontEnums[lp]);
574
+ }
575
+ }
576
+ }
577
+ return result;
578
+ }
540
579
  function objDefineAccessors(target, prop, getProp, setProp) {
541
580
  if (_objDefineProperty$1) {
542
581
  try {
@@ -589,18 +628,45 @@
589
628
  function throwError(message) {
590
629
  throw new Error(message);
591
630
  }
631
+ function _createProxyFunction(source, funcName) {
632
+ var srcFunc = null;
633
+ var src = null;
634
+ if (isFunction(source)) {
635
+ srcFunc = source;
636
+ }
637
+ else {
638
+ src = source;
639
+ }
640
+ return function () {
641
+ var originalArguments = arguments;
642
+ if (srcFunc) {
643
+ src = srcFunc();
644
+ }
645
+ if (src) {
646
+ return src[funcName].apply(src, originalArguments);
647
+ }
648
+ };
649
+ }
650
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
651
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
652
+ if (target && name && source) {
653
+ if (overwriteTarget || isUndefined(target[name])) {
654
+ target[name] = _createProxyFunction(source, theFunc);
655
+ }
656
+ }
657
+ }
592
658
  function createEnumStyle(values) {
593
659
  var enumClass = {};
594
660
  objForEachKey(values, function (field, value) {
595
661
  enumClass[field] = value;
596
662
  if (!isUndefined(enumClass[value])) {
597
- throwError("Value: [" + value + "] already exists for " + field);
663
+ throwError("[" + value + "] exists for " + field);
598
664
  }
599
665
  enumClass[value] = field;
600
666
  });
601
667
  return objFreeze(enumClass);
602
668
  }
603
- function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
669
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
604
670
  var theArgs = arguments;
605
671
  var extended = theArgs[0] || {};
606
672
  var argLen = theArgs.length;
@@ -930,6 +996,10 @@
930
996
  }
931
997
  return DiagnosticLogger;
932
998
  }());
999
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
1000
+ if (isUserAct === void 0) { isUserAct = false; }
1001
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
1002
+ }
933
1003
 
934
1004
  var strExecutionContextKey = "ctx";
935
1005
  var PerfEvent = /** @class */ (function () {
@@ -1202,8 +1272,11 @@
1202
1272
  return createTelemetryProxyChain([startAt], config, core);
1203
1273
  }
1204
1274
  function _createInternalContext(telemetryChain, config, core, startAt) {
1205
- var _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1275
+ var _nextProxy = null;
1206
1276
  var _onComplete = [];
1277
+ if (startAt !== null) {
1278
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1279
+ }
1207
1280
  var context = {
1208
1281
  _next: _moveNext,
1209
1282
  ctx: {
@@ -1253,7 +1326,7 @@
1253
1326
  completeDetails.func.call(completeDetails.self, completeDetails.args);
1254
1327
  }
1255
1328
  catch (e) {
1256
- core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1329
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1257
1330
  }
1258
1331
  });
1259
1332
  _onComplete = [];
@@ -1352,6 +1425,27 @@
1352
1425
  context.createNew = _createNew;
1353
1426
  return context;
1354
1427
  }
1428
+ function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1429
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1430
+ var context = internalContext.ctx;
1431
+ function _processNext(updateState) {
1432
+ return context.iterate(function (plugin) {
1433
+ if (isFunction(plugin[strUpdate])) {
1434
+ plugin[strUpdate](context, updateState);
1435
+ }
1436
+ });
1437
+ }
1438
+ function _createNew(plugins, startAt) {
1439
+ if (plugins === void 0) { plugins = null; }
1440
+ if (isArray(plugins)) {
1441
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1442
+ }
1443
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1444
+ }
1445
+ context.processNext = _processNext;
1446
+ context.createNew = _createNew;
1447
+ return context;
1448
+ }
1355
1449
  function createTelemetryProxyChain(plugins, config, core, startAt) {
1356
1450
  var firstProxy = null;
1357
1451
  var add = startAt ? false : true;
@@ -1398,6 +1492,7 @@
1398
1492
  },
1399
1493
  processTelemetry: _processTelemetry,
1400
1494
  unload: _unloadPlugin,
1495
+ update: _updatePlugin,
1401
1496
  _id: chainId,
1402
1497
  _setNext: function (nextPlugin) {
1403
1498
  nextProxy = nextPlugin;
@@ -1437,7 +1532,7 @@
1437
1532
  hasRun = true;
1438
1533
  }
1439
1534
  if (!nextProxy || !hasNextRun) {
1440
- itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1535
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1441
1536
  }
1442
1537
  }
1443
1538
  }, details, isAsync);
@@ -1485,6 +1580,24 @@
1485
1580
  unloadCtx.processNext(unloadState);
1486
1581
  }
1487
1582
  }
1583
+ function _updatePlugin(updateCtx, updateState) {
1584
+ function _callUpdate() {
1585
+ var hasRun = false;
1586
+ if (plugin) {
1587
+ var pluginState = _getPluginState(plugin);
1588
+ var pluginCore = plugin[strCore] || pluginState.core;
1589
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1590
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1591
+ hasRun = true;
1592
+ }
1593
+ }
1594
+ }
1595
+ return hasRun;
1596
+ }
1597
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1598
+ updateCtx.processNext(updateState);
1599
+ }
1600
+ }
1488
1601
  return objFreeze(proxyChain);
1489
1602
  }
1490
1603
 
@@ -1654,7 +1767,7 @@
1654
1767
  _supportsCookies = doc[strCookie] !== undefined;
1655
1768
  }
1656
1769
  catch (e) {
1657
- logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1770
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1658
1771
  }
1659
1772
  }
1660
1773
  return _supportsCookies;
@@ -1735,6 +1848,30 @@
1735
1848
 
1736
1849
  var strExtensionConfig = "extensionConfig";
1737
1850
 
1851
+ function createUnloadHandlerContainer() {
1852
+ var handlers = [];
1853
+ function _addHandler(handler) {
1854
+ if (handler) {
1855
+ handlers.push(handler);
1856
+ }
1857
+ }
1858
+ function _runHandlers(unloadCtx, unloadState) {
1859
+ arrForEach(handlers, function (handler) {
1860
+ try {
1861
+ handler(unloadCtx, unloadState);
1862
+ }
1863
+ catch (e) {
1864
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1865
+ }
1866
+ });
1867
+ handlers = [];
1868
+ }
1869
+ return {
1870
+ add: _addHandler,
1871
+ run: _runHandlers
1872
+ };
1873
+ }
1874
+
1738
1875
  var strGetPlugin = "getPlugin";
1739
1876
  var BaseTelemetryPlugin = /** @class */ (function () {
1740
1877
  function BaseTelemetryPlugin() {
@@ -1742,6 +1879,7 @@
1742
1879
  var _isinitialized;
1743
1880
  var _rootCtx;
1744
1881
  var _nextPlugin;
1882
+ var _unloadHandlerContainer;
1745
1883
  var _hooks;
1746
1884
  _initDefaults();
1747
1885
  dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
@@ -1763,6 +1901,7 @@
1763
1901
  function _unloadCallback() {
1764
1902
  if (!unloadDone) {
1765
1903
  unloadDone = true;
1904
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1766
1905
  arrForEach(_hooks, function (fn) {
1767
1906
  fn.rm();
1768
1907
  });
@@ -1781,6 +1920,30 @@
1781
1920
  }
1782
1921
  return result;
1783
1922
  };
1923
+ _self.update = function (updateCtx, updateState) {
1924
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
1925
+ return;
1926
+ }
1927
+ var result;
1928
+ var updateDone = false;
1929
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1930
+ var theUpdateState = updateState || {
1931
+ reason: 0
1932
+ };
1933
+ function _updateCallback() {
1934
+ if (!updateDone) {
1935
+ updateDone = true;
1936
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
1937
+ }
1938
+ }
1939
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
1940
+ _updateCallback();
1941
+ }
1942
+ else {
1943
+ result = true;
1944
+ }
1945
+ return result;
1946
+ };
1784
1947
  _self._addHook = function (hooks) {
1785
1948
  if (hooks) {
1786
1949
  if (isArray(hooks)) {
@@ -1791,6 +1954,7 @@
1791
1954
  }
1792
1955
  }
1793
1956
  };
1957
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1794
1958
  });
1795
1959
  _self.diagLog = function (itemCtx) {
1796
1960
  return _getTelCtx(itemCtx).diagLog();
@@ -1847,11 +2011,180 @@
1847
2011
  _rootCtx = null;
1848
2012
  _nextPlugin = null;
1849
2013
  _hooks = [];
2014
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1850
2015
  }
1851
2016
  }
1852
2017
  return BaseTelemetryPlugin;
1853
2018
  }());
1854
2019
 
2020
+ var strOnPrefix = "on";
2021
+ var strAttachEvent = "attachEvent";
2022
+ var strAddEventHelper = "addEventListener";
2023
+ var strDetachEvent = "detachEvent";
2024
+ var strRemoveEventListener = "removeEventListener";
2025
+ var strEvents = "events";
2026
+ createUniqueNamespace("aiEvtPageHide");
2027
+ createUniqueNamespace("aiEvtPageShow");
2028
+ var _guid = 1;
2029
+ var elmNodeData = createElmNodeData("events");
2030
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2031
+ function _normalizeNamespace(name) {
2032
+ if (name && name.replace) {
2033
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
2034
+ }
2035
+ return name;
2036
+ }
2037
+ function _getEvtNamespace(eventName, evtNamespace) {
2038
+ if (evtNamespace) {
2039
+ var theNamespace_1 = "";
2040
+ if (isArray(evtNamespace)) {
2041
+ theNamespace_1 = "";
2042
+ arrForEach(evtNamespace, function (name) {
2043
+ name = _normalizeNamespace(name);
2044
+ if (name) {
2045
+ if (name[0] !== ".") {
2046
+ name = "." + name;
2047
+ }
2048
+ theNamespace_1 += name;
2049
+ }
2050
+ });
2051
+ }
2052
+ else {
2053
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
2054
+ }
2055
+ if (theNamespace_1) {
2056
+ if (theNamespace_1[0] !== ".") {
2057
+ theNamespace_1 = "." + theNamespace_1;
2058
+ }
2059
+ eventName = (eventName || "") + theNamespace_1;
2060
+ }
2061
+ }
2062
+ var parsedEvent = (eventNamespace.exec(eventName) || []);
2063
+ return {
2064
+ type: parsedEvent[1],
2065
+ ns: ((parsedEvent[2] || "").split(".").sort()).join(".")
2066
+ };
2067
+ }
2068
+ function _getRegisteredEvents(target, evtName, addDefault) {
2069
+ if (addDefault === void 0) { addDefault = true; }
2070
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2071
+ var registeredEvents = aiEvts[evtName];
2072
+ if (!registeredEvents) {
2073
+ registeredEvents = aiEvts[evtName] = [];
2074
+ }
2075
+ return registeredEvents;
2076
+ }
2077
+ function _doDetach(obj, evtName, handlerRef, useCapture) {
2078
+ if (obj && evtName && evtName.type) {
2079
+ if (obj[strRemoveEventListener]) {
2080
+ obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
2081
+ }
2082
+ else if (obj[strDetachEvent]) {
2083
+ obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
2084
+ }
2085
+ }
2086
+ }
2087
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
2088
+ var result = false;
2089
+ if (obj && evtName && evtName.type && handlerRef) {
2090
+ if (obj[strAddEventHelper]) {
2091
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2092
+ result = true;
2093
+ }
2094
+ else if (obj[strAttachEvent]) {
2095
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2096
+ result = true;
2097
+ }
2098
+ }
2099
+ return result;
2100
+ }
2101
+ function _doUnregister(target, events, evtName, unRegFn) {
2102
+ var idx = events.length;
2103
+ while (idx--) {
2104
+ var theEvent = events[idx];
2105
+ if (theEvent) {
2106
+ if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
2107
+ if (!unRegFn || unRegFn(theEvent)) {
2108
+ _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
2109
+ events.splice(idx, 1);
2110
+ }
2111
+ }
2112
+ }
2113
+ }
2114
+ }
2115
+ function _unregisterEvents(target, evtName, unRegFn) {
2116
+ if (evtName.type) {
2117
+ _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
2118
+ }
2119
+ else {
2120
+ var eventCache = elmNodeData.get(target, strEvents, {});
2121
+ objForEachKey(eventCache, function (evtType, events) {
2122
+ _doUnregister(target, events, evtName, unRegFn);
2123
+ });
2124
+ if (objKeys(eventCache).length === 0) {
2125
+ elmNodeData.kill(target, strEvents);
2126
+ }
2127
+ }
2128
+ }
2129
+ function mergeEvtNamespace(theNamespace, namespaces) {
2130
+ var newNamespaces;
2131
+ if (namespaces) {
2132
+ if (isArray(namespaces)) {
2133
+ newNamespaces = [theNamespace].concat(namespaces);
2134
+ }
2135
+ else {
2136
+ newNamespaces = [theNamespace, namespaces];
2137
+ }
2138
+ }
2139
+ else {
2140
+ newNamespaces = theNamespace;
2141
+ }
2142
+ return newNamespaces;
2143
+ }
2144
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2145
+ if (useCapture === void 0) { useCapture = false; }
2146
+ var result = false;
2147
+ if (target) {
2148
+ try {
2149
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
2150
+ result = _doAttach(target, evtName, handlerRef, useCapture);
2151
+ if (result && elmNodeData.accept(target)) {
2152
+ var registeredEvent = {
2153
+ guid: _guid++,
2154
+ evtName: evtName,
2155
+ handler: handlerRef,
2156
+ capture: useCapture
2157
+ };
2158
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2159
+ }
2160
+ }
2161
+ catch (e) {
2162
+ }
2163
+ }
2164
+ return result;
2165
+ }
2166
+ function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
2167
+ if (useCapture === void 0) { useCapture = false; }
2168
+ if (target) {
2169
+ try {
2170
+ var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
2171
+ var found_1 = false;
2172
+ _unregisterEvents(target, evtName_1, function (regEvent) {
2173
+ if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
2174
+ found_1 = true;
2175
+ return true;
2176
+ }
2177
+ return false;
2178
+ });
2179
+ if (!found_1) {
2180
+ _doDetach(target, evtName_1, handlerRef, useCapture);
2181
+ }
2182
+ }
2183
+ catch (e) {
2184
+ }
2185
+ }
2186
+ }
2187
+
1855
2188
  function generateW3CId() {
1856
2189
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1857
2190
  var oct = strEmpty$1, tmp;
@@ -1960,6 +2293,143 @@
1960
2293
  InMemoryStorageBufferFull: 105
1961
2294
  });
1962
2295
 
2296
+ var aiInstrumentHooks = "_aiHooks";
2297
+ var cbNames = [
2298
+ "req", "rsp", "hkErr", "fnErr"
2299
+ ];
2300
+ function _arrLoop(arr, fn) {
2301
+ if (arr) {
2302
+ for (var lp = 0; lp < arr.length; lp++) {
2303
+ if (fn(arr[lp], lp)) {
2304
+ break;
2305
+ }
2306
+ }
2307
+ }
2308
+ }
2309
+ function _doCallbacks(hooks, callDetails, cbArgs, hookCtx, type) {
2310
+ if (type >= 0 && type <= 2 ) {
2311
+ _arrLoop(hooks, function (hook, idx) {
2312
+ var cbks = hook.cbks;
2313
+ var cb = cbks[cbNames[type]];
2314
+ if (cb) {
2315
+ callDetails.ctx = function () {
2316
+ var ctx = hookCtx[idx] = (hookCtx[idx] || {});
2317
+ return ctx;
2318
+ };
2319
+ try {
2320
+ cb.apply(callDetails.inst, cbArgs);
2321
+ }
2322
+ catch (err) {
2323
+ var orgEx = callDetails.err;
2324
+ try {
2325
+ var hookErrorCb = cbks[cbNames[2 ]];
2326
+ if (hookErrorCb) {
2327
+ callDetails.err = err;
2328
+ hookErrorCb.apply(callDetails.inst, cbArgs);
2329
+ }
2330
+ }
2331
+ catch (e) {
2332
+ }
2333
+ finally {
2334
+ callDetails.err = orgEx;
2335
+ }
2336
+ }
2337
+ }
2338
+ });
2339
+ }
2340
+ }
2341
+ function _createFunctionHook(aiHook) {
2342
+ return function () {
2343
+ var funcThis = this;
2344
+ var orgArgs = arguments;
2345
+ var hooks = aiHook.h;
2346
+ var funcArgs = {
2347
+ name: aiHook.n,
2348
+ inst: funcThis,
2349
+ ctx: null,
2350
+ set: _replaceArg
2351
+ };
2352
+ var hookCtx = [];
2353
+ var cbArgs = _createArgs([funcArgs], orgArgs);
2354
+ funcArgs.evt = getGlobalInst("event");
2355
+ function _createArgs(target, theArgs) {
2356
+ _arrLoop(theArgs, function (arg) {
2357
+ target.push(arg);
2358
+ });
2359
+ return target;
2360
+ }
2361
+ function _replaceArg(idx, value) {
2362
+ orgArgs = _createArgs([], orgArgs);
2363
+ orgArgs[idx] = value;
2364
+ cbArgs = _createArgs([funcArgs], orgArgs);
2365
+ }
2366
+ _doCallbacks(hooks, funcArgs, cbArgs, hookCtx, 0 );
2367
+ var theFunc = aiHook.f;
2368
+ try {
2369
+ funcArgs.rslt = theFunc.apply(funcThis, orgArgs);
2370
+ }
2371
+ catch (err) {
2372
+ funcArgs.err = err;
2373
+ _doCallbacks(hooks, funcArgs, cbArgs, hookCtx, 3 );
2374
+ throw err;
2375
+ }
2376
+ _doCallbacks(hooks, funcArgs, cbArgs, hookCtx, 1 );
2377
+ return funcArgs.rslt;
2378
+ };
2379
+ }
2380
+ function _getOwner(target, name, checkPrototype) {
2381
+ var owner = null;
2382
+ if (target) {
2383
+ if (hasOwnProperty(target, name)) {
2384
+ owner = target;
2385
+ }
2386
+ else if (checkPrototype) {
2387
+ owner = _getOwner(_getObjProto(target), name, false);
2388
+ }
2389
+ }
2390
+ return owner;
2391
+ }
2392
+ function InstrumentFunc(target, funcName, callbacks, checkPrototype) {
2393
+ if (checkPrototype === void 0) { checkPrototype = true; }
2394
+ if (target && funcName && callbacks) {
2395
+ var owner = _getOwner(target, funcName, checkPrototype);
2396
+ if (owner) {
2397
+ var fn = owner[funcName];
2398
+ if (typeof fn === strShimFunction) {
2399
+ var aiHook_1 = fn[aiInstrumentHooks];
2400
+ if (!aiHook_1) {
2401
+ aiHook_1 = {
2402
+ i: 0,
2403
+ n: funcName,
2404
+ f: fn,
2405
+ h: []
2406
+ };
2407
+ var newFunc = _createFunctionHook(aiHook_1);
2408
+ newFunc[aiInstrumentHooks] = aiHook_1;
2409
+ owner[funcName] = newFunc;
2410
+ }
2411
+ var theHook = {
2412
+ id: aiHook_1.i,
2413
+ cbks: callbacks,
2414
+ rm: function () {
2415
+ var id = this.id;
2416
+ _arrLoop(aiHook_1.h, function (hook, idx) {
2417
+ if (hook.id === id) {
2418
+ aiHook_1.h.splice(idx, 1);
2419
+ return 1;
2420
+ }
2421
+ });
2422
+ }
2423
+ };
2424
+ aiHook_1.i++;
2425
+ aiHook_1.h.push(theHook);
2426
+ return theHook;
2427
+ }
2428
+ }
2429
+ }
2430
+ return null;
2431
+ }
2432
+
1963
2433
  function dataSanitizeKeyAndAddUniqueness(logger, key, map) {
1964
2434
  var origLength = key.length;
1965
2435
  var field = dataSanitizeKey(logger, key);
@@ -1980,7 +2450,7 @@
1980
2450
  name = strTrim(name.toString());
1981
2451
  if (name.length > 150 ) {
1982
2452
  nameTrunc = name.substring(0, 150 );
1983
- logger && logger.throwInternal(2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2453
+ _throwInternal(logger, 2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1984
2454
  }
1985
2455
  }
1986
2456
  return nameTrunc || name;
@@ -1993,7 +2463,7 @@
1993
2463
  value = strTrim(value);
1994
2464
  if (value.toString().length > maxLength) {
1995
2465
  valueTrunc = value.toString().substring(0, maxLength);
1996
- logger && logger.throwInternal(2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2466
+ _throwInternal(logger, 2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
1997
2467
  }
1998
2468
  }
1999
2469
  return valueTrunc || value;
@@ -2006,7 +2476,7 @@
2006
2476
  if (message) {
2007
2477
  if (message.length > 32768 ) {
2008
2478
  messageTrunc = message.substring(0, 32768 );
2009
- logger && logger.throwInternal(2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2479
+ _throwInternal(logger, 2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
2010
2480
  }
2011
2481
  }
2012
2482
  return messageTrunc || message;
@@ -2017,7 +2487,7 @@
2017
2487
  var value = "" + exception;
2018
2488
  if (value.length > 32768 ) {
2019
2489
  exceptionTrunc = value.substring(0, 32768 );
2020
- logger && logger.throwInternal(2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2490
+ _throwInternal(logger, 2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
2021
2491
  }
2022
2492
  }
2023
2493
  return exceptionTrunc || exception;
@@ -2031,7 +2501,7 @@
2031
2501
  value = getJSON().stringify(value);
2032
2502
  }
2033
2503
  catch (e) {
2034
- logger && logger.throwInternal(2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2504
+ _throwInternal(logger, 2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2035
2505
  }
2036
2506
  }
2037
2507
  value = dataSanitizeString(logger, value, 8192 );
@@ -2062,7 +2532,7 @@
2062
2532
  input = strTrim(input);
2063
2533
  if (input.length > maxLength) {
2064
2534
  inputTrunc = input.substring(0, maxLength);
2065
- logger && logger.throwInternal(2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2535
+ _throwInternal(logger, 2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2066
2536
  }
2067
2537
  }
2068
2538
  return inputTrunc || input;
@@ -2128,6 +2598,7 @@
2128
2598
  W3C: 2
2129
2599
  });
2130
2600
 
2601
+ var _canUseLocalStorage = undefined;
2131
2602
  var _canUseSessionStorage = undefined;
2132
2603
  function _getVerifiedStorageObject(storageType) {
2133
2604
  try {
@@ -2154,10 +2625,21 @@
2154
2625
  return null;
2155
2626
  }
2156
2627
  function utlDisableStorage() {
2628
+ _canUseLocalStorage = false;
2157
2629
  _canUseSessionStorage = false;
2158
2630
  }
2159
- function utlCanUseSessionStorage() {
2160
- if (_canUseSessionStorage === undefined) {
2631
+ function utlEnableStorage() {
2632
+ _canUseLocalStorage = utlCanUseLocalStorage(true);
2633
+ _canUseSessionStorage = utlCanUseSessionStorage(true);
2634
+ }
2635
+ function utlCanUseLocalStorage(reset) {
2636
+ if (reset || _canUseLocalStorage === undefined) {
2637
+ _canUseLocalStorage = !!_getVerifiedStorageObject(StorageType.LocalStorage);
2638
+ }
2639
+ return _canUseLocalStorage;
2640
+ }
2641
+ function utlCanUseSessionStorage(reset) {
2642
+ if (reset || _canUseSessionStorage === undefined) {
2161
2643
  _canUseSessionStorage = !!_getVerifiedStorageObject(StorageType.SessionStorage);
2162
2644
  }
2163
2645
  return _canUseSessionStorage;
@@ -2170,7 +2652,7 @@
2170
2652
  }
2171
2653
  catch (e) {
2172
2654
  _canUseSessionStorage = false;
2173
- logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2655
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2174
2656
  }
2175
2657
  }
2176
2658
  return null;
@@ -2184,7 +2666,7 @@
2184
2666
  }
2185
2667
  catch (e) {
2186
2668
  _canUseSessionStorage = false;
2187
- logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2669
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
2188
2670
  }
2189
2671
  }
2190
2672
  return false;
@@ -2198,7 +2680,7 @@
2198
2680
  }
2199
2681
  catch (e) {
2200
2682
  _canUseSessionStorage = false;
2201
- logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2683
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2202
2684
  }
2203
2685
  }
2204
2686
  return false;
@@ -3421,6 +3903,33 @@
3421
3903
  return PageViewPerformanceManager;
3422
3904
  }());
3423
3905
 
3906
+ var Timing = /** @class */ (function () {
3907
+ function Timing(logger, name) {
3908
+ var _self = this;
3909
+ var _events = {};
3910
+ _self.start = function (name) {
3911
+ if (typeof _events[name] !== "undefined") {
3912
+ _throwInternal(logger, LoggingSeverity.WARNING, _InternalMessageId.StartCalledMoreThanOnce, "start was called more than once for this event without calling stop.", { name: name, key: name }, true);
3913
+ }
3914
+ _events[name] = +new Date;
3915
+ };
3916
+ _self.stop = function (name, url, properties, measurements) {
3917
+ var start = _events[name];
3918
+ if (isNaN(start)) {
3919
+ _throwInternal(logger, LoggingSeverity.WARNING, _InternalMessageId.StopCalledWithoutStart, "stop was called without a corresponding start.", { name: name, key: name }, true);
3920
+ }
3921
+ else {
3922
+ var end = +new Date;
3923
+ var duration = dateTimeUtilsDuration(start, end);
3924
+ _self.action(name, url, duration, properties, measurements);
3925
+ }
3926
+ delete _events[name];
3927
+ _events[name] = undefined;
3928
+ };
3929
+ }
3930
+ return Timing;
3931
+ }());
3932
+
3424
3933
  var durationProperty = "duration";
3425
3934
  var strEvent = "event";
3426
3935
  function _dispatchEvent(target, evnt) {
@@ -3438,47 +3947,78 @@
3438
3947
  }
3439
3948
  return error || "";
3440
3949
  }
3441
- var ApplicationInsights = /** @class */ (function (_super) {
3442
- __extendsFn(ApplicationInsights, _super);
3443
- function ApplicationInsights() {
3950
+ var MinMilliSeconds = 60000;
3951
+ function _configMilliseconds(value, defValue) {
3952
+ value = value || defValue;
3953
+ if (value < MinMilliSeconds) {
3954
+ value = MinMilliSeconds;
3955
+ }
3956
+ return value;
3957
+ }
3958
+ function _getDefaultConfig(config) {
3959
+ if (!config) {
3960
+ config = {};
3961
+ }
3962
+ config.sessionRenewalMs = _configMilliseconds(config.sessionRenewalMs, 30 * 60 * 1000);
3963
+ config.sessionExpirationMs = _configMilliseconds(config.sessionExpirationMs, 24 * 60 * 60 * 1000);
3964
+ config.disableExceptionTracking = stringToBoolOrDefault(config.disableExceptionTracking);
3965
+ config.autoTrackPageVisitTime = stringToBoolOrDefault(config.autoTrackPageVisitTime);
3966
+ config.overridePageViewDuration = stringToBoolOrDefault(config.overridePageViewDuration);
3967
+ config.enableUnhandledPromiseRejectionTracking = stringToBoolOrDefault(config.enableUnhandledPromiseRejectionTracking);
3968
+ if (isNaN(config.samplingPercentage) || config.samplingPercentage <= 0 || config.samplingPercentage >= 100) {
3969
+ config.samplingPercentage = 100;
3970
+ }
3971
+ config.isStorageUseDisabled = stringToBoolOrDefault(config.isStorageUseDisabled);
3972
+ config.isBrowserLinkTrackingEnabled = stringToBoolOrDefault(config.isBrowserLinkTrackingEnabled);
3973
+ config.enableAutoRouteTracking = stringToBoolOrDefault(config.enableAutoRouteTracking);
3974
+ config.namePrefix = config.namePrefix || "";
3975
+ config.enableDebug = stringToBoolOrDefault(config.enableDebug);
3976
+ config.disableFlushOnBeforeUnload = stringToBoolOrDefault(config.disableFlushOnBeforeUnload);
3977
+ config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
3978
+ return config;
3979
+ }
3980
+ function _updateStorageUsage(extConfig) {
3981
+ if (!isUndefined(extConfig.isStorageUseDisabled)) {
3982
+ if (extConfig.isStorageUseDisabled) {
3983
+ utlDisableStorage();
3984
+ }
3985
+ else {
3986
+ utlEnableStorage();
3987
+ }
3988
+ }
3989
+ }
3990
+ var AnalyticsPlugin = /** @class */ (function (_super) {
3991
+ __extendsFn(AnalyticsPlugin, _super);
3992
+ function AnalyticsPlugin() {
3444
3993
  var _this = _super.call(this) || this;
3445
3994
  _this.identifier = AnalyticsPluginIdentifier;
3446
3995
  _this.priority = 180;
3447
3996
  _this.autoRoutePVDelay = 500;
3448
3997
  var _eventTracking;
3449
3998
  var _pageTracking;
3450
- var _properties;
3999
+ var _pageViewManager;
4000
+ var _pageViewPerformanceManager;
4001
+ var _pageVisitTimeManager;
4002
+ var _preInitTelemetryInitializers;
4003
+ var _isBrowserLinkTrackingEnabled;
4004
+ var _browserLinkInitializerAdded;
4005
+ var _enableAutoRouteTracking;
4006
+ var _historyListenerAdded;
4007
+ var _disableExceptionTracking;
4008
+ var _autoExceptionInstrumented;
4009
+ var _enableUnhandledPromiseRejectionTracking;
4010
+ var _autoUnhandledPromiseInstrumented;
3451
4011
  var _prevUri;
3452
4012
  var _currUri;
3453
- dynamicProto(ApplicationInsights, _this, function (_self, _base) {
3454
- var location = getLocation(true);
3455
- _prevUri = location && location.href || "";
4013
+ var _evtNamespace;
4014
+ dynamicProto(AnalyticsPlugin, _this, function (_self, _base) {
4015
+ var _addHook = _base._addHook;
4016
+ _initDefaults();
3456
4017
  _self.getCookieMgr = function () {
3457
4018
  return safeGetCookieMgr(_self.core);
3458
4019
  };
3459
4020
  _self.processTelemetry = function (env, itemCtx) {
3460
- doPerf(_self.core, function () { return _self.identifier + ":processTelemetry"; }, function () {
3461
- var doNotSendItem = false;
3462
- var telemetryInitializersCount = _self._telemetryInitializers.length;
3463
- itemCtx = _self._getTelCtx(itemCtx);
3464
- for (var i = 0; i < telemetryInitializersCount; ++i) {
3465
- var telemetryInitializer = _self._telemetryInitializers[i];
3466
- if (telemetryInitializer) {
3467
- try {
3468
- if (telemetryInitializer.apply(null, [env]) === false) {
3469
- doNotSendItem = true;
3470
- break;
3471
- }
3472
- }
3473
- catch (e) {
3474
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
3475
- }
3476
- }
3477
- }
3478
- if (!doNotSendItem) {
3479
- _self.processNext(env, itemCtx);
3480
- }
3481
- }, function () { return ({ item: env }); }, !(env.sync));
4021
+ _self.processNext(env, itemCtx);
3482
4022
  };
3483
4023
  _self.trackEvent = function (event, customProperties) {
3484
4024
  try {
@@ -3486,7 +4026,7 @@
3486
4026
  _self.core.track(telemetryItem);
3487
4027
  }
3488
4028
  catch (e) {
3489
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4029
+ _throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3490
4030
  }
3491
4031
  };
3492
4032
  _self.startTrackEvent = function (name) {
@@ -3494,7 +4034,7 @@
3494
4034
  _eventTracking.start(name);
3495
4035
  }
3496
4036
  catch (e) {
3497
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackEventFailed, "startTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4037
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackEventFailed, "startTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3498
4038
  }
3499
4039
  };
3500
4040
  _self.stopTrackEvent = function (name, properties, measurements) {
@@ -3502,7 +4042,7 @@
3502
4042
  _eventTracking.stop(name, undefined, properties);
3503
4043
  }
3504
4044
  catch (e) {
3505
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackEventFailed, "stopTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4045
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackEventFailed, "stopTrackEvent failed, event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3506
4046
  }
3507
4047
  };
3508
4048
  _self.trackTrace = function (trace, customProperties) {
@@ -3511,7 +4051,7 @@
3511
4051
  _self.core.track(telemetryItem);
3512
4052
  }
3513
4053
  catch (e) {
3514
- _self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4054
+ _throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TrackTraceFailed, "trackTrace failed, trace will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3515
4055
  }
3516
4056
  };
3517
4057
  _self.trackMetric = function (metric, customProperties) {
@@ -3520,19 +4060,19 @@
3520
4060
  _self.core.track(telemetryItem);
3521
4061
  }
3522
4062
  catch (e) {
3523
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackMetricFailed, "trackMetric failed, metric will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4063
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackMetricFailed, "trackMetric failed, metric will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3524
4064
  }
3525
4065
  };
3526
4066
  _self.trackPageView = function (pageView, customProperties) {
3527
4067
  try {
3528
4068
  var inPv = pageView || {};
3529
- _self._pageViewManager.trackPageView(inPv, __assignFn(__assignFn(__assignFn({}, inPv.properties), inPv.measurements), customProperties));
4069
+ _pageViewManager.trackPageView(inPv, __assignFn(__assignFn(__assignFn({}, inPv.properties), inPv.measurements), customProperties));
3530
4070
  if (_self.config.autoTrackPageVisitTime) {
3531
- _self._pageVisitTimeManager.trackPreviousPageVisit(inPv.name, inPv.uri);
4071
+ _pageVisitTimeManager.trackPreviousPageVisit(inPv.name, inPv.uri);
3532
4072
  }
3533
4073
  }
3534
4074
  catch (e) {
3535
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageView failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4075
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageView failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3536
4076
  }
3537
4077
  };
3538
4078
  _self.sendPageViewInternal = function (pageView, properties, systemProperties) {
@@ -3548,12 +4088,13 @@
3548
4088
  _self.core.track(telemetryItem);
3549
4089
  };
3550
4090
  _self.trackPageViewPerformance = function (pageViewPerformance, customProperties) {
4091
+ var inPvp = pageViewPerformance || {};
3551
4092
  try {
3552
- _self._pageViewPerformanceManager.populatePageViewPerformanceEvent(pageViewPerformance);
3553
- _self.sendPageViewPerformanceInternal(pageViewPerformance, customProperties);
4093
+ _pageViewPerformanceManager.populatePageViewPerformanceEvent(inPvp);
4094
+ _self.sendPageViewPerformanceInternal(inPvp, customProperties);
3554
4095
  }
3555
4096
  catch (e) {
3556
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageViewPerformance failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4097
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackPVFailed, "trackPageViewPerformance failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3557
4098
  }
3558
4099
  };
3559
4100
  _self.startTrackPage = function (name) {
@@ -3565,7 +4106,7 @@
3565
4106
  _pageTracking.start(name);
3566
4107
  }
3567
4108
  catch (e) {
3568
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackFailed, "startTrackPage failed, page view may not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4109
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StartTrackFailed, "startTrackPage failed, page view may not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3569
4110
  }
3570
4111
  };
3571
4112
  _self.stopTrackPage = function (name, url, properties, measurement) {
@@ -3580,11 +4121,11 @@
3580
4121
  }
3581
4122
  _pageTracking.stop(name, url, properties, measurement);
3582
4123
  if (_self.config.autoTrackPageVisitTime) {
3583
- _self._pageVisitTimeManager.trackPreviousPageVisit(name, url);
4124
+ _pageVisitTimeManager.trackPreviousPageVisit(name, url);
3584
4125
  }
3585
4126
  }
3586
4127
  catch (e) {
3587
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackFailed, "stopTrackPage failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4128
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.StopTrackFailed, "stopTrackPage failed, page view will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3588
4129
  }
3589
4130
  };
3590
4131
  _self.sendExceptionInternal = function (exception, customProperties, systemProperties) {
@@ -3594,11 +4135,14 @@
3594
4135
  _self.core.track(telemetryItem);
3595
4136
  };
3596
4137
  _self.trackException = function (exception, customProperties) {
4138
+ if (exception && !exception.exception && exception.error) {
4139
+ exception.exception = exception.error;
4140
+ }
3597
4141
  try {
3598
4142
  _self.sendExceptionInternal(exception, customProperties);
3599
4143
  }
3600
4144
  catch (e) {
3601
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
4145
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
3602
4146
  }
3603
4147
  };
3604
4148
  _self._onerror = function (exception) {
@@ -3632,158 +4176,97 @@
3632
4176
  }
3633
4177
  catch (e) {
3634
4178
  var errorString = error ? (error.name + ", " + error.message) : "null";
3635
- _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.ExceptionWhileLoggingError, "_onError threw exception while logging error, error will not be collected: "
4179
+ _throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.ExceptionWhileLoggingError, "_onError threw exception while logging error, error will not be collected: "
3636
4180
  + getExceptionName(e), { exception: dumpObj(e), errorString: errorString });
3637
4181
  }
3638
4182
  };
3639
4183
  _self.addTelemetryInitializer = function (telemetryInitializer) {
3640
- _self._telemetryInitializers.push(telemetryInitializer);
4184
+ if (_self.core) {
4185
+ return _self.core.addTelemetryInitializer(telemetryInitializer);
4186
+ }
4187
+ if (!_preInitTelemetryInitializers) {
4188
+ _preInitTelemetryInitializers = [];
4189
+ }
4190
+ _preInitTelemetryInitializers.push(telemetryInitializer);
3641
4191
  };
3642
4192
  _self.initialize = function (config, core, extensions, pluginChain) {
3643
4193
  if (_self.isInitialized()) {
3644
4194
  return;
3645
4195
  }
3646
4196
  if (isNullOrUndefined(core)) {
3647
- throw Error("Error initializing");
4197
+ throwError("Error initializing");
3648
4198
  }
3649
4199
  _base.initialize(config, core, extensions, pluginChain);
3650
- _self.setInitialized(false);
3651
- var ctx = _self._getTelCtx();
3652
- var identifier = _self.identifier;
3653
- _self.config = ctx.getExtCfg(identifier);
3654
- var defaults = ApplicationInsights.getDefaultConfig(config);
3655
- if (defaults !== undefined) {
3656
- objForEachKey(defaults, function (field, value) {
3657
- _self.config[field] = ctx.getConfig(identifier, field, value);
3658
- if (_self.config[field] === undefined) {
3659
- _self.config[field] = value;
3660
- }
3661
- });
3662
- }
3663
- if (_self.config.isStorageUseDisabled) {
3664
- utlDisableStorage();
3665
- }
3666
- var configGetters = {
3667
- instrumentationKey: function () { return config.instrumentationKey; },
3668
- accountId: function () { return _self.config.accountId || config.accountId; },
3669
- sessionRenewalMs: function () { return _self.config.sessionRenewalMs || config.sessionRenewalMs; },
3670
- sessionExpirationMs: function () { return _self.config.sessionExpirationMs || config.sessionExpirationMs; },
3671
- sampleRate: function () { return _self.config.samplingPercentage || config.samplingPercentage; },
3672
- sdkExtension: function () { return _self.config.sdkExtension || config.sdkExtension; },
3673
- isBrowserLinkTrackingEnabled: function () { return _self.config.isBrowserLinkTrackingEnabled || config.isBrowserLinkTrackingEnabled; },
3674
- appId: function () { return _self.config.appId || config.appId; }
3675
- };
3676
- _self._pageViewPerformanceManager = new PageViewPerformanceManager(_self.core);
3677
- _self._pageViewManager = new PageViewManager(_this, _self.config.overridePageViewDuration, _self.core, _self._pageViewPerformanceManager);
3678
- _self._pageVisitTimeManager = new PageVisitTimeManager(_self.diagLog(), function (pageName, pageUrl, pageVisitTime) { return trackPageVisitTime(pageName, pageUrl, pageVisitTime); });
3679
- _self._telemetryInitializers = _self._telemetryInitializers || [];
3680
- _addDefaultTelemetryInitializers(configGetters);
3681
- _eventTracking = new Timing(_self.diagLog(), "trackEvent");
3682
- _eventTracking.action =
3683
- function (name, url, duration, properties) {
3684
- if (!properties) {
4200
+ try {
4201
+ _evtNamespace = mergeEvtNamespace(createUniqueNamespace("AnalyticsPlugin"), core.evtNamespace && core.evtNamespace());
4202
+ if (_preInitTelemetryInitializers) {
4203
+ arrForEach(_preInitTelemetryInitializers, function (initializer) {
4204
+ core.addTelemetryInitializer(initializer);
4205
+ });
4206
+ _preInitTelemetryInitializers = null;
4207
+ }
4208
+ var extConfig = _populateDefaults(config);
4209
+ _updateStorageUsage(extConfig);
4210
+ _pageViewPerformanceManager = new PageViewPerformanceManager(_self.core);
4211
+ _pageViewManager = new PageViewManager(_this, extConfig.overridePageViewDuration, _self.core, _pageViewPerformanceManager);
4212
+ _pageVisitTimeManager = new PageVisitTimeManager(_self.diagLog(), function (pageName, pageUrl, pageVisitTime) { return trackPageVisitTime(pageName, pageUrl, pageVisitTime); });
4213
+ _updateBrowserLinkTracking(extConfig, config);
4214
+ _eventTracking = new Timing(_self.diagLog(), "trackEvent");
4215
+ _eventTracking.action =
4216
+ function (name, url, duration, properties) {
4217
+ if (!properties) {
4218
+ properties = {};
4219
+ }
4220
+ properties[durationProperty] = duration.toString();
4221
+ _self.trackEvent({ name: name, properties: properties });
4222
+ };
4223
+ _pageTracking = new Timing(_self.diagLog(), "trackPageView");
4224
+ _pageTracking.action = function (name, url, duration, properties, measurements) {
4225
+ if (isNullOrUndefined(properties)) {
3685
4226
  properties = {};
3686
4227
  }
3687
4228
  properties[durationProperty] = duration.toString();
3688
- _self.trackEvent({ name: name, properties: properties });
4229
+ var pageViewItem = {
4230
+ name: name,
4231
+ uri: url,
4232
+ properties: properties,
4233
+ measurements: measurements
4234
+ };
4235
+ _self.sendPageViewInternal(pageViewItem, properties);
3689
4236
  };
3690
- _pageTracking = new Timing(_self.diagLog(), "trackPageView");
3691
- _pageTracking.action = function (name, url, duration, properties, measurements) {
3692
- if (isNullOrUndefined(properties)) {
3693
- properties = {};
4237
+ if (hasWindow()) {
4238
+ _updateExceptionTracking(extConfig);
4239
+ _updateLocationChange(extConfig);
3694
4240
  }
3695
- properties[durationProperty] = duration.toString();
3696
- var pageViewItem = {
3697
- name: name,
3698
- uri: url,
3699
- properties: properties,
3700
- measurements: measurements
3701
- };
3702
- _self.sendPageViewInternal(pageViewItem, properties);
3703
- };
3704
- var _window = getWindow();
3705
- var _history = getHistory();
3706
- var _location = getLocation(true);
3707
- var instance = _this;
3708
- if (_self.config.disableExceptionTracking === false &&
3709
- !_self.config.autoExceptionInstrumented && _window) {
3710
- var onerror_1 = "onerror";
3711
- var originalOnError_1 = _window[onerror_1];
3712
- _window.onerror = function (message, url, lineNumber, columnNumber, error) {
3713
- var evt = _window[strEvent];
3714
- var handled = originalOnError_1 && originalOnError_1(message, url, lineNumber, columnNumber, error);
3715
- if (handled !== true) {
3716
- instance._onerror(Exception.CreateAutoException(message, url, lineNumber, columnNumber, error, evt));
3717
- }
3718
- return handled;
3719
- };
3720
- _self.config.autoExceptionInstrumented = true;
3721
- }
3722
- if (_self.config.disableExceptionTracking === false &&
3723
- _self.config.enableUnhandledPromiseRejectionTracking === true &&
3724
- !_self.config.autoUnhandledPromiseInstrumented && _window) {
3725
- var onunhandledrejection_1 = "onunhandledrejection";
3726
- var originalOnUnhandledRejection_1 = _window[onunhandledrejection_1];
3727
- _window[onunhandledrejection_1] = function (error) {
3728
- var evt = _window[strEvent];
3729
- var handled = originalOnUnhandledRejection_1 && originalOnUnhandledRejection_1.call(_window, error);
3730
- if (handled !== true) {
3731
- instance._onerror(Exception.CreateAutoException(_getReason(error), _location ? _location.href : "", 0, 0, error, evt));
3732
- }
3733
- return handled;
3734
- };
3735
- _self.config.autoUnhandledPromiseInstrumented = true;
3736
- }
3737
- if (_self.config.enableAutoRouteTracking === true
3738
- && _history && isFunction(_history.pushState) && isFunction(_history.replaceState)
3739
- && _window
3740
- && typeof Event !== "undefined") {
3741
- var _self_1 = _this;
3742
- arrForEach(extensions, function (extension) {
3743
- if (extension.identifier === PropertiesPluginIdentifier) {
3744
- _properties = extension;
4241
+ }
4242
+ catch (e) {
4243
+ _self.setInitialized(false);
4244
+ throw e;
4245
+ }
4246
+ };
4247
+ _self._doTeardown = function (unloadCtx, unloadState) {
4248
+ eventOff(window, null, null, _evtNamespace);
4249
+ _initDefaults();
4250
+ };
4251
+ function _populateDefaults(config) {
4252
+ var ctx = createProcessTelemetryContext(null, config, _self.core);
4253
+ var identifier = _self.identifier;
4254
+ var defaults = _getDefaultConfig(config);
4255
+ var extConfig = _self.config = ctx.getExtCfg(identifier);
4256
+ if (defaults !== undefined) {
4257
+ objForEachKey(defaults, function (field, value) {
4258
+ extConfig[field] = ctx.getConfig(identifier, field, value);
4259
+ if (extConfig[field] === undefined) {
4260
+ extConfig = value;
3745
4261
  }
3746
4262
  });
3747
- _history.pushState = (function (f) { return function pushState() {
3748
- var ret = f.apply(this, arguments);
3749
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "pushState"));
3750
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3751
- return ret;
3752
- }; })(_history.pushState);
3753
- _history.replaceState = (function (f) { return function replaceState() {
3754
- var ret = f.apply(this, arguments);
3755
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "replaceState"));
3756
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3757
- return ret;
3758
- }; })(_history.replaceState);
3759
- if (_window.addEventListener) {
3760
- _window.addEventListener(_self_1.config.namePrefix + "popstate", function () {
3761
- _dispatchEvent(_window, createDomEvent(_self_1.config.namePrefix + "locationchange"));
3762
- });
3763
- _window.addEventListener(_self_1.config.namePrefix + "locationchange", function () {
3764
- if (_properties && _properties.context && _properties.context.telemetryTrace) {
3765
- _properties.context.telemetryTrace.traceID = generateW3CId();
3766
- var traceLocationName = "_unknown_";
3767
- if (_location && _location.pathname) {
3768
- traceLocationName = _location.pathname + (_location.hash || "");
3769
- }
3770
- _properties.context.telemetryTrace.name = dataSanitizeString(_self_1.diagLog(), traceLocationName);
3771
- }
3772
- if (_currUri) {
3773
- _prevUri = _currUri;
3774
- _currUri = _location && _location.href || "";
3775
- }
3776
- else {
3777
- _currUri = _location && _location.href || "";
3778
- }
3779
- setTimeout((function (uri) {
3780
- _self_1.trackPageView({ refUri: uri, properties: { duration: 0 } });
3781
- }).bind(_this, _prevUri), _self_1.autoRoutePVDelay);
3782
- });
3783
- }
3784
4263
  }
3785
- _self.setInitialized(true);
3786
- };
4264
+ return extConfig;
4265
+ }
4266
+ function _updateBrowserLinkTracking(extConfig, config) {
4267
+ _isBrowserLinkTrackingEnabled = extConfig.isBrowserLinkTrackingEnabled || config.isBrowserLinkTrackingEnabled;
4268
+ _addDefaultTelemetryInitializers();
4269
+ }
3787
4270
  function trackPageVisitTime(pageName, pageUrl, pageVisitTime) {
3788
4271
  var properties = { PageName: pageName, PageUrl: pageUrl };
3789
4272
  _self.trackMetric({
@@ -3794,11 +4277,11 @@
3794
4277
  sampleCount: 1
3795
4278
  }, properties);
3796
4279
  }
3797
- function _addDefaultTelemetryInitializers(configGetters) {
3798
- if (!configGetters.isBrowserLinkTrackingEnabled()) {
4280
+ function _addDefaultTelemetryInitializers() {
4281
+ if (!_browserLinkInitializerAdded && _isBrowserLinkTrackingEnabled) {
3799
4282
  var browserLinkPaths_1 = ["/browserLinkSignalR/", "/__browserLink/"];
3800
4283
  var dropBrowserLinkRequests = function (envelope) {
3801
- if (envelope.baseType === RemoteDependencyData.dataType) {
4284
+ if (_isBrowserLinkTrackingEnabled && envelope.baseType === RemoteDependencyData.dataType) {
3802
4285
  var remoteData = envelope.baseData;
3803
4286
  if (remoteData) {
3804
4287
  for (var i = 0; i < browserLinkPaths_1.length; i++) {
@@ -3810,72 +4293,150 @@
3810
4293
  }
3811
4294
  return true;
3812
4295
  };
3813
- _addTelemetryInitializer(dropBrowserLinkRequests);
4296
+ _self.addTelemetryInitializer(dropBrowserLinkRequests);
4297
+ _browserLinkInitializerAdded = true;
3814
4298
  }
3815
4299
  }
3816
- function _addTelemetryInitializer(telemetryInitializer) {
3817
- _self._telemetryInitializers.push(telemetryInitializer);
3818
- }
3819
4300
  function _sendCORSException(exception, properties) {
3820
4301
  var telemetryItem = TelemetryItemCreator.create(exception, Exception.dataType, Exception.envelopeType, _self.diagLog(), properties);
3821
4302
  _self.core.track(telemetryItem);
3822
4303
  }
3823
- });
3824
- return _this;
3825
- }
3826
- ApplicationInsights.getDefaultConfig = function (config) {
3827
- if (!config) {
3828
- config = {};
3829
- }
3830
- config.sessionRenewalMs = 30 * 60 * 1000;
3831
- config.sessionExpirationMs = 24 * 60 * 60 * 1000;
3832
- config.disableExceptionTracking = stringToBoolOrDefault(config.disableExceptionTracking);
3833
- config.autoTrackPageVisitTime = stringToBoolOrDefault(config.autoTrackPageVisitTime);
3834
- config.overridePageViewDuration = stringToBoolOrDefault(config.overridePageViewDuration);
3835
- config.enableUnhandledPromiseRejectionTracking = stringToBoolOrDefault(config.enableUnhandledPromiseRejectionTracking);
3836
- if (isNaN(config.samplingPercentage) || config.samplingPercentage <= 0 || config.samplingPercentage >= 100) {
3837
- config.samplingPercentage = 100;
3838
- }
3839
- config.isStorageUseDisabled = stringToBoolOrDefault(config.isStorageUseDisabled);
3840
- config.isBrowserLinkTrackingEnabled = stringToBoolOrDefault(config.isBrowserLinkTrackingEnabled);
3841
- config.enableAutoRouteTracking = stringToBoolOrDefault(config.enableAutoRouteTracking);
3842
- config.namePrefix = config.namePrefix || "";
3843
- config.enableDebug = stringToBoolOrDefault(config.enableDebug);
3844
- config.disableFlushOnBeforeUnload = stringToBoolOrDefault(config.disableFlushOnBeforeUnload);
3845
- config.disableFlushOnUnload = stringToBoolOrDefault(config.disableFlushOnUnload, config.disableFlushOnBeforeUnload);
3846
- return config;
3847
- };
3848
- ApplicationInsights.Version = "2.8.0-beta.2203-02";
3849
- return ApplicationInsights;
3850
- }(BaseTelemetryPlugin));
3851
- var Timing = /** @class */ (function () {
3852
- function Timing(logger, name) {
3853
- var _self = this;
3854
- var _events = {};
3855
- _self.start = function (name) {
3856
- if (typeof _events[name] !== "undefined") {
3857
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StartCalledMoreThanOnce, "start was called more than once for this event without calling stop.", { name: name, key: name }, true);
4304
+ function _updateExceptionTracking(extConfig) {
4305
+ var _window = getWindow();
4306
+ var locn = getLocation(true);
4307
+ _disableExceptionTracking = extConfig.disableExceptionTracking;
4308
+ if (!_disableExceptionTracking && !_autoExceptionInstrumented && !extConfig.autoExceptionInstrumented) {
4309
+ _addHook(InstrumentFunc(_window, "onerror", {
4310
+ ns: _evtNamespace,
4311
+ rsp: function (callDetails, message, url, lineNumber, columnNumber, error) {
4312
+ if (!_disableExceptionTracking && callDetails.rslt !== true) {
4313
+ _self._onerror(Exception.CreateAutoException(message, url, lineNumber, columnNumber, error, callDetails.evt));
4314
+ }
4315
+ }
4316
+ }));
4317
+ _autoExceptionInstrumented = true;
4318
+ }
4319
+ _addUnhandledPromiseRejectionTracking(extConfig, _window, locn);
3858
4320
  }
3859
- _events[name] = +new Date;
3860
- };
3861
- _self.stop = function (name, url, properties, measurements) {
3862
- var start = _events[name];
3863
- if (isNaN(start)) {
3864
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.StopCalledWithoutStart, "stop was called without a corresponding start.", { name: name, key: name }, true);
4321
+ function _updateLocationChange(extConfig) {
4322
+ var win = getWindow();
4323
+ var locn = getLocation(true);
4324
+ _enableAutoRouteTracking = extConfig.enableAutoRouteTracking === true;
4325
+ if (win && _enableAutoRouteTracking && hasHistory()) {
4326
+ var _history = getHistory();
4327
+ if (isFunction(_history.pushState) && isFunction(_history.replaceState) && typeof Event !== strShimUndefined) {
4328
+ _addHistoryListener(extConfig, win, _history, locn);
4329
+ }
4330
+ }
3865
4331
  }
3866
- else {
3867
- var end = +new Date;
3868
- var duration = dateTimeUtilsDuration(start, end);
3869
- _self.action(name, url, duration, properties, measurements);
4332
+ function _addHistoryListener(extConfig, win, history, locn) {
4333
+ function _popstateHandler() {
4334
+ if (_enableAutoRouteTracking) {
4335
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "locationchange"));
4336
+ }
4337
+ }
4338
+ function _locationChangeHandler() {
4339
+ if (_currUri) {
4340
+ _prevUri = _currUri;
4341
+ _currUri = locn && locn.href || "";
4342
+ }
4343
+ else {
4344
+ _currUri = locn && locn.href || "";
4345
+ }
4346
+ if (_enableAutoRouteTracking) {
4347
+ var properties = _self.core.getPlugin(PropertiesPluginIdentifier);
4348
+ if (properties) {
4349
+ var context = properties.plugin.context;
4350
+ if (context && context.telemetryTrace) {
4351
+ context.telemetryTrace.traceID = generateW3CId();
4352
+ var traceLocationName = "_unknown_";
4353
+ if (locn && locn.pathname) {
4354
+ traceLocationName = locn.pathname + (locn.hash || "");
4355
+ }
4356
+ context.telemetryTrace.name = dataSanitizeString(_self.diagLog(), traceLocationName);
4357
+ }
4358
+ }
4359
+ setTimeout((function (uri) {
4360
+ _self.trackPageView({ refUri: uri, properties: { duration: 0 } });
4361
+ }).bind(this, _prevUri), _self.autoRoutePVDelay);
4362
+ }
4363
+ }
4364
+ if (!_historyListenerAdded) {
4365
+ _addHook(InstrumentFunc(history, "pushState", {
4366
+ ns: _evtNamespace,
4367
+ rsp: function () {
4368
+ if (_enableAutoRouteTracking) {
4369
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "pushState"));
4370
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "locationchange"));
4371
+ }
4372
+ }
4373
+ }));
4374
+ _addHook(InstrumentFunc(history, "replaceState", {
4375
+ ns: _evtNamespace,
4376
+ rsp: function () {
4377
+ if (_enableAutoRouteTracking) {
4378
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "replaceState"));
4379
+ _dispatchEvent(win, createDomEvent(extConfig.namePrefix + "locationchange"));
4380
+ }
4381
+ }
4382
+ }));
4383
+ eventOn(win, extConfig.namePrefix + "popstate", _popstateHandler, _evtNamespace);
4384
+ eventOn(win, extConfig.namePrefix + "locationchange", _locationChangeHandler, _evtNamespace);
4385
+ _historyListenerAdded = true;
4386
+ }
3870
4387
  }
3871
- delete _events[name];
3872
- _events[name] = undefined;
3873
- };
4388
+ function _addUnhandledPromiseRejectionTracking(extConfig, _window, _location) {
4389
+ _enableUnhandledPromiseRejectionTracking = extConfig.enableUnhandledPromiseRejectionTracking === true;
4390
+ if (_enableUnhandledPromiseRejectionTracking && !_autoUnhandledPromiseInstrumented) {
4391
+ _addHook(InstrumentFunc(_window, "onunhandledrejection", {
4392
+ ns: _evtNamespace,
4393
+ rsp: function (callDetails, error) {
4394
+ if (_enableUnhandledPromiseRejectionTracking && callDetails.rslt !== true) {
4395
+ _self._onerror(Exception.CreateAutoException(_getReason(error), _location ? _location.href : "", 0, 0, error, callDetails.evt));
4396
+ }
4397
+ }
4398
+ }));
4399
+ _autoUnhandledPromiseInstrumented = true;
4400
+ extConfig.autoUnhandledPromiseInstrumented = _autoUnhandledPromiseInstrumented;
4401
+ }
4402
+ }
4403
+ function _throwInternal(severity, msgId, msg, properties, isUserAct) {
4404
+ _self.diagLog().throwInternal(severity, msgId, msg, properties, isUserAct);
4405
+ }
4406
+ function _initDefaults() {
4407
+ _eventTracking = null;
4408
+ _pageTracking = null;
4409
+ _pageViewManager = null;
4410
+ _pageViewPerformanceManager = null;
4411
+ _pageVisitTimeManager = null;
4412
+ _preInitTelemetryInitializers = null;
4413
+ _isBrowserLinkTrackingEnabled = false;
4414
+ _browserLinkInitializerAdded = false;
4415
+ _enableAutoRouteTracking = false;
4416
+ _historyListenerAdded = false;
4417
+ _disableExceptionTracking = false;
4418
+ _autoExceptionInstrumented = false;
4419
+ _enableUnhandledPromiseRejectionTracking = false;
4420
+ _autoUnhandledPromiseInstrumented = false;
4421
+ var location = getLocation(true);
4422
+ _prevUri = location && location.href || "";
4423
+ _currUri = null;
4424
+ _evtNamespace = null;
4425
+ }
4426
+ objDefineAccessors(_self, "_pageViewManager", function () { return _pageViewManager; });
4427
+ objDefineAccessors(_self, "_pageViewPerformanceManager", function () { return _pageViewPerformanceManager; });
4428
+ objDefineAccessors(_self, "_pageVisitTimeManager", function () { return _pageVisitTimeManager; });
4429
+ objDefineAccessors(_self, "_evtNamespace", function () { return "." + _evtNamespace; });
4430
+ });
4431
+ return _this;
3874
4432
  }
3875
- return Timing;
3876
- }());
4433
+ AnalyticsPlugin.Version = "2.8.0-beta.2203-05";
4434
+ AnalyticsPlugin.getDefaultConfig = _getDefaultConfig;
4435
+ return AnalyticsPlugin;
4436
+ }(BaseTelemetryPlugin));
3877
4437
 
3878
- exports.ApplicationInsights = ApplicationInsights;
4438
+ exports.AnalyticsPlugin = AnalyticsPlugin;
4439
+ exports.ApplicationInsights = AnalyticsPlugin;
3879
4440
 
3880
4441
  (function(obj, prop, descriptor) { /* ai_es3_polyfil defineProperty */ var func = Object["defineProperty"]; if (func) { try { return func(obj, prop, descriptor); } catch(e) { /* IE8 defines defineProperty, but will throw */ } } if (descriptor && typeof descriptor.value !== undefined) { obj[prop] = descriptor.value; } return obj; })(exports, '__esModule', { value: true });
3881
4442