@microsoft/applicationinsights-core-js 2.7.5-nightly.2203-02 → 2.7.5-nightly.2203-03

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 (160) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +1999 -793
  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 +15679 -8835
  7. package/dist/applicationinsights-core-js.api.md +425 -48
  8. package/dist/applicationinsights-core-js.d.ts +784 -123
  9. package/dist/applicationinsights-core-js.js +1999 -793
  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 +784 -123
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +3 -69
  15. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  16. package/dist-esm/JavaScriptSDK/BaseCore.js +496 -99
  17. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +120 -21
  19. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  20. package/dist-esm/JavaScriptSDK/ChannelController.js +202 -87
  21. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  22. package/dist-esm/JavaScriptSDK/Constants.js +1 -1
  23. package/dist-esm/JavaScriptSDK/CookieMgr.js +4 -4
  24. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/CoreUtils.js +7 -148
  26. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +93 -0
  28. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -0
  29. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  30. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +25 -12
  31. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  32. package/dist-esm/JavaScriptSDK/EnvUtils.js +13 -12
  33. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/EventHelpers.js +477 -0
  35. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -0
  36. package/dist-esm/JavaScriptSDK/HelperFuncs.js +89 -86
  37. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  38. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +3 -1
  39. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  40. package/dist-esm/JavaScriptSDK/InternalConstants.js +28 -0
  41. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -0
  42. package/dist-esm/JavaScriptSDK/NotificationManager.js +37 -42
  43. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  44. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  45. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +430 -119
  46. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  47. package/dist-esm/JavaScriptSDK/RandomHelper.js +30 -4
  48. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  49. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +60 -14
  50. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  51. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +81 -0
  52. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -0
  53. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +33 -0
  54. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -0
  55. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +90 -96
  57. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  58. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +8 -0
  60. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js.map +1 -0
  61. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +8 -0
  62. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +1 -0
  63. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -2
  64. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js.map +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/IInstrumentHooks.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +6 -0
  77. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +1 -0
  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 -2
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js.map +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +8 -0
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js.map +1 -0
  84. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +8 -0
  85. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +1 -0
  86. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +6 -0
  87. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +1 -0
  88. package/dist-esm/applicationinsights-core-js.js +12 -7
  89. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  90. package/package.json +2 -2
  91. package/src/JavaScriptSDK/AppInsightsCore.ts +2 -101
  92. package/src/JavaScriptSDK/BaseCore.ts +696 -120
  93. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +205 -31
  94. package/src/JavaScriptSDK/ChannelController.ts +242 -103
  95. package/src/JavaScriptSDK/CookieMgr.ts +7 -5
  96. package/src/JavaScriptSDK/CoreUtils.ts +8 -172
  97. package/src/JavaScriptSDK/DataCacheHelper.ts +106 -0
  98. package/src/JavaScriptSDK/DiagnosticLogger.ts +27 -12
  99. package/src/JavaScriptSDK/EnvUtils.ts +13 -12
  100. package/src/JavaScriptSDK/EventHelpers.ts +550 -0
  101. package/src/JavaScriptSDK/HelperFuncs.ts +123 -97
  102. package/src/JavaScriptSDK/InstrumentHooks.ts +4 -2
  103. package/src/JavaScriptSDK/InternalConstants.ts +26 -0
  104. package/src/JavaScriptSDK/NotificationManager.ts +34 -37
  105. package/src/JavaScriptSDK/PerfManager.ts +4 -7
  106. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +543 -134
  107. package/src/JavaScriptSDK/RandomHelper.ts +35 -3
  108. package/src/JavaScriptSDK/TelemetryHelpers.ts +83 -21
  109. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +111 -0
  110. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +46 -0
  111. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +184 -87
  112. package/src/JavaScriptSDK.Enums/SendRequestReason.ts +5 -0
  113. package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +27 -0
  114. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +27 -0
  115. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +82 -2
  116. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +16 -5
  117. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +16 -6
  118. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +94 -14
  119. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +16 -0
  120. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +28 -10
  121. package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +9 -11
  122. package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +10 -0
  123. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +34 -0
  124. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +17 -0
  125. package/types/JavaScriptSDK/AppInsightsCore.d.ts +0 -21
  126. package/types/JavaScriptSDK/BaseCore.d.ts +81 -3
  127. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +53 -10
  128. package/types/JavaScriptSDK/ChannelController.d.ts +16 -17
  129. package/types/JavaScriptSDK/CoreUtils.d.ts +1 -48
  130. package/types/JavaScriptSDK/DataCacheHelper.d.ts +13 -0
  131. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +10 -0
  132. package/types/JavaScriptSDK/EventHelpers.d.ts +154 -0
  133. package/types/JavaScriptSDK/HelperFuncs.d.ts +33 -32
  134. package/types/JavaScriptSDK/InternalConstants.d.ts +20 -0
  135. package/types/JavaScriptSDK/PerfManager.d.ts +1 -1
  136. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +69 -6
  137. package/types/JavaScriptSDK/RandomHelper.d.ts +6 -0
  138. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +23 -3
  139. package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +16 -0
  140. package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +11 -0
  141. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +91 -2
  142. package/types/JavaScriptSDK.Enums/SendRequestReason.d.ts +4 -0
  143. package/types/JavaScriptSDK.Enums/TelemetryUnloadReason.d.ts +21 -0
  144. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +20 -0
  145. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +72 -1
  146. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +16 -5
  147. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +9 -0
  148. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +82 -11
  149. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +13 -0
  150. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +25 -8
  151. package/types/JavaScriptSDK.Interfaces/ITelemetryPluginChain.d.ts +9 -10
  152. package/types/JavaScriptSDK.Interfaces/ITelemetryUnloadState.d.ts +6 -0
  153. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +22 -0
  154. package/types/JavaScriptSDK.Interfaces/IUnloadableComponent.d.ts +13 -0
  155. package/types/applicationinsights-core-js.d.ts +18 -9
  156. package/types/tsdoc-metadata.json +1 -1
  157. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +0 -76
  158. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +0 -1
  159. package/src/JavaScriptSDK/TelemetryPluginChain.ts +0 -120
  160. package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +0 -32
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 2.7.5-nightly.2203-02
2
+ * Microsoft Application Insights Core Javascript SDK, 2.7.5-nightly.2203-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -20,39 +20,61 @@ import { strShimObject as strObject } from '@microsoft/applicationinsights-shims
20
20
  import { strShimPrototype as strPrototype } from '@microsoft/applicationinsights-shims';
21
21
  import { strShimUndefined as strUndefined } from '@microsoft/applicationinsights-shims';
22
22
 
23
+ /**
24
+ * Get all of the registered events on the target object, this is primarily used for testing cleanup but may also be used by
25
+ * applications to remove their own events
26
+ * @param target - The EventTarget that has registered events
27
+ * @param eventName - [Optional] The name of the event to return the registered handlers and full name (with namespaces)
28
+ * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
29
+ * if the eventName also includes a namespace the namespace(s) are merged into a single namespace
30
+ */
31
+ export declare function __getRegisteredEvents(target: any, eventName?: string, evtNamespace?: string | string[]): _IRegisteredEvents[];
32
+
23
33
  /**
24
34
  * Trys to add an event handler for the specified event to the window, body and document
25
35
  * @param eventName {string} - The name of the event
26
36
  * @param callback {any} - The callback function that needs to be executed for the given event
37
+ * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
27
38
  * @return {boolean} - true if the handler was successfully added
28
39
  */
29
- export declare function addEventHandler(eventName: string, callback: any): boolean;
40
+ export declare function addEventHandler(eventName: string, callback: any, evtNamespace?: string | string[] | null): boolean;
30
41
 
31
42
  /**
32
43
  * Bind the listener to the array of events
33
44
  * @param events An string array of event names to bind the listener to
34
45
  * @param listener The event callback to call when the event is triggered
35
46
  * @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
47
+ * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
36
48
  * @returns true - when at least one of the events was registered otherwise false
37
49
  */
