@microsoft/applicationinsights-properties-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.
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "applicationinsights-properties-js",
3
- "version": "2.8.0-beta.2203-02",
3
+ "version": "2.8.0-beta.2203-05",
4
4
  "ext": {
5
5
  "@js": {
6
6
  "file": "applicationinsights-properties-js.js",
7
7
  "type": "text/javascript; charset=utf-8",
8
- "integrity": "sha256-PsEgMM/8lx4MJ+zBsjy+glkBlk7WS9soN+FGOKKWrLw= sha384-hdFZ3HzPLk+MllyS615v3BcrBfebmAabD5NWueRPJdghFaiW2vS2zUw5Q4nqqz2+ sha512-HIvSgynyxNVY0fv/cj8vmB1dtAL3KRe9Titg0dXRHawddV0/dmfANdIdJ3q8AndQ7d4QEfub5CC9Aaf+4TpfDA==",
8
+ "integrity": "sha256-YZ48jQOXWKEF6Q2wXkHfkXFB7iLhNl5obXDgcswxCIM= sha384-qFI5jwcgBSTKzdu9vMUG6TR/zHPaK4mI6h7lJvsPOI/4EjxqkU1SLm/cQNSAdcip sha512-+IBPN4C/ZPm6waiQUF1Ucz5JbeJ3Fb+Jqc+3XnVrwdKYh9BYWIPm6jZRb7xr571N8vUDOkgmpGxBaC0/fW/Sjw==",
9
9
  "hashes": {
10
- "sha256": "PsEgMM/8lx4MJ+zBsjy+glkBlk7WS9soN+FGOKKWrLw=",
11
- "sha384": "hdFZ3HzPLk+MllyS615v3BcrBfebmAabD5NWueRPJdghFaiW2vS2zUw5Q4nqqz2+",
12
- "sha512": "HIvSgynyxNVY0fv/cj8vmB1dtAL3KRe9Titg0dXRHawddV0/dmfANdIdJ3q8AndQ7d4QEfub5CC9Aaf+4TpfDA=="
10
+ "sha256": "YZ48jQOXWKEF6Q2wXkHfkXFB7iLhNl5obXDgcswxCIM=",
11
+ "sha384": "qFI5jwcgBSTKzdu9vMUG6TR/zHPaK4mI6h7lJvsPOI/4EjxqkU1SLm/cQNSAdcip",
12
+ "sha512": "+IBPN4C/ZPm6waiQUF1Ucz5JbeJ3Fb+Jqc+3XnVrwdKYh9BYWIPm6jZRb7xr571N8vUDOkgmpGxBaC0/fW/Sjw=="
13
13
  }
14
14
  },
15
15
  "@min.js": {
16
16
  "file": "applicationinsights-properties-js.min.js",
17
17
  "type": "text/javascript; charset=utf-8",
18
- "integrity": "sha256-L6FxejOcyvRRXgQa/30uHOdPvnj6+NpaxzuO8of/K+A= sha384-2+BDjhGcnDTCWZhn1YiqYmZN25pEMgyJer4QBGkExJKmmLxmHs34Ah/doOuT1lP/ sha512-Ck+CvCuHbkJlLNX2MPo7byJ0onmb4ogqUbr29HxzmwIcI/wmcsGoKWPqD7jJIxVuPWQYxVbtwA2vsdlqaYAjVg==",
18
+ "integrity": "sha256-LG8+owGxsqBiaqs4kDxa2q/b7r5bnrNqgmg26s0+vf0= sha384-1lTLSrIaKrv4aQC5CzCSeCcRsURd5zbKkqjACOoc3VAL6GJH2bvVQ8nCjjHo0myX sha512-5qcPNZj2GnDUxQukUikEz4BAtR7RPjjlO884xfewloZAB8mMKALEuR7uDqseiJLpzkmG0fmqz/jJamBtFr+oxw==",
19
19
  "hashes": {
20
- "sha256": "L6FxejOcyvRRXgQa/30uHOdPvnj6+NpaxzuO8of/K+A=",
21
- "sha384": "2+BDjhGcnDTCWZhn1YiqYmZN25pEMgyJer4QBGkExJKmmLxmHs34Ah/doOuT1lP/",
22
- "sha512": "Ck+CvCuHbkJlLNX2MPo7byJ0onmb4ogqUbr29HxzmwIcI/wmcsGoKWPqD7jJIxVuPWQYxVbtwA2vsdlqaYAjVg=="
20
+ "sha256": "LG8+owGxsqBiaqs4kDxa2q/b7r5bnrNqgmg26s0+vf0=",
21
+ "sha384": "1lTLSrIaKrv4aQC5CzCSeCcRsURd5zbKkqjACOoc3VAL6GJH2bvVQ8nCjjHo0myX",
22
+ "sha512": "5qcPNZj2GnDUxQukUikEz4BAtR7RPjjlO884xfewloZAB8mMKALEuR7uDqseiJLpzkmG0fmqz/jJamBtFr+oxw=="
23
23
  }
24
24
  }
25
25
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.8.0-beta.2203-02
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.0-beta.2203-05
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -327,6 +327,7 @@
327
327
  var strIsInitialized = "isInitialized";
328
328
  var strTeardown = "teardown";
329
329
  var strCore = "core";
330
+ var strUpdate = "update";
330
331
  var strDisabled = "disabled";
331
332
  var strDoTeardown = "_doTeardown";
332
333
 
@@ -603,6 +604,33 @@
603
604
  function throwError(message) {
604
605
  throw new Error(message);
605
606
  }
607
+ function _createProxyFunction(source, funcName) {
608
+ var srcFunc = null;
609
+ var src = null;
610
+ if (isFunction(source)) {
611
+ srcFunc = source;
612
+ }
613
+ else {
614
+ src = source;
615
+ }
616
+ return function () {
617
+ var originalArguments = arguments;
618
+ if (srcFunc) {
619
+ src = srcFunc();
620
+ }
621
+ if (src) {
622
+ return src[funcName].apply(src, originalArguments);
623
+ }
624
+ };
625
+ }
626
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
627
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
628
+ if (target && name && source) {
629
+ if (overwriteTarget || isUndefined(target[name])) {
630
+ target[name] = _createProxyFunction(source, theFunc);
631
+ }
632
+ }
633
+ }
606
634
  function createClassFromInterface(defaults) {
607
635
  return /** @class */ (function () {
608
636
  function class_1() {
@@ -621,13 +649,13 @@
621
649
  objForEachKey(values, function (field, value) {
622
650
  enumClass[field] = value;
623
651
  if (!isUndefined(enumClass[value])) {
624
- throwError("Value: [" + value + "] already exists for " + field);
652
+ throwError("[" + value + "] exists for " + field);
625
653
  }
626
654
  enumClass[value] = field;
627
655
  });
628
656
  return objFreeze(enumClass);
629
657
  }
630
- function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
658
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
631
659
  var theArgs = arguments;
632
660
  var extended = theArgs[0] || {};
633
661
  var argLen = theArgs.length;
@@ -937,6 +965,10 @@
937
965
  }
938
966
  return DiagnosticLogger;
939
967
  }());
