@microsoft/applicationinsights-core-js 2.8.5-nightly.2206-04 → 2.8.5-nightly.2207-02

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,19 +1,19 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
- import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"
4
- import { BaseCore } from "./BaseCore";
5
- import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
6
- import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
7
- import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
8
- import { eEventsDiscardedReason } from "../JavaScriptSDK.Enums/EventsDiscardedReason";
9
- import { NotificationManager } from "./NotificationManager";
10
- import { doPerf } from "./PerfManager";
11
- import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
12
- import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
13
- import { DiagnosticLogger } from "./DiagnosticLogger";
14
- import dynamicProto from "@microsoft/dynamicproto-js";
15
- import { isNullOrUndefined, throwError } from "./HelperFuncs";
16
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ import dynamicProto from "@microsoft/dynamicproto-js";
4
+ import { eEventsDiscardedReason } from "../JavaScriptSDK.Enums/EventsDiscardedReason";
5
+ import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
6
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
7
+ import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
8
+ import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
9
+ import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
10
+ import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
11
+ import { BaseCore } from "./BaseCore";
12
+ import { DiagnosticLogger } from "./DiagnosticLogger";
13
+ import { isNullOrUndefined, throwError } from "./HelperFuncs";
14
+ import { NotificationManager } from "./NotificationManager";
15
+ import { doPerf } from "./PerfManager";
16
+
17
17
  export class AppInsightsCore extends BaseCore implements IAppInsightsCore {
18
18
  constructor() {
19
19
  super();
@@ -62,4 +62,4 @@ export class AppInsightsCore extends BaseCore implements IAppInsightsCore {
62
62
  public track(telemetryItem: ITelemetryItem) {
63
63
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
64
64
  }
65
- }
65
+ }
@@ -1,47 +1,50 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
- "use strict";
4
-
5
- import { objCreateFn } from "@microsoft/applicationinsights-shims";
6
- import dynamicProto from "@microsoft/dynamicproto-js";
7
- import { IAppInsightsCore, ILoadedPlugin } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"
8
- import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
9
- import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
10
- import { IChannelControls } from "../JavaScriptSDK.Interfaces/IChannelControls";
11
- import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
12
- import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
13
- import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
14
- import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
15
- import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
16
- import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
17
- import { createDistributedTraceContext, initializePlugins, sortPlugins, _getPluginState } from "./TelemetryHelpers";
18
- import { eLoggingSeverity, _eInternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
19
- import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager";
20
- import { getGblPerfMgr, PerfManager } from "./PerfManager";
21
- import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
22
- import { createCookieMgr } from "./CookieMgr";
23
- import {
24
- arrForEach, isNullOrUndefined, getSetValue, setValue, isNotTruthy, isFunction, objExtend, objFreeze, proxyFunctionAs, proxyFunctions, throwError,
25
- toISOString,
26
- arrIndexOf
27
- } from "./HelperFuncs";
28
- import { strExtensionConfig, strIKey } from "./Constants";
29
- import { DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole } from "./DiagnosticLogger";
30
- import { getDebugListener } from "./DbgExtensionUtils";
31
- import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
32
- import { ChannelControllerPriority, createChannelControllerPlugin, createChannelQueues, IChannelController, IInternalChannelController, _IInternalChannels } from "./ChannelController";
33
- import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../JavaScriptSDK.Interfaces/ITelemetryInitializers";
34
- import { TelemetryInitializerPlugin } from "./TelemetryInitializerPlugin";
35
- import { createUniqueNamespace } from "./DataCacheHelper";
36
- import { createUnloadHandlerContainer, IUnloadHandlerContainer, UnloadHandler } from "./UnloadHandlerContainer";
37
- import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
38
- import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
39
- import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
40
- import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
41
- import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
42
- import { strAddNotificationListener, strDisabled, strEventsDiscarded, strEventsSendRequest, strEventsSent, strRemoveNotificationListener, strTeardown } from "./InternalConstants";
43
- import { IDistributedTraceContext } from "../JavaScriptSDK.Interfaces/IDistributedTraceContext";
44
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ "use strict";
4
+
5
+ import dynamicProto from "@microsoft/dynamicproto-js";
6
+ import { objCreateFn } from "@microsoft/applicationinsights-shims";
7
+ import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
8
+ import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
9
+ import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
10
+ import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
11
+ import { IAppInsightsCore, ILoadedPlugin } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
12
+ import { IChannelControls } from "../JavaScriptSDK.Interfaces/IChannelControls";
13
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
14
+ import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
15
+ import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
16
+ import { IDistributedTraceContext } from "../JavaScriptSDK.Interfaces/IDistributedTraceContext";
17
+ import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
18
+ import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
19
+ import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager";
20
+ import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
21
+ import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../JavaScriptSDK.Interfaces/ITelemetryInitializers";
22
+ import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
23
+ import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
24
+ import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
25
+ import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
26
+ import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
27
+ import {
28
+ ChannelControllerPriority, IChannelController, IInternalChannelController, _IInternalChannels, createChannelControllerPlugin,
29
+ createChannelQueues
30
+ } from "./ChannelController";
31
+ import { createCookieMgr } from "./CookieMgr";
32
+ import { createUniqueNamespace } from "./DataCacheHelper";
33
+ import { getDebugListener } from "./DbgExtensionUtils";
34
+ import { DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole } from "./DiagnosticLogger";
35
+ import {
36
+ arrForEach, arrIndexOf, getCfgValue, getSetValue, isFunction, isNullOrUndefined, objExtend, objFreeze, proxyFunctionAs, proxyFunctions,
37
+ throwError, toISOString
38
+ } from "./HelperFuncs";
39
+ import { STR_CHANNELS, STR_CREATE_PERF_MGR, STR_DISABLED, STR_EXTENSIONS, STR_EXTENSION_CONFIG } from "./InternalConstants";
40
+ import { PerfManager, getGblPerfMgr } from "./PerfManager";
41
+ import {
42
+ createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext, createTelemetryProxyChain
43
+ } from "./ProcessTelemetryContext";
44
+ import { _getPluginState, createDistributedTraceContext, initializePlugins, sortPlugins } from "./TelemetryHelpers";
45
+ import { TelemetryInitializerPlugin } from "./TelemetryInitializerPlugin";
46
+ import { IUnloadHandlerContainer, UnloadHandler, createUnloadHandlerContainer } from "./UnloadHandlerContainer";
47
+
45
48
  const strValidationError = "Plugins must provide initialize method";
46
49
  const strNotificationManager = "_notificationManager";
47
50
  const strSdkUnloadingError = "SDK is still unloading...";
@@ -72,6 +75,7 @@ function _validateExtensions(logger: IDiagnosticLogger, channelPriority: number,
72
75
 
73
76
  // Extension validation
74
77
  arrForEach(allExtensions, (ext: ITelemetryPlugin) => {
78
+ // Check for ext.initialize
75
79
  if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
76
80
  throwError(strValidationError);
77
81
  }
@@ -116,11 +120,11 @@ function _isPluginPresent(thePlugin: IPlugin, plugins: IPlugin[]) {
116
120
 
117
121
  function _createDummyNotificationManager(): INotificationManager {
118
122
  return objCreateFn({
119
- [strAddNotificationListener]: (listener: INotificationListener) => { },
120
- [strRemoveNotificationListener]: (listener: INotificationListener) => { },
121
- [strEventsSent]: (events: ITelemetryItem[]) => { },
122
- [strEventsDiscarded]: (events: ITelemetryItem[], reason: number) => { },
123
- [strEventsSendRequest]: (sendReason: number, isAsync: boolean) => { }
123
+ addNotificationListener: (listener: INotificationListener) => { },
124
+ removeNotificationListener: (listener: INotificationListener) => { },
125
+ eventsSent: (events: ITelemetryItem[]) => { },
126
+ eventsDiscarded: (events: ITelemetryItem[], reason: number) => { },
127
+ eventsSendRequest: (sendReason: number, isAsync: boolean) => { }
124
128
  });
125
129
  }
126
130
 
@@ -134,6 +138,7 @@ export class BaseCore implements IAppInsightsCore {
134
138
 
135
139
  constructor() {
136
140
  // NOTE!: DON'T set default values here, instead set them in the _initDefaults() function as it is also called during teardown()
141
+ let _config: IConfiguration;
137
142
  let _isInitialized: boolean;
138
143
  let _eventQueue: ITelemetryItem[];
139
144
  let _notificationManager: INotificationManager | null | undefined;
@@ -166,6 +171,7 @@ export class BaseCore implements IAppInsightsCore {
166
171
 
167
172
  _self.isInitialized = () => _isInitialized;
168
173
 
174
+ // Creating the self.initialize = ()
169
175
  _self.initialize = (config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void => {
170
176
  if (_isUnloading) {
171
177
  throwError(strSdkUnloadingError);
@@ -176,7 +182,10 @@ export class BaseCore implements IAppInsightsCore {
176
182
  throwError("Core should not be initialized more than once");
177
183
  }
178
184
 
179
- if (!config || isNullOrUndefined(config.instrumentationKey)) {
185
+ _config = config || {};
186
+ _self.config = _config;
187
+
188
+ if (isNullOrUndefined(config.instrumentationKey)) {
180
189
  throwError("Please provide instrumentation key");
181
190
  }
182
191
 
@@ -184,29 +193,28 @@ export class BaseCore implements IAppInsightsCore {
184
193
 
185
194
  // For backward compatibility only
186
195
  _self[strNotificationManager] = notificationManager;
187
- _self.config = config || {};
188
196
 
189
- _initDebugListener(config);
190
- _initPerfManager(config);
197
+ _initDebugListener();
198
+ _initPerfManager();
191
199
 
192
- config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
193
-
194
200
  // add notification to the extensions in the config so other plugins can access it
195
- _initExtConfig(config);
201
+ _initExtConfig();
196
202
 
197
203
  if (logger) {
198
204
  _self.logger = logger;
199
205
  }
200
206
 
207
+ let cfgExtensions = getSetValue(_config, STR_EXTENSIONS, []);
208
+
201
209
  // Extension validation
202
210
  _configExtensions = [];
203
- _configExtensions.push(...extensions, ...config.extensions);
204
- _channelConfig = (config||{}).channels;
211
+ _configExtensions.push(...extensions, ...cfgExtensions);
212
+ _channelConfig = getSetValue(_config, STR_CHANNELS, []);
205
213
 
206
- _initPluginChain(config, null);
214
+ _initPluginChain(null);
207
215
 
208
216
  if (!_channelQueue || _channelQueue.length === 0) {
209
- throwError("No channels available");
217
+ throwError("No " + STR_CHANNELS + " available");
210
218
  }
211
219
 
212
220
  _isInitialized = true;
@@ -226,13 +234,13 @@ export class BaseCore implements IAppInsightsCore {
226
234
 
227
235
  _self.track = (telemetryItem: ITelemetryItem) => {
228
236
  // setup default iKey if not passed in
229
- setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);
237
+ telemetryItem.iKey = telemetryItem.iKey || _config.instrumentationKey;
230
238
 
231
239
  // add default timestamp if not passed in
232
- setValue(telemetryItem, "time", toISOString(new Date()), null, isNotTruthy);
240
+ telemetryItem.time = telemetryItem.time || toISOString(new Date());
233
241
 
234
242
  // Common Schema 4.0
235
- setValue(telemetryItem, "ver", "4.0", null, isNullOrUndefined);
243
+ telemetryItem.ver = telemetryItem.ver || "4.0";
236
244
 
237
245
  if (!_isUnloading && _self.isInitialized()) {
238
246
  // Process the telemetry plugin chain
@@ -263,9 +271,9 @@ export class BaseCore implements IAppInsightsCore {
263
271
  * called.
264
272
  * @param {INotificationListener} listener - An INotificationListener object.
265
273
  */
266
- _self[strAddNotificationListener] = (listener: INotificationListener): void => {
274
+ _self.addNotificationListener = (listener: INotificationListener): void => {
267
275
  if (_notificationManager) {
268
- _notificationManager[strAddNotificationListener](listener);
276
+ _notificationManager.addNotificationListener(listener);
269
277
  }
270
278
  };
271
279
 
@@ -273,15 +281,15 @@ export class BaseCore implements IAppInsightsCore {
273
281
  * Removes all instances of the listener.
274
282
  * @param {INotificationListener} listener - INotificationListener to remove.
275
283
  */
276
- _self[strRemoveNotificationListener] = (listener: INotificationListener): void => {
284
+ _self.removeNotificationListener = (listener: INotificationListener): void => {
277
285
  if (_notificationManager) {
278
- _notificationManager[strRemoveNotificationListener](listener);
286
+ _notificationManager.removeNotificationListener(listener);
279
287
  }
280
288
  }
281
289
 
282
290
  _self.getCookieMgr = (): ICookieMgr => {
283
291
  if (!_cookieManager) {
284
- _cookieManager = createCookieMgr(_self.config, _self.logger);
292
+ _cookieManager = createCookieMgr(_config, _self.logger);
285
293
  }
286
294
 
287
295
  return _cookieManager;
@@ -293,8 +301,11 @@ export class BaseCore implements IAppInsightsCore {
293
301
 
294
302
  _self.getPerfMgr = (): IPerfManager => {
295
303
  if (!_perfManager && !_cfgPerfManager) {
296
- if (_self.config && _self.config.enablePerfMgr && isFunction(_self.config.createPerfMgr)) {
297
- _cfgPerfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());
304
+ if (getCfgValue(_config.enablePerfMgr)) {
305
+ let createPerfMgr = getCfgValue(_config.createPerfMgr);
306
+ if (isFunction(createPerfMgr)) {
307
+ _cfgPerfManager = createPerfMgr(_self, _self.getNotifyMgr());
308
+ }
298
309
  }
299
310
  }
300
311
 
@@ -326,7 +337,7 @@ export class BaseCore implements IAppInsightsCore {
326
337
  _self.pollInternalLogs = (eventName?: string): number => {
327
338
  _internalLogsEventName = eventName || null;
328
339
 
329
- let interval = _self.config.diagnosticLogInterval;
340
+ let interval: number = getCfgValue(_config.diagnosticLogInterval);
330
341
  if (!interval || !(interval > 0)) {
331
342
  interval = 10000;
332
343
  }
@@ -423,7 +434,7 @@ export class BaseCore implements IAppInsightsCore {
423
434
  updateState.added = [plugin];
424
435
 
425
436
  // Re-Initialize the plugin chain
426
- _initPluginChain(_self.config, updateState);
437
+ _initPluginChain(updateState);
427
438
  addCb && addCb(true);
428
439
  }
429
440
 
@@ -474,8 +485,9 @@ export class BaseCore implements IAppInsightsCore {
474
485
  _isInitialized = false;
475
486
 
476
487
  // Use a default logger so initialization errors are not dropped on the floor with full logging
477
- _self.config = objExtend(true, {}, defaultInitConfig);
478
- _self.logger = new DiagnosticLogger(_self.config);
488
+ _config = objExtend(true, {}, defaultInitConfig);
489
+ _self.config = _config;
490
+ _self.logger = new DiagnosticLogger(_config);
479
491
  _self._extensions = [];
480
492
 
481
493
  _telemetryInitializerPlugin = new TelemetryInitializerPlugin();
@@ -498,11 +510,11 @@ export class BaseCore implements IAppInsightsCore {
498
510
  }
499
511
 
500
512
  function _createTelCtx(): IProcessTelemetryContext {
501
- return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
513
+ return createProcessTelemetryContext(_getPluginChain(), _config, _self);
502
514
  }
503
515
 
504
516
  // Initialize or Re-initialize the plugins
505
- function _initPluginChain(config: IConfiguration, updateState: ITelemetryUpdateState | null) {
517
+ function _initPluginChain(updateState: ITelemetryUpdateState | null) {
506
518
  // Extension validation
507
519
  let theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
508
520
 
@@ -513,7 +525,7 @@ export class BaseCore implements IAppInsightsCore {
513
525
  let allExtensions = theExtensions.all;
514
526
 
515
527
  // Initialize the Channel Queues and the channel plugins first
516
- _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));
528
+ _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, _self));
517
529
  if (_channelControl) {
518
530
  // During add / remove of a plugin this may get called again, so don't re-add if already present
519
531
  // But we also want the controller as the last, so remove if already present
@@ -542,7 +554,7 @@ export class BaseCore implements IAppInsightsCore {
542
554
  _self._extensions = sortPlugins(allExtensions);
543
555
 
544
556
  // Initialize the controls
545
- _channelControl.initialize(config, _self, allExtensions);
557
+ _channelControl.initialize(_config, _self, allExtensions);
546
558
 
547
559
  initializePlugins(_createTelCtx(), allExtensions);
548
560
 
@@ -574,11 +586,11 @@ export class BaseCore implements IAppInsightsCore {
574
586
  theExt = {
575
587
  plugin: thePlugin as T,
576
588
  setEnabled: (enabled: boolean) => {
577
- _getPluginState(thePlugin)[strDisabled] = !enabled;
589
+ _getPluginState(thePlugin)[STR_DISABLED] = !enabled;
578
590
  },
579
591
  isEnabled: () => {
580
592
  let pluginState = _getPluginState(thePlugin);
581
- return !pluginState[strTeardown] && !pluginState[strDisabled];
593
+ return !pluginState.teardown && !pluginState[STR_DISABLED];
582
594
  },
583
595
  remove: (isAsync: boolean = true, removeCb?: (removed?: boolean) => void): void => {
584
596
  let pluginsToRemove: IPlugin[] = [thePlugin];
@@ -590,7 +602,7 @@ export class BaseCore implements IAppInsightsCore {
590
602
  _removePlugins(pluginsToRemove, unloadState, (removed) => {
591
603
  if (removed) {
592
604
  // Re-Initialize the plugin chain
593
- _initPluginChain(_self.config, {
605
+ _initPluginChain({
594
606
  reason: TelemetryUpdateReason.PluginRemoved,
595
607
  removed: pluginsToRemove
596
608
  });
@@ -615,7 +627,7 @@ export class BaseCore implements IAppInsightsCore {
615
627
  extensions.push(_telemetryInitializerPlugin);
616
628
  }
617
629
 
618
- _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);
630
+ _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _config, _self);
619
631
  }
620
632
 
621
633
  return _pluginChain;
@@ -624,7 +636,7 @@ export class BaseCore implements IAppInsightsCore {
624
636
  function _removePlugins(thePlugins: IPlugin[], unloadState: ITelemetryUnloadState, removeComplete: (removed: boolean) => void) {
625
637
 
626
638
  if (thePlugins && thePlugins.length > 0) {
627
- let unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);
639
+ let unloadChain = createTelemetryProxyChain(thePlugins, _config, _self);
628
640
  let unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self);
629
641
 
630
642
  unloadCtx.onComplete(() => {
@@ -676,7 +688,7 @@ export class BaseCore implements IAppInsightsCore {
676
688
  arrForEach(queue, (logMessage: _InternalLogMessage) => {
677
689
  const item: ITelemetryItem = {
678
690
  name: _internalLogsEventName ? _internalLogsEventName : "InternalMessageId: " + logMessage.messageId,
679
- iKey: _self.config.instrumentationKey,
691
+ iKey: getCfgValue(_config.instrumentationKey),
680
692
  time: toISOString(new Date()),
681
693
  baseType: _InternalLogMessage.dataType,
682
694
  baseData: { message: logMessage.message }
@@ -697,34 +709,37 @@ export class BaseCore implements IAppInsightsCore {
697
709
  return true;
698
710
  }
699
711
 
700
- function _initDebugListener(config: IConfiguration) {
712
+ function _initDebugListener() {
713
+ let disableDbgExt = getCfgValue(_config.disableDbgExt);
701
714
 
702
- if (config.disableDbgExt === true && _debugListener) {
715
+ if (disableDbgExt === true && _debugListener) {
703
716
  // Remove any previously loaded debug listener
704
- _notificationManager[strRemoveNotificationListener](_debugListener);
717
+ _notificationManager.removeNotificationListener(_debugListener);
705
718
  _debugListener = null;
706
719
  }
707
720
 
708
- if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {
709
- _debugListener = getDebugListener(config);
710
- _notificationManager[strAddNotificationListener](_debugListener);
721
+ if (_notificationManager && !_debugListener && disableDbgExt !== true) {
722
+ _debugListener = getDebugListener(_config);
723
+ _notificationManager.addNotificationListener(_debugListener);
711
724
  }
712
725
  }
713
726
 
714
- function _initPerfManager(config: IConfiguration) {
715
- if (!config.enablePerfMgr && _cfgPerfManager) {
727
+ function _initPerfManager() {
728
+ let enablePerfMgr = getCfgValue(_config.enablePerfMgr);
729
+
730
+ if (!enablePerfMgr && _cfgPerfManager) {
716
731
  // Remove any existing config based performance manager
717
732
  _cfgPerfManager = null;
718
733
  }
719
734
 
720
- if (config.enablePerfMgr) {
735
+ if (enablePerfMgr) {
721
736
  // Set the performance manager creation function if not defined
722
- setValue(_self.config, "createPerfMgr", _createPerfManager);
737
+ getSetValue(_config, STR_CREATE_PERF_MGR, _createPerfManager);
723
738
  }
724
739
  }
725
740
 
726
- function _initExtConfig(config: IConfiguration) {
727
- let extConfig = getSetValue(config, strExtensionConfig);
741
+ function _initExtConfig() {
742
+ let extConfig = getSetValue(_config, STR_EXTENSION_CONFIG, {});
728
743
  extConfig.NotificationManager = _notificationManager;
729
744
  }
730
745
 
@@ -932,4 +947,4 @@ export class BaseCore implements IAppInsightsCore {
932
947
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
933
948
  return false;
934
949
  }
935
- }
950
+ }
@@ -1,27 +1,29 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
-
4
- "use strict";
5
-
6
- import dynamicProto from "@microsoft/dynamicproto-js";
7
- import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"
8
- import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
9
- import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
10
- import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
11
- import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
12
- import { IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
13
- import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
14
- import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext } from "./ProcessTelemetryContext";
15
- import { arrForEach, isArray, isFunction, isNullOrUndefined, proxyFunctionAs, setValue } from "./HelperFuncs";
16
- import { strExtensionConfig } from "./Constants";
17
- import { createUnloadHandlerContainer, IUnloadHandlerContainer, UnloadHandler } from "./UnloadHandlerContainer";
18
- import { IInstrumentHook } from "../JavaScriptSDK.Interfaces/IInstrumentHooks";
19
- import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
20
- import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
21
- import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
22
- import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
23
- import { strDoTeardown, strIsInitialized, strSetNextPlugin } from "./InternalConstants";
24
-
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+ "use strict";
4
+
5
+ import dynamicProto from "@microsoft/dynamicproto-js";
6
+ import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
7
+ import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
8
+ import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
9
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
10
+ import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
11
+ import { IInstrumentHook } from "../JavaScriptSDK.Interfaces/IInstrumentHooks";
12
+ import {
13
+ IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext
14
+ } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
15
+ import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
16
+ import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
17
+ import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
18
+ import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
19
+ import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
20
+ import { arrForEach, isArray, isFunction, isNullOrUndefined, proxyFunctionAs, setValue } from "./HelperFuncs";
21
+ import { STR_EXTENSION_CONFIG } from "./InternalConstants";
22
+ import {
23
+ createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext
24
+ } from "./ProcessTelemetryContext";
25
+ import { IUnloadHandlerContainer, UnloadHandler, createUnloadHandlerContainer } from "./UnloadHandlerContainer";
26
+
25
27
  let strGetPlugin = "getPlugin";
26
28
 
27
29
  /**
@@ -140,11 +142,13 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
140
142
 
141
143
  _unloadHandlerContainer.run(theUnloadCtx, unloadState);
142
144
 
145
+ let oldHooks = _hooks;
146
+ _hooks = [];
147
+
143
148
  // Remove all instrumentation hooks
144
- arrForEach(_hooks, (fn) => {
149
+ arrForEach(oldHooks, (fn) => {
145
150
  fn.rm();
146
151
  });
147
- _hooks = [];
148
152
 
149
153
  if (result === true) {
150
154
  theUnloadCtx.processNext(theUnloadState);
@@ -154,7 +158,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
154
158
  }
155
159
  }
156
160
 
157
- if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
161
+ if (!_self._doTeardown || _self._doTeardown(theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
158
162
  _unloadCallback();
159
163
  } else {
160
164
  // Tell the caller that we will be calling processNext()
@@ -215,7 +219,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
215
219
  return _getTelCtx(itemCtx).diagLog();
216
220
  }
217
221
 
218
- _self[strIsInitialized] = () => {
222
+ _self.isInitialized = () => {
219
223
  return _isinitialized;
220
224
  }
221
225
 
@@ -228,7 +232,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
228
232
  // should use processNext() function. If you require access to the plugin use the
229
233
  // IProcessTelemetryContext.getNext().getPlugin() while in the pipeline, Note getNext() may return null.
230
234
 
231
- _self[strSetNextPlugin] = (next: ITelemetryPlugin | ITelemetryPluginChain) => {
235
+ _self.setNextPlugin = (next: ITelemetryPlugin | ITelemetryPluginChain) => {
232
236
  _nextPlugin = next;
233
237
  };
234
238
 
@@ -245,7 +249,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
245
249
 
246
250
  _self._getTelCtx = _getTelCtx;
247
251
 
248
- function _getTelCtx(currentCtx:IProcessTelemetryContext = null) {
252
+ function _getTelCtx(currentCtx: IProcessTelemetryContext = null) {
249
253
  let itemCtx:IProcessTelemetryContext = currentCtx;
250
254
  if (!itemCtx) {
251
255
  let rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
@@ -264,7 +268,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
264
268
  function _setDefaults(config: IConfiguration, core: IAppInsightsCore, pluginChain: ITelemetryPluginChain) {
265
269
  if (config) {
266
270
  // Make sure the extensionConfig exists
267
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
271
+ setValue(config, STR_EXTENSION_CONFIG, [], null, isNullOrUndefined);
268
272
  }
269
273
 
270
274
  if (!pluginChain && core) {
@@ -337,4 +341,4 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
337
341
  protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void {
338
342
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
339
343
  }
340
- }
344
+ }