38
- export declare function addEventListeners(events: string[], listener: any, excludeEvents?: string[]): boolean;
50
+ export declare function addEventListeners(events: string[], listener: any, excludeEvents?: string[], evtNamespace?: string | string[]): boolean;
39
51
 
40
52
  /**
41
- * Listen to the pagehide and visibility changing to 'hidden' events
53
+ * Listen to the pagehide and visibility changing to 'hidden' events, because the 'visibilitychange' uses
54
+ * an internal proxy to detect the visibility state you SHOULD use a unique namespace when if you plan to call
55
+ * removePageShowEventListener as the remove ignores the listener argument for the 'visibilitychange' event.
42
56
  * @param listener - The event callback to call when a page hide event is triggered
43
57
  * @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
58
+ * @param evtNamespace - [Optional] A Namespace to append to the event listeners so they can be uniquely identified and removed
59
+ * based on this namespace. This call also adds an additional unique "pageshow" namespace to the events
60
+ * so that only the matching "removePageHideEventListener" can remove these events.
44
61
  * Suggestion: pass as true if you are also calling addPageUnloadEventListener as that also hooks pagehide
45
62
  * @returns true - when at least one of the events was registered otherwise false
46
63
  */
47
- export declare function addPageHideEventListener(listener: any, excludeEvents?: string[]): boolean;
64
+ export declare function addPageHideEventListener(listener: any, excludeEvents?: string[] | null, evtNamespace?: string | string[] | null): boolean;
48
65
 
49
66
  /**
50
- * Listen to the pageshow and visibility changing to 'visible' events
67
+ * Listen to the pageshow and visibility changing to 'visible' events, because the 'visibilitychange' uses
68
+ * an internal proxy to detect the visibility state you SHOULD use a unique namespace when if you plan to call
69
+ * removePageShowEventListener as the remove ignores the listener argument for the 'visibilitychange' event.
51
70
  * @param listener - The event callback to call when a page is show event is triggered
52
71
  * @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
72
+ * @param evtNamespace - [Optional/Recommended] A Namespace to append to the event listeners so they can be uniquely
73
+ * identified and removed based on this namespace. This call also adds an additional unique "pageshow" namespace to the events
74
+ * so that only the matching "removePageShowEventListener" can remove these events.
53
75
  * @returns true - when at least one of the events was registered otherwise false
54
76
  */
55
- export declare function addPageShowEventListener(listener: any, excludeEvents?: string[]): boolean;
77
+ export declare function addPageShowEventListener(listener: any, excludeEvents?: string[] | null, evtNamespace?: string | string[] | null): boolean;
56
78
 
57
79
  /**
58
80
  * Listen to the 'beforeunload', 'unload' and 'pagehide' events which indicates a page unload is occurring,
@@ -62,34 +84,15 @@ export declare function addPageShowEventListener(listener: any, excludeEvents?:
62
84
  * need to listen to the 'addPageHideEventListener' and 'addPageShowEventListener' events.
63
85
  * @param listener - The event callback to call when a page unload event is triggered
64
86
  * @param excludeEvents - [Optional] An array of events that should not be hooked, unless no other events can be.
87
+ * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
65
88
  * @returns true - when at least one of the events was registered otherwise false
66
89
  */
67
- export declare function addPageUnloadEventListener(listener: any, excludeEvents?: string[]): boolean;
90
+ export declare function addPageUnloadEventListener(listener: any, excludeEvents?: string[], evtNamespace?: string | string[]): boolean;
68
91
 
69
92
  export declare class AppInsightsCore extends BaseCore implements IAppInsightsCore {
70
93
  constructor();
71
94
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
72
95
  track(telemetryItem: ITelemetryItem): void;
73
- /**
74
- * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
75
- * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
76
- * called.
77
- * @param {INotificationListener} listener - An INotificationListener object.
78
- */
79
- addNotificationListener(listener: INotificationListener): void;
80
- /**
81
- * Removes all instances of the listener.
82
- * @param {INotificationListener} listener - INotificationListener to remove.
83
- */
84
- removeNotificationListener(listener: INotificationListener): void;
85
- /**
86
- * Periodically check logger.queue for
87
- */
88
- pollInternalLogs(eventName?: string): number;
89
- /**
90
- * Periodically check logger.queue for
91
- */
92
- stopPollingInternalLogs(): void;
93
96
  }
94
97
 
95
98
  export declare function areCookiesSupported(logger?: IDiagnosticLogger): any;
@@ -102,7 +105,7 @@ export declare function areCookiesSupported(logger?: IDiagnosticLogger): any;
102
105
  * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. It can return -1 to break out of the loop
103
106
  * @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
104
107
  */
105
- export declare function arrForEach<T>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => void | number, thisArg?: any): void;
108
+ export declare function arrForEach<T = any>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => undefined | void | number, thisArg?: any): void;
106
109
 
107
110
  /**
108
111
  * Returns the index of the first occurrence of a value in an array. This helper exists to avoid adding a polyfil for older browsers
@@ -137,7 +140,7 @@ export declare function arrReduce<T, R>(arr: T[], callbackfn: (previousValue: T
137
140
  /**
138
141
  * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
139
142
  * @param obj Object to add the event too.
140
- * @param eventNameWithoutOn String that specifies any of the standard DHTML Events without "on" prefix
143
+ * @param eventNameWithoutOn String that specifies any of the standard DHTML Events without "on" prefix and optional (dot "." prefixed) namespaces "click" "click.mynamespace".
141
144
  * @param handlerRef Pointer that specifies the function to call when event fires
142
145
  * @param useCapture [Optional] Defaults to false
143
146
  * @returns True if the function was bound successfully to the event, otherwise false
@@ -156,6 +159,18 @@ export declare class BaseCore implements IAppInsightsCore {
156
159
  track(telemetryItem: ITelemetryItem): void;
157
160
  getProcessTelContext(): IProcessTelemetryContext;
158
161
  getNotifyMgr(): INotificationManager;
162
+ /**
163
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
164
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
165
+ * called.
166
+ * @param {INotificationListener} listener - An INotificationListener object.
167
+ */
168
+ addNotificationListener(listener: INotificationListener): void;
169
+ /**
170
+ * Removes all instances of the listener.
171
+ * @param {INotificationListener} listener - INotificationListener to remove.
172
+ */
173
+ removeNotificationListener(listener: INotificationListener): void;
159
174
  /**
160
175
  * Get the current cookie manager for this instance
161
176
  */
@@ -168,7 +183,67 @@ export declare class BaseCore implements IAppInsightsCore {
168
183
  getPerfMgr(): IPerfManager;
169
184
  setPerfMgr(perfMgr: IPerfManager): void;
170
185
  eventCnt(): number;
186
+ /**
187
+ * Periodically check logger.queue for
188
+ */
189
+ pollInternalLogs(eventName?: string): number;
190
+ /**
191
+ * Periodically check logger.queue for
192
+ */
193
+ stopPollingInternalLogs(): void;
194
+ /**
195
+ * Add a telemetry processor to decorate or drop telemetry events.
196
+ * @param telemetryInitializer - The Telemetry Initializer function
197
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
198
+ */
199
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
200
+ /**
201
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
202
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
203
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
204
+ * approach is to create a new instance and initialize that instance.
205
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
206
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
207
+ * @param isAsync - Can the unload be performed asynchronously (default)
208
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
209
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
210
+ */
211
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
212
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
213
+ /**
214
+ * Add a new plugin to the installation
215
+ * @param plugin - The new plugin to add
216
+ * @param replaceExisting - should any existing plugin be replaced, default is false
217
+ * @param doAsync - Should the add be performed asynchronously
218
+ * @param addCb - [Optional] callback to call after the plugin has been added
219
+ */
220
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
221
+ /**
222
+ * Returns the unique event namespace that should be used
223
+ */
224
+ evtNamespace(): string;
225
+ /**
226
+ * Add an unload handler that will be called when the SDK is being unloaded
227
+ * @param handler - the handler
228
+ */
229
+ addUnloadCb(handler: UnloadHandler): void;
230
+ /**
231
+ * Flush and send any batched / cached data immediately
232
+ * @param async - send data asynchronously when true (defaults to true)
233
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
234
+ * If the caller doesn't return true the caller should assume that it may never be called.
235
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
236
+ * @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
237
+ */
238
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void;
171
239
  protected releaseQueue(): void;
240
+ /**
241
+ * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
242
+ * @param updateCtx - The plugin update context
243
+ * @param updateState - The Update State
244
+ * @returns boolean - True means the extension class will call updateState otherwise the Core will
245
+ */
246
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
172
247
  }