968
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
969
+ if (isUserAct === void 0) { isUserAct = false; }
970
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
971
+ }
940
972
 
941
973
  var strExecutionContextKey = "ctx";
942
974
  var PerfEvent = /** @class */ (function () {
@@ -1209,8 +1241,11 @@
1209
1241
  return createTelemetryProxyChain([startAt], config, core);
1210
1242
  }
1211
1243
  function _createInternalContext(telemetryChain, config, core, startAt) {
1212
- var _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1244
+ var _nextProxy = null;
1213
1245
  var _onComplete = [];
1246
+ if (startAt !== null) {
1247
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1248
+ }
1214
1249
  var context = {
1215
1250
  _next: _moveNext,
1216
1251
  ctx: {
@@ -1260,7 +1295,7 @@
1260
1295
  completeDetails.func.call(completeDetails.self, completeDetails.args);
1261
1296
  }
1262
1297
  catch (e) {
1263
- core.logger.throwInternal(2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1298
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1264
1299
  }
1265
1300
  });
1266
1301
  _onComplete = [];
@@ -1359,6 +1394,27 @@
1359
1394
  context.createNew = _createNew;
1360
1395
  return context;
1361
1396
  }
1397
+ function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1398
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1399
+ var context = internalContext.ctx;
1400
+ function _processNext(updateState) {
1401
+ return context.iterate(function (plugin) {
1402
+ if (isFunction(plugin[strUpdate])) {
1403
+ plugin[strUpdate](context, updateState);
1404
+ }
1405
+ });
1406
+ }
1407
+ function _createNew(plugins, startAt) {
1408
+ if (plugins === void 0) { plugins = null; }
1409
+ if (isArray(plugins)) {
1410
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1411
+ }
1412
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1413
+ }
1414
+ context.processNext = _processNext;
1415
+ context.createNew = _createNew;
1416
+ return context;
1417
+ }
1362
1418
  function createTelemetryProxyChain(plugins, config, core, startAt) {
1363
1419
  var firstProxy = null;
1364
1420
  var add = startAt ? false : true;
@@ -1405,6 +1461,7 @@
1405
1461
  },
