@microsoft/applicationinsights-core-js 2.7.1-nightly.202110-08 → 2.7.1-nightly.202110-17

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 (57) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +25 -21
  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 +90 -1
  7. package/dist/applicationinsights-core-js.api.md +2 -0
  8. package/dist/applicationinsights-core-js.d.ts +13 -1
  9. package/dist/applicationinsights-core-js.js +25 -21
  10. package/dist/applicationinsights-core-js.js.map +1 -1
  11. package/dist/applicationinsights-core-js.min.js +2 -2
  12. package/dist/applicationinsights-core-js.min.js.map +1 -1
  13. package/dist/applicationinsights-core-js.rollup.d.ts +13 -1
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
  15. package/dist-esm/JavaScriptSDK/BaseCore.js +5 -8
  16. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
  18. package/dist-esm/JavaScriptSDK/ChannelController.js +1 -1
  19. package/dist-esm/JavaScriptSDK/Constants.js +1 -1
  20. package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
  21. package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
  22. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +31 -16
  23. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  24. package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
  25. package/dist-esm/JavaScriptSDK/HelperFuncs.js +1 -1
  26. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
  27. package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
  28. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  29. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
  30. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  31. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +1 -1
  32. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +1 -1
  33. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  34. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  35. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  36. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  37. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  38. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  39. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  40. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  41. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  42. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  43. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  44. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  45. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  46. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  47. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  48. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  49. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  50. package/dist-esm/applicationinsights-core-js.js +1 -1
  51. package/package.json +1 -1
  52. package/src/JavaScriptSDK/BaseCore.ts +5 -7
  53. package/src/JavaScriptSDK/DiagnosticLogger.ts +40 -15
  54. package/src/JavaScriptSDK.Interfaces/IDiagnosticLogger.ts +8 -0
  55. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +5 -0
  56. package/types/JavaScriptSDK.Interfaces/IDiagnosticLogger.d.ts +7 -0
  57. package/types/tsdoc-metadata.json +1 -1
@@ -24,6 +24,8 @@ const AiUserActionablePrefix = "AI: ";
24
24
  */
25
25
  const AIInternalMessagePrefix = "AITR_";
26
26
 
27
+ const strErrorToConsole = "errorToConsole";
28
+ const strWarnToConsole = "warnToConsole";
27
29
 
28
30
  function _sanitizeDiagnosticText(text: string) {
29
31
  if (text) {
@@ -33,6 +35,20 @@ function _sanitizeDiagnosticText(text: string) {
33
35
  return "";
34
36
  }
35
37
 
38
+ function _logToConsole(func: string, message: string) {
39
+ let theConsole = getConsole();
40
+ if (!!theConsole) {
41
+ let logFunc = "log";
42
+ if (theConsole[func]) {
43
+ logFunc = func;
44
+ }
45
+
46
+ if (isFunction(theConsole[logFunc])) {
47
+ theConsole[logFunc](message);
48
+ }
49
+ }
50
+ }
51
+
36
52
  export class _InternalLogMessage{
37
53
  public static dataType: string = "MessageData";
38
54
 
@@ -107,20 +123,23 @@ export class DiagnosticLogger implements IDiagnosticLogger {
107
123
  if (_self.enableDebugExceptions()) {
108
124
  throw message;
109
125
  } else {
126
+ // Get the logging function and fallback to warnToConsole of for some reason errorToConsole doesn't exist
127
+ let logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
128
+
110
129
  if (!isUndefined(message.message)) {
111
130
  const logLevel = _self.consoleLoggingLevel();
112
131
  if (isUserAct) {
113
132
  // check if this message type was already logged to console for this page view and if so, don't log it again
114
133
  const messageKey: number = +message.messageId;
115
134
 
116
- if (!_messageLogged[messageKey] && logLevel >= LoggingSeverity.WARNING) {
117
- _self.warnToConsole(message.message);
135
+ if (!_messageLogged[messageKey] && logLevel >= severity) {
136
+ _self[logFunc](message.message);
118
137
  _messageLogged[messageKey] = true;
119
138
  }
120
139
  } else {
121
- // don't log internal AI traces in the console, unless the verbose logging is enabled
122
- if (logLevel >= LoggingSeverity.WARNING) {
123
- _self.warnToConsole(message.message);
140
+ // Only log traces if the console Logging Level is >= the throwInternal severity level
141
+ if (logLevel >= severity) {
142
+ _self[logFunc](message.message);
124
143
  }
125
144
  }
126
145
 
@@ -134,17 +153,15 @@ export class DiagnosticLogger implements IDiagnosticLogger {
134
153
  * @param message {string} - The warning message
135
154
  */
136
155
  _self.warnToConsole = (message: string) => {
137
- let theConsole = getConsole();
138
- if (!!theConsole) {
139
- let logFunc = "log";
140
- if (theConsole.warn) {
141
- logFunc = "warn";
142
- }
156
+ _logToConsole("warn", message);
157
+ }
143
158
 
144
- if (isFunction(theConsole[logFunc])) {
145
- theConsole[logFunc](message);
146
- }
147
- }
159
+ /**
160
+ * This will write an error to the console if possible
161
+ * @param message {string} - The error message
162
+ */
163
+ _self.errorToConsole = (message: string) => {
164
+ _logToConsole("error", message);
148
165
  }
149
166
 
150
167
  /**
@@ -261,6 +278,14 @@ export class DiagnosticLogger implements IDiagnosticLogger {
261
278
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
262
279
  }
263
280
 
281
+ /**
282
+ * This will write an error to the console if possible
283
+ * @param message {string} - The warning message
284
+ */
285
+ public errorToConsole(message: string) {
286
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
287
+ }
288
+
264
289
  /**
265
290
  * Resets the internal message count
266
291
  */
@@ -48,6 +48,14 @@ export interface IDiagnosticLogger {
48
48
  */
49
49
  warnToConsole(message: string): void;
50
50
 
51
+ /**
52
+ * This will write an error to the console if possible.
53
+ * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
54
+ * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
55
+ * @param message {string} - The error message
56
+ */
57
+ errorToConsole?(message: string): void;
58
+
51
59
  /**
52
60
  * Resets the internal message count
53
61
  */
@@ -47,6 +47,11 @@ export declare class DiagnosticLogger implements IDiagnosticLogger {
47
47
  * @param message {string} - The warning message
48
48
  */
49
49
  warnToConsole(message: string): void;
50
+ /**
51
+ * This will write an error to the console if possible
52
+ * @param message {string} - The warning message
53
+ */
54
+ errorToConsole(message: string): void;
50
55
  /**
51
56
  * Resets the internal message count
52
57
  */
@@ -36,6 +36,13 @@ export interface IDiagnosticLogger {
36
36
  * @param message {string} - The warning message
37
37
  */
38
38
  warnToConsole(message: string): void;
39
+ /**
40
+ * This will write an error to the console if possible.
41
+ * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
42
+ * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
43
+ * @param message {string} - The error message
44
+ */
45
+ errorToConsole?(message: string): void;
39
46
  /**
40
47
  * Resets the internal message count
41
48
  */
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.18.11"
8
+ "packageVersion": "7.18.16"
9
9
  }
10
10
  ]
11
11
  }