@microsoft/applicationinsights-core-js 2.8.0-beta.2202-07 → 2.8.0-beta.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.
- package/browser/applicationinsights-core-js.integrity.json +9 -9
- package/browser/applicationinsights-core-js.js +1137 -484
- package/browser/applicationinsights-core-js.js.map +1 -1
- package/browser/applicationinsights-core-js.min.js +2 -2
- package/browser/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.api.json +6529 -2784
- package/dist/applicationinsights-core-js.api.md +290 -30
- package/dist/applicationinsights-core-js.d.ts +481 -89
- package/dist/applicationinsights-core-js.js +1137 -484
- package/dist/applicationinsights-core-js.js.map +1 -1
- package/dist/applicationinsights-core-js.min.js +2 -2
- package/dist/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.rollup.d.ts +481 -89
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +248 -32
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +50 -5
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +105 -73
- package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +3 -4
- package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js +6 -122
- package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js +93 -0
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -0
- package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +12 -12
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +8 -7
- package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EventHelpers.js +472 -0
- package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -0
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +32 -59
- package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK/InternalConstants.js +28 -0
- package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -0
- package/dist-esm/JavaScriptSDK/NotificationManager.js +8 -11
- package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +195 -107
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +3 -2
- package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +32 -13
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +4 -6
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +32 -0
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +90 -96
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +8 -0
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -2
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js.map +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +8 -0
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js.map +1 -0
- package/dist-esm/applicationinsights-core-js.js +9 -4
- package/dist-esm/applicationinsights-core-js.js.map +1 -1
- package/package.json +1 -1
- package/src/JavaScriptSDK/BaseCore.ts +312 -33
- package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +90 -5
- package/src/JavaScriptSDK/ChannelController.ts +107 -61
- package/src/JavaScriptSDK/CookieMgr.ts +4 -4
- package/src/JavaScriptSDK/CoreUtils.ts +6 -143
- package/src/JavaScriptSDK/DataCacheHelper.ts +106 -0
- package/src/JavaScriptSDK/DiagnosticLogger.ts +12 -11
- package/src/JavaScriptSDK/EnvUtils.ts +7 -6
- package/src/JavaScriptSDK/EventHelpers.ts +542 -0
- package/src/JavaScriptSDK/HelperFuncs.ts +35 -54
- package/src/JavaScriptSDK/InternalConstants.ts +26 -0
- package/src/JavaScriptSDK/NotificationManager.ts +7 -11
- package/src/JavaScriptSDK/ProcessTelemetryContext.ts +248 -121
- package/src/JavaScriptSDK/RandomHelper.ts +2 -1
- package/src/JavaScriptSDK/TelemetryHelpers.ts +47 -15
- package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +5 -15
- package/src/JavaScriptSDK/UnloadHandlerContainer.ts +44 -0
- package/src/JavaScriptSDK.Enums/LoggingEnums.ts +184 -87
- package/src/JavaScriptSDK.Enums/SendRequestReason.ts +5 -0
- package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +27 -0
- package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +49 -2
- package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +9 -2
- package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +55 -16
- package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +16 -9
- package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +9 -11
- package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +10 -0
- package/types/JavaScriptSDK/BaseCore.d.ts +21 -1
- package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +26 -1
- package/types/JavaScriptSDK/ChannelController.d.ts +4 -0
- package/types/JavaScriptSDK/CoreUtils.d.ts +1 -42
- package/types/JavaScriptSDK/DataCacheHelper.d.ts +13 -0
- package/types/JavaScriptSDK/EventHelpers.d.ts +152 -0
- package/types/JavaScriptSDK/HelperFuncs.d.ts +8 -17
- package/types/JavaScriptSDK/InternalConstants.d.ts +20 -0
- package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +12 -3
- package/types/JavaScriptSDK/TelemetryHelpers.d.ts +8 -0
- package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +0 -7
- package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +11 -0
- package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +91 -2
- package/types/JavaScriptSDK.Enums/SendRequestReason.d.ts +4 -0
- package/types/JavaScriptSDK.Enums/TelemetryUnloadReason.d.ts +21 -0
- package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +41 -1
- package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +9 -2
- package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +49 -14
- package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +15 -8
- package/types/JavaScriptSDK.Interfaces/ITelemetryPluginChain.d.ts +9 -10
- package/types/JavaScriptSDK.Interfaces/ITelemetryUnloadState.d.ts +6 -0
- package/types/applicationinsights-core-js.d.ts +7 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft Application Insights Core Javascript SDK, 2.8.0-beta.
|
|
2
|
+
* Microsoft Application Insights Core Javascript SDK, 2.8.0-beta.2203-03
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -14,39 +14,59 @@ declare namespace ApplicationInsights {
|
|
|
14
14
|
import { strShimPrototype as strPrototype } from '@microsoft/applicationinsights-shims';
|
|
15
15
|
import { strShimUndefined as strUndefined } from '@microsoft/applicationinsights-shims';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Get all of the registered events on the target object, this is primarily used for testing cleanup but may also be used by
|
|
19
|
+
* applications to remove their own events
|
|
20
|
+
* @param target - The EventTarget that has registered events
|
|
21
|
+
* @param evtName - [Optional] The name of the event to return the registered handlers and full name (with namespaces)
|
|
22
|
+
*/
|
|
23
|
+
function __getRegisteredEvents(target: any, evtName?: string): _IRegisteredEvents[];
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* Trys to add an event handler for the specified event to the window, body and document
|
|
19
27
|
* @param eventName {string} - The name of the event
|
|
20
28
|
* @param callback {any} - The callback function that needs to be executed for the given event
|
|
29
|
+
* @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
|
|
21
30
|
* @return {boolean} - true if the handler was successfully added
|
|
22
31
|
*/
|
|
23
|
-
function addEventHandler(eventName: string, callback: any): boolean;
|
|
32
|
+
function addEventHandler(eventName: string, callback: any, evtNamespace?: string | string[]): boolean;
|
|
24
33
|
|
|
25
34
|
/**
|
|
26
35
|
* Bind the listener to the array of events
|
|
27
36
|
* @param events An string array of event names to bind the listener to
|
|
28
37
|
* @param listener The event callback to call when the event is triggered
|
|
29
38
|
* @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
|
|
39
|
+
* @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
|
|
30
40
|
* @returns true - when at least one of the events was registered otherwise false
|
|
31
41
|
*/
|
|
32
|
-
function addEventListeners(events: string[], listener: any, excludeEvents?: string[]): boolean;
|
|
42
|
+
function addEventListeners(events: string[], listener: any, excludeEvents?: string[], evtNamespace?: string | string[]): boolean;
|
|
33
43
|
|
|
34
44
|
/**
|
|
35
|
-
* Listen to the pagehide and visibility changing to 'hidden' events
|
|
45
|
+
* Listen to the pagehide and visibility changing to 'hidden' events, because the 'visibilitychange' uses
|
|
46
|
+
* an internal proxy to detect the visibility state you SHOULD use a unique namespace when if you plan to call
|
|
47
|
+
* removePageShowEventListener as the remove ignores the listener argument for the 'visibilitychange' event.
|
|
36
48
|
* @param listener - The event callback to call when a page hide event is triggered
|
|
37
49
|
* @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
|
|
50
|
+
* @param evtNamespace - [Optional] A Namespace to append to the event listeners so they can be uniquely identified and removed
|
|
51
|
+
* based on this namespace. This call also adds an additional unique "pageshow" namespace to the events
|
|
52
|
+
* so that only the matching "removePageHideEventListener" can remove these events.
|
|
38
53
|
* Suggestion: pass as true if you are also calling addPageUnloadEventListener as that also hooks pagehide
|
|
39
54
|
* @returns true - when at least one of the events was registered otherwise false
|
|
40
55
|
*/
|
|
41
|
-
function addPageHideEventListener(listener: any, excludeEvents?: string[]): boolean;
|
|
56
|
+
function addPageHideEventListener(listener: any, excludeEvents: string[], evtNamespace?: string | string[]): boolean;
|
|
42
57
|
|
|
43
58
|
/**
|
|
44
|
-
* Listen to the pageshow and visibility changing to 'visible' events
|
|
59
|
+
* Listen to the pageshow and visibility changing to 'visible' events, because the 'visibilitychange' uses
|
|
60
|
+
* an internal proxy to detect the visibility state you SHOULD use a unique namespace when if you plan to call
|
|
61
|
+
* removePageShowEventListener as the remove ignores the listener argument for the 'visibilitychange' event.
|
|
45
62
|
* @param listener - The event callback to call when a page is show event is triggered
|
|
46
63
|
* @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
|
|
64
|
+
* @param evtNamespace - [Optional/Recommended] A Namespace to append to the event listeners so they can be uniquely
|
|
65
|
+
* identified and removed based on this namespace. This call also adds an additional unique "pageshow" namespace to the events
|
|
66
|
+
* so that only the matching "removePageShowEventListener" can remove these events.
|
|
47
67
|
* @returns true - when at least one of the events was registered otherwise false
|
|
48
68
|
*/
|
|
49
|
-
function addPageShowEventListener(listener: any, excludeEvents?: string[]): boolean;
|
|
69
|
+
function addPageShowEventListener(listener: any, excludeEvents: string[], evtNamespace?: string | string[]): boolean;
|
|
50
70
|
|
|
51
71
|
/**
|
|
52
72
|
* Listen to the 'beforeunload', 'unload' and 'pagehide' events which indicates a page unload is occurring,
|
|
@@ -56,9 +76,10 @@ declare namespace ApplicationInsights {
|
|
|
56
76
|
* need to listen to the 'addPageHideEventListener' and 'addPageShowEventListener' events.
|
|
57
77
|
* @param listener - The event callback to call when a page unload event is triggered
|
|
58
78
|
* @param excludeEvents - [Optional] An array of events that should not be hooked, unless no other events can be.
|
|
79
|
+
* @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
|
|
59
80
|
* @returns true - when at least one of the events was registered otherwise false
|
|
60
81
|
*/
|
|
61
|
-
function addPageUnloadEventListener(listener: any, excludeEvents?: string[]): boolean;
|
|
82
|
+
function addPageUnloadEventListener(listener: any, excludeEvents: string[], evtNamespace?: string | string[]): boolean;
|
|
62
83
|
|
|
63
84
|
class AppInsightsCore extends BaseCore implements IAppInsightsCore {
|
|
64
85
|
constructor();
|
|
@@ -111,7 +132,7 @@ declare namespace ApplicationInsights {
|
|
|
111
132
|
/**
|
|
112
133
|
* Binds the specified function to an event, so that the function gets called whenever the event fires on the object
|
|
113
134
|
* @param obj Object to add the event too.
|
|
114
|
-
* @param eventNameWithoutOn String that specifies any of the standard DHTML Events without "on" prefix
|
|
135
|
+
* @param eventNameWithoutOn String that specifies any of the standard DHTML Events without "on" prefix and optional (dot "." prefixed) namespaces "click" "click.mynamespace".
|
|
115
136
|
* @param handlerRef Pointer that specifies the function to call when event fires
|
|
116
137
|
* @param useCapture [Optional] Defaults to false
|
|
117
138
|
* @returns True if the function was bound successfully to the event, otherwise false
|
|
@@ -168,7 +189,26 @@ declare namespace ApplicationInsights {
|
|
|
168
189
|
* @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
|
|
169
190
|
*/
|
|
170
191
|
addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
|
|
192
|
+
/**
|
|
193
|
+
* Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
|
|
194
|
+
* to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
|
|
195
|
+
* unload call return `true` stating that all plugins reported that they also unloaded, the recommended
|
|
196
|
+
* approach is to create a new instance and initialize that instance.
|
|
197
|
+
* This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
|
|
198
|
+
* to successfully remove any global references or they may just be completing the unload process asynchronously.
|
|
199
|
+
*/
|
|
200
|
+
unload(isAsync?: boolean, unloadComplete?: () => void): void;
|
|
171
201
|
getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
|
|
202
|
+
addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
|
|
203
|
+
/**
|
|
204
|
+
* Returns the unique event namespace that should be used
|
|
205
|
+
*/
|
|
206
|
+
evtNamespace(): string;
|
|
207
|
+
/**
|
|
208
|
+
* Add an unload handler that will be called when the SDK is being unloaded
|
|
209
|
+
* @param handler - the handler
|
|
210
|
+
*/
|
|
211
|
+
addUnloadCb(handler: UnloadHandler): void;
|
|
172
212
|
protected releaseQueue(): void;
|
|
173
213
|
}
|
|
174
214
|
|
|
@@ -217,9 +257,32 @@ declare namespace ApplicationInsights {
|
|
|
217
257
|
* Internal helper to allow setting of the internal initialized setting for inherited instances and unit testing
|
|
218
258
|
*/
|
|
219
259
|
protected setInitialized: (isInitialized: boolean) => void;
|
|
260
|
+
/**
|
|
261
|
+
* Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
|
|
262
|
+
* finishes it's removal.
|
|
263
|
+
* @param unloadCtx - This is the context that should be used during unloading.
|
|
264
|
+
* @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.
|
|
265
|
+
* @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.
|
|
266
|
+
* @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
|
|
267
|
+
*/
|
|
268
|
+
protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
|
|
220
269
|
constructor();
|
|
221
270
|
initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
271
|
+
/**
|
|
272
|
+
* Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
|
|
273
|
+
* therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
|
|
274
|
+
* processTelemetry calls are ignored and it just calls the processNext() with the provided context.
|
|
275
|
+
* @param unloadCtx - This is the context that should be used during unloading.
|
|
276
|
+
* @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.
|
|
277
|
+
* @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
|
|
278
|
+
*/
|
|
279
|
+
teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
|
|
222
280
|
abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
281
|
+
/**
|
|
282
|
+
* Add an unload handler that will be called when the SDK is being unloaded
|
|
283
|
+
* @param handler - the handler
|
|
284
|
+
*/
|
|
285
|
+
protected _addUnloadCb(handler: UnloadHandler): void;
|
|
223
286
|
/**
|
|
224
287
|
* Add this hook so that it is automatically removed during unloading
|
|
225
288
|
* @param hooks - The single hook or an array of IInstrumentHook objects
|
|
@@ -250,14 +313,29 @@ declare namespace ApplicationInsights {
|
|
|
250
313
|
|
|
251
314
|
function createCookieMgr(rootConfig?: IConfiguration, logger?: IDiagnosticLogger): ICookieMgr;
|
|
252
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Create an enum style object which has both the key => value and value => key mappings
|
|
318
|
+
* @param values - The values to populate on the new object
|
|
319
|
+
* @returns
|
|
320
|
+
*/
|
|
321
|
+
function createEnumStyle<T>(values: T): T;
|
|
322
|
+
|
|
253
323
|
/**
|
|
254
324
|
* Creates a new Telemetry Item context with the current config, core and plugin execution chain
|
|
255
325
|
* @param plugins - The plugin instances that will be executed
|
|
256
326
|
* @param config - The current config
|
|
257
327
|
* @param core - The current core instance
|
|
328
|
+
* @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
|
|
258
329
|
*/
|
|
259
330
|
function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext;
|
|
260
331
|
|
|
332
|
+
function createUniqueNamespace(name: string, includeVersion?: boolean): string;
|
|
333
|
+
|
|
334
|
+
function createUnloadHandlerContainer(): {
|
|
335
|
+
add: (handler: UnloadHandler) => void;
|
|
336
|
+
run: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
|
|
337
|
+
};
|
|
338
|
+
|
|
261
339
|
/**
|
|
262
340
|
* 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)
|
|
263
341
|
* https://caniuse.com/#search=Date.now
|
|
@@ -274,8 +352,11 @@ declare namespace ApplicationInsights {
|
|
|
274
352
|
/**
|
|
275
353
|
* Removes an event handler for the specified event
|
|
276
354
|
* @param Object to remove the event from
|
|
277
|
-
* @param eventNameWithoutOn {string} - The name of the event
|
|
278
|
-
*
|
|
355
|
+
* @param eventNameWithoutOn {string} - The name of the event, with optional namespaces or just the namespaces,
|
|
356
|
+
* such as "click", "click.mynamespace" or ".mynamespace"
|
|
357
|
+
* @param handlerRef {any} - The callback function that needs to be removed from the given event, when using a
|
|
358
|
+
* namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
|
|
359
|
+
* otherwise this will only remove events with this specific handler.
|
|
279
360
|
* @param useCapture [Optional] Defaults to false
|
|
280
361
|
*/
|
|
281
362
|
function detachEvent(obj: any, eventNameWithoutOn: string, handlerRef: any, useCapture?: boolean): void;
|
|
@@ -356,8 +437,131 @@ declare namespace ApplicationInsights {
|
|
|
356
437
|
*/
|
|
357
438
|
function dumpObj(object: any): string;
|
|
358
439
|
|
|
440
|
+
const enum _eInternalMessageId {
|
|
441
|
+
BrowserDoesNotSupportLocalStorage = 0,
|
|
442
|
+
BrowserCannotReadLocalStorage = 1,
|
|
443
|
+
BrowserCannotReadSessionStorage = 2,
|
|
444
|
+
BrowserCannotWriteLocalStorage = 3,
|
|
445
|
+
BrowserCannotWriteSessionStorage = 4,
|
|
446
|
+
BrowserFailedRemovalFromLocalStorage = 5,
|
|
447
|
+
BrowserFailedRemovalFromSessionStorage = 6,
|
|
448
|
+
CannotSendEmptyTelemetry = 7,
|
|
449
|
+
ClientPerformanceMathError = 8,
|
|
450
|
+
ErrorParsingAISessionCookie = 9,
|
|
451
|
+
ErrorPVCalc = 10,
|
|
452
|
+
ExceptionWhileLoggingError = 11,
|
|
453
|
+
FailedAddingTelemetryToBuffer = 12,
|
|
454
|
+
FailedMonitorAjaxAbort = 13,
|
|
455
|
+
FailedMonitorAjaxDur = 14,
|
|
456
|
+
FailedMonitorAjaxOpen = 15,
|
|
457
|
+
FailedMonitorAjaxRSC = 16,
|
|
458
|
+
FailedMonitorAjaxSend = 17,
|
|
459
|
+
FailedMonitorAjaxGetCorrelationHeader = 18,
|
|
460
|
+
FailedToAddHandlerForOnBeforeUnload = 19,
|
|
461
|
+
FailedToSendQueuedTelemetry = 20,
|
|
462
|
+
FailedToReportDataLoss = 21,
|
|
463
|
+
FlushFailed = 22,
|
|
464
|
+
MessageLimitPerPVExceeded = 23,
|
|
465
|
+
MissingRequiredFieldSpecification = 24,
|
|
466
|
+
NavigationTimingNotSupported = 25,
|
|
467
|
+
OnError = 26,
|
|
468
|
+
SessionRenewalDateIsZero = 27,
|
|
469
|
+
SenderNotInitialized = 28,
|
|
470
|
+
StartTrackEventFailed = 29,
|
|
471
|
+
StopTrackEventFailed = 30,
|
|
472
|
+
StartTrackFailed = 31,
|
|
473
|
+
StopTrackFailed = 32,
|
|
474
|
+
TelemetrySampledAndNotSent = 33,
|
|
475
|
+
TrackEventFailed = 34,
|
|
476
|
+
TrackExceptionFailed = 35,
|
|
477
|
+
TrackMetricFailed = 36,
|
|
478
|
+
TrackPVFailed = 37,
|
|
479
|
+
TrackPVFailedCalc = 38,
|
|
480
|
+
TrackTraceFailed = 39,
|
|
481
|
+
TransmissionFailed = 40,
|
|
482
|
+
FailedToSetStorageBuffer = 41,
|
|
483
|
+
FailedToRestoreStorageBuffer = 42,
|
|
484
|
+
InvalidBackendResponse = 43,
|
|
485
|
+
FailedToFixDepricatedValues = 44,
|
|
486
|
+
InvalidDurationValue = 45,
|
|
487
|
+
TelemetryEnvelopeInvalid = 46,
|
|
488
|
+
CreateEnvelopeError = 47,
|
|
489
|
+
CannotSerializeObject = 48,
|
|
490
|
+
CannotSerializeObjectNonSerializable = 49,
|
|
491
|
+
CircularReferenceDetected = 50,
|
|
492
|
+
ClearAuthContextFailed = 51,
|
|
493
|
+
ExceptionTruncated = 52,
|
|
494
|
+
IllegalCharsInName = 53,
|
|
495
|
+
ItemNotInArray = 54,
|
|
496
|
+
MaxAjaxPerPVExceeded = 55,
|
|
497
|
+
MessageTruncated = 56,
|
|
498
|
+
NameTooLong = 57,
|
|
499
|
+
SampleRateOutOfRange = 58,
|
|
500
|
+
SetAuthContextFailed = 59,
|
|
501
|
+
SetAuthContextFailedAccountName = 60,
|
|
502
|
+
StringValueTooLong = 61,
|
|
503
|
+
StartCalledMoreThanOnce = 62,
|
|
504
|
+
StopCalledWithoutStart = 63,
|
|
505
|
+
TelemetryInitializerFailed = 64,
|
|
506
|
+
TrackArgumentsNotSpecified = 65,
|
|
507
|
+
UrlTooLong = 66,
|
|
508
|
+
SessionStorageBufferFull = 67,
|
|
509
|
+
CannotAccessCookie = 68,
|
|
510
|
+
IdTooLong = 69,
|
|
511
|
+
InvalidEvent = 70,
|
|
512
|
+
FailedMonitorAjaxSetRequestHeader = 71,
|
|
513
|
+
SendBrowserInfoOnUserInit = 72,
|
|
514
|
+
PluginException = 73,
|
|
515
|
+
NotificationException = 74,
|
|
516
|
+
SnippetScriptLoadFailure = 99,
|
|
517
|
+
InvalidInstrumentationKey = 100,
|
|
518
|
+
CannotParseAiBlobValue = 101,
|
|
519
|
+
InvalidContentBlob = 102,
|
|
520
|
+
TrackPageActionEventFailed = 103,
|
|
521
|
+
FailedAddingCustomDefinedRequestContext = 104,
|
|
522
|
+
InMemoryStorageBufferFull = 105
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const enum eLoggingSeverity {
|
|
526
|
+
/**
|
|
527
|
+
* Error will be sent as internal telemetry
|
|
528
|
+
*/
|
|
529
|
+
CRITICAL = 1,
|
|
530
|
+
/**
|
|
531
|
+
* Error will NOT be sent as internal telemetry, and will only be shown in browser console
|
|
532
|
+
*/
|
|
533
|
+
WARNING = 2
|
|
534
|
+
}
|
|
535
|
+
|
|
359
536
|
const EventHelper: IEventHelper;
|
|
360
537
|
|
|
538
|
+
/**
|
|
539
|
+
* Removes an event handler for the specified event
|
|
540
|
+
* @param Object to remove the event from
|
|
541
|
+
* @param eventName {string} - The name of the event, with optional namespaces or just the namespaces,
|
|
542
|
+
* such as "click", "click.mynamespace" or ".mynamespace"
|
|
543
|
+
* @param handlerRef {any} - The callback function that needs to be removed from the given event, when using a
|
|
544
|
+
* namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
|
|
545
|
+
* otherwise this will only remove events with this specific handler.
|
|
546
|
+
* @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
|
|
547
|
+
* if the eventName also includes a namespace the namespace(s) are merged into a single namespace
|
|
548
|
+
* @param useCapture [Optional] Defaults to false
|
|
549
|
+
*/
|
|
550
|
+
function eventOff<T>(target: T, eventName: string, handlerRef: any, evtNamespace?: string | string[], useCapture?: boolean): void;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Binds the specified function to an event, so that the function gets called whenever the event fires on the object
|
|
554
|
+
* @param obj Object to add the event too.
|
|
555
|
+
* @param eventName String that specifies any of the standard DHTML Events without "on" prefix, if may also include an optional (dot "." prefixed)
|
|
556
|
+
* namespaces "click" "click.mynamespace" in addition to specific namespaces.
|
|
557
|
+
* @param handlerRef Pointer that specifies the function to call when event fires
|
|
558
|
+
* @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
|
|
559
|
+
* if the eventName also includes a namespace the namespace(s) are merged into a single namespace
|
|
560
|
+
* @param useCapture [Optional] Defaults to false
|
|
561
|
+
* @returns True if the function was bound successfully to the event, otherwise false
|
|
562
|
+
*/
|
|
563
|
+
function eventOn<T>(target: T, eventName: string, handlerRef: any, evtNamespace?: string | string[], useCapture?: boolean): boolean;
|
|
564
|
+
|
|
361
565
|
/**
|
|
362
566
|
* The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
|
|
363
567
|
*/
|
|
@@ -603,11 +807,97 @@ declare namespace ApplicationInsights {
|
|
|
603
807
|
* Return a new instance of the IProcessTelemetryContext for processing events
|
|
604
808
|
*/
|
|
605
809
|
getProcessTelContext(): IProcessTelemetryContext;
|
|
810
|
+
/**
|
|
811
|
+
* Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
|
|
812
|
+
* to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
|
|
813
|
+
* unload call return `true` stating that all plugins reported that they also unloaded, the recommended
|
|
814
|
+
* approach is to create a new instance and initialize that instance.
|
|
815
|
+
* This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
|
|
816
|
+
* to successfully remove any global references or they may just be completing the unload process asynchronously.
|
|
817
|
+
*/
|
|
818
|
+
unload(isAsync?: boolean, unloadComplete?: () => void): void;
|
|
606
819
|
/**
|
|
607
820
|
* Find and return the (first) plugin with the specified identifier if present
|
|
608
821
|
* @param pluginIdentifier
|
|
609
822
|
*/
|
|
610
823
|
getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
|
|
824
|
+
/**
|
|
825
|
+
* Add a new plugin to the installation
|
|
826
|
+
* @param plugin - The new plugin to add
|
|
827
|
+
* @param replaceExisting - should any existing plugin be replaced
|
|
828
|
+
* @param doAsync - Should the add be performed asynchronously
|
|
829
|
+
*/
|
|
830
|
+
addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
|
|
831
|
+
/**
|
|
832
|
+
* Returns the unique event namespace that should be used when registering events
|
|
833
|
+
*/
|
|
834
|
+
evtNamespace(): string;
|
|
835
|
+
/**
|
|
836
|
+
* Add a handler that will be called when the SDK is being unloaded
|
|
837
|
+
* @param handler - the handler
|
|
838
|
+
*/
|
|
839
|
+
addUnloadCb(handler: UnloadHandler): void;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
interface IBaseProcessingContext {
|
|
843
|
+
/**
|
|
844
|
+
* The current core instance for the request
|
|
845
|
+
*/
|
|
846
|
+
core: () => IAppInsightsCore;
|
|
847
|
+
/**
|
|
848
|
+
* THe current diagnostic logger for the request
|
|
849
|
+
*/
|
|
850
|
+
diagLog: () => IDiagnosticLogger;
|
|
851
|
+
/**
|
|
852
|
+
* Gets the current core config instance
|
|
853
|
+
*/
|
|
854
|
+
getCfg: () => IConfiguration;
|
|
855
|
+
/**
|
|
856
|
+
* Gets the named extension config
|
|
857
|
+
*/
|
|
858
|
+
getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
|
|
859
|
+
/**
|
|
860
|
+
* Gets the named config from either the named identifier extension or core config if neither exist then the
|
|
861
|
+
* default value is returned
|
|
862
|
+
* @param identifier The named extension identifier
|
|
863
|
+
* @param field The config field name
|
|
864
|
+
* @param defaultValue The default value to return if no defined config exists
|
|
865
|
+
*/
|
|
866
|
+
getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
|
|
867
|
+
/**
|
|
868
|
+
* Helper to allow plugins to check and possibly shortcut executing code only
|
|
869
|
+
* required if there is a nextPlugin
|
|
870
|
+
*/
|
|
871
|
+
hasNext: () => boolean;
|
|
872
|
+
/**
|
|
873
|
+
* Returns the next configured plugin proxy
|
|
874
|
+
*/
|
|
875
|
+
getNext: () => ITelemetryPluginChain;
|
|
876
|
+
/**
|
|
877
|
+
* Helper to set the next plugin proxy
|
|
878
|
+
*/
|
|
879
|
+
setNext: (nextCtx: ITelemetryPluginChain) => void;
|
|
880
|
+
/**
|
|
881
|
+
* Synchronously iterate over the context chain running the callback for each plugin, once
|
|
882
|
+
* every plugin has been executed via the callback, any associated onComplete will be called.
|
|
883
|
+
* @param callback - The function call for each plugin in the context chain
|
|
884
|
+
*/
|
|
885
|
+
iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
|
|
886
|
+
/**
|
|
887
|
+
* Set the function to call when the current chain has executed all processNext or unloadNext items.
|
|
888
|
+
* @param onComplete - The onComplete to call
|
|
889
|
+
* @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
|
|
890
|
+
* @param args - Any additional arguments to pass to the onComplete function
|
|
891
|
+
*/
|
|
892
|
+
onComplete: (onComplete: Function, that?: any, ...args: any[]) => void;
|
|
893
|
+
/**
|
|
894
|
+
* Create a new context using the core and config from the current instance, returns a new instance of the same type
|
|
895
|
+
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
896
|
+
* then the current execution order will be copied.
|
|
897
|
+
* @param startAt - The plugin to start processing from, if missing from the execution
|
|
898
|
+
* order then the next plugin will be NOT set.
|
|
899
|
+
*/
|
|
900
|
+
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
|
|
611
901
|
}
|
|
612
902
|
|
|
613
903
|
/**
|
|
@@ -623,9 +913,14 @@ declare namespace ApplicationInsights {
|
|
|
623
913
|
*/
|
|
624
914
|
resume(): void;
|
|
625
915
|
/**
|
|
626
|
-
* Tear down
|
|
916
|
+
* Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
|
|
917
|
+
* therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
|
|
918
|
+
* processTelemetry calls are ignored and it just calls the processNext() with the provided context.
|
|
919
|
+
* @param unloadCtx - This is the context that should be used during unloading.
|
|
920
|
+
* @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.
|
|
921
|
+
* @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
|
|
627
922
|
*/
|
|
628
|
-
teardown()
|
|
923
|
+
teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
|
|
629
924
|
/**
|
|
630
925
|
* Flush to send data immediately; channel should default to sending data asynchronously
|
|
631
926
|
* @param async - send data asynchronously when true
|
|
@@ -994,7 +1289,7 @@ declare namespace ApplicationInsights {
|
|
|
994
1289
|
* @param callback {any} - The callback function that needs to be executed for the given event
|
|
995
1290
|
* @return {boolean} - true if the handler was successfully added
|
|
996
1291
|
*/
|
|
997
|
-
addEventHandler: (eventName: string, callback: any) => boolean;
|
|
1292
|
+
addEventHandler: (eventName: string, callback: any, evtNamespace?: string | string[]) => boolean;
|
|
998
1293
|
/**
|
|
999
1294
|
* 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)
|
|
1000
1295
|
* https://caniuse.com/#search=Date.now
|
|
@@ -1230,6 +1525,20 @@ declare namespace ApplicationInsights {
|
|
|
1230
1525
|
|
|
1231
1526
|
interface ILoadedPlugin<T extends IPlugin> {
|
|
1232
1527
|
plugin: T;
|
|
1528
|
+
/**
|
|
1529
|
+
* Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
|
|
1530
|
+
* via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
|
|
1531
|
+
* @returns boolean = true if the plugin is in a state where it is operational.
|
|
1532
|
+
*/
|
|
1533
|
+
isEnabled: () => boolean;
|
|
1534
|
+
/**
|
|
1535
|
+
* You can optionally enable / disable a plugin from processing events.
|
|
1536
|
+
* Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
|
|
1537
|
+
* as the plugin must also have been successfully initialized and not had it's `teardown` method called
|
|
1538
|
+
* (unless it's also been re-initialized)
|
|
1539
|
+
*/
|
|
1540
|
+
setEnabled: (isEnabled: boolean) => void;
|
|
1541
|
+
remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
|
|
1233
1542
|
}
|
|
1234
1543
|
|
|
1235
1544
|
/**
|
|
@@ -1448,7 +1757,7 @@ declare namespace ApplicationInsights {
|
|
|
1448
1757
|
InMemoryStorageBufferFull: number;
|
|
1449
1758
|
};
|
|
1450
1759
|
|
|
1451
|
-
type _InternalMessageId = number |
|
|
1760
|
+
type _InternalMessageId = number | _eInternalMessageId;
|
|
1452
1761
|
|
|
1453
1762
|
/**
|
|
1454
1763
|
* This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
|
|
@@ -1569,10 +1878,14 @@ declare namespace ApplicationInsights {
|
|
|
1569
1878
|
*/
|
|
1570
1879
|
isInitialized?: () => boolean;
|
|
1571
1880
|
/**
|
|
1572
|
-
* Tear down the plugin and remove any hooked value, the plugin should
|
|
1573
|
-
* therefore
|
|
1881
|
+
* Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
|
|
1882
|
+
* therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
|
|
1883
|
+
* processTelemetry calls are ignored and it just calls the processNext() with the provided context.
|
|
1884
|
+
* @param unloadCtx - This is the context that should be used during unloading.
|
|
1885
|
+
* @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.
|
|
1886
|
+
* @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
|
|
1574
1887
|
*/
|
|
1575
|
-
teardown?: () => void;
|
|
1888
|
+
teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
|
|
1576
1889
|
/**
|
|
1577
1890
|
* Extension name
|
|
1578
1891
|
*/
|
|
@@ -1587,67 +1900,47 @@ declare namespace ApplicationInsights {
|
|
|
1587
1900
|
* The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
|
|
1588
1901
|
* between multiple AppInsights instances
|
|
1589
1902
|
*/
|
|
1590
|
-
interface IProcessTelemetryContext {
|
|
1591
|
-
/**
|
|
1592
|
-
* The current core instance for the request
|
|
1593
|
-
*/
|
|
1594
|
-
core: () => IAppInsightsCore;
|
|
1595
|
-
/**
|
|
1596
|
-
* THe current diagnostic logger for the request
|
|
1597
|
-
*/
|
|
1598
|
-
diagLog: () => IDiagnosticLogger;
|
|
1599
|
-
/**
|
|
1600
|
-
* Gets the current core config instance
|
|
1601
|
-
*/
|
|
1602
|
-
getCfg: () => IConfiguration;
|
|
1603
|
-
/**
|
|
1604
|
-
* Gets the named extension config
|
|
1605
|
-
*/
|
|
1606
|
-
getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
|
|
1607
|
-
/**
|
|
1608
|
-
* Gets the named config from either the named identifier extension or core config if neither exist then the
|
|
1609
|
-
* default value is returned
|
|
1610
|
-
* @param identifier The named extension identifier
|
|
1611
|
-
* @param field The config field name
|
|
1612
|
-
* @param defaultValue The default value to return if no defined config exists
|
|
1613
|
-
*/
|
|
1614
|
-
getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
|
|
1615
|
-
/**
|
|
1616
|
-
* Helper to allow plugins to check and possibly shortcut executing code only
|
|
1617
|
-
* required if there is a nextPlugin
|
|
1618
|
-
*/
|
|
1619
|
-
hasNext: () => boolean;
|
|
1620
|
-
/**
|
|
1621
|
-
* Returns the next configured plugin proxy
|
|
1622
|
-
*/
|
|
1623
|
-
getNext: () => ITelemetryPluginChain;
|
|
1624
|
-
/**
|
|
1625
|
-
* Helper to set the next plugin proxy
|
|
1626
|
-
*/
|
|
1627
|
-
setNext: (nextCtx: ITelemetryPluginChain) => void;
|
|
1903
|
+
interface IProcessTelemetryContext extends IBaseProcessingContext {
|
|
1628
1904
|
/**
|
|
1629
1905
|
* Call back for telemetry processing before it it is sent
|
|
1630
1906
|
* @param env - This is the current event being reported
|
|
1907
|
+
* @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
|
|
1631
1908
|
*/
|
|
1632
|
-
processNext: (env: ITelemetryItem) => void;
|
|
1633
|
-
/**
|
|
1634
|
-
* Synchronously iterate over the context chain running the callback for each plugin, once
|
|
1635
|
-
* every plugin has been executed via the callback, any associated onComplete will be called.
|
|
1636
|
-
* @param callback - The function call for each plugin in the context chain
|
|
1637
|
-
*/
|
|
1638
|
-
iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
|
|
1909
|
+
processNext: (env: ITelemetryItem) => boolean | void;
|
|
1639
1910
|
/**
|
|
1640
|
-
* Create a new context using the core and config from the current instance
|
|
1911
|
+
* Create a new context using the core and config from the current instance, returns a new instance of the same type
|
|
1641
1912
|
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
1642
1913
|
* then the current execution order will be copied.
|
|
1643
1914
|
* @param startAt - The plugin to start processing from, if missing from the execution
|
|
1644
1915
|
* order then the next plugin will be NOT set.
|
|
1645
1916
|
*/
|
|
1646
1917
|
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
/**
|
|
1921
|
+
* The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
|
|
1922
|
+
* between multiple AppInsights instances
|
|
1923
|
+
*/
|
|
1924
|
+
interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
|
|
1647
1925
|
/**
|
|
1648
|
-
*
|
|
1926
|
+
* This Plugin has finished unloading, so unload the next one
|
|
1927
|
+
* @param uploadState - The state of the unload process
|
|
1928
|
+
* @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
|
|
1649
1929
|
*/
|
|
1650
|
-
|
|
1930
|
+
processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
|
|
1931
|
+
/**
|
|
1932
|
+
* Create a new context using the core and config from the current instance, returns a new instance of the same type
|
|
1933
|
+
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
1934
|
+
* then the current execution order will be copied.
|
|
1935
|
+
* @param startAt - The plugin to start processing from, if missing from the execution
|
|
1936
|
+
* order then the next plugin will be NOT set.
|
|
1937
|
+
*/
|
|
1938
|
+
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
interface _IRegisteredEvents {
|
|
1942
|
+
name: string;
|
|
1943
|
+
handler: any;
|
|
1651
1944
|
}
|
|
1652
1945
|
|
|
1653
1946
|
/**
|
|
@@ -1806,15 +2099,7 @@ declare namespace ApplicationInsights {
|
|
|
1806
2099
|
/**
|
|
1807
2100
|
* Configuration provided to SDK core
|
|
1808
2101
|
*/
|
|
1809
|
-
interface ITelemetryPlugin extends IPlugin {
|
|
1810
|
-
/**
|
|
1811
|
-
* Call back for telemetry processing before it it is sent
|
|
1812
|
-
* @param env - This is the current event being reported
|
|
1813
|
-
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
|
|
1814
|
-
* can optionally use this to access the current core instance or define / pass additional information
|
|
1815
|
-
* to later plugins (vs appending items to the telemetry item)
|
|
1816
|
-
*/
|
|
1817
|
-
processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
|
|
2102
|
+
interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
|
|
1818
2103
|
/**
|
|
1819
2104
|
* Set next extension for telemetry processing, this is not optional as plugins should use the
|
|
1820
2105
|
* processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
|
|
@@ -1830,7 +2115,7 @@ declare namespace ApplicationInsights {
|
|
|
1830
2115
|
/**
|
|
1831
2116
|
* Configuration provided to SDK core
|
|
1832
2117
|
*/
|
|
1833
|
-
interface ITelemetryPluginChain {
|
|
2118
|
+
interface ITelemetryPluginChain extends ITelemetryProcessor {
|
|
1834
2119
|
/**
|
|
1835
2120
|
* Returns the underlying plugin that is being proxied for the processTelemetry call
|
|
1836
2121
|
*/
|
|
@@ -1839,6 +2124,16 @@ declare namespace ApplicationInsights {
|
|
|
1839
2124
|
* Returns the next plugin
|
|
1840
2125
|
*/
|
|
1841
2126
|
getNext: () => ITelemetryPluginChain;
|
|
2127
|
+
/**
|
|
2128
|
+
* This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
|
|
2129
|
+
* call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
|
|
2130
|
+
* @param unloadCtx - The unload context to use for this call.
|
|
2131
|
+
* @param unloadState - The details of the unload operation
|
|
2132
|
+
*/
|
|
2133
|
+
unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
interface ITelemetryProcessor {
|
|
1842
2137
|
/**
|
|
1843
2138
|
* Call back for telemetry processing before it it is sent
|
|
1844
2139
|
* @param env - This is the current event being reported
|
|
@@ -1846,7 +2141,18 @@ declare namespace ApplicationInsights {
|
|
|
1846
2141
|
* can optionally use this to access the current core instance or define / pass additional information
|
|
1847
2142
|
* to later plugins (vs appending items to the telemetry item)
|
|
1848
2143
|
*/
|
|
1849
|
-
processTelemetry: (env: ITelemetryItem, itemCtx
|
|
2144
|
+
processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
interface ITelemetryUnloadState {
|
|
2148
|
+
reason: TelemetryUnloadReason;
|
|
2149
|
+
isAsync: boolean;
|
|
2150
|
+
flushComplete?: boolean;
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
interface IUnloadHandlerContainer {
|
|
2154
|
+
add: (handler: UnloadHandler) => void;
|
|
2155
|
+
run: (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
|
|
1850
2156
|
}
|
|
1851
2157
|
|
|
1852
2158
|
/**
|
|
@@ -1861,16 +2167,14 @@ declare namespace ApplicationInsights {
|
|
|
1861
2167
|
*/
|
|
1862
2168
|
function _legacyCookieMgr(config?: IConfiguration, logger?: IDiagnosticLogger): ICookieMgr;
|
|
1863
2169
|
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
WARNING = 2
|
|
1873
|
-
}
|
|
2170
|
+
const LoggingSeverity: {
|
|
2171
|
+
CRITICAL: number;
|
|
2172
|
+
WARNING: number;
|
|
2173
|
+
};
|
|
2174
|
+
|
|
2175
|
+
type LoggingSeverity = number | eLoggingSeverity;
|
|
2176
|
+
|
|
2177
|
+
function mergeEvtNamespace(theNamespace: string, namespaces: string | string[]): string | string[];
|
|
1874
2178
|
|
|
1875
2179
|
const MinChannelPriorty: number;
|
|
1876
2180
|
|
|
@@ -1962,6 +2266,18 @@ declare namespace ApplicationInsights {
|
|
|
1962
2266
|
*/
|
|
1963
2267
|
function objDefineAccessors<T>(target: any, prop: string, getProp?: () => T, setProp?: (v: T) => void): boolean;
|
|
1964
2268
|
|
|
2269
|
+
/**
|
|
2270
|
+
* Pass in the objects to merge as arguments, this will only "merge" (extend) properties that are owned by the object.
|
|
2271
|
+
* It will NOT merge inherited or non-enumerable properties.
|
|
2272
|
+
* @param obj1 - object to merge. Set this argument to 'true' for a deep extend.
|
|
2273
|
+
* @param obj2 - object to merge.
|
|
2274
|
+
* @param obj3 - object to merge.
|
|
2275
|
+
* @param obj4 - object to merge.
|
|
2276
|
+
* @param obj5 - object to merge.
|
|
2277
|
+
* @returns The extended first object.
|
|
2278
|
+
*/
|
|
2279
|
+
function objExtend<T1, T2, T3, T4, T5, T6>(obj?: boolean | T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6;
|
|
2280
|
+
|
|
1965
2281
|
/**
|
|
1966
2282
|
* This is a helper function for the equivalent of arForEach(objKeys(target), callbackFn), this is a
|
|
1967
2283
|
* performance optimization to avoid the creation of a new array for large objects
|
|
@@ -2108,8 +2424,9 @@ declare namespace ApplicationInsights {
|
|
|
2108
2424
|
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
|
|
2109
2425
|
* can optionally use this to access the current core instance or define / pass additional information
|
|
2110
2426
|
* to later plugins (vs appending items to the telemetry item)
|
|
2427
|
+
* @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
|
|
2111
2428
|
*/
|
|
2112
|
-
processNext: (env: ITelemetryItem) => void;
|
|
2429
|
+
processNext: (env: ITelemetryItem) => boolean | void;
|
|
2113
2430
|
/**
|
|
2114
2431
|
* Synchronously iterate over the context chain running the callback for each plugin, once
|
|
2115
2432
|
* every plugin has been executed via the callback, any associated onComplete will be called.
|
|
@@ -2117,7 +2434,6 @@ declare namespace ApplicationInsights {
|
|
|
2117
2434
|
*/
|
|
2118
2435
|
iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
|
|
2119
2436
|
/**
|
|
2120
|
-
/**
|
|
2121
2437
|
* Create a new context using the core and config from the current instance
|
|
2122
2438
|
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
2123
2439
|
* then the current execution order will be copied.
|
|
@@ -2155,6 +2471,17 @@ declare namespace ApplicationInsights {
|
|
|
2155
2471
|
*/
|
|
2156
2472
|
function proxyAssign<T, S>(target: T, source: S, chkSet?: (name: string, isFunc?: boolean, source?: S, target?: T) => boolean): T;
|
|
2157
2473
|
|
|
2474
|
+
function proxyFunctionAs<T, S>(target: T, name: string, source: S | (() => S), theFunc: (keyof S), overwriteTarget?: boolean): void;
|
|
2475
|
+
|
|
2476
|
+
/**
|
|
2477
|
+
* Creates proxy functions on the target which internally will call the source version with all arguments passed to the target method.
|
|
2478
|
+
*
|
|
2479
|
+
* @param target - The target object to be assigned with the source properties and functions
|
|
2480
|
+
* @param source - The source object which will be assigned / called by setting / calling the targets proxies
|
|
2481
|
+
* @param functionsToProxy - An array of function names that will be proxied on the target
|
|
2482
|
+
*/
|
|
2483
|
+
function proxyFunctions<T, S>(target: T, source: S | (() => S), functionsToProxy: (keyof S)[], overwriteTarget?: boolean): T;
|
|
2484
|
+
|
|
2158
2485
|
/**
|
|
2159
2486
|
* generate a random 32-bit number (0x000000..0xFFFFFFFF) or (-0x80000000..0x7FFFFFFF), defaults un-unsigned.
|
|
2160
2487
|
* @param signed - True to return a signed 32-bit number (-0x80000000..0x7FFFFFFF) otherwise an unsigned one (0x000000..0xFFFFFFFF)
|
|
@@ -2168,6 +2495,43 @@ declare namespace ApplicationInsights {
|
|
|
2168
2495
|
*/
|
|
2169
2496
|
function randomValue(maxValue: number): number;
|
|
2170
2497
|
|
|
2498
|
+
/**
|
|
2499
|
+
* Trys to remove event handler(s) for the specified event/namespace to the window, body and document
|
|
2500
|
+
* @param eventName {string} - The name of the event, with optional namespaces or just the namespaces,
|
|
2501
|
+
* such as "click", "click.mynamespace" or ".mynamespace"
|
|
2502
|
+
* @param callback {any} - - The callback function that needs to be removed from the given event, when using a
|
|
2503
|
+
* namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
|
|
2504
|
+
* otherwise this will only remove events with this specific handler.
|
|
2505
|
+
* @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
|
|
2506
|
+
*/
|
|
2507
|
+
function removeEventHandler(eventName: string, callback: any, evtNamespace?: string | string[]): void;
|
|
2508
|
+
|
|
2509
|
+
/**
|
|
2510
|
+
* Remove the listener from the array of events
|
|
2511
|
+
* @param events An string array of event names to bind the listener to
|
|
2512
|
+
* @param listener The event callback to call when the event is triggered
|
|
2513
|
+
* @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
|
|
2514
|
+
*/
|
|
2515
|
+
function removeEventListeners(events: string[], listener: any, evtNamespace?: string | string[]): void;
|
|
2516
|
+
|
|
2517
|
+
/**
|
|
2518
|
+
* Removes the pageHide event listeners added by addPageHideEventListener, because the 'visibilitychange' uses
|
|
2519
|
+
* an internal proxy to detect the visibility state you SHOULD use a unique namespace when calling addPageHideEventListener
|
|
2520
|
+
* as the remove ignores the listener argument for the 'visibilitychange' event.
|
|
2521
|
+
* @param listener - The specific listener to remove for the 'pageshow' event only (ignored for 'visibilitychange')
|
|
2522
|
+
* @param evtNamespace - The unique namespace used when calling addPageShowEventListener
|
|
2523
|
+
*/
|
|
2524
|
+
function removePageHideEventListener(listener: any, evtNamespace?: string | string[]): void;
|
|
2525
|
+
|
|
2526
|
+
/**
|
|
2527
|
+
* Remove any matching 'beforeunload', 'unload' and 'pagehide' events that may have been added via addEventListener,
|
|
2528
|
+
* addEventListeners, addPageUnloadEventListener or addPageHideEventListener.
|
|
2529
|
+
* @param listener - The specific event callback to to be removed
|
|
2530
|
+
* @param evtNamespace - [Optional] Namespace(s) uniquely identified and removed based on this namespace.
|
|
2531
|
+
* @returns true - when at least one of the events was registered otherwise false
|
|
2532
|
+
*/
|
|
2533
|
+
function removePageUnloadEventListener(listener: any, evtNamespace?: string | string[]): void;
|
|
2534
|
+
|
|
2171
2535
|
/**
|
|
2172
2536
|
* Helper to return the ICookieMgr from the core (if not null/undefined) or a default implementation
|
|
2173
2537
|
* associated with the configuration or a legacy default.
|
|
@@ -2211,6 +2575,10 @@ declare namespace ApplicationInsights {
|
|
|
2211
2575
|
* The event(s) being sent as a retry
|
|
2212
2576
|
*/
|
|
2213
2577
|
Retry = 5,
|
|
2578
|
+
/**
|
|
2579
|
+
* The SDK is unloading
|
|
2580
|
+
*/
|
|
2581
|
+
SdkUnload = 6,
|
|
2214
2582
|
/**
|
|
2215
2583
|
* Maximum batch size would be exceeded
|
|
2216
2584
|
*/
|
|
@@ -2299,6 +2667,28 @@ declare namespace ApplicationInsights {
|
|
|
2299
2667
|
|
|
2300
2668
|
type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
|
|
2301
2669
|
|
|
2670
|
+
/**
|
|
2671
|
+
* The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
|
|
2672
|
+
*/
|
|
2673
|
+
const enum TelemetryUnloadReason {
|
|
2674
|
+
/**
|
|
2675
|
+
* Teardown has been called without any context.
|
|
2676
|
+
*/
|
|
2677
|
+
ManualTeardown = 0,
|
|
2678
|
+
/**
|
|
2679
|
+
* Just this plugin is being removed
|
|
2680
|
+
*/
|
|
2681
|
+
PluginUnload = 1,
|
|
2682
|
+
/**
|
|
2683
|
+
* This instance of the plugin is being removed and replaced
|
|
2684
|
+
*/
|
|
2685
|
+
PluginReplace = 2,
|
|
2686
|
+
/**
|
|
2687
|
+
* The entire SDK is being unloaded
|
|
2688
|
+
*/
|
|
2689
|
+
SdkUnload = 50
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2302
2692
|
function throwError(message: string): never;
|
|
2303
2693
|
|
|
2304
2694
|
/**
|
|
@@ -2310,6 +2700,8 @@ declare namespace ApplicationInsights {
|
|
|
2310
2700
|
|
|
2311
2701
|
const Undefined = "undefined";
|
|
2312
2702
|
|
|
2703
|
+
type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
|
|
2704
|
+
|
|
2313
2705
|
function useXDomainRequest(): boolean | undefined;
|
|
2314
2706
|
|
|
2315
2707
|
|