@microsoft/applicationinsights-core-js 2.8.5-nightly.2206-03 → 2.8.5-nightly.2207-01

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 (133) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +807 -711
  3. package/browser/applicationinsights-core-js.js.map +1 -1
  4. package/browser/applicationinsights-core-js.min.js +2 -2
  5. package/browser/applicationinsights-core-js.min.js.map +1 -1
  6. package/dist/applicationinsights-core-js.api.json +400 -336
  7. package/dist/applicationinsights-core-js.d.ts +1 -1
  8. package/dist/applicationinsights-core-js.js +807 -711
  9. package/dist/applicationinsights-core-js.js.map +1 -1
  10. package/dist/applicationinsights-core-js.min.js +2 -2
  11. package/dist/applicationinsights-core-js.min.js.map +1 -1
  12. package/dist/applicationinsights-core-js.rollup.d.ts +1 -1
  13. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +14 -10
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  15. package/dist-esm/JavaScriptSDK/BaseCore.js +158 -139
  16. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +39 -36
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  19. package/dist-esm/JavaScriptSDK/ChannelController.js +60 -61
  20. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  21. package/dist-esm/JavaScriptSDK/CookieMgr.js +46 -43
  22. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  23. package/dist-esm/JavaScriptSDK/CoreUtils.js +16 -15
  24. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +7 -5
  26. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +4 -3
  28. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js.map +1 -1
  29. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +56 -56
  30. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  31. package/dist-esm/JavaScriptSDK/EnvUtils.js +21 -20
  32. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  33. package/dist-esm/JavaScriptSDK/EventHelpers.js +45 -39
  34. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  35. package/dist-esm/JavaScriptSDK/HelperFuncs.js +49 -40
  36. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  37. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +18 -16
  38. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  39. package/dist-esm/JavaScriptSDK/InternalConstants.js +19 -21
  40. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/NotificationManager.js +26 -23
  42. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/PerfManager.js +41 -35
  44. package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +54 -53
  46. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  47. package/dist-esm/JavaScriptSDK/RandomHelper.js +5 -4
  48. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  49. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +34 -34
  50. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  51. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +11 -10
  52. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  53. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +4 -3
  54. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -1
  55. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +26 -23
  56. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  57. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +103 -86
  60. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  61. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  70. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  85. package/dist-esm/__DynamicConstants.js +70 -0
  86. package/dist-esm/__DynamicConstants.js.map +1 -0
  87. package/dist-esm/applicationinsights-core-js.js +1 -1
  88. package/package.json +5 -2
  89. package/src/JavaScriptSDK/AppInsightsCore.ts +17 -17
  90. package/src/JavaScriptSDK/BaseCore.ts +112 -97
  91. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +36 -32
  92. package/src/JavaScriptSDK/ChannelController.ts +39 -37
  93. package/src/JavaScriptSDK/CookieMgr.ts +27 -27
  94. package/src/JavaScriptSDK/CoreUtils.ts +19 -20
  95. package/src/JavaScriptSDK/DataCacheHelper.ts +12 -11
  96. package/src/JavaScriptSDK/DbgExtensionUtils.ts +9 -9
  97. package/src/JavaScriptSDK/DiagnosticLogger.ts +49 -50
  98. package/src/JavaScriptSDK/EnvUtils.ts +15 -17
  99. package/src/JavaScriptSDK/EventHelpers.ts +15 -14
  100. package/src/JavaScriptSDK/HelperFuncs.ts +20 -11
  101. package/src/JavaScriptSDK/InstrumentHooks.ts +11 -13
  102. package/src/JavaScriptSDK/InternalConstants.ts +20 -20
  103. package/src/JavaScriptSDK/NotificationManager.ts +27 -27
  104. package/src/JavaScriptSDK/PerfManager.ts +21 -19
  105. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +38 -34
  106. package/src/JavaScriptSDK/RandomHelper.ts +8 -9
  107. package/src/JavaScriptSDK/TelemetryHelpers.ts +33 -34
  108. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +17 -16
  109. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +11 -11
  110. package/src/JavaScriptSDK/W3cTraceParent.ts +6 -6
  111. package/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts +1 -1
  112. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +72 -56
  113. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +1 -1
  114. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +2 -2
  115. package/types/JavaScriptSDK/AppInsightsCore.d.ts +4 -4
  116. package/types/JavaScriptSDK/BaseCore.d.ts +11 -11
  117. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +4 -4
  118. package/types/JavaScriptSDK/ChannelController.d.ts +1 -2
  119. package/types/JavaScriptSDK/CookieMgr.d.ts +3 -3
  120. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +2 -2
  121. package/types/JavaScriptSDK/HelperFuncs.d.ts +6 -0
  122. package/types/JavaScriptSDK/InstrumentHooks.d.ts +1 -1
  123. package/types/JavaScriptSDK/InternalConstants.d.ts +16 -20
  124. package/types/JavaScriptSDK/NotificationManager.d.ts +1 -1
  125. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +2 -2
  126. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +4 -4
  127. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +2 -2
  128. package/types/__DynamicConstants.d.ts +56 -0
  129. package/types/tsdoc-metadata.json +1 -1
  130. package/dist-esm/JavaScriptSDK/Constants.js +0 -9
  131. package/dist-esm/JavaScriptSDK/Constants.js.map +0 -1
  132. package/src/JavaScriptSDK/Constants.ts +0 -5
  133. package/types/JavaScriptSDK/Constants.d.ts +0 -2