173
248
 
174
249
  /**
@@ -177,6 +252,13 @@ export declare class BaseCore implements IAppInsightsCore {
177
252
  * implementation so that new default implementations can be added without breaking all plugins.
178
253
  */
179
254
  export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
255
+ identifier: string;
256
+ version?: string;
257
+ /**
258
+ * Holds the core instance that was used during initialization
259
+ */
260
+ core: IAppInsightsCore;
261
+ priority: number;
180
262
  /**
181
263
  * Call back for telemetry processing before it it is sent
182
264
  * @param env - This is the current event being reported
@@ -198,13 +280,6 @@ export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
198
280
  * Returns whether the plugin has been initialized
199
281
  */
200
282
  isInitialized: () => boolean;
201
- identifier: string;
202
- version?: string;
203
- /**
204
- * Holds the core instance that was used during initialization
205
- */
206
- core: IAppInsightsCore;
207
- priority: number;
208
283
  /**
209
284
  * Helper to return the current IProcessTelemetryContext, if the passed argument exists this just
210
285
  * returns that value (helps with minification for callers), otherwise it will return the configured
@@ -217,12 +292,51 @@ export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
217
292
  */
218
293
  protected setInitialized: (isInitialized: boolean) => void;
219
294
  /**
220
- * Internal helper to initialize the instance
295
+ * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
296
+ * finishes it's removal.
297
+ * @param unloadCtx - This is the context that should be used during unloading.
298
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
299
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async unload/teardown operations.
300
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
221
301
  */
222
- private _baseTelInit;
302
+ protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
303
+ /**
304
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
305
+ * @param updateCtx - This is the context that should be used during updating.
306
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
307
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async update operations.
308
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
309
+ */
310
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
223
311
  constructor();
224
312
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
313
+ /**
314
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
315
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
316
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
317
+ * @param unloadCtx - This is the context that should be used during unloading.
318
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
319
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
320
+ */
321
+ teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
225
322
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
323
+ /**
324
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
325
+ * @param updateCtx - This is the context that should be used during updating.
326
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
327
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
328
+ */
329
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
330
+ /**
331
+ * Add an unload handler that will be called when the SDK is being unloaded
332
+ * @param handler - the handler
333
+ */
334
+ protected _addUnloadCb(handler: UnloadHandler): void;
335
+ /**
336
+ * Add this hook so that it is automatically removed during unloading
337
+ * @param hooks - The single hook or an array of IInstrumentHook objects
338
+ */
339
+ protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void;
226
340
  }
227
341
 
228
342
  /**
@@ -248,6 +362,29 @@ export declare function createClassFromInterface<T>(defaults?: T): new () => T;
248
362
 
249
363
  export declare function createCookieMgr(rootConfig?: IConfiguration, logger?: IDiagnosticLogger): ICookieMgr;
250
364
 
365
+ /**
366
+ * Create an enum style object which has both the key => value and value => key mappings
367
+ * @param values - The values to populate on the new object
368
+ * @returns
369
+ */
370
+ export declare function createEnumStyle<T>(values: T): T;
371
+
372
+ /**
373
+ * Creates a new Telemetry Item context with the current config, core and plugin execution chain
374
+ * @param plugins - The plugin instances that will be executed
375
+ * @param config - The current config
376
+ * @param core - The current core instance
377
+ * @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
+ */
379
+ export declare function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain | null, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext;
380
+
381
+ export declare function createUniqueNamespace(name: string, includeVersion?: boolean): string;
382
+
383
+ export declare function createUnloadHandlerContainer(): {
384
+ add: (handler: UnloadHandler) => void;
385
+ run: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
386
+ };
387
+
251
388
  /**
252
389
  * Return the current time via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less)
253
390
  * https://caniuse.com/#search=Date.now
@@ -264,8 +401,11 @@ export declare function deleteCookie(logger: IDiagnosticLogger, name: string): b
264
401
  /**
265
402
  * Removes an event handler for the specified event
266
403
  * @param Object to remove the event from
267
- * @param eventNameWithoutOn {string} - The name of the event
268
- * @param handlerRef {any} - The callback function that needs to be executed for the given event
404
+ * @param eventNameWithoutOn {string} - The name of the event, with optional namespaces or just the namespaces,
405
+ * such as "click", "click.mynamespace" or ".mynamespace"
406
+ * @param handlerRef {any} - The callback function that needs to be removed from the given event, when using a
407
+ * namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
408
+ * otherwise this will only remove events with this specific handler.
269
409
  * @param useCapture [Optional] Defaults to false
270
410
  */
271
411
  export declare function detachEvent(obj: any, eventNameWithoutOn: string, handlerRef: any, useCapture?: boolean): void;