1406
1462
  processTelemetry: _processTelemetry,
1407
1463
  unload: _unloadPlugin,
1464
+ update: _updatePlugin,
1408
1465
  _id: chainId,
1409
1466
  _setNext: function (nextPlugin) {
1410
1467
  nextProxy = nextPlugin;
@@ -1444,7 +1501,7 @@
1444
1501
  hasRun = true;
1445
1502
  }
1446
1503
  if (!nextProxy || !hasNextRun) {
1447
- itemCtx.diagLog().throwInternal(1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1504
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1448
1505
  }
1449
1506
  }
1450
1507
  }, details, isAsync);
@@ -1492,6 +1549,24 @@
1492
1549
  unloadCtx.processNext(unloadState);
1493
1550
  }
1494
1551
  }
1552
+ function _updatePlugin(updateCtx, updateState) {
1553
+ function _callUpdate() {
1554
+ var hasRun = false;
1555
+ if (plugin) {
1556
+ var pluginState = _getPluginState(plugin);
1557
+ var pluginCore = plugin[strCore] || pluginState.core;
1558
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1559
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1560
+ hasRun = true;
1561
+ }
1562
+ }
1563
+ }
1564
+ return hasRun;
1565
+ }
1566
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1567
+ updateCtx.processNext(updateState);
1568
+ }
1569
+ }
1495
1570
  return objFreeze(proxyChain);
1496
1571
  }
1497
1572
 
@@ -1661,7 +1736,7 @@
1661
1736
  _supportsCookies = doc[strCookie] !== undefined;
1662
1737
  }
1663
1738
  catch (e) {
1664
- logger && logger.throwInternal(2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1739
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
1665
1740
  }
1666
1741
  }
1667
1742
  return _supportsCookies;
@@ -1742,6 +1817,30 @@
1742
1817
 
1743
1818
  var strExtensionConfig = "extensionConfig";
1744
1819
 
1820
+ function createUnloadHandlerContainer() {
1821
+ var handlers = [];
1822
+ function _addHandler(handler) {
1823
+ if (handler) {
1824
+ handlers.push(handler);
1825
+ }
1826
+ }
1827
+ function _runHandlers(unloadCtx, unloadState) {
1828
+ arrForEach(handlers, function (handler) {
1829
+ try {
1830
+ handler(unloadCtx, unloadState);
1831
+ }
1832
+ catch (e) {
1833
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1834
+ }
1835
+ });
1836
+ handlers = [];
1837
+ }
1838
+ return {
1839
+ add: _addHandler,
1840
+ run: _runHandlers
1841
+ };
1842
+ }
1843
+
1745
1844
  var strGetPlugin = "getPlugin";
1746
1845
  var BaseTelemetryPlugin = /** @class */ (function () {
1747
1846
  function BaseTelemetryPlugin() {
@@ -1749,6 +1848,7 @@
1749
1848
  var _isinitialized;
1750
1849
  var _rootCtx;
1751
1850
  var _nextPlugin;
1851
+ var _unloadHandlerContainer;
1752
1852
  var _hooks;
1753
1853
  _initDefaults();
1754
1854
  dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
@@ -1770,6 +1870,7 @@
1770
1870
  function _unloadCallback() {
1771
1871
  if (!unloadDone) {
1772
1872
  unloadDone = true;
1873
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1773
1874
  arrForEach(_hooks, function (fn) {
1774
1875
  fn.rm();
1775
1876
  });
@@ -1788,6 +1889,30 @@
1788
1889
  }
1789
1890
  return result;
1790
1891
  };
1892
+ _self.update = function (updateCtx, updateState) {
1893
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
1894
+ return;
1895
+ }
1896
+ var result;
1897
+ var updateDone = false;
1898
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1899
+ var theUpdateState = updateState || {
1900
+ reason: 0
1901
+ };
1902
+ function _updateCallback() {
1903
+ if (!updateDone) {
1904
+ updateDone = true;
1905
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
1906
+ }
1907
+ }
1908
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
1909
+ _updateCallback();
1910
+ }
1911
+ else {
1912
+ result = true;
1913
+ }
1914
+ return result;
1915
+ };
1791
1916
  _self._addHook = function (hooks) {
1792
1917
  if (hooks) {
1793
1918
  if (isArray(hooks)) {
@@ -1798,6 +1923,7 @@
1798
1923
  }
1799
1924
  }
1800
1925
  };
1926
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1801
1927
  });
