@microsoft/applicationinsights-core-js 3.0.0-beta.2209-03 → 3.0.0-beta.2210-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 (179) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +1249 -675
  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 +3669 -1713
  7. package/dist/applicationinsights-core-js.api.md +131 -54
  8. package/dist/applicationinsights-core-js.d.ts +332 -131
  9. package/dist/applicationinsights-core-js.js +1249 -675
  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 +332 -131
  14. package/dist-esm/Config/ConfigDefaults.js +114 -0
  15. package/dist-esm/Config/ConfigDefaults.js.map +1 -0
  16. package/dist-esm/Config/DynamicConfig.js +129 -0
  17. package/dist-esm/Config/DynamicConfig.js.map +1 -0
  18. package/dist-esm/Config/DynamicProperty.js +139 -0
  19. package/dist-esm/Config/DynamicProperty.js.map +1 -0
  20. package/dist-esm/Config/DynamicState.js +109 -0
  21. package/dist-esm/Config/DynamicState.js.map +1 -0
  22. package/dist-esm/Config/DynamicSupport.js +57 -0
  23. package/dist-esm/Config/DynamicSupport.js.map +1 -0
  24. package/dist-esm/Config/IConfigDefaults.js +8 -0
  25. package/dist-esm/Config/IConfigDefaults.js.map +1 -0
  26. package/dist-esm/Config/IDynamicConfigHandler.js +8 -0
  27. package/dist-esm/Config/IDynamicConfigHandler.js.map +1 -0
  28. package/dist-esm/Config/IDynamicPropertyHandler.js +8 -0
  29. package/dist-esm/Config/IDynamicPropertyHandler.js.map +1 -0
  30. package/dist-esm/Config/IDynamicWatcher.js +8 -0
  31. package/dist-esm/Config/IDynamicWatcher.js.map +1 -0
  32. package/dist-esm/Config/_IDynamicConfigHandlerState.js +6 -0
  33. package/dist-esm/Config/_IDynamicConfigHandlerState.js.map +1 -0
  34. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +808 -23
  35. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  36. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +22 -18
  37. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  38. package/dist-esm/JavaScriptSDK/ChannelController.js +1 -1
  39. package/dist-esm/JavaScriptSDK/CookieMgr.js +78 -38
  40. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/CoreUtils.js +6 -5
  42. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +10 -8
  44. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  46. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +40 -23
  47. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  48. package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -115
  49. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  50. package/dist-esm/JavaScriptSDK/EventHelpers.js +30 -29
  51. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  52. package/dist-esm/JavaScriptSDK/HelperFuncs.js +19 -34
  53. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  54. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
  55. package/dist-esm/JavaScriptSDK/InternalConstants.js +5 -1
  56. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
  57. package/dist-esm/JavaScriptSDK/NotificationManager.js +18 -11
  58. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  59. package/dist-esm/JavaScriptSDK/PerfManager.js +2 -3
  60. package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
  61. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +62 -53
  62. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  63. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  64. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +8 -10
  65. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  66. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +3 -4
  67. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  68. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  69. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +12 -10
  70. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  71. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -2
  72. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js.map +1 -1
  73. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +2 -107
  75. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  76. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  85. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  86. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  87. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  88. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  89. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  90. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  91. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  92. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  93. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  94. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  95. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  96. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  97. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  98. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  99. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js +8 -0
  100. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js.map +1 -0
  101. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +3 -1
  102. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +1 -1
  103. package/dist-esm/__DynamicConstants.js +26 -23
  104. package/dist-esm/__DynamicConstants.js.map +1 -1
  105. package/dist-esm/applicationinsights-core-js.js +6 -4
  106. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  107. package/package.json +2 -2
  108. package/src/JavaScriptSDK/AppInsightsCore.ts +1156 -16
  109. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +25 -17
  110. package/src/JavaScriptSDK/CookieMgr.ts +88 -41
  111. package/src/JavaScriptSDK/CoreUtils.ts +4 -3
  112. package/src/JavaScriptSDK/DiagnosticLogger.ts +51 -29
  113. package/src/JavaScriptSDK/EnvUtils.ts +0 -133
  114. package/src/JavaScriptSDK/EventHelpers.ts +29 -28
  115. package/src/JavaScriptSDK/HelperFuncs.ts +22 -39
  116. package/src/JavaScriptSDK/InternalConstants.ts +5 -0
  117. package/src/JavaScriptSDK/NotificationManager.ts +25 -14
  118. package/src/JavaScriptSDK/PerfManager.ts +2 -2
  119. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +73 -56
  120. package/src/JavaScriptSDK/TelemetryHelpers.ts +8 -9
  121. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +2 -2
  122. package/src/JavaScriptSDK/W3cTraceParent.ts +7 -6
  123. package/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts +0 -1
  124. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +9 -108
  125. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +1 -1
  126. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +28 -3
  127. package/src/JavaScriptSDK.Interfaces/ICookieMgr.ts +8 -0
  128. package/src/JavaScriptSDK.Interfaces/IDiagnosticLogger.ts +15 -8
  129. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +3 -1
  130. package/src/JavaScriptSDK.Interfaces/INotificationListener.ts +5 -5
  131. package/src/JavaScriptSDK.Interfaces/INotificationManager.ts +8 -8
  132. package/src/JavaScriptSDK.Interfaces/IPerfManager.ts +3 -3
  133. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +10 -9
  134. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +2 -1
  135. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +15 -5
  136. package/src/JavaScriptSDK.Interfaces/IUnloadHook.ts +22 -0
  137. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +3 -3
  138. package/tsconfig.json +3 -2
  139. package/types/Config/ConfigDefaults.d.ts +10 -0
  140. package/types/Config/DynamicConfig.d.ts +23 -0
  141. package/types/Config/DynamicProperty.d.ts +3 -0
  142. package/types/Config/DynamicState.d.ts +3 -0
  143. package/types/Config/DynamicSupport.d.ts +15 -0
  144. package/types/Config/IConfigDefaults.d.ts +42 -0
  145. package/types/Config/IDynamicConfigHandler.d.ts +46 -0
  146. package/types/Config/IDynamicPropertyHandler.d.ts +11 -0
  147. package/types/Config/IDynamicWatcher.d.ts +28 -0
  148. package/types/Config/_IDynamicConfigHandlerState.d.ts +35 -0
  149. package/types/JavaScriptSDK/AppInsightsCore.d.ts +136 -4
  150. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +2 -2
  151. package/types/JavaScriptSDK/CookieMgr.d.ts +0 -10
  152. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +18 -16
  153. package/types/JavaScriptSDK/EventHelpers.d.ts +24 -24
  154. package/types/JavaScriptSDK/HelperFuncs.d.ts +13 -11
  155. package/types/JavaScriptSDK/InternalConstants.d.ts +4 -0
  156. package/types/JavaScriptSDK/NotificationManager.d.ts +7 -7
  157. package/types/JavaScriptSDK/PerfManager.d.ts +2 -2
  158. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +3 -2
  159. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +3 -3
  160. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +7 -5
  161. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +1 -0
  162. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +25 -3
  163. package/types/JavaScriptSDK.Interfaces/ICookieMgr.d.ts +6 -0
  164. package/types/JavaScriptSDK.Interfaces/IDiagnosticLogger.d.ts +14 -8
  165. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +2 -1
  166. package/types/JavaScriptSDK.Interfaces/INotificationListener.d.ts +5 -5
  167. package/types/JavaScriptSDK.Interfaces/INotificationManager.d.ts +8 -8
  168. package/types/JavaScriptSDK.Interfaces/IPerfManager.d.ts +3 -3
  169. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +5 -9
  170. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +2 -1
  171. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +13 -2
  172. package/types/JavaScriptSDK.Interfaces/IUnloadHook.d.ts +18 -0
  173. package/types/__DynamicConstants.d.ts +18 -15
  174. package/types/applicationinsights-core-js.d.ts +11 -4
  175. package/types/tsdoc-metadata.json +1 -1
  176. package/dist-esm/JavaScriptSDK/BaseCore.js +0 -654
  177. package/dist-esm/JavaScriptSDK/BaseCore.js.map +0 -1
  178. package/src/JavaScriptSDK/BaseCore.ts +0 -948
  179. package/types/JavaScriptSDK/BaseCore.d.ts +0 -124
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 3.0.0-beta.2209-03
2
+ * Microsoft Application Insights Core Javascript SDK, 3.0.0-beta.2210-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -11,6 +11,7 @@ declare namespace ApplicationInsights {
11
11
  import { arrIndexOf } from '@nevware21/ts-utils';
12
12
  import { arrMap } from '@nevware21/ts-utils';
13
13
  import { arrReduce } from '@nevware21/ts-utils';
14
+ import { asString } from '@nevware21/ts-utils';
14
15
  import { objDeepFreeze as deepFreeze } from '@nevware21/ts-utils';
15
16
  import { dumpObj } from '@nevware21/ts-utils';
16
17
  import { EnumCls } from '@nevware21/ts-utils';
@@ -67,8 +68,8 @@ declare namespace ApplicationInsights {
67
68
 
68
69
  /**
69
70
  * Trys to add an event handler for the specified event to the window, body and document
70
- * @param eventName {string} - The name of the event
71
- * @param callback {any} - The callback function that needs to be executed for the given event
71
+ * @param eventName - {string} - The name of the event
72
+ * @param callback - {any} - The callback function that needs to be executed for the given event
72
73
  * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
73
74
  * @return {boolean} - true if the handler was successfully added
74
75
  */
@@ -76,8 +77,8 @@ declare namespace ApplicationInsights {
76
77
 
77
78
  /**
78
79
  * Bind the listener to the array of events
79
- * @param events An string array of event names to bind the listener to
80
- * @param listener The event callback to call when the event is triggered
80
+ * @param events - An string array of event names to bind the listener to
81
+ * @param listener - The event callback to call when the event is triggered
81
82
  * @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
82
83
  * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
83
84
  * @returns true - when at least one of the events was registered otherwise false
@@ -124,33 +125,7 @@ declare namespace ApplicationInsights {
124
125
  */
125
126
  function addPageUnloadEventListener(listener: any, excludeEvents?: string[], evtNamespace?: string | string[]): boolean;
126
127
 
127
- class AppInsightsCore extends BaseCore implements IAppInsightsCore {
128
- constructor();
129
- initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
130
- track(telemetryItem: ITelemetryItem): void;
131
- }
132
-
133
- function areCookiesSupported(logger?: IDiagnosticLogger): any;
134
-
135
- export { arrForEach }
136
-
137
- export { arrIndexOf }
138
-
139
- export { arrMap }
140
-
141
- export { arrReduce }
142
-
143
- /**
144
- * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
145
- * @param obj Object to add the event too.
146
- * @param eventNameWithoutOn String that specifies any of the standard DHTML Events without "on" prefix and optional (dot "." prefixed) namespaces "click" "click.mynamespace".
147
- * @param handlerRef Pointer that specifies the function to call when event fires
148
- * @param useCapture [Optional] Defaults to false
149
- * @returns True if the function was bound successfully to the event, otherwise false
150
- */
151
- function attachEvent(obj: any, eventNameWithoutOn: string, handlerRef: any, useCapture?: boolean): boolean;
152
-
153
- class BaseCore implements IAppInsightsCore {
128
+ class AppInsightsCore implements IAppInsightsCore {
154
129
  static defaultConfig: IConfiguration;
155
130
  config: IConfiguration;
156
131
  logger: IDiagnosticLogger;
@@ -166,12 +141,12 @@ declare namespace ApplicationInsights {
166
141
  * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
167
142
  * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
168
143
  * called.
169
- * @param {INotificationListener} listener - An INotificationListener object.
144
+ * @param listener - An INotificationListener object.
170
145
  */
171
146
  addNotificationListener(listener: INotificationListener): void;
172
147
  /**
173
148
  * Removes all instances of the listener.
174
- * @param {INotificationListener} listener - INotificationListener to remove.
149
+ * @param listener - INotificationListener to remove.
175
150
  */
176
151
  removeNotificationListener(listener: INotificationListener): void;
177
152
  /**
@@ -199,7 +174,7 @@ declare namespace ApplicationInsights {
199
174
  * @param telemetryInitializer - The Telemetry Initializer function
200
175
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
201
176
  */
202
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
177
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
203
178
  /**
204
179
  * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
205
180
  * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
@@ -221,6 +196,12 @@ declare namespace ApplicationInsights {
221
196
  * @param addCb - [Optional] callback to call after the plugin has been added
222
197
  */
223
198
  addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
199
+ /**
200
+ * Update the configuration used and broadcast the changes to all loaded plugins
201
+ * @param newConfig - The new configuration is apply
202
+ * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to true.
203
+ */
204
+ updateCfg<T extends IConfiguration = IConfiguration>(newConfig: T, mergeExisting?: boolean): void;
224
205
  /**
225
206
  * Returns the unique event namespace that should be used
226
207
  */
@@ -248,6 +229,18 @@ declare namespace ApplicationInsights {
248
229
  * Sets the current distributed trace context for this instance if available
249
230
  */
250
231
  setTraceCtx(newTracectx: IDistributedTraceContext): void;
232
+ /**
233
+ * Add this hook so that it is automatically removed during unloading
234
+ * @param hooks - The single hook or an array of IInstrumentHook objects
235
+ */
236
+ addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
237
+ /**
238
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
239
+ * handler will be recalled.
240
+ * @param handler
241
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
242
+ */
243
+ onCfgChange<T extends IConfiguration = IConfiguration>(handler: WatcherFunction<T>): IUnloadHook;
251
244
  protected releaseQueue(): void;
252
245
  /**
253
246
  * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
@@ -258,6 +251,30 @@ declare namespace ApplicationInsights {
258
251
  protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
259
252
  }
260
253
 
254
+ function applyDefaults<C>(theConfig: C, defaultValues: IConfigDefaults<C>): C;
255
+
256
+ function areCookiesSupported(logger?: IDiagnosticLogger): any;
257
+
258
+ export { arrForEach }
259
+
260
+ export { arrIndexOf }
261
+
262
+ export { arrMap }
263
+
264
+ export { arrReduce }
265
+
266
+ export { asString }
267
+
268
+ /**
269
+ * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
270
+ * @param obj - Object to add the event too.
271
+ * @param eventNameWithoutOn - String that specifies any of the standard DHTML Events without "on" prefix and optional (dot "." prefixed) namespaces "click" "click.mynamespace".
272
+ * @param handlerRef - Pointer that specifies the function to call when event fires
273
+ * @param useCapture - [Optional] Defaults to false
274
+ * @returns True if the function was bound successfully to the event, otherwise false
275
+ */
276
+ function attachEvent(obj: any, eventNameWithoutOn: string, handlerRef: any, useCapture?: boolean): boolean;
277
+
261
278
  /**
262
279
  * BaseTelemetryPlugin provides a basic implementation of the ITelemetryPlugin interface so that plugins
263
280
  * can avoid implementation the same set of boiler plate code as well as provide a base
@@ -348,18 +365,27 @@ declare namespace ApplicationInsights {
348
365
  * Add this hook so that it is automatically removed during unloading
349
366
  * @param hooks - The single hook or an array of IInstrumentHook objects
350
367
  */
351
- protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void;
368
+ protected _addHook(hooks: IUnloadHook | IUnloadHook[] | ILegacyUnloadHook | ILegacyUnloadHook[]): void;
352
369
  }
353
370
 
354
371
  /**
355
372
  * Simpler helper to create a dynamic class that implements the interface and populates the values with the defaults.
356
373
  * Only instance properties (hasOwnProperty) values are copied from the defaults to the new instance
357
- * @param defaults Simple helper
374
+ * @param defaults - Simple helper
358
375
  */
359
376
  function createClassFromInterface<T>(defaults?: T): new () => T;
360
377
 
361
378
  function createCookieMgr(rootConfig?: IConfiguration, logger?: IDiagnosticLogger): ICookieMgr;
362
379
 
380
+ /**
381
+ * Create or return a dynamic version of the passed config, if it is not already dynamic
382
+ * @param config - The config to be converted into a dynamic config
383
+ * @param defaultConfig - The default values to apply on the config if the properties don't already exist
384
+ * @param inPlace - Should the config be converted in-place into a dynamic config or a new instance returned, defaults to true
385
+ * @returns The dynamic config handler for the config (whether new or existing)
386
+ */
387
+ function createDynamicConfig<T extends IConfiguration>(config: T, defaultConfig?: IConfigDefaults<T>, logger?: IDiagnosticLogger, inPlace?: boolean): IDynamicConfigHandler<T>;
388
+
363
389
  /**
364
390
  * Create an enum style object which has both the key => value and value => key mappings
365
391
  * @param values - The values to populate on the new object
@@ -376,7 +402,7 @@ declare namespace ApplicationInsights {
376
402
  * @param core - The current core instance
377
403
  * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
378
404
  */
379
- function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain | null, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext;
405
+ function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain | null, cfg: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext;
380
406
 
381
407
  /**
382
408
  * Create a new ITraceParent instance using the provided values.
@@ -418,13 +444,13 @@ declare namespace ApplicationInsights {
418
444
 
419
445
  /**
420
446
  * Removes an event handler for the specified event
421
- * @param Object to remove the event from
422
- * @param eventNameWithoutOn {string} - The name of the event, with optional namespaces or just the namespaces,
447
+ * @param Object - to remove the event from
448
+ * @param eventNameWithoutOn - {string} - The name of the event, with optional namespaces or just the namespaces,
423
449
  * such as "click", "click.mynamespace" or ".mynamespace"
424
- * @param handlerRef {any} - The callback function that needs to be removed from the given event, when using a
450
+ * @param handlerRef - {any} - The callback function that needs to be removed from the given event, when using a
425
451
  * namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
426
452
  * otherwise this will only remove events with this specific handler.
427
- * @param useCapture [Optional] Defaults to false
453
+ * @param useCapture - [Optional] Defaults to false
428
454
  */
429
455
  function detachEvent(obj: any, eventNameWithoutOn: string, handlerRef: any, useCapture?: boolean): void;
430
456
 
@@ -457,18 +483,18 @@ declare namespace ApplicationInsights {
457
483
  maxInternalMessageLimit(): number;
458
484
  /**
459
485
  * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
460
- * @param severity {LoggingSeverity} - The severity of the log message
461
- * @param message {_InternalLogMessage} - The log message.
486
+ * @param severity - {LoggingSeverity} - The severity of the log message
487
+ * @param message - {_InternalLogMessage} - The log message.
462
488
  */
463
- throwInternal(severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
489
+ throwInternal(severity: LoggingSeverity, msgId: _eInternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
464
490
  /**
465
491
  * This will write a warning to the console if possible
466
- * @param message {string} - The warning message
492
+ * @param message - {string} - The warning message
467
493
  */
468
494
  warnToConsole(message: string): void;
469
495
  /**
470
496
  * This will write an error to the console if possible
471
- * @param message {string} - The warning message
497
+ * @param message - {string} - The warning message
472
498
  */
473
499
  errorToConsole(message: string): void;
474
500
  /**
@@ -477,10 +503,11 @@ declare namespace ApplicationInsights {
477
503
  resetInternalMessageCount(): void;
478
504
  /**
479
505
  * Logs a message to the internal queue.
480
- * @param severity {LoggingSeverity} - The severity of the log message
481
- * @param message {_InternalLogMessage} - The message to log.
506
+ * @param severity - {LoggingSeverity} - The severity of the log message
507
+ * @param message - {_InternalLogMessage} - The message to log.
482
508
  */
483
509
  logInternalMessage(severity: LoggingSeverity, message: _InternalLogMessage): void;
510
+ update(updateState: ITelemetryUpdateState): void;
484
511
  }
485
512
 
486
513
  /**
@@ -608,10 +635,16 @@ declare namespace ApplicationInsights {
608
635
  TrackPageActionEventFailed = 103,
609
636
  FailedAddingCustomDefinedRequestContext = 104,
610
637
  InMemoryStorageBufferFull = 105,
611
- InstrumentationKeyDeprecation = 106
638
+ InstrumentationKeyDeprecation = 106,
639
+ ConfigWatcherException = 107,
640
+ DynamicConfigException = 108
612
641
  }
613
642
 
614
643
  const enum eLoggingSeverity {
644
+ /**
645
+ * No Logging will be enabled
646
+ */
647
+ DISABLED = 0,
615
648
  /**
616
649
  * Error will be sent as internal telemetry
617
650
  */
@@ -626,27 +659,27 @@ declare namespace ApplicationInsights {
626
659
 
627
660
  /**
628
661
  * Removes an event handler for the specified event
629
- * @param Object to remove the event from
630
- * @param eventName {string} - The name of the event, with optional namespaces or just the namespaces,
662
+ * @param Object - to remove the event from
663
+ * @param eventName - {string} - The name of the event, with optional namespaces or just the namespaces,
631
664
  * such as "click", "click.mynamespace" or ".mynamespace"
632
- * @param handlerRef {any} - The callback function that needs to be removed from the given event, when using a
665
+ * @param handlerRef - {any} - The callback function that needs to be removed from the given event, when using a
633
666
  * namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
634
667
  * otherwise this will only remove events with this specific handler.
635
668
  * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
636
669
  * if the eventName also includes a namespace the namespace(s) are merged into a single namespace
637
- * @param useCapture [Optional] Defaults to false
670
+ * @param useCapture - [Optional] Defaults to false
638
671
  */
639
672
  function eventOff<T>(target: T, eventName: string, handlerRef: any, evtNamespace?: string | string[] | null, useCapture?: boolean): void;
640
673
 
641
674
  /**
642
675
  * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
643
- * @param obj Object to add the event too.
644
- * @param eventName String that specifies any of the standard DHTML Events without "on" prefix, if may also include an optional (dot "." prefixed)
676
+ * @param obj - Object to add the event too.
677
+ * @param eventName - String that specifies any of the standard DHTML Events without "on" prefix, if may also include an optional (dot "." prefixed)
645
678
  * namespaces "click" "click.mynamespace" in addition to specific namespaces.
646
- * @param handlerRef Pointer that specifies the function to call when event fires
679
+ * @param handlerRef - Pointer that specifies the function to call when event fires
647
680
  * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
648
681
  * if the eventName also includes a namespace the namespace(s) are merged into a single namespace
649
- * @param useCapture [Optional] Defaults to false
682
+ * @param useCapture - [Optional] Defaults to false
650
683
  * @returns True if the function was bound successfully to the event, otherwise false
651
684
  */
652
685
  function eventOn<T>(target: T, eventName: string, handlerRef: any, evtNamespace?: string | string[] | null, useCapture?: boolean): boolean;
@@ -709,17 +742,19 @@ declare namespace ApplicationInsights {
709
742
 
710
743
  export { getDocument }
711
744
 
745
+ /**
746
+ * @internal
747
+ * Get the dynamic config handler if the value is already dynamic
748
+ * @param value
749
+ * @returns
750
+ */
751
+ function getDynamicConfigHandler<T>(value: T | IDynamicConfigHandler<T>): IDynamicConfigHandler<T> | null;
752
+
712
753
  /**
713
754
  * Returns the name of object if it's an Error. Otherwise, returns empty string.
714
755
  */
715
756
  function getExceptionName(object: any): string;
716
757
 
717
- const enum GetExtCfgMergeType {
718
- None = 0,
719
- MergeDefaultOnly = 1,
720
- MergeDefaultFromRootOrDefault = 2
721
- }
722
-
723
758
  /**
724
759
  * Get the current global performance manager that will be used with no performance manager is supplied.
725
760
  * @returns - The current default manager
@@ -823,12 +858,12 @@ declare namespace ApplicationInsights {
823
858
  * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
824
859
  * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
825
860
  * called.
826
- * @param {INotificationListener} listener - An INotificationListener object.
861
+ * @param listener - An INotificationListener object.
827
862
  */
828
863
  addNotificationListener?(listener: INotificationListener): void;
829
864
  /**
830
865
  * Removes all instances of the listener.
831
- * @param {INotificationListener} listener - INotificationListener to remove.
866
+ * @param listener - INotificationListener to remove.
832
867
  */
833
868
  removeNotificationListener?(listener: INotificationListener): void;
834
869
  /**
@@ -836,7 +871,7 @@ declare namespace ApplicationInsights {
836
871
  * @param telemetryInitializer - The Telemetry Initializer function
837
872
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
838
873
  */
839
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
874
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
840
875
  pollInternalLogs?(eventName?: string): number;
841
876
  stopPollingInternalLogs?(): void;
842
877
  /**
@@ -868,6 +903,14 @@ declare namespace ApplicationInsights {
868
903
  * @param addCb - [Optional] callback to call after the plugin has been added
869
904
  */
870
905
  addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
906
+ /**
907
+ * Update the configuration used and broadcast the changes to all loaded plugins, this does NOT support updating, adding or removing
908
+ * any the plugins (extensions or channels). It will notify each plugin (if supported) that the configuration has changed but it will
909
+ * not remove or add any new plugins, you need to call addPlugin or getPlugin(identifier).remove();
910
+ * @param newConfig - The new configuration is apply
911
+ * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to merge.
912
+ */
913
+ updateCfg<T extends IConfiguration = IConfiguration>(newConfig: T, mergeExisting?: boolean): void;
871
914
  /**
872
915
  * Returns the unique event namespace that should be used when registering events
873
916
  */
@@ -877,6 +920,11 @@ declare namespace ApplicationInsights {
877
920
  * @param handler - the handler
878
921
  */
879
922
  addUnloadCb(handler: UnloadHandler): void;
923
+ /**
924
+ * Add this hook so that it is automatically removed during unloading
925
+ * @param hooks - The single hook or an array of IInstrumentHook objects
926
+ */
927
+ addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
880
928
  /**
881
929
  * Flush and send any batched / cached data immediately
882
930
  * @param async - send data asynchronously when true (defaults to true)
@@ -896,6 +944,13 @@ declare namespace ApplicationInsights {
896
944
  * Sets the current distributed trace context for this instance if available
897
945
  */
898
946
  setTraceCtx(newTraceCtx: IDistributedTraceContext | null | undefined): void;
947
+ /**
948
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
949
+ * handler will be recalled.
950
+ * @param handler
951
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
952
+ */
953
+ onCfgChange<T extends IConfiguration = IConfiguration>(handler: WatcherFunction<T>): IUnloadHook;
899
954
  }
900
955
 
901
956
  interface IBaseProcessingContext {
@@ -914,13 +969,13 @@ declare namespace ApplicationInsights {
914
969
  /**
915
970
  * Gets the named extension config
916
971
  */
917
- getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
972
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
918
973
  /**
919
974
  * Gets the named config from either the named identifier extension or core config if neither exist then the
920
975
  * default value is returned
921
- * @param identifier The named extension identifier
922
- * @param field The config field name
923
- * @param defaultValue The default value to return if no defined config exists
976
+ * @param identifier - The named extension identifier
977
+ * @param field - The config field name
978
+ * @param defaultValue - The default value to return if no defined config exists
924
979
  */
925
980
  getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
926
981
  /**
@@ -991,6 +1046,51 @@ declare namespace ApplicationInsights {
991
1046
  flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
992
1047
  }
993
1048
 
1049
+ /**
1050
+ * The type to identify whether the default value should be applied in preference to the provided value.
1051
+ */
1052
+ type IConfigCheckFn<V> = (value: V) => boolean;
1053
+
1054
+ /**
1055
+ * The default values with a check function
1056
+ */
1057
+ interface IConfigDefaultCheck<T, V, C extends IConfiguration = IConfiguration> {
1058
+ /**
1059
+ * Callback function to check if the user-supplied value is valid, if not the default will be applied
1060
+ */
1061
+ isVal?: IConfigCheckFn<V>;
1062
+ /**
1063
+ * Optional function to allow converting and setting of the default value
1064
+ */
1065
+ set?: IConfigSetFn<T, V>;
1066
+ /**
1067
+ * The default value to apply if the user-supplied value is not valid
1068
+ */
1069
+ v?: V;
1070
+ /**
1071
+ * The default fallback key if the main key is not present, this is the key value from the config
1072
+ */
1073
+ fb?: keyof T | keyof C | Array<keyof T | keyof C>;
1074
+ /**
1075
+ * Use this check to determine the default fallback, default only checked whether the property isDefined,
1076
+ * therefore `null`; `""` are considered to be valid values.
1077
+ */
1078
+ dfVal?: (value: any) => boolean;
1079
+ }
1080
+
1081
+ /**
1082
+ * The Type definition to define default values to be applied to the config
1083
+ * The value may be either the direct value or a ConfigDefaultCheck definition
1084
+ */
1085
+ type IConfigDefaults<T, C extends IConfiguration = IConfiguration> = {
1086
+ [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
1087
+ };
1088
+
1089
+ /**
1090
+ * The type which identifies the function use to validate the user supplied value
1091
+ */
1092
+ type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
1093
+
994
1094
  /**
995
1095
  * Configuration provided to SDK core
996
1096
  */
@@ -1172,6 +1272,11 @@ declare namespace ApplicationInsights {
1172
1272
  * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not available)
1173
1273
  */
1174
1274
  purge(name: string, path?: string): boolean;
1275
+ /**
1276
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
1277
+ * @param updateState
1278
+ */
1279
+ update?(updateState: ITelemetryUpdateState): void;
1175
1280
  }
1176
1281
 
1177
1282
  /**
@@ -1265,20 +1370,20 @@ declare namespace ApplicationInsights {
1265
1370
  queue: _InternalLogMessage[];
1266
1371
  /**
1267
1372
  * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
1268
- * @param severity {LoggingSeverity} - The severity of the log message
1269
- * @param message {_InternalLogMessage} - The log message.
1373
+ * @param severity - {LoggingSeverity} - The severity of the log message
1374
+ * @param message - {_InternalLogMessage} - The log message.
1270
1375
  */
1271
- throwInternal(severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
1376
+ throwInternal(severity: LoggingSeverity, msgId: _eInternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
1272
1377
  /**
1273
1378
  * This will write a warning to the console if possible
1274
- * @param message {string} - The warning message
1379
+ * @param message - {string} - The warning message
1275
1380
  */
1276
1381
  warnToConsole(message: string): void;
1277
1382
  /**
1278
1383
  * This will write an error to the console if possible.
1279
1384
  * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
1280
1385
  * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
1281
- * @param message {string} - The error message
1386
+ * @param message - {string} - The error message
1282
1387
  */
1283
1388
  errorToConsole?(message: string): void;
1284
1389
  /**
@@ -1287,10 +1392,15 @@ declare namespace ApplicationInsights {
1287
1392
  resetInternalMessageCount(): void;
1288
1393
  /**
1289
1394
  * Logs a message to the internal queue.
1290
- * @param severity {LoggingSeverity} - The severity of the log message
1291
- * @param message {_InternalLogMessage} - The message to log.
1395
+ * @param severity - {LoggingSeverity} - The severity of the log message
1396
+ * @param message - {_InternalLogMessage} - The message to log.
1292
1397
  */
1293
1398
  logInternalMessage?(severity: LoggingSeverity, message: _InternalLogMessage): void;
1399
+ /**
1400
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
1401
+ * @param updateState
1402
+ */
1403
+ update?(updateState: ITelemetryUpdateState): void;
1294
1404
  }
1295
1405
 
1296
1406
  interface IDistributedTraceContext {
@@ -1337,6 +1447,50 @@ declare namespace ApplicationInsights {
1337
1447
  setTraceFlags(newValue?: number): void;
1338
1448
  }
1339
1449
 
1450
+ /**
1451
+ * This interface identifies the config which can track changes
1452
+ */
1453
+ interface IDynamicConfigHandler<T extends IConfiguration> {
1454
+ /**
1455
+ * Unique Id for this config handler
1456
+ */
1457
+ readonly uid: string;
1458
+ /**
1459
+ * Link back to the configuration object that should be used to get/set values
1460
+ */
1461
+ cfg: T;
1462
+ /**
1463
+ * The logger instance to use to loger any issues
1464
+ */
1465
+ logger: IDiagnosticLogger;
1466
+ /**
1467
+ * Helper to call any listeners that are waiting to be notified
1468
+ */
1469
+ notify: () => void;
1470
+ /**
1471
+ * Watch and track changes for accesses to the current config anb
1472
+ */
1473
+ watch: (configHandler: WatcherFunction<T>) => IWatcherHandler<T>;
1474
+ /**
1475
+ * Set the value against the provided config/name with the value, the property
1476
+ * will be converted to be dynamic (if not already) as long as the provided config
1477
+ * is already a tracked dynamic object.
1478
+ * @throws TypeError if the provided config is not a monitored dynamic config
1479
+ */
1480
+ set: <C, V>(theConfig: C, name: string, value: V) => V;
1481
+ }
1482
+
1483
+ interface IDynamicPropertyHandler<T> {
1484
+ /**
1485
+ * Identifies the name of the field that is handled by this handler
1486
+ */
1487
+ n: string;
1488
+ /**
1489
+ * The current collection is watcher handlers which should be called if the value changes
1490
+ */
1491
+ h: IWatcherHandler<T>[];
1492
+ }
1493
+
1340
1494
  interface IInstrumentCallDetails {
1341
1495
  name: string;
1342
1496
  inst: any;
@@ -1371,7 +1525,7 @@ declare namespace ApplicationInsights {
1371
1525
  /**
1372
1526
  * The holder of the specific instance callback
1373
1527
  */
1374
- interface IInstrumentHook {
1528
+ interface IInstrumentHook extends IUnloadHook {
1375
1529
  /** Unique Id for this callback on the hooked method */
1376
1530
  id: number;
1377
1531
  /** Holds the callbacks */
@@ -1416,6 +1570,16 @@ declare namespace ApplicationInsights {
1416
1570
  fnErr?: InstrumentorHooksCallback;
1417
1571
  }
1418
1572
 
1573
+ /**
1574
+ * An alternate interface which provides automatic removal during unloading of the component
1575
+ */
1576
+ interface ILegacyUnloadHook {
1577
+ /**
1578
+ * Legacy Self remove the referenced component
1579
+ */
1580
+ remove: () => void;
1581
+ }
1582
+
1419
1583
  interface ILoadedPlugin<T extends IPlugin> {
1420
1584
  plugin: T;
1421
1585
  /**
@@ -1437,9 +1601,9 @@ declare namespace ApplicationInsights {
1437
1601
  /**
1438
1602
  * Initialize the queue of plugins
1439
1603
  * @param plugins - The array of plugins to initialize and setting of the next plugin
1440
- * @param config The current config for the instance
1441
- * @param core THe current core instance
1442
- * @param extensions The extensions
1604
+ * @param config - The current config for the instance
1605
+ * @param core - THe current core instance
1606
+ * @param extensions - The extensions
1443
1607
  */
1444
1608
  function initializePlugins(processContext: IProcessTelemetryContext, extensions: IPlugin[]): void;
1445
1609
 
@@ -1450,20 +1614,20 @@ declare namespace ApplicationInsights {
1450
1614
  interface INotificationListener {
1451
1615
  /**
1452
1616
  * [Optional] A function called when events are sent.
1453
- * @param {ITelemetryItem[]} events - The array of events that have been sent.
1617
+ * @param events - The array of events that have been sent.
1454
1618
  */
1455
1619
  eventsSent?: (events: ITelemetryItem[]) => void;
1456
1620
  /**
1457
1621
  * [Optional] A function called when events are discarded.
1458
- * @param {ITelemetryItem[]} events - The array of events that have been discarded.
1459
- * @param {number} reason - The reason for discarding the events. The EventsDiscardedReason
1622
+ * @param events - The array of events that have been discarded.
1623
+ * @param reason - The reason for discarding the events. The EventsDiscardedReason
1460
1624
  * constant should be used to check the different values.
1461
1625
  */
1462
1626
  eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
1463
1627
  /**
1464
1628
  * [Optional] A function called when the events have been requested to be sent to the sever.
1465
- * @param {number} sendReason - The reason why the event batch is being sent.
1466
- * @param {boolean} isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1629
+ * @param sendReason - The reason why the event batch is being sent.
1630
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1467
1631
  */
1468
1632
  eventsSendRequest?: (sendReason: number, isAsync?: boolean) => void;
1469
1633
  /**
@@ -1481,36 +1645,36 @@ declare namespace ApplicationInsights {
1481
1645
  listeners: INotificationListener[];
1482
1646
  /**
1483
1647
  * Adds a notification listener.
1484
- * @param {INotificationListener} listener - The notification listener to be added.
1648
+ * @param listener - The notification listener to be added.
1485
1649
  */
1486
1650
  addNotificationListener(listener: INotificationListener): void;
1487
1651
  /**
1488
1652
  * Removes all instances of the listener.
1489
- * @param {INotificationListener} listener - AWTNotificationListener to remove.
1653
+ * @param listener - AWTNotificationListener to remove.
1490
1654
  */
1491
1655
  removeNotificationListener(listener: INotificationListener): void;
1492
1656
  /**
1493
1657
  * Notification for events sent.
1494
- * @param {ITelemetryItem[]} events - The array of events that have been sent.
1658
+ * @param events - The array of events that have been sent.
1495
1659
  */
1496
1660
  eventsSent(events: ITelemetryItem[]): void;
1497
1661
  /**
1498
1662
  * Notification for events being discarded.
1499
- * @param {ITelemetryItem[]} events - The array of events that have been discarded by the SDK.
1500
- * @param {number} reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
1663
+ * @param events - The array of events that have been discarded by the SDK.
1664
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
1501
1665
  * constant should be used to check the different values.
1502
1666
  */
1503
1667
  eventsDiscarded(events: ITelemetryItem[], reason: number): void;
1504
1668
  /**
1505
1669
  * [Optional] A function called when the events have been requested to be sent to the sever.
1506
- * @param {number} sendReason - The reason why the event batch is being sent.
1507
- * @param {boolean} isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1670
+ * @param sendReason - The reason why the event batch is being sent.
1671
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1508
1672
  */
1509
1673
  eventsSendRequest?(sendReason: number, isAsync: boolean): void;
1510
1674
  /**
1511
1675
  * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1512
1676
  * the event can be displayed via the debug plugin extension.
1513
- * @param perfEvent
1677
+ * @param perfEvent - The perf event details
1514
1678
  */
1515
1679
  perfEvent?(perfEvent: IPerfEvent): void;
1516
1680
  }
@@ -1568,17 +1732,10 @@ declare namespace ApplicationInsights {
1568
1732
  class _InternalLogMessage {
1569
1733
  static dataType: string;
1570
1734
  message: string;
1571
- messageId: _InternalMessageId;
1572
- constructor(msgId: _InternalMessageId, msg: string, isUserAct?: boolean, properties?: Object);
1735
+ messageId: _eInternalMessageId;
1736
+ constructor(msgId: _eInternalMessageId, msg: string, isUserAct?: boolean, properties?: Object);
1573
1737
  }
1574
1738
 
1575
- /**
1576
- * Internal message ID. Please create a new one for every conceptually different message. Please keep alphabetically ordered
1577
- */
1578
- const _InternalMessageId: EnumValue<typeof _eInternalMessageId>;
1579
-
1580
- type _InternalMessageId = number | _eInternalMessageId;
1581
-
1582
1739
  /**
1583
1740
  * This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
1584
1741
  */
@@ -1644,14 +1801,14 @@ declare namespace ApplicationInsights {
1644
1801
  /**
1645
1802
  * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
1646
1803
  * want to monitor this source event.
1647
- * @param src The source name of the event
1804
+ * @param src - The source name of the event
1648
1805
  * @param payloadDetails - An optional callback function to fetch the payload details for the event.
1649
1806
  * @param isAsync - Is the event occurring from a async event
1650
1807
  */
1651
1808
  create(src: string, payloadDetails?: () => any, isAsync?: boolean): IPerfEvent | null | undefined;
1652
1809
  /**
1653
1810
  * Complete the perfEvent and fire any notifications.
1654
- * @param perfEvent Fire the event which will also complete the passed event
1811
+ * @param perfEvent - Fire the event which will also complete the passed event
1655
1812
  */
1656
1813
  fire(perfEvent: IPerfEvent): void;
1657
1814
  /**
@@ -1677,7 +1834,7 @@ declare namespace ApplicationInsights {
1677
1834
  getPerfMgr(): IPerfManager;
1678
1835
  /**
1679
1836
  * Set the current performance manager
1680
- * @param perfMgr The performance manager
1837
+ * @param perfMgr - The performance manager
1681
1838
  */
1682
1839
  setPerfMgr(perfMgr: IPerfManager): void;
1683
1840
  }
@@ -1894,7 +2051,7 @@ declare namespace ApplicationInsights {
1894
2051
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
1895
2052
  }
1896
2053
 
1897
- interface ITelemetryInitializerHandler {
2054
+ interface ITelemetryInitializerHandler extends ILegacyUnloadHook {
1898
2055
  remove(): void;
1899
2056
  }
1900
2057
 
@@ -2012,12 +2169,22 @@ declare namespace ApplicationInsights {
2012
2169
  * Identifies the reason for the update notification, this is a bitwise numeric value
2013
2170
  */
2014
2171
  reason: TelemetryUpdateReason;
2172
+ /**
2173
+ * This is a new active configuration that should be used
2174
+ */
2175
+ cfg?: IConfiguration;
2176
+ /**
2177
+ * The detected changes
2178
+ */
2179
+ oldCfg?: IConfiguration;
2015
2180
  /**
2016
2181
  * If this is a configuration update this was the previous configuration that was used
2017
2182
  */
2183
+ newConfig?: IConfiguration;
2018
2184
  /**
2019
- * If this is a configuration update is the new configuration that is being used
2185
+ * Was the new config requested to be merged with the existing config
2020
2186
  */
2187
+ merge?: boolean;
2021
2188
  /**
2022
2189
  * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2023
2190
  */
@@ -2078,6 +2245,26 @@ declare namespace ApplicationInsights {
2078
2245
  run: (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2079
2246
  }
2080
2247
 
2248
+ /**
2249
+ * An interface which provides automatic removal during unloading of the component
2250
+ */
2251
+ interface IUnloadHook {
2252
+ /**
2253
+ * Self remove the referenced component
2254
+ */
2255
+ rm: () => void;
2256
+ }
2257
+
2258
+ interface IWatchDetails<T extends IConfiguration> {
2259
+ cfg: T;
2260
+ hdlr: IDynamicConfigHandler<T>;
2261
+ }
2262
+
2263
+ interface IWatcherHandler<T extends IConfiguration> extends IUnloadHook {
2264
+ fn: WatcherFunction<T>;
2265
+ rm: () => void;
2266
+ }
2267
+
2081
2268
  const LoggingSeverity: EnumValue<typeof eLoggingSeverity>;
2082
2269
 
2083
2270
  type LoggingSeverity = number | eLoggingSeverity;
@@ -2085,8 +2272,8 @@ declare namespace ApplicationInsights {
2085
2272
  /**
2086
2273
  * Logs a message to the internal queue.
2087
2274
  * @param logger - The Diagnostic Logger instance to use.
2088
- * @param severity {LoggingSeverity} - The severity of the log message
2089
- * @param message {_InternalLogMessage} - The message to log.
2275
+ * @param severity - {LoggingSeverity} - The severity of the log message
2276
+ * @param message - {_InternalLogMessage} - The message to log.
2090
2277
  */
2091
2278
  function _logInternalMessage(logger: IDiagnosticLogger, severity: LoggingSeverity, message: _InternalLogMessage): void;
2092
2279
 
@@ -2122,7 +2309,7 @@ declare namespace ApplicationInsights {
2122
2309
  * normalizes the name so that it would. This method does not identify or change any keywords
2123
2310
  * meaning that if you pass in a known keyword the same value will be returned.
2124
2311
  * This is a simplified version
2125
- * @param name The name to validate
2312
+ * @param name - The name to validate
2126
2313
  */
2127
2314
  function normalizeJsName(name: string): string;
2128
2315
 
@@ -2134,30 +2321,30 @@ declare namespace ApplicationInsights {
2134
2321
  constructor(config?: IConfiguration);
2135
2322
  /**
2136
2323
  * Adds a notification listener.
2137
- * @param {INotificationListener} listener - The notification listener to be added.
2324
+ * @param listener - The notification listener to be added.
2138
2325
  */
2139
2326
  addNotificationListener(listener: INotificationListener): void;
2140
2327
  /**
2141
2328
  * Removes all instances of the listener.
2142
- * @param {INotificationListener} listener - AWTNotificationListener to remove.
2329
+ * @param listener - AWTNotificationListener to remove.
2143
2330
  */
2144
2331
  removeNotificationListener(listener: INotificationListener): void;
2145
2332
  /**
2146
2333
  * Notification for events sent.
2147
- * @param {ITelemetryItem[]} events - The array of events that have been sent.
2334
+ * @param events - The array of events that have been sent.
2148
2335
  */
2149
2336
  eventsSent(events: ITelemetryItem[]): void;
2150
2337
  /**
2151
2338
  * Notification for events being discarded.
2152
- * @param {ITelemetryItem[]} events - The array of events that have been discarded by the SDK.
2153
- * @param {number} reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
2339
+ * @param events - The array of events that have been discarded by the SDK.
2340
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
2154
2341
  * constant should be used to check the different values.
2155
2342
  */
2156
2343
  eventsDiscarded(events: ITelemetryItem[], reason: number): void;
2157
2344
  /**
2158
2345
  * [Optional] A function called when the events have been requested to be sent to the sever.
2159
- * @param {number} sendReason - The reason why the event batch is being sent.
2160
- * @param {boolean} isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
2346
+ * @param sendReason - The reason why the event batch is being sent.
2347
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
2161
2348
  */
2162
2349
  eventsSendRequest?(sendReason: number, isAsync: boolean): void;
2163
2350
  /**
@@ -2196,6 +2383,17 @@ declare namespace ApplicationInsights {
2196
2383
 
2197
2384
  export { objToString }
2198
2385
 
2386
+ /**
2387
+ * Watch and track changes for accesses to the current config, the provided config MUST already be
2388
+ * a dynamic config or a child accessed via the dynamic config
2389
+ * @param config
2390
+ * @param configHandler
2391
+ * @param logger - The logger instance to use if there is no existing handler
2392
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
2393
+ * @throws TypeError if the provided config is not a dynamic config instance
2394
+ */
2395
+ function onConfigChange<T>(config: T, configHandler: WatcherFunction<T>, logger?: IDiagnosticLogger): IWatcherHandler<T>;
2396
+
2199
2397
  /**
2200
2398
  * A helper function to assist with JIT performance for objects that have properties added / removed dynamically
2201
2399
  * this is primarily for chromium based browsers and has limited effects on Firefox and none of IE. Only call this
@@ -2263,14 +2461,14 @@ declare namespace ApplicationInsights {
2263
2461
  /**
2264
2462
  * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
2265
2463
  * want to monitor this source event.
2266
- * @param src The source name of the event
2464
+ * @param src - The source name of the event
2267
2465
  * @param payloadDetails - An optional callback function to fetch the payload details for the event.
2268
2466
  * @param isAsync - Is the event occurring from a async event
2269
2467
  */
2270
2468
  create(src: string, payload?: any, isAsync?: boolean): IPerfEvent | null | undefined;
2271
2469
  /**
2272
2470
  * Complete the perfEvent and fire any notifications.
2273
- * @param perfEvent Fire the event which will also complete the passed event
2471
+ * @param perfEvent - Fire the event which will also complete the passed event
2274
2472
  */
2275
2473
  fire(perfEvent: IPerfEvent): void;
2276
2474
  /**
@@ -2301,7 +2499,7 @@ declare namespace ApplicationInsights {
2301
2499
  * Gets the current core config instance
2302
2500
  */
2303
2501
  getCfg: () => IConfiguration;
2304
- getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
2502
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
2305
2503
  getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
2306
2504
  /**
2307
2505
  * Returns the IAppInsightsCore instance for the current request
@@ -2413,9 +2611,9 @@ declare namespace ApplicationInsights {
2413
2611
 
2414
2612
  /**
2415
2613
  * Trys to remove event handler(s) for the specified event/namespace to the window, body and document
2416
- * @param eventName {string} - The name of the event, with optional namespaces or just the namespaces,
2614
+ * @param eventName - {string} - The name of the event, with optional namespaces or just the namespaces,
2417
2615
  * such as "click", "click.mynamespace" or ".mynamespace"
2418
- * @param callback {any} - - The callback function that needs to be removed from the given event, when using a
2616
+ * @param callback - {any} - - The callback function that needs to be removed from the given event, when using a
2419
2617
  * namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
2420
2618
  * otherwise this will only remove events with this specific handler.
2421
2619
  * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
@@ -2424,8 +2622,8 @@ declare namespace ApplicationInsights {
2424
2622
 
2425
2623
  /**
2426
2624
  * Remove the listener from the array of events
2427
- * @param events An string array of event names to bind the listener to
2428
- * @param listener The event callback to call when the event is triggered
2625
+ * @param events - An string array of event names to bind the listener to
2626
+ * @param listener - The event callback to call when the event is triggered
2429
2627
  * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
2430
2628
  */
2431
2629
  function removeEventListeners(events: string[], listener: any, evtNamespace?: string | string[]): void;
@@ -2600,6 +2798,7 @@ declare namespace ApplicationInsights {
2600
2798
  /**
2601
2799
  * The configuration has ben updated or changed
2602
2800
  */
2801
+ ConfigurationChanged = 1,
2603
2802
  /**
2604
2803
  * One or more plugins have been added
2605
2804
  */
@@ -2618,15 +2817,15 @@ declare namespace ApplicationInsights {
2618
2817
  * support minification as logger.throwInternal() will not compress the publish "throwInternal" used throughout
2619
2818
  * the code.
2620
2819
  * @param logger - The Diagnostic Logger instance to use.
2621
- * @param severity {LoggingSeverity} - The severity of the log message
2622
- * @param message {_InternalLogMessage} - The log message.
2820
+ * @param severity - {LoggingSeverity} - The severity of the log message
2821
+ * @param message - {_InternalLogMessage} - The log message.
2623
2822
  */
2624
- function _throwInternal(logger: IDiagnosticLogger, severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
2823
+ function _throwInternal(logger: IDiagnosticLogger, severity: LoggingSeverity, msgId: _eInternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
2625
2824
 
2626
2825
  /**
2627
2826
  * Convert a date to I.S.O. format in IE8
2628
2827
  */
2629
- function toISOString(date: Date): any;
2828
+ function toISOString(date: Date): string;
2630
2829
 
2631
2830
  function uaDisallowsSameSiteNone(userAgent: string): boolean;
2632
2831
 
@@ -2650,9 +2849,11 @@ declare namespace ApplicationInsights {
2650
2849
  /**
2651
2850
  * This is a helper method which will call warnToConsole on the passed logger with the provided message.
2652
2851
  * @param logger - The Diagnostic Logger instance to use.
2653
- * @param message {_InternalLogMessage} - The log message.
2852
+ * @param message - {_InternalLogMessage} - The log message.
2654
2853
  */
2655
2854
  function _warnToConsole(logger: IDiagnosticLogger, message: string): void;
2656
2855
 
2856
+ type WatcherFunction<T extends IConfiguration> = (details: IWatchDetails<T>) => void;
2857
+
2657
2858
 
2658
2859
  }