@@ -346,8 +486,131 @@ export declare function doPerf<T>(mgrSource: IPerfManagerProvider | IPerfManager
346
486
  */
347
487
  export declare function dumpObj(object: any): string;
348
488
 
489
+ export declare const enum _eInternalMessageId {
490
+ BrowserDoesNotSupportLocalStorage = 0,
491
+ BrowserCannotReadLocalStorage = 1,
492
+ BrowserCannotReadSessionStorage = 2,
493
+ BrowserCannotWriteLocalStorage = 3,
494
+ BrowserCannotWriteSessionStorage = 4,
495
+ BrowserFailedRemovalFromLocalStorage = 5,
496
+ BrowserFailedRemovalFromSessionStorage = 6,
497
+ CannotSendEmptyTelemetry = 7,
498
+ ClientPerformanceMathError = 8,
499
+ ErrorParsingAISessionCookie = 9,
500
+ ErrorPVCalc = 10,
501
+ ExceptionWhileLoggingError = 11,
502
+ FailedAddingTelemetryToBuffer = 12,
503
+ FailedMonitorAjaxAbort = 13,
504
+ FailedMonitorAjaxDur = 14,
505
+ FailedMonitorAjaxOpen = 15,
506
+ FailedMonitorAjaxRSC = 16,
507
+ FailedMonitorAjaxSend = 17,
508
+ FailedMonitorAjaxGetCorrelationHeader = 18,
509
+ FailedToAddHandlerForOnBeforeUnload = 19,
510
+ FailedToSendQueuedTelemetry = 20,
511
+ FailedToReportDataLoss = 21,
512
+ FlushFailed = 22,
513
+ MessageLimitPerPVExceeded = 23,
514
+ MissingRequiredFieldSpecification = 24,
515
+ NavigationTimingNotSupported = 25,
516
+ OnError = 26,
517
+ SessionRenewalDateIsZero = 27,
518
+ SenderNotInitialized = 28,
519
+ StartTrackEventFailed = 29,
520
+ StopTrackEventFailed = 30,
521
+ StartTrackFailed = 31,
522
+ StopTrackFailed = 32,
523
+ TelemetrySampledAndNotSent = 33,
524
+ TrackEventFailed = 34,
525
+ TrackExceptionFailed = 35,
526
+ TrackMetricFailed = 36,
527
+ TrackPVFailed = 37,
528
+ TrackPVFailedCalc = 38,
529
+ TrackTraceFailed = 39,
530
+ TransmissionFailed = 40,
531
+ FailedToSetStorageBuffer = 41,
532
+ FailedToRestoreStorageBuffer = 42,
533
+ InvalidBackendResponse = 43,
534
+ FailedToFixDepricatedValues = 44,
535
+ InvalidDurationValue = 45,
536
+ TelemetryEnvelopeInvalid = 46,
537
+ CreateEnvelopeError = 47,
538
+ CannotSerializeObject = 48,
539
+ CannotSerializeObjectNonSerializable = 49,
540
+ CircularReferenceDetected = 50,
541
+ ClearAuthContextFailed = 51,
542
+ ExceptionTruncated = 52,
543
+ IllegalCharsInName = 53,
544
+ ItemNotInArray = 54,
545
+ MaxAjaxPerPVExceeded = 55,
546
+ MessageTruncated = 56,
547
+ NameTooLong = 57,
548
+ SampleRateOutOfRange = 58,
549
+ SetAuthContextFailed = 59,
550
+ SetAuthContextFailedAccountName = 60,
551
+ StringValueTooLong = 61,
552
+ StartCalledMoreThanOnce = 62,
553
+ StopCalledWithoutStart = 63,
554
+ TelemetryInitializerFailed = 64,
555
+ TrackArgumentsNotSpecified = 65,
556
+ UrlTooLong = 66,
557
+ SessionStorageBufferFull = 67,
558
+ CannotAccessCookie = 68,
559
+ IdTooLong = 69,
560
+ InvalidEvent = 70,
561
+ FailedMonitorAjaxSetRequestHeader = 71,
562
+ SendBrowserInfoOnUserInit = 72,
563
+ PluginException = 73,
564
+ NotificationException = 74,
565
+ SnippetScriptLoadFailure = 99,
566
+ InvalidInstrumentationKey = 100,
567
+ CannotParseAiBlobValue = 101,
568
+ InvalidContentBlob = 102,
569
+ TrackPageActionEventFailed = 103,
570
+ FailedAddingCustomDefinedRequestContext = 104,
571
+ InMemoryStorageBufferFull = 105
572
+ }
573
+
574
+ export declare const enum eLoggingSeverity {
575
+ /**
576
+ * Error will be sent as internal telemetry
577
+ */
578
+ CRITICAL = 1,
579
+ /**
580
+ * Error will NOT be sent as internal telemetry, and will only be shown in browser console
581
+ */
582
+ WARNING = 2
583
+ }
584
+
349
585
  export declare const EventHelper: IEventHelper;
350
586
 
587
+ /**
588
+ * Removes an event handler for the specified event
589
+ * @param Object to remove the event from
590
+ * @param eventName {string} - The name of the event, with optional namespaces or just the namespaces,
591
+ * such as "click", "click.mynamespace" or ".mynamespace"
592
+ * @param handlerRef {any} - The callback function that needs to be removed from the given event, when using a
593
+ * namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
594
+ * otherwise this will only remove events with this specific handler.
595
+ * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
596
+ * if the eventName also includes a namespace the namespace(s) are merged into a single namespace
597
+ * @param useCapture [Optional] Defaults to false
598
+ */
599
+ export declare function eventOff<T>(target: T, eventName: string, handlerRef: any, evtNamespace?: string | string[] | null, useCapture?: boolean): void;
600
+
601
+ /**
602
+ * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
603
+ * @param obj Object to add the event too.
604
+ * @param eventName String that specifies any of the standard DHTML Events without "on" prefix, if may also include an optional (dot "." prefixed)
605
+ * namespaces "click" "click.mynamespace" in addition to specific namespaces.
606
+ * @param handlerRef Pointer that specifies the function to call when event fires
607
+ * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
608
+ * if the eventName also includes a namespace the namespace(s) are merged into a single namespace
609
+ * @param useCapture [Optional] Defaults to false
610
+ * @returns True if the function was bound successfully to the event, otherwise false
611
+ */
612
+ export declare function eventOn<T>(target: T, eventName: string, handlerRef: any, evtNamespace?: string | string[] | null, useCapture?: boolean): boolean;
613
+
351
614
  /**
352
615
  * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
353
616
  */
@@ -417,6 +680,12 @@ export declare function getDocument(): Document | null;
417
680
  */
418
681
  export declare function getExceptionName(object: any): string;
419
682
 
683
+ export declare const enum GetExtCfgMergeType {
684
+ None = 0,
685
+ MergeDefaultOnly = 1,
686
+ MergeDefaultFromRootOrDefault = 2
687
+ }
688
+
420
689
  /**
421
690
  * Get the current global performance manager that will be used with no performance manager is supplied.
422
691
  * @returns - The current default manager
@@ -575,12 +844,123 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
575
844
  * @param {INotificationListener} listener - INotificationListener to remove.
576
845
  */
577
846
  removeNotificationListener?(listener: INotificationListener): void;
847
+ /**
848
+ * Add a telemetry processor to decorate or drop telemetry events.
849
+ * @param telemetryInitializer - The Telemetry Initializer function
850
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
851
+ */
852
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
578
853
  pollInternalLogs?(eventName?: string): number;
579
854
  stopPollingInternalLogs?(): void;
580
855
  /**
581
856
  * Return a new instance of the IProcessTelemetryContext for processing events
582
857
  */
583
858
  getProcessTelContext(): IProcessTelemetryContext;
859
+ /**
860
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
861
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
862
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
863
+ * approach is to create a new instance and initialize that instance.
864
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
865
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
866
+ * @param isAsync - Can the unload be performed asynchronously (default)
867
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
868
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
869
+ */
870
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
871
+ /**
872
+ * Find and return the (first) plugin with the specified identifier if present
873
+ * @param pluginIdentifier
874
+ */
875
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
876
+ /**
877
+ * Add a new plugin to the installation
878
+ * @param plugin - The new plugin to add
879
+ * @param replaceExisting - should any existing plugin be replaced, default is false
880
+ * @param doAsync - Should the add be performed asynchronously
881
+ * @param addCb - [Optional] callback to call after the plugin has been added
882
+ */
883
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
884
+ /**
885
+ * Returns the unique event namespace that should be used when registering events
886
+ */
887
+ evtNamespace(): string;
888
+ /**
889
+ * Add a handler that will be called when the SDK is being unloaded
890
+ * @param handler - the handler
891
+ */
892
+ addUnloadCb(handler: UnloadHandler): void;
893
+ /**
894
+ * Flush and send any batched / cached data immediately
895
+ * @param async - send data asynchronously when true (defaults to true)
896
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
897
+ * If the caller doesn't return true the caller should assume that it may never be called.
898
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
899
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
900
+ * @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
901
+ */
902
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
903
+ }
904
+
905
+ export declare interface IBaseProcessingContext {
906
+ /**
907
+ * The current core instance for the request
908
+ */
909
+ core: () => IAppInsightsCore;
910
+ /**
911
+ * THe current diagnostic logger for the request
912
+ */
913
+ diagLog: () => IDiagnosticLogger;
914
+ /**
915
+ * Gets the current core config instance
916
+ */
917
+ getCfg: () => IConfiguration;
918
+ /**
919
+ * Gets the named extension config
920
+ */
921
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
922
+ /**
923
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
924
+ * default value is returned
925
+ * @param identifier The named extension identifier
926
+ * @param field The config field name
927
+ * @param defaultValue The default value to return if no defined config exists
928
+ */
929
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
930
+ /**
931
+ * Helper to allow plugins to check and possibly shortcut executing code only
932
+ * required if there is a nextPlugin
933
+ */
934
+ hasNext: () => boolean;
935
+ /**
936
+ * Returns the next configured plugin proxy
937
+ */
938
+ getNext: () => ITelemetryPluginChain;
939
+ /**
940
+ * Helper to set the next plugin proxy
941
+ */
942
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
943
+ /**
944
+ * Synchronously iterate over the context chain running the callback for each plugin, once
945
+ * every plugin has been executed via the callback, any associated onComplete will be called.
946
+ * @param callback - The function call for each plugin in the context chain
947
+ */
948
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
949
+ /**
950
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
951
+ * @param onComplete - The onComplete to call
952
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
953
+ * @param args - Any additional arguments to pass to the onComplete function
954
+ */
955
+ onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
956
+ /**
957
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
958
+ * @param plugins - The execution order to process the plugins, if null or not supplied
959
+ * then the current execution order will be copied.
960
+ * @param startAt - The plugin to start processing from, if missing from the execution
961
+ * order then the next plugin will be NOT set.
962
+ */
963
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
584
964
  }