@@ -1,24 +1,26 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // // Licensed under the MIT License.
3
-
4
- import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
5
- import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
6
- import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
7
- import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
8
- import { IChannelControls } from "../JavaScriptSDK.Interfaces/IChannelControls";
9
- import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
10
- import { IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
11
- import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
12
- import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
13
- import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
14
- import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
15
- import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
16
- import { arrForEach, isArray, objFreeze, throwError } from "./HelperFuncs";
17
- import { strPause, strProcessNext, strResume, strTeardown } from "./InternalConstants";
18
- import { createProcessTelemetryContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
19
- import { initializePlugins } from "./TelemetryHelpers";
20
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // // Licensed under the MIT License.
3
+
4
+ import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
5
+ import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
6
+ import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
7
+ import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
8
+ import { IChannelControls } from "../JavaScriptSDK.Interfaces/IChannelControls";
9
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
10
+ import {
11
+ IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext
12
+ } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
13
+ import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
14
+ import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
15
+ import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
16
+ import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
17
+ import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
18
+ import { arrForEach, isArray, objFreeze, throwError } from "./HelperFuncs";
19
+ import { createProcessTelemetryContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
20
+ import { initializePlugins } from "./TelemetryHelpers";
21
+
21
22
  export const ChannelControllerPriority = 500;
23
+
22
24
  const ChannelValidationMessage = "Channel has invalid priority - ";
23
25
 
24
26
  export interface IChannelController extends IChannelControls {
@@ -36,7 +38,7 @@ export interface _IInternalChannels {
36
38
  chain: ITelemetryPluginChain;
37
39
  }
38
40
 
39
- function _addChannelQueue(channelQueue: _IInternalChannels[], queue: IChannelControls[], config: IConfiguration, core: IAppInsightsCore) {
41
+ function _addChannelQueue(channelQueue: _IInternalChannels[], queue: IChannelControls[], core: IAppInsightsCore) {
40
42
  if (queue && isArray(queue) && queue.length > 0) {
41
43
  queue = queue.sort((a, b) => { // sort based on priority within each queue
42
44
  return a.priority - b.priority;
@@ -50,7 +52,7 @@ function _addChannelQueue(channelQueue: _IInternalChannels[], queue: IChannelCon
50
52
 
51
53
  channelQueue.push({
52
54
  queue: objFreeze(queue),
53
- chain: createTelemetryProxyChain(queue, config, core)
55
+ chain: createTelemetryProxyChain(queue, core.config, core)
54
56
  });
55
57
  }
56
58
  }
@@ -98,9 +100,9 @@ export function createChannelControllerPlugin(channelQueue: _IInternalChannels[]
98
100
  };
99
101
 
100
102
  _processChannelQueue(channelQueue, updateCtx, (chainCtx: IProcessTelemetryUpdateContext) => {
101
- chainCtx[strProcessNext](theUpdateState);
103
+ chainCtx.processNext(theUpdateState);
102
104
  }, () => {
103
- updateCtx[strProcessNext](theUpdateState);
105
+ updateCtx.processNext(theUpdateState);
104
106
  });
105
107
 
106
108
  return true;
@@ -113,9 +115,9 @@ export function createChannelControllerPlugin(channelQueue: _IInternalChannels[]
113
115
  };
114
116
 
115
117
  _processChannelQueue(channelQueue, unloadCtx, (chainCtx: IProcessTelemetryUnloadContext) => {
116
- chainCtx[strProcessNext](theUnloadState);
118
+ chainCtx.processNext(theUnloadState);
117
119
  }, () => {
118
- unloadCtx[strProcessNext](theUnloadState);
120
+ unloadCtx.processNext(theUnloadState);
119
121
  isInitialized = false;
120
122
  });
121
123
 
@@ -165,27 +167,27 @@ export function createChannelControllerPlugin(channelQueue: _IInternalChannels[]
165
167
  },
166
168
  processTelemetry: (item: ITelemetryItem, itemCtx: IProcessTelemetryContext) => {
167
169
  _processChannelQueue(channelQueue, itemCtx || _getTelCtx(), (chainCtx: IProcessTelemetryContext) => {
168
- chainCtx[strProcessNext](item);
170
+ chainCtx.processNext(item);
169
171
  }, () => {
170
- itemCtx[strProcessNext](item);
172
+ itemCtx.processNext(item);
171
173
  });
172
174
  },
173
175
  update: _doUpdate,
174
- [strPause]: () => {
176
+ pause: () => {
175
177
  _processChannelQueue(channelQueue, _getTelCtx(), (chainCtx: IProcessTelemetryContext) => {
176
178
  chainCtx.iterate<IChannelControls>((plugin) => {
177
- plugin[strPause] && plugin[strPause]();
179
+ plugin.pause && plugin.pause();
178
180
  });
179
181
  }, null);
180
182
  },
181
- [strResume]: () => {
183
+ resume: () => {
182
184
  _processChannelQueue(channelQueue, _getTelCtx(), (chainCtx: IProcessTelemetryContext) => {
183
185
  chainCtx.iterate<IChannelControls>((plugin) => {
184
- plugin[strResume] && plugin[strResume]();
186
+ plugin.resume && plugin.resume();
185
187
  });
186
188
  }, null);
187
189
  },
188
- [strTeardown]: _doTeardown,
190
+ teardown: _doTeardown,
189
191
  getChannel: _getChannel,
190
192
  flush: (isAsync: boolean, callBack: (flushComplete?: boolean) => void, sendReason: SendRequestReason, cbTimeout?: number) => {
191
193
  // Setting waiting to one so that we don't call the callBack until we finish iterating
@@ -250,12 +252,12 @@ export function createChannelControllerPlugin(channelQueue: _IInternalChannels[]
250
252
  return channelController;
251
253
  }
252
254
 
253
- export function createChannelQueues(channels: IChannelControls[][], extensions: IPlugin[], config: IConfiguration, core: IAppInsightsCore) {
255
+ export function createChannelQueues(channels: IChannelControls[][], extensions: IPlugin[], core: IAppInsightsCore) {
254
256
  let channelQueue: _IInternalChannels[] = [];
255
257
 
256
258
  if (channels) {
257
259
  // Add and sort the configuration channel queues
258
- arrForEach(channels, queue => _addChannelQueue(channelQueue, queue, config, core));
260
+ arrForEach(channels, queue => _addChannelQueue(channelQueue, queue, core));
259
261
  }
260
262
 
261
263
  if (extensions) {
@@ -267,8 +269,8 @@ export function createChannelQueues(channels: IChannelControls[][], extensions:
267
269
  }
268
270
  });
269
271
 
270
- _addChannelQueue(channelQueue, extensionQueue, config, core);
272
+ _addChannelQueue(channelQueue, extensionQueue, core);
271
273
  }
272
274
 
273
275
  return channelQueue;
274
- }
276
+ }
@@ -1,18 +1,18 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
- import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
4
- import { ICookieMgr, ICookieMgrConfig } from "../JavaScriptSDK.Interfaces/ICookieMgr";
5
- import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
6
- import { dumpObj, getDocument, getLocation, getNavigator, isIE } from "./EnvUtils";
7
- import {
8
- arrForEach, dateNow, getExceptionName, isFunction, isNotNullOrUndefined, isNullOrUndefined, isString, isTruthy, isUndefined,
9
- objForEachKey, setValue, strContains, strEndsWith, strTrim
10
- } from "./HelperFuncs";
11
- import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
12
- import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
13
- import { strEmpty } from "./InternalConstants";
14
- import { _throwInternal } from "./DiagnosticLogger";
15
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
4
+ import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
5
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
6
+ import { ICookieMgr, ICookieMgrConfig } from "../JavaScriptSDK.Interfaces/ICookieMgr";
7
+ import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
8
+ import { _throwInternal } from "./DiagnosticLogger";
9
+ import { dumpObj, getDocument, getLocation, getNavigator, isIE } from "./EnvUtils";
10
+ import {
11
+ arrForEach, dateNow, getExceptionName, isFunction, isNotNullOrUndefined, isNullOrUndefined, isString, isTruthy, isUndefined,
12
+ objForEachKey, setValue, strContains, strEndsWith, strTrim
13
+ } from "./HelperFuncs";
14
+ import { STR_EMPTY } from "./InternalConstants";
15
+
16
16
  const strToGMTString = "toGMTString";
17
17
  const strToUTCString = "toUTCString";
18
18
  const strCookie = "cookie";
@@ -140,7 +140,7 @@ export function createCookieMgr(rootConfig?: IConfiguration, logger?: IDiagnosti
140
140
  let result = false;
141
141
  if (_isMgrEnabled(cookieMgr)) {
142
142
  let values: any = {};
143
- let theValue = strTrim(value || strEmpty);
143
+ let theValue = strTrim(value || STR_EMPTY);
144
144
  let idx = theValue.indexOf(";");
145
145
  if (idx !== -1) {
146
146
  theValue = strTrim(value.substring(0, idx));
@@ -162,14 +162,14 @@ export function createCookieMgr(rootConfig?: IConfiguration, logger?: IDiagnosti
162
162
  let expiry = new Date();
163
163
  expiry.setTime(expireMs);
164
164
  setValue(values, strExpires,
165
- _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty,
165
+ _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY,
166
166
  isTruthy);
167
167
  }
168
168
  }
169
169
 
170
170
  if (!_isIE) {
171
171
  // Only replace if not already present
172
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
172
+ setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
173
173
  }
174
174
  }
175
175
 
@@ -197,7 +197,7 @@ export function createCookieMgr(rootConfig?: IConfiguration, logger?: IDiagnosti
197
197
  return result;
198
198
  },
199
199
  get: (name: string): string => {
200
- let value = strEmpty
200
+ let value = STR_EMPTY
201
201
  if (_isMgrEnabled(cookieMgr)) {
202
202
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
203
203
  }
@@ -228,7 +228,7 @@ export function createCookieMgr(rootConfig?: IConfiguration, logger?: IDiagnosti
228
228
  }
229
229
 
230
230
  let delCookie = cookieMgrConfig.delCookie || _setCookieValue;
231
- delCookie(name, _formatCookieValue(strEmpty, values));
231
+ delCookie(name, _formatCookieValue(STR_EMPTY, values));
232
232
  result = true;
233
233
  }
234
234
 
@@ -270,7 +270,7 @@ function _extractParts(theValue: string) {
270
270
  if (theValue && theValue.length) {
271
271
  let parts = strTrim(theValue).split(";");
272
272
  arrForEach(parts, (thePart) => {
273
- thePart = strTrim(thePart || strEmpty);
273
+ thePart = strTrim(thePart || STR_EMPTY);
274
274
  if (thePart) {
275
275
  let idx = thePart.indexOf("=");
276
276
  if (idx === -1) {
@@ -294,24 +294,24 @@ function _formatDate(theDate: Date, func: string) {
294
294
  }
295
295
 
296
296
  function _formatCookieValue(value: string, values: any) {
297
- let cookieValue = value || strEmpty;
297
+ let cookieValue = value || STR_EMPTY;
298
298
  objForEachKey(values, (name, theValue) => {
299
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
299
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : STR_EMPTY);
300
300
  });
301
301
 
302
302
  return cookieValue;
303
303
  }
304
304
 
305
305
  function _getCookieValue(name: string) {
306
- let cookieValue = strEmpty;
306
+ let cookieValue = STR_EMPTY;
307
307
  if (_doc) {
308
- let theCookie = _doc[strCookie] || strEmpty;
308
+ let theCookie = _doc[strCookie] || STR_EMPTY;
309
309
  if (_parsedCookieValue !== theCookie) {
310
310
  _cookieCache = _extractParts(theCookie);
311
311
  _parsedCookieValue = theCookie;
312
312
  }
313
313
 
314
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
314
+ cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);
315
315
  }
316
316
 
317
317
  return cookieValue;
@@ -380,4 +380,4 @@ export function uaDisallowsSameSiteNone(userAgent: string) {
380
380
  }
381
381
 
382
382
  return false;
383
- }
383
+ }
@@ -1,21 +1,20 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
- "use strict";
4
- import { objCreateFn, strShimUndefined } from "@microsoft/applicationinsights-shims";
5
- import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
6
- import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
7
- import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
8
- import { _gblCookieMgr } from "./CookieMgr";
9
- import { getPerformance, isIE } from "./EnvUtils";
10
- import {
11
- arrForEach, arrIndexOf, arrMap, arrReduce, dateNow, hasOwnProperty,
12
- isArray, isBoolean, isDate, isError, isFunction, isNullOrUndefined, isNumber, isObject, isString, isTypeof,
13
- isUndefined, objDefineAccessors, objKeys, strTrim, toISOString
14
- } from "./HelperFuncs";
15
- import { addEventHandler, attachEvent, detachEvent } from "./EventHelpers";
16
- import { randomValue, random32, mwcRandomSeed, mwcRandom32, newId } from "./RandomHelper";
17
- import { strEmpty } from "./InternalConstants";
18
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ "use strict";
4
+ import { objCreateFn, strShimUndefined } from "@microsoft/applicationinsights-shims";
5
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
6
+ import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
7
+ import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
8
+ import { _gblCookieMgr } from "./CookieMgr";
9
+ import { getPerformance, isIE } from "./EnvUtils";
10
+ import { addEventHandler, attachEvent, detachEvent } from "./EventHelpers";
11
+ import {
12
+ arrForEach, arrIndexOf, arrMap, arrReduce, dateNow, hasOwnProperty, isArray, isBoolean, isDate, isError, isFunction, isNullOrUndefined,
13
+ isNumber, isObject, isString, isTypeof, isUndefined, objDefineAccessors, objKeys, strTrim, toISOString
14
+ } from "./HelperFuncs";
15
+ import { STR_EMPTY } from "./InternalConstants";
16
+ import { mwcRandom32, mwcRandomSeed, newId, random32, randomValue } from "./RandomHelper";
17
+
19
18
  let _cookieMgrs: ICookieMgr[] = null;
20
19
  let _canUseCookies: boolean; // legacy supported config
21
20
 
@@ -68,7 +67,7 @@ export function generateW3CId(): string {
68
67
  const hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
69
68
 
70
69
  // rfc4122 version 4 UUID without dashes and with lowercase letters
71
- let oct = strEmpty, tmp;
70
+ let oct = STR_EMPTY, tmp;
72
71
  for (let a = 0; a < 4; a++) {
73
72
  tmp = random32();
74
73
  oct +=
@@ -486,4 +485,4 @@ export function setCookie(logger: IDiagnosticLogger, name: string, value: string
486
485
  */
487
486
  export function deleteCookie(logger: IDiagnosticLogger, name: string) {
488
487
  return _legacyCookieMgr(null, logger).del(name);
489
- }
488
+ }
@@ -1,13 +1,14 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
-
4
- import { ObjDefineProperty } from "@microsoft/applicationinsights-shims";
5
- import { normalizeJsName } from "./HelperFuncs";
6
- import { newId } from "./RandomHelper";
7
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ import { ObjDefineProperty } from "@microsoft/applicationinsights-shims";
5
+ import { normalizeJsName } from "./HelperFuncs";
6
+ import { STR_EMPTY } from "./InternalConstants";
7
+ import { newId } from "./RandomHelper";
8
+
8
9
  const _objDefineProperty = ObjDefineProperty;
9
10
 
10
- const version = "2.8.5-nightly.2206-03";
11
+ const version = "#version#";
11
12
  let instanceName = "." + newId(6);
12
13
  let _dataUid = 0;
13
14
 
@@ -67,13 +68,13 @@ function _getCache(data: IDataCache, target: Node) {
67
68
  }
68
69
 
69
70
  export function createUniqueNamespace(name: string, includeVersion: boolean = false): string {
70
- return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
71
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : STR_EMPTY) + instanceName);
71
72
  }
72
73
 
73
74
  export function createElmNodeData(name?: string) {
74
75
 
75
76
  let data = {
76
- id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
77
+ id: createUniqueNamespace("_aiData-" + (name || STR_EMPTY) + "." + version),
77
78
  accept: function (target: any) {
78
79
  return _canAcceptData(target);
79
80
  },
@@ -103,4 +104,4 @@ export function createElmNodeData(name?: string) {
103
104
  };
104
105
 
105
106
  return data;
106
- }
107
+ }
@@ -1,11 +1,11 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
-
4
- import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
5
- import { IDbgExtension } from "../JavaScriptSDK.Interfaces/IDbgExtension";
6
- import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
7
- import { getGlobalInst } from "./EnvUtils";
8
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
5
+ import { IDbgExtension } from "../JavaScriptSDK.Interfaces/IDbgExtension";
6
+ import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
7
+ import { getGlobalInst } from "./EnvUtils";
8
+
9
9
  const listenerFuncs = [ "eventsSent", "eventsDiscarded", "eventsSendRequest", "perfEvent" ];
10
10
 
11
11
  let _aiNamespace: any = null;
@@ -52,4 +52,4 @@ export function getDebugListener(config: IConfiguration): INotificationListener
52
52
  }
53
53
 
54
54
  return _debugListener;
55
- }
55
+ }
@@ -1,16 +1,16 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
- "use strict"
4
- import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"
5
- import { _InternalMessageId, _eInternalMessageId, LoggingSeverity, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
6
- import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
7
- import { hasJSON, getJSON, getConsole, dumpObj } from "./EnvUtils";
8
- import dynamicProto from "@microsoft/dynamicproto-js";
9
- import { isFunction, isNullOrUndefined, isUndefined } from "./HelperFuncs";
10
- import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
11
- import { getDebugExt } from "./DbgExtensionUtils";
12
- import { strEmpty } from "./InternalConstants";
13
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ "use strict"
4
+ import dynamicProto from "@microsoft/dynamicproto-js";
5
+ import { LoggingSeverity, _InternalMessageId, _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
6
+ import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
7
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
8
+ import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
9
+ import { getDebugExt } from "./DbgExtensionUtils";
10
+ import { dumpObj, getConsole, getJSON, hasJSON } from "./EnvUtils";
11
+ import { getCfgValue, isFunction, isUndefined } from "./HelperFuncs";
12
+ import { STR_EMPTY, STR_ERROR_TO_CONSOLE, STR_WARN_TO_CONSOLE } from "./InternalConstants";
13
+
14
14
  /**
15
15
  * For user non actionable traces use AI Internal prefix.
16
16
  */
@@ -26,15 +26,12 @@ const AiUserActionablePrefix = "AI: ";
26
26
  */
27
27
  const AIInternalMessagePrefix = "AITR_";
28
28
 
29
- const strErrorToConsole = "errorToConsole";
30
- const strWarnToConsole = "warnToConsole";
31
-
32
29
  function _sanitizeDiagnosticText(text: string) {
33
30
  if (text) {
34
- return "\"" + text.replace(/\"/g, strEmpty) + "\"";
31
+ return "\"" + text.replace(/\"/g, STR_EMPTY) + "\"";
35
32
  }
36
33
 
37
- return strEmpty;
34
+ return STR_EMPTY;
38
35
  }
39
36
 
40
37
  function _logToConsole(func: string, message: string) {
@@ -65,14 +62,14 @@ export class _InternalLogMessage{
65
62
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
66
63
  msgId;
67
64
 
68
- let strProps:string = strEmpty;
65
+ let strProps:string = STR_EMPTY;
69
66
  if (hasJSON()) {
70
67
  strProps = getJSON().stringify(properties);
71
68
  }
72
69
 
73
70
  const diagnosticText =
74
- (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
75
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
71
+ (msg ? " message:" + _sanitizeDiagnosticText(msg) : STR_EMPTY) +
72
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : STR_EMPTY);
76
73
 
77
74
  _self.message += diagnosticText;
78
75
  }
@@ -94,25 +91,28 @@ export class DiagnosticLogger implements IDiagnosticLogger {
94
91
  /**
95
92
  * Count of internal messages sent
96
93
  */
97
- let _messageCount = 0;
94
+ let _messageCount: number = 0;
98
95
 
99
96
  /**
100
97
  * Holds information about what message types were already logged to console or sent to server.
101
98
  */
102
99
  let _messageLogged: { [msg: number]: boolean } = {};
103
100
 
101
+ let _loggingLevelConsole: number;
102
+ let _loggingLevelTelemetry: number;
103
+ let _maxInternalMessageLimit: number;
104
+ let _enableDebugExceptions: boolean;
105
+
104
106
  dynamicProto(DiagnosticLogger, this, (_self) => {
105
- if (isNullOrUndefined(config)) {
106
- config = {};
107
- }
107
+ _setDefaultsFromConfig(config || {});
108
108
 
109
- _self.consoleLoggingLevel = () => _getConfigValue("loggingLevelConsole", 0);
109
+ _self.consoleLoggingLevel = () => _loggingLevelConsole;
110
110
 
111
- _self.telemetryLoggingLevel = () => _getConfigValue("loggingLevelTelemetry", 1);
111
+ _self.telemetryLoggingLevel = () => _loggingLevelTelemetry;
112
112
 
113
- _self.maxInternalMessageLimit = () => _getConfigValue("maxMessageLimit", 25);
113
+ _self.maxInternalMessageLimit = () => _maxInternalMessageLimit;
114
114
 
115
- _self.enableDebugExceptions = () => _getConfigValue("enableDebugExceptions", false);
115
+ _self.enableDebugExceptions = () => _enableDebugExceptions;
116
116
 
117
117
  /**
118
118
  * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
@@ -122,30 +122,29 @@ export class DiagnosticLogger implements IDiagnosticLogger {
122
122
  _self.throwInternal = (severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct = false) => {
123
123
  const message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
124
124
 
125
- if (_self.enableDebugExceptions()) {
125
+ if (_enableDebugExceptions) {
126
126
  throw dumpObj(message);
127
127
  } else {
128
128
  // Get the logging function and fallback to warnToConsole of for some reason errorToConsole doesn't exist
129
- let logFunc = severity === eLoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
129
+ let logFunc = severity === eLoggingSeverity.CRITICAL ? STR_ERROR_TO_CONSOLE : STR_WARN_TO_CONSOLE;
130
130
 
131
131
  if (!isUndefined(message.message)) {
132
- const logLevel = _self.consoleLoggingLevel();
133
132
  if (isUserAct) {
134
133
  // check if this message type was already logged to console for this page view and if so, don't log it again
135
134
  const messageKey: number = +message.messageId;
136
135
 
137
- if (!_messageLogged[messageKey] && logLevel >= severity) {
136
+ if (!_messageLogged[messageKey] && _loggingLevelConsole >= severity) {
138
137
  _self[logFunc](message.message);
139
138
  _messageLogged[messageKey] = true;
140
139
  }
141
140
  } else {
142
141
  // Only log traces if the console Logging Level is >= the throwInternal severity level
143
- if (logLevel >= severity) {
142
+ if (_loggingLevelConsole >= severity) {
144
143
  _self[logFunc](message.message);
145
144
  }
146
145
  }
147
146
 
148
- _self.logInternalMessage(severity, message);
147
+ _logInternalMessage(severity, message);
149
148
  } else {
150
149
  _debugExtMsg("throw" + (severity === eLoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
151
150
  }
@@ -183,7 +182,9 @@ export class DiagnosticLogger implements IDiagnosticLogger {
183
182
  * @param severity {LoggingSeverity} - The severity of the log message
184
183
  * @param message {_InternalLogMessage} - The message to log.
185
184
  */
186
- _self.logInternalMessage = (severity: LoggingSeverity, message: _InternalLogMessage): void => {
185
+ _self.logInternalMessage = _logInternalMessage;
186
+
187
+ function _logInternalMessage(severity: LoggingSeverity, message: _InternalLogMessage): void {
187
188
  if (_areInternalMessagesThrottled()) {
188
189
  return;
189
190
  }
@@ -201,14 +202,14 @@ export class DiagnosticLogger implements IDiagnosticLogger {
201
202
 
202
203
  if (logMessage) {
203
204
  // Push the event in the internal queue
204
- if (severity <= _self.telemetryLoggingLevel()) {
205
+ if (severity <= _loggingLevelTelemetry) {
205
206
  _self.queue.push(message);
206
207
  _messageCount++;
207
208
  _debugExtMsg((severity === eLoggingSeverity.CRITICAL ? "error" : "warn"), message);
208
209
  }
209
210
 
210
211
  // When throttle limit reached, send a special event
211
- if (_messageCount === _self.maxInternalMessageLimit()) {
212
+ if (_messageCount === _maxInternalMessageLimit) {
212
213
  const throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
213
214
  const throttleMessage = new _InternalLogMessage(_eInternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
214
215
  _self.queue.push(throttleMessage);
@@ -219,23 +220,21 @@ export class DiagnosticLogger implements IDiagnosticLogger {
219
220
  }
220
221
  }
221
222
  }
222
- };
223
-
224
- function _getConfigValue<T>(name: keyof IConfiguration, defValue: T): T {
225
- let value = config[name] as T;
226
- if (!isNullOrUndefined(value)) {
227
- return value;
228
- }
223
+ }
229
224
 
230
- return defValue;
225
+ function _setDefaultsFromConfig(config: IConfiguration) {
226
+ _loggingLevelConsole = getCfgValue(config.loggingLevelConsole, 0);
227
+ _loggingLevelTelemetry = getCfgValue(config.loggingLevelTelemetry, 1)
228
+ _maxInternalMessageLimit = getCfgValue(config.maxMessageLimit, 25);
229
+ _enableDebugExceptions = getCfgValue(config.enableDebugExceptions, false);
231
230
  }
232
231
 
233
232
  function _areInternalMessagesThrottled(): boolean {
234
- return _messageCount >= _self.maxInternalMessageLimit();
233
+ return _messageCount >= _maxInternalMessageLimit;
235
234
  }
236
235
 
237
236
  function _debugExtMsg(name: string, data: any) {
238
- let dbgExt = getDebugExt(config);
237
+ let dbgExt = getDebugExt(config || {});
239
238
  if (dbgExt && dbgExt.diagLog) {
240
239
  dbgExt.diagLog(name, data);
241
240
  }
@@ -335,7 +334,7 @@ function _getLogger(logger: IDiagnosticLogger) {
335
334
  * @param message {_InternalLogMessage} - The log message.
336
335
  */
337
336
  export function _throwInternal(logger: IDiagnosticLogger, severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct = false) {
338
- (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
337
+ _getLogger(logger).throwInternal(severity, msgId, msg, properties, isUserAct);
339
338
  }
340
339
 
341
340
  /**
@@ -355,4 +354,4 @@ export function _warnToConsole(logger: IDiagnosticLogger, message: string) {
355
354
  */
356
355
  export function _logInternalMessage(logger: IDiagnosticLogger, severity: LoggingSeverity, message: _InternalLogMessage) {
357
356
  _getLogger(logger).logInternalMessage(severity, message);
358
- }
357
+ }