1802
1928
  _self.diagLog = function (itemCtx) {
1803
1929
  return _getTelCtx(itemCtx).diagLog();
@@ -1854,6 +1980,7 @@
1854
1980
  _rootCtx = null;
1855
1981
  _nextPlugin = null;
1856
1982
  _hooks = [];
1983
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1857
1984
  }
1858
1985
  }
1859
1986
  return BaseTelemetryPlugin;
@@ -1987,7 +2114,7 @@
1987
2114
  name = strTrim(name.toString());
1988
2115
  if (name.length > 150 ) {
1989
2116
  nameTrunc = name.substring(0, 150 );
1990
- logger && logger.throwInternal(2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
2117
+ _throwInternal(logger, 2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
1991
2118
  }
1992
2119
  }
1993
2120
  return nameTrunc || name;
@@ -2000,7 +2127,7 @@
2000
2127
  value = strTrim(value);
2001
2128
  if (value.toString().length > maxLength) {
2002
2129
  valueTrunc = value.toString().substring(0, maxLength);
2003
- logger && logger.throwInternal(2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2130
+ _throwInternal(logger, 2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
2004
2131
  }
2005
2132
  }
2006
2133
  return valueTrunc || value;
@@ -2017,7 +2144,7 @@
2017
2144
  value = getJSON().stringify(value);
2018
2145
  }
2019
2146
  catch (e) {
2020
- logger && logger.throwInternal(2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2147
+ _throwInternal(logger, 2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
2021
2148
  }
2022
2149
  }
2023
2150
  value = dataSanitizeString(logger, value, 8192 );
@@ -2048,7 +2175,7 @@
2048
2175
  input = strTrim(input);
2049
2176
  if (input.length > maxLength) {
2050
2177
  inputTrunc = input.substring(0, maxLength);
2051
- logger && logger.throwInternal(2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2178
+ _throwInternal(logger, 2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
2052
2179
  }
2053
2180
  }
2054
2181
  return inputTrunc || input;
@@ -2123,8 +2250,8 @@
2123
2250
  }
2124
2251
  return null;
2125
2252
  }
2126
- function utlCanUseLocalStorage() {
2127
- if (_canUseLocalStorage === undefined) {
2253
+ function utlCanUseLocalStorage(reset) {
2254
+ if (reset || _canUseLocalStorage === undefined) {
2128
2255
  _canUseLocalStorage = !!_getVerifiedStorageObject(StorageType.LocalStorage);
2129
2256
  }
2130
2257
  return _canUseLocalStorage;
@@ -2137,7 +2264,7 @@
2137
2264
  }
2138
2265
  catch (e) {
2139
2266
  _canUseLocalStorage = false;
2140
- logger.throwInternal(2 , _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2267
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2141
2268
  }
2142
2269
  }
2143
2270
  return null;
@@ -2151,7 +2278,7 @@
2151
2278
  }
2152
2279
  catch (e) {
2153
2280
  _canUseLocalStorage = false;
2154
- logger.throwInternal(2 , _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2281
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + getExceptionName(e), { exception: dumpObj(e) });
2155
2282
  }
2156
2283
  }
2157
2284
  return false;
@@ -2165,7 +2292,7 @@
2165
2292
  }
2166
2293
  catch (e) {
2167
2294
  _canUseLocalStorage = false;
2168
- logger.throwInternal(2 , _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2295
+ _throwInternal(logger, 2 , _InternalMessageId.BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + getExceptionName(e), { exception: dumpObj(e) });
2169
2296
  }
2170
2297
  }
2171
2298
  return false;
@@ -2467,7 +2594,7 @@
2467
2594
  return Device;
2468
2595
  }());
2469
2596
 
2470
- var Version = "2.8.0-beta.2203-02";
2597
+ var Version = "2.8.0-beta.2203-05";
2471
2598
  var Internal = /** @class */ (function () {
2472
2599
  function Internal(config) {
2473
2600
  this.sdkVersion = (config.sdkExtension && config.sdkExtension() ? config.sdkExtension() + "_" : "") + "javascript:" + Version;