585
965
 
586
966
  /**
@@ -596,15 +976,23 @@ export declare interface IChannelControls extends ITelemetryPlugin {
596
976
  */
597
977
  resume(): void;
598
978
  /**
599
- * Tear down transmission pipeline
979
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
980
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
981
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
982
+ * @param unloadCtx - This is the context that should be used during unloading.
983
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
984
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
600
985
  */
601
- teardown(): void;
986
+ teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
602
987
  /**
603
988
  * Flush to send data immediately; channel should default to sending data asynchronously
604
- * @param async: send data asynchronously when true
605
- * @param callBack: if specified, notify caller when send is complete
989
+ * @param async - send data asynchronously when true
990
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
991
+ * If the caller doesn't return true the caller should assume that it may never be called.
992
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
993
+ * @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
606
994
  */
607
- flush(async: boolean, callBack?: () => void): void;
995
+ flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
608
996
  }
609
997
 
610
998
  /**
@@ -964,7 +1352,7 @@ export declare interface ICoreUtils {
964
1352
  * @param callback {any} - The callback function that needs to be executed for the given event
965
1353
  * @return {boolean} - true if the handler was successfully added
966
1354
  */
967
- addEventHandler: (eventName: string, callback: any) => boolean;
1355
+ addEventHandler: (eventName: string, callback: any, evtNamespace?: string | string[]) => boolean;
968
1356
  /**
969
1357
  * Return the current time via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less)
970
1358
  * https://caniuse.com/#search=Date.now
@@ -1149,6 +1537,10 @@ export declare interface IInstrumentCallDetails {
1149
1537
  * The error (exception) which occurred while executing the original method
1150
1538
  */
1151
1539
  err?: Error;
1540
+ /**
1541
+ * The Event object from (window.event) at the start of the original call
1542
+ */
1543
+ evt?: Event;
1152
1544
  }
1153
1545
 
1154
1546
  /**
@@ -1175,6 +1567,11 @@ export declare interface IInstrumentHooks {
1175
1567
  * You must always supply the error callback
1176
1568
  */
1177
1569
  export declare interface IInstrumentHooksCallbacks {
1570
+ /**
1571
+ * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
1572
+ * identify the source of the instrumented hooks
1573
+ */
1574
+ ns?: string | string[];
1178
1575
  /**
1179
1576
  * The hook callback to call before the original function is called
1180
1577
  */
@@ -1194,6 +1591,24 @@ export declare interface IInstrumentHooksCallbacks {
1194
1591
  fnErr?: InstrumentorHooksCallback;
1195
1592
  }
1196
1593
 
1594
+ export declare interface ILoadedPlugin<T extends IPlugin> {
1595
+ plugin: T;
1596
+ /**
1597
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
1598
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
1599
+ * @returns boolean = true if the plugin is in a state where it is operational.
1600
+ */
1601
+ isEnabled: () => boolean;
1602
+ /**
1603
+ * You can optionally enable / disable a plugin from processing events.
1604
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
1605
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
1606
+ * (unless it's also been re-initialized)
1607
+ */
1608
+ setEnabled: (isEnabled: boolean) => void;
1609
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1610
+ }
1611
+
1197
1612
  /**
1198
1613
  * Initialize the queue of plugins
1199
1614
  * @param plugins - The array of plugins to initialize and setting of the next plugin
@@ -1201,7 +1616,7 @@ export declare interface IInstrumentHooksCallbacks {
1201
1616
  * @param core THe current core instance
1202
1617
  * @param extensions The extensions
1203
1618
  */
1204
- export declare function initializePlugins(processContext: ProcessTelemetryContext, extensions: IPlugin[]): void;
1619
+ export declare function initializePlugins(processContext: IProcessTelemetryContext, extensions: IPlugin[]): void;
1205
1620
 
1206
1621
  /**
1207
1622
  * An interface used for the notification listener.
@@ -1410,7 +1825,7 @@ export declare const _InternalMessageId: {
1410
1825
  InMemoryStorageBufferFull: number;
1411
1826
  };
1412
1827
 
1413
- export declare type _InternalMessageId = number | typeof _InternalMessageId;
1828
+ export declare type _InternalMessageId = number | _eInternalMessageId;
1414
1829
 
1415
1830
  /**
1416
1831
  * This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
@@ -1531,10 +1946,14 @@ export declare interface IPlugin {
1531
1946
  */
1532
1947
  isInitialized?: () => boolean;
1533
1948
  /**
1534
- * Tear down the plugin and remove any hooked value, the plugin should remove that it is no longer initialized and
1535
- * therefore can be re-initialized after being torn down.
1949
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
1950
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
1951
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
1952
+ * @param unloadCtx - This is the context that should be used during unloading.
1953
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
1954
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1536
1955
  */
1537
- teardown?: () => void;
1956
+ teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1538
1957
  /**
1539
1958
  * Extension name
1540
1959
  */
@@ -1549,61 +1968,73 @@ export declare interface IPlugin {
1549
1968
  * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1550
1969
  * between multiple AppInsights instances
1551
1970
  */
1552
- export declare interface IProcessTelemetryContext {
1553
- /**
1554
- * The current core instance for the request
1555
- */
1556
- core: () => IAppInsightsCore;
1557
- /**
1558
- * THe current diagnostic logger for the request
1559
- */
1560
- diagLog: () => IDiagnosticLogger;
1971
+ export declare interface IProcessTelemetryContext extends IBaseProcessingContext {
1561
1972
  /**
1562
- * Gets the current core config instance
1563
- */
1564
- getCfg: () => IConfiguration;
1565
- /**
1566
- * Gets the named extension config
1567
- */
1568
- getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
1569
- /**
1570
- * Gets the named config from either the named identifier extension or core config if neither exist then the
1571
- * default value is returned
1572
- * @param identifier The named extension identifier
1573
- * @param field The config field name
1574
- * @param defaultValue The default value to return if no defined config exists
1973
+ * Call back for telemetry processing before it it is sent
1974
+ * @param env - This is the current event being reported
1975
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1575
1976
  */
1576
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
1977
+ processNext: (env: ITelemetryItem) => boolean | void;
1577
1978
  /**
1578
- * Helper to allow plugins to check and possibly shortcut executing code only
1579
- * required if there is a nextPlugin
1979
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1980
+ * @param plugins - The execution order to process the plugins, if null or not supplied
1981
+ * then the current execution order will be copied.
1982
+ * @param startAt - The plugin to start processing from, if missing from the execution
1983
+ * order then the next plugin will be NOT set.
1580
1984
  */
1581
- hasNext: () => boolean;
1985
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
1986
+ }
1987
+
1988
+ /**
1989
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
1990
+ * or the SDK is being unloaded.
1991
+ */
1992
+ export declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1582
1993
  /**
1583
- * Returns the next configured plugin proxy
1994
+ * This Plugin has finished unloading, so unload the next one
1995
+ * @param uploadState - The state of the unload process
1996
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1584
1997
  */
1585
- getNext: () => ITelemetryPluginChain;
1998
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
1586
1999
  /**
1587
- * Helper to set the next plugin proxy
2000
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2001
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2002
+ * then the current execution order will be copied.
2003
+ * @param startAt - The plugin to start processing from, if missing from the execution
2004
+ * order then the next plugin will be NOT set.
1588
2005
  */
1589
- setNext: (nextCtx: ITelemetryPluginChain) => void;
2006
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
2007
+ }
2008
+
2009
+ /**
2010
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
2011
+ * for when plugins are added, removed or the configuration was changed.
2012
+ */
2013
+ export declare interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
1590
2014
  /**
1591
- * Call back for telemetry processing before it it is sent
1592
- * @param env - This is the current event being reported
2015
+ * This Plugin has finished unloading, so unload the next one
2016
+ * @param updateState - The update State
2017
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1593
2018
  */
1594
- processNext: (env: ITelemetryItem) => void;
2019
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
1595
2020
  /**
1596
- * Create a new context using the core and config from the current instance
2021
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1597
2022
  * @param plugins - The execution order to process the plugins, if null or not supplied
1598
2023
  * then the current execution order will be copied.
1599
2024
  * @param startAt - The plugin to start processing from, if missing from the execution
1600
2025
  * order then the next plugin will be NOT set.
1601
2026
  */
1602
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2027
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2028
+ }
2029
+
2030
+ export declare interface _IRegisteredEvents {
2031
+ name: string;
2032
+ handler: any;
1603
2033
  }
1604
2034
 
1605
2035
  /**
1606
- * Check if an object is of type Array
2036
+ * Check if an object is of type Array with optional generic T, the generic type is not validated
2037
+ * and exists to help with TypeScript validation only.
1607
2038
  */
1608
2039
  export declare let isArray: <T = any>(obj: any) => obj is Array<T>;
1609
2040
 
@@ -1644,13 +2075,13 @@ export declare function isFunction(value: any): value is Function;
1644
2075
  */
1645
2076
  export declare function isIE(): boolean;
1646
2077
 
1647
- export declare function isNotNullOrUndefined(value: any): boolean;
2078
+ export declare function isNotNullOrUndefined<T>(value: T): value is T;
1648
2079
 
1649
2080
  export declare function isNotTruthy(value: any): boolean;
1650
2081
 
1651
- export declare function isNotUndefined(value: any): boolean;
2082
+ export declare function isNotUndefined<T>(value: T): value is T;
1652
2083
 
1653
- export declare function isNullOrUndefined(value: any): boolean;
2084
+ export declare function isNullOrUndefined(value: any): value is null | undefined;
1654
2085
 
1655
2086
  /**
1656
2087
  * Checks if the type of value is a number.
@@ -1659,7 +2090,7 @@ export declare function isNullOrUndefined(value: any): boolean;
1659
2090
  */
1660
2091
  export declare function isNumber(value: any): value is number;
1661
2092
 
1662
- export declare function isObject(value: any): boolean;
2093
+ export declare function isObject<T>(value: T): value is T;
1663
2094
 
1664
2095
  /**
1665
2096
  * Returns whether the environment is reporting that we are running in a React Native Environment
@@ -1687,7 +2118,7 @@ export declare function isTruthy(value: any): boolean;
1687
2118
 
1688
2119
  export declare function isTypeof(value: any, theType: string): boolean;
1689
2120
 
1690
- export declare function isUndefined(value: any): boolean;
2121
+ export declare function isUndefined(value: any): value is undefined;
1691
2122
 
1692
2123
  /**
1693
2124
  * Checks if XMLHttpRequest is supported
@@ -1695,6 +2126,19 @@ export declare function isUndefined(value: any): boolean;
1695
2126
  */
1696
2127
  export declare function isXhrSupported(): boolean;
1697
2128
 
2129
+ export declare interface ITelemetryInitializerContainer {
2130
+ /**
2131
+ * Add a telemetry processor to decorate or drop telemetry events.
2132
+ * @param telemetryInitializer - The Telemetry Initializer function
2133
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
2134
+ */
2135
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
2136
+ }
2137
+
2138
+ export declare interface ITelemetryInitializerHandler {
2139
+ remove(): void;
2140
+ }
2141
+
1698
2142
  /**
1699
2143
  * Telemety item supported in Core
1700
2144
  */
@@ -1744,15 +2188,7 @@ export declare interface ITelemetryItem {
1744
2188
  /**
1745
2189
  * Configuration provided to SDK core
1746
2190
  */
1747
- export declare interface ITelemetryPlugin extends IPlugin {
1748
- /**
1749
- * Call back for telemetry processing before it it is sent
1750
- * @param env - This is the current event being reported
1751
- * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
1752
- * can optionally use this to access the current core instance or define / pass additional information
1753
- * to later plugins (vs appending items to the telemetry item)
1754
- */
1755
- processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2191
+ export declare interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
1756
2192
  /**
1757
2193
  * Set next extension for telemetry processing, this is not optional as plugins should use the
1758
2194
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
@@ -1768,7 +2204,7 @@ export declare interface ITelemetryPlugin extends IPlugin {
1768
2204
  /**
1769
2205
  * Configuration provided to SDK core
1770
2206
  */
1771
- export declare interface ITelemetryPluginChain {
2207
+ export declare interface ITelemetryPluginChain extends ITelemetryProcessor {
1772
2208
  /**
1773
2209
  * Returns the underlying plugin that is being proxied for the processTelemetry call
1774
2210
  */
@@ -1777,6 +2213,16 @@ export declare interface ITelemetryPluginChain {
1777
2213
  * Returns the next plugin
1778
2214
  */
1779
2215
  getNext: () => ITelemetryPluginChain;
2216
+ /**
2217
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
2218
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
2219
+ * @param unloadCtx - The unload context to use for this call.
2220
+ * @param unloadState - The details of the unload operation
2221
+ */
2222
+ unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2223
+ }
2224
+
2225
+ declare interface ITelemetryProcessor {
1780
2226
  /**
1781
2227
  * Call back for telemetry processing before it it is sent
1782
2228
  * @param env - This is the current event being reported
@@ -1784,7 +2230,60 @@ export declare interface ITelemetryPluginChain {
1784
2230
  * can optionally use this to access the current core instance or define / pass additional information
1785
2231
  * to later plugins (vs appending items to the telemetry item)
1786
2232
  */
1787
- processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
2233
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2234
+ /**
2235
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2236
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2237
+ * the configuration has bee updated.
2238
+ * @param updateCtx - This is the context that should be used during updating.
2239
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2240
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2241
+ */
2242
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2243
+ }
2244
+
2245
+ export declare interface ITelemetryUnloadState {
2246
+ reason: TelemetryUnloadReason;
2247
+ isAsync: boolean;
2248
+ flushComplete?: boolean;
2249
+ }
2250
+
2251
+ export declare interface ITelemetryUpdateState {
2252
+ /**
2253
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2254
+ */
2255
+ reason: TelemetryUpdateReason;
2256
+ /**
2257
+ * If this is a configuration update this was the previous configuration that was used
2258
+ */
2259
+ /**
2260
+ * If this is a configuration update is the new configuration that is being used
2261
+ */
2262
+ /**
2263
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2264
+ */
2265
+ added?: IPlugin[];
2266
+ /**
2267
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2268
+ */
2269
+ removed?: IPlugin[];
2270
+ }
2271
+
2272
+ export declare interface IUnloadableComponent {
2273
+ /**
2274
+ * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
2275
+ * finishes it's removal.
2276
+ * @param unloadCtx - This is the context that should be used during unloading.
2277
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
2278
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async unload/teardown operations.
2279
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
2280
+ */
2281
+ _doUnload?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
2282
+ }
2283
+
2284
+ export declare interface IUnloadHandlerContainer {
2285
+ add: (handler: UnloadHandler) => void;
2286
+ run: (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
1788
2287
  }
1789
2288
 
1790
2289
  /**
@@ -1799,16 +2298,14 @@ export declare interface ITelemetryPluginChain {
1799
2298
  */
1800
2299
  export declare function _legacyCookieMgr(config?: IConfiguration, logger?: IDiagnosticLogger): ICookieMgr;
1801
2300
 
1802
- export declare enum LoggingSeverity {
1803
- /**
1804
- * Error will be sent as internal telemetry
1805
- */
1806
- CRITICAL = 1,
1807
- /**
1808
- * Error will NOT be sent as internal telemetry, and will only be shown in browser console
1809
- */
1810
- WARNING = 2
1811
- }
2301
+ export declare const LoggingSeverity: {
2302
+ CRITICAL: number;
2303
+ WARNING: number;
2304
+ };
2305
+
2306
+ export declare type LoggingSeverity = number | eLoggingSeverity;
2307
+
2308
+ export declare function mergeEvtNamespace(theNamespace: string, namespaces?: string | string[] | null): string | string[];
1812
2309
 
1813
2310
  export declare const MinChannelPriorty: number;
1814
2311
 
@@ -1900,13 +2397,27 @@ export { objCreate }
1900
2397
  */
1901
2398
  export declare function objDefineAccessors<T>(target: any, prop: string, getProp?: () => T, setProp?: (v: T) => void): boolean;
1902
2399
 
2400
+ /**
2401
+ * Pass in the objects to merge as arguments, this will only "merge" (extend) properties that are owned by the object.
2402
+ * It will NOT merge inherited or non-enumerable properties.
2403
+ * @param obj1 - object to merge. Set this argument to 'true' for a deep extend.
2404
+ * @param obj2 - object to merge.
2405
+ * @param obj3 - object to merge.
2406
+ * @param obj4 - object to merge.
2407
+ * @param obj5 - object to merge.
2408
+ * @returns The extended first object.
2409
+ */
2410
+ export declare function objExtend<T2, T3, T4, T5, T6>(deepExtend?: boolean, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T2 & T3 & T4 & T5 & T6;
2411
+
2412
+ export declare function objExtend<T1, T2, T3, T4, T5, T6>(obj1?: T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6;
2413
+
1903
2414
  /**
1904
2415
  * This is a helper function for the equivalent of arForEach(objKeys(target), callbackFn), this is a
1905
2416
  * performance optimization to avoid the creation of a new array for large objects
1906
2417
  * @param target The target object to find and process the keys
1907
2418
  * @param callbackfn The function to call with the details
1908
2419
  */
1909
- export declare function objForEachKey(target: any, callbackfn: (name: string, value: any) => void): void;
2420
+ export declare function objForEachKey<T = any>(target: T, callbackfn: (name: string, value: T[keyof T]) => void): void;
1910
2421
 
1911
2422
  export declare const objFreeze: <T>(value: T) => T;
1912
2423
 
@@ -1920,6 +2431,8 @@ export declare function objKeys(obj: {}): string[];
1920
2431
 
1921
2432
  export declare const objSeal: <T>(value: T) => T;
1922
2433
 
2434
+ export declare function objToString(obj: any): any;
2435
+
1923
2436
  /**
1924
2437
  * A helper function to assist with JIT performance for objects that have properties added / removed dynamically
1925
2438
  * this is primarily for chromium based browsers and has limited effects on Firefox and none of IE. Only call this
@@ -1975,7 +2488,7 @@ export declare class PerfManager implements IPerfManager {
1975
2488
  * Defined as private so it can be visualized via the DebugPlugin
1976
2489
  */
1977
2490
  private ctx;
1978
- constructor(manager: INotificationManager);
2491
+ constructor(manager?: INotificationManager);
1979
2492
  /**
1980
2493
  * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
1981
2494
  * want to monitor this source event.
@@ -2008,13 +2521,17 @@ export declare class PerfManager implements IPerfManager {
2008
2521
  */
2009
2522
  export declare function perfNow(): number;
2010
2523
 
2524
+ /**
2525
+ * This class will be removed!
2526
+ * @deprecated use createProcessTelemetryContext() instead
2527
+ */
2011
2528
  export declare class ProcessTelemetryContext implements IProcessTelemetryContext {
2012
2529
  /**
2013
2530
  * Gets the current core config instance
2014
2531
  */
2015
2532
  getCfg: () => IConfiguration;
2016
2533
  getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
2017
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
2534
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
2018
2535
  /**
2019
2536
  * Returns the IAppInsightsCore instance for the current request
2020
2537
  */
@@ -2042,19 +2559,34 @@ export declare class ProcessTelemetryContext implements IProcessTelemetryContext
2042
2559
  * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
2043
2560
  * can optionally use this to access the current core instance or define / pass additional information
2044
2561
  * to later plugins (vs appending items to the telemetry item)
2562
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2563
+ */
2564
+ processNext: (env: ITelemetryItem) => boolean | void;
2565
+ /**
2566
+ * Synchronously iterate over the context chain running the callback for each plugin, once
2567
+ * every plugin has been executed via the callback, any associated onComplete will be called.
2568
+ * @param callback - The function call for each plugin in the context chain
2045
2569
  */
2046
- processNext: (env: ITelemetryItem) => void;
2570
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
2047
2571
  /**
2048
2572
  * Create a new context using the core and config from the current instance
2573
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2574
+ * then the current execution order will be copied.
2575
+ * @param startAt - The plugin to start processing from, if missing from the execution
2576
+ * order then the next plugin will be NOT set.
2049
2577
  */
2050
2578
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2579
+ /**
2580
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
2581
+ */
2582
+ onComplete: (onComplete: () => void) => void;
2051
2583
  /**
2052
2584
  * Creates a new Telemetry Item context with the current config, core and plugin execution chain
2053
2585
  * @param plugins - The plugin instances that will be executed
2054
2586
  * @param config - The current config
2055
2587
  * @param core - The current core instance
2056
2588
  */
2057
- constructor(plugins: IPlugin[] | ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin);
2589
+ constructor(pluginChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin);
2058
2590
  }
2059
2591
 
2060
2592
  /**
@@ -2071,9 +2603,19 @@ export declare class ProcessTelemetryContext implements IProcessTelemetryContext
2071
2603
  * @param target - The target object to be assigned with the source properties and functions
2072
2604
  * @param source - The source object which will be assigned / called by setting / calling the targets proxies
2073
2605
  * @param chkSet - An optional callback to determine whether a specific property/function should be proxied
2074
- * @memberof Initialization
2075
2606
  */
2076
- export declare function proxyAssign(target: any, source: any, chkSet?: (name: string, isFunc?: boolean, source?: any, target?: any) => boolean): any;
2607
+ export declare function proxyAssign<T, S>(target: T, source: S, chkSet?: (name: string, isFunc?: boolean, source?: S, target?: T) => boolean): T;
2608
+
2609
+ export declare function proxyFunctionAs<T, S>(target: T, name: string, source: S | (() => S), theFunc: (keyof S), overwriteTarget?: boolean): void;
2610
+
2611
+ /**
2612
+ * Creates proxy functions on the target which internally will call the source version with all arguments passed to the target method.
2613
+ *
2614
+ * @param target - The target object to be assigned with the source properties and functions
2615
+ * @param source - The source object which will be assigned / called by setting / calling the targets proxies
2616
+ * @param functionsToProxy - An array of function names that will be proxied on the target
2617
+ */
2618
+ export declare function proxyFunctions<T, S>(target: T, source: S | (() => S), functionsToProxy: (keyof S)[], overwriteTarget?: boolean): T;
2077
2619
 
2078
2620
  /**
2079
2621
  * generate a random 32-bit number (0x000000..0xFFFFFFFF) or (-0x80000000..0x7FFFFFFF), defaults un-unsigned.
@@ -2088,6 +2630,52 @@ export declare function random32(signed?: boolean): number;
2088
2630
  */
2089
2631
  export declare function randomValue(maxValue: number): number;
2090
2632
 
2633
+ /**
2634
+ * Trys to remove event handler(s) for the specified event/namespace to the window, body and document
2635
+ * @param eventName {string} - The name of the event, with optional namespaces or just the namespaces,
2636
+ * such as "click", "click.mynamespace" or ".mynamespace"
2637
+ * @param callback {any} - - The callback function that needs to be removed from the given event, when using a
2638
+ * namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
2639
+ * otherwise this will only remove events with this specific handler.
2640
+ * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
2641
+ */
2642
+ export declare function removeEventHandler(eventName: string, callback: any, evtNamespace?: string | string[] | null): void;
2643
+
2644
+ /**
2645
+ * Remove the listener from the array of events
2646
+ * @param events An string array of event names to bind the listener to
2647
+ * @param listener The event callback to call when the event is triggered
2648
+ * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
2649
+ */
2650
+ export declare function removeEventListeners(events: string[], listener: any, evtNamespace?: string | string[]): void;
2651
+
2652
+ /**
2653
+ * Removes the pageHide event listeners added by addPageHideEventListener, because the 'visibilitychange' uses
2654
+ * an internal proxy to detect the visibility state you SHOULD use a unique namespace when calling addPageHideEventListener
2655
+ * as the remove ignores the listener argument for the 'visibilitychange' event.
2656
+ * @param listener - The specific listener to remove for the 'pageshow' event only (ignored for 'visibilitychange')
2657
+ * @param evtNamespace - The unique namespace used when calling addPageShowEventListener
2658
+ */
2659
+ export declare function removePageHideEventListener(listener: any, evtNamespace?: string | string[] | null): void;
2660
+
2661
+ /**
2662
+ * Removes the pageShow event listeners added by addPageShowEventListener, because the 'visibilitychange' uses
2663
+ * an internal proxy to detect the visibility state you SHOULD use a unique namespace when calling addPageShowEventListener
2664
+ * as the remove ignores the listener argument for the 'visibilitychange' event.
2665
+ * @param listener - The specific listener to remove for the 'pageshow' event only (ignored for 'visibilitychange')
2666
+ * @param evtNamespace - The unique namespace used when calling addPageShowEventListener
2667
+ */
2668
+ export declare function removePageShowEventListener(listener: any, evtNamespace?: string | string[] | null): void;
2669
+
2670
+ /**
2671
+ * Remove any matching 'beforeunload', 'unload' and 'pagehide' events that may have been added via addEventListener,
2672
+ * addEventListeners, addPageUnloadEventListener or addPageHideEventListener.
2673
+ * @param listener - The specific event callback to to be removed
2674
+ * @param evtNamespace - [Optional] Namespace(s) uniquely identified and removed based on this namespace.
2675
+ * @returns true - when at least one of the events was registered otherwise false
2676
+ */
2677
+ export declare function removePageUnloadEventListener(listener: any, evtNamespace?: string | string[]): void;
2678
+
2091
2679
  /**
2092
2680
  * Helper to return the ICookieMgr from the core (if not null/undefined) or a default implementation
2093
2681
  * associated with the configuration or a legacy default.
@@ -2131,6 +2719,10 @@ export declare const enum SendRequestReason {
2131
2719
  * The event(s) being sent as a retry
2132
2720
  */
2133
2721
  Retry = 5,
2722
+ /**
2723
+ * The SDK is unloading
2724
+ */
2725
+ SdkUnload = 6,
2134
2726
  /**
2135
2727
  * Maximum batch size would be exceeded
2136
2728
  */
@@ -2169,9 +2761,9 @@ export declare function setGblPerfMgr(perfManager: IPerfManager): void;
2169
2761
  * @param srcChk - [Optional] Callback to check to original value that if supplied will be called if the new value should be set (if allowed)
2170
2762
  * @returns The existing or new value, depending what was set
2171
2763
  */
2172
- export declare function setValue<T, K extends keyof T>(target: T, field: K, value: T[K], valChk?: (value: T[K]) => boolean, srcChk?: (value: T[K]) => boolean): T[K];
2764
+ export declare function setValue<T, K extends keyof T>(target: T, field: K, value: T[K], valChk?: ((value: T[K]) => boolean) | null, srcChk?: ((value: T[K]) => boolean) | null): T[K];
2173
2765
 
2174
- export declare function sortPlugins(plugins: IPlugin[]): IPlugin[];
2766
+ export declare function sortPlugins<T = IPlugin>(plugins: T[]): T[];
2175
2767
 
2176
2768
  /**
2177
2769
  * A simple wrapper (for minification support) to check if the value contains the search string.
@@ -2217,8 +2809,64 @@ export declare interface Tags {
2217
2809
  [key: string]: any;
2218
2810
  }
2219
2811
 
2812
+ export declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
2813
+
2814
+ /**
2815
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
2816
+ */
2817
+ export declare const enum TelemetryUnloadReason {
2818
+ /**
2819
+ * Teardown has been called without any context.
2820
+ */
2821
+ ManualTeardown = 0,
2822
+ /**
2823
+ * Just this plugin is being removed
2824
+ */
2825
+ PluginUnload = 1,
2826
+ /**
2827
+ * This instance of the plugin is being removed and replaced
2828
+ */
2829
+ PluginReplace = 2,
2830
+ /**
2831
+ * The entire SDK is being unloaded
2832
+ */
2833
+ SdkUnload = 50
2834
+ }
2835
+
2836
+ /**
2837
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2838
+ */
2839
+ export declare const enum TelemetryUpdateReason {
2840
+ /**
2841
+ * Unknown.
2842
+ */
2843
+ Unknown = 0,
2844
+ /**
2845
+ * The configuration has ben updated or changed
2846
+ */
2847
+ /**
2848
+ * One or more plugins have been added
2849
+ */
2850
+ PluginAdded = 16,
2851
+ /**
2852
+ * One or more plugins have been removed
2853
+ */
2854
+ PluginRemoved = 32
2855
+ }
2856
+
2220
2857
  export declare function throwError(message: string): never;
2221
2858
 
2859
+ /**
2860
+ * This is a helper method which will call throwInternal on the passed logger, will throw exceptions in
2861
+ * debug mode or attempt to log the error as a console warning. This helper is provided mostly to better
2862
+ * support minification as logger.throwInternal() will not compress the publish "throwInternal" used throughout
2863
+ * the code.
2864
+ * @param logger - The Diagnostic Logger instance to use.
2865
+ * @param severity {LoggingSeverity} - The severity of the log message
2866
+ * @param message {_InternalLogMessage} - The log message.
2867
+ */
2868
+ export declare function _throwInternal(logger: IDiagnosticLogger, severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
2869
+
2222
2870
  /**
2223
2871
  * Convert a date to I.S.O. format in IE8
2224
2872
  */
@@ -2228,6 +2876,19 @@ export declare function uaDisallowsSameSiteNone(userAgent: string): boolean;
2228
2876
 
2229
2877
  export declare const Undefined = "undefined";
2230
2878
 
2879
+ /**
2880
+ * Teardown / Unload helper to perform teardown/unloading operations for the provided components synchronously or asynchronously, this will call any
2881
+ * _doTeardown() or _doUnload() functions on the provided components to allow them to finish removal.
2882
+ * @param components - The components you want to unload
2883
+ * @param unloadCtx - This is the context that should be used during unloading.
2884
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
2885
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async unload/teardown operations.
2886
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
2887
+ */
2888
+ export declare function unloadComponents(components: any | IUnloadableComponent[], unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void): void | boolean;
2889
+
2890
+ export declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2891
+
2231
2892
  export declare function useXDomainRequest(): boolean | undefined;
2232
2893
 
2233
2894
  export { }