@microsoft/applicationinsights-core-js 2.8.0-nightly.2202-06 → 2.8.0-nightly.2204-04
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 +1999 -793
- 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 +16363 -9167
- package/dist/applicationinsights-core-js.api.md +425 -48
- package/dist/applicationinsights-core-js.d.ts +784 -123
- package/dist/applicationinsights-core-js.js +1999 -793
- 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 +784 -123
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +3 -69
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +496 -99
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +120 -21
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +202 -87
- package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +4 -4
- package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js +7 -148
- 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 +25 -12
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +13 -12
- package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EventHelpers.js +477 -0
- package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -0
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +89 -86
- package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +3 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +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 +37 -42
- package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +430 -119
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +30 -4
- package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +60 -14
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +81 -0
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -0
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +33 -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.Enums/TelemetryUpdateReason.js +8 -0
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -2
- package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js.map +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 +6 -0
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +1 -0
- 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/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +8 -0
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +6 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +1 -0
- package/dist-esm/applicationinsights-core-js.js +12 -7
- package/dist-esm/applicationinsights-core-js.js.map +1 -1
- package/package.json +2 -2
- package/src/JavaScriptSDK/AppInsightsCore.ts +2 -101
- package/src/JavaScriptSDK/BaseCore.ts +696 -120
- package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +205 -31
- package/src/JavaScriptSDK/ChannelController.ts +242 -103
- package/src/JavaScriptSDK/CookieMgr.ts +7 -5
- package/src/JavaScriptSDK/CoreUtils.ts +8 -172
- package/src/JavaScriptSDK/DataCacheHelper.ts +106 -0
- package/src/JavaScriptSDK/DiagnosticLogger.ts +27 -12
- package/src/JavaScriptSDK/EnvUtils.ts +13 -12
- package/src/JavaScriptSDK/EventHelpers.ts +550 -0
- package/src/JavaScriptSDK/HelperFuncs.ts +123 -97
- package/src/JavaScriptSDK/InstrumentHooks.ts +4 -2
- package/src/JavaScriptSDK/InternalConstants.ts +26 -0
- package/src/JavaScriptSDK/NotificationManager.ts +34 -37
- package/src/JavaScriptSDK/PerfManager.ts +4 -7
- package/src/JavaScriptSDK/ProcessTelemetryContext.ts +543 -134
- package/src/JavaScriptSDK/RandomHelper.ts +35 -3
- package/src/JavaScriptSDK/TelemetryHelpers.ts +83 -21
- package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +111 -0
- package/src/JavaScriptSDK/UnloadHandlerContainer.ts +46 -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.Enums/TelemetryUpdateReason.ts +27 -0
- package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +82 -2
- package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +16 -5
- package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +16 -6
- package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +94 -14
- package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +16 -0
- package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +28 -10
- package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +9 -11
- package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +10 -0
- package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +34 -0
- package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +17 -0
- package/types/JavaScriptSDK/AppInsightsCore.d.ts +0 -21
- package/types/JavaScriptSDK/BaseCore.d.ts +81 -3
- package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +53 -10
- package/types/JavaScriptSDK/ChannelController.d.ts +16 -17
- package/types/JavaScriptSDK/CoreUtils.d.ts +1 -48
- package/types/JavaScriptSDK/DataCacheHelper.d.ts +13 -0
- package/types/JavaScriptSDK/DiagnosticLogger.d.ts +10 -0
- package/types/JavaScriptSDK/EventHelpers.d.ts +154 -0
- package/types/JavaScriptSDK/HelperFuncs.d.ts +33 -32
- package/types/JavaScriptSDK/InternalConstants.d.ts +20 -0
- package/types/JavaScriptSDK/PerfManager.d.ts +1 -1
- package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +69 -6
- package/types/JavaScriptSDK/RandomHelper.d.ts +6 -0
- package/types/JavaScriptSDK/TelemetryHelpers.d.ts +23 -3
- package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +16 -0
- 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.Enums/TelemetryUpdateReason.d.ts +20 -0
- package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +72 -1
- package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +16 -5
- package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +9 -0
- package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +82 -11
- package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +13 -0
- package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +25 -8
- package/types/JavaScriptSDK.Interfaces/ITelemetryPluginChain.d.ts +9 -10
- package/types/JavaScriptSDK.Interfaces/ITelemetryUnloadState.d.ts +6 -0
- package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +22 -0
- package/types/JavaScriptSDK.Interfaces/IUnloadableComponent.d.ts +13 -0
- package/types/applicationinsights-core-js.d.ts +18 -9
- package/types/tsdoc-metadata.json +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +0 -76
- package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +0 -1
- package/src/JavaScriptSDK/TelemetryPluginChain.ts +0 -120
- package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +0 -32
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { IAppInsightsCore } from "./IAppInsightsCore";
|
|
2
|
-
import { IDiagnosticLogger } from "./IDiagnosticLogger";
|
|
3
2
|
import { IConfiguration } from "./IConfiguration";
|
|
3
|
+
import { IDiagnosticLogger } from "./IDiagnosticLogger";
|
|
4
4
|
import { ITelemetryItem } from "./ITelemetryItem";
|
|
5
|
-
import { IPlugin } from "./ITelemetryPlugin";
|
|
5
|
+
import { IPlugin, ITelemetryPlugin } from "./ITelemetryPlugin";
|
|
6
6
|
import { ITelemetryPluginChain } from "./ITelemetryPluginChain";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
|
|
8
|
+
import { ITelemetryUpdateState } from "./ITelemetryUpdateState";
|
|
9
|
+
export declare const enum GetExtCfgMergeType {
|
|
10
|
+
None = 0,
|
|
11
|
+
MergeDefaultOnly = 1,
|
|
12
|
+
MergeDefaultFromRootOrDefault = 2
|
|
13
|
+
}
|
|
14
|
+
export interface IBaseProcessingContext {
|
|
12
15
|
/**
|
|
13
16
|
* The current core instance for the request
|
|
14
17
|
*/
|
|
@@ -24,7 +27,7 @@ export interface IProcessTelemetryContext {
|
|
|
24
27
|
/**
|
|
25
28
|
* Gets the named extension config
|
|
26
29
|
*/
|
|
27
|
-
getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
|
|
30
|
+
getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
|
|
28
31
|
/**
|
|
29
32
|
* Gets the named config from either the named identifier extension or core config if neither exist then the
|
|
30
33
|
* default value is returned
|
|
@@ -32,7 +35,7 @@ export interface IProcessTelemetryContext {
|
|
|
32
35
|
* @param field The config field name
|
|
33
36
|
* @param defaultValue The default value to return if no defined config exists
|
|
34
37
|
*/
|
|
35
|
-
getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
|
|
38
|
+
getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
|
|
36
39
|
/**
|
|
37
40
|
* Helper to allow plugins to check and possibly shortcut executing code only
|
|
38
41
|
* required if there is a nextPlugin
|
|
@@ -46,13 +49,41 @@ export interface IProcessTelemetryContext {
|
|
|
46
49
|
* Helper to set the next plugin proxy
|
|
47
50
|
*/
|
|
48
51
|
setNext: (nextCtx: ITelemetryPluginChain) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Synchronously iterate over the context chain running the callback for each plugin, once
|
|
54
|
+
* every plugin has been executed via the callback, any associated onComplete will be called.
|
|
55
|
+
* @param callback - The function call for each plugin in the context chain
|
|
56
|
+
*/
|
|
57
|
+
iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Set the function to call when the current chain has executed all processNext or unloadNext items.
|
|
60
|
+
* @param onComplete - The onComplete to call
|
|
61
|
+
* @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
|
|
62
|
+
* @param args - Any additional arguments to pass to the onComplete function
|
|
63
|
+
*/
|
|
64
|
+
onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Create a new context using the core and config from the current instance, returns a new instance of the same type
|
|
67
|
+
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
68
|
+
* then the current execution order will be copied.
|
|
69
|
+
* @param startAt - The plugin to start processing from, if missing from the execution
|
|
70
|
+
* order then the next plugin will be NOT set.
|
|
71
|
+
*/
|
|
72
|
+
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
|
|
76
|
+
* between multiple AppInsights instances
|
|
77
|
+
*/
|
|
78
|
+
export interface IProcessTelemetryContext extends IBaseProcessingContext {
|
|
49
79
|
/**
|
|
50
80
|
* Call back for telemetry processing before it it is sent
|
|
51
81
|
* @param env - This is the current event being reported
|
|
82
|
+
* @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
|
|
52
83
|
*/
|
|
53
|
-
processNext: (env: ITelemetryItem) => void;
|
|
84
|
+
processNext: (env: ITelemetryItem) => boolean | void;
|
|
54
85
|
/**
|
|
55
|
-
* Create a new context using the core and config from the current instance
|
|
86
|
+
* Create a new context using the core and config from the current instance, returns a new instance of the same type
|
|
56
87
|
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
57
88
|
* then the current execution order will be copied.
|
|
58
89
|
* @param startAt - The plugin to start processing from, if missing from the execution
|
|
@@ -60,3 +91,43 @@ export interface IProcessTelemetryContext {
|
|
|
60
91
|
*/
|
|
61
92
|
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
|
|
62
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* The current context for the current call to teardown() implementations, used to support when plugins are being removed
|
|
96
|
+
* or the SDK is being unloaded.
|
|
97
|
+
*/
|
|
98
|
+
export interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
|
|
99
|
+
/**
|
|
100
|
+
* This Plugin has finished unloading, so unload the next one
|
|
101
|
+
* @param uploadState - The state of the unload process
|
|
102
|
+
* @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
|
|
103
|
+
*/
|
|
104
|
+
processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
|
|
105
|
+
/**
|
|
106
|
+
* Create a new context using the core and config from the current instance, returns a new instance of the same type
|
|
107
|
+
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
108
|
+
* then the current execution order will be copied.
|
|
109
|
+
* @param startAt - The plugin to start processing from, if missing from the execution
|
|
110
|
+
* order then the next plugin will be NOT set.
|
|
111
|
+
*/
|
|
112
|
+
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The current context for the current call to the plugin update() implementations, used to support the notifications
|
|
116
|
+
* for when plugins are added, removed or the configuration was changed.
|
|
117
|
+
*/
|
|
118
|
+
export interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
|
|
119
|
+
/**
|
|
120
|
+
* This Plugin has finished unloading, so unload the next one
|
|
121
|
+
* @param updateState - The update State
|
|
122
|
+
* @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
|
|
123
|
+
*/
|
|
124
|
+
processNext: (updateState: ITelemetryUpdateState) => boolean | void;
|
|
125
|
+
/**
|
|
126
|
+
* Create a new context using the core and config from the current instance, returns a new instance of the same type
|
|
127
|
+
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
128
|
+
* then the current execution order will be copied.
|
|
129
|
+
* @param startAt - The plugin to start processing from, if missing from the execution
|
|
130
|
+
* order then the next plugin will be NOT set.
|
|
131
|
+
*/
|
|
132
|
+
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
|
|
133
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ITelemetryItem } from "./ITelemetryItem";
|
|
2
|
+
export declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
|
|
3
|
+
export interface ITelemetryInitializerHandler {
|
|
4
|
+
remove(): void;
|
|
5
|
+
}
|
|
6
|
+
export interface ITelemetryInitializerContainer {
|
|
7
|
+
/**
|
|
8
|
+
* Add a telemetry processor to decorate or drop telemetry events.
|
|
9
|
+
* @param telemetryInitializer - The Telemetry Initializer function
|
|
10
|
+
* @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
|
|
11
|
+
*/
|
|
12
|
+
addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
|
|
13
|
+
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ITelemetryItem } from "./ITelemetryItem";
|
|
2
2
|
import { IConfiguration } from "./IConfiguration";
|
|
3
3
|
import { IAppInsightsCore } from "./IAppInsightsCore";
|
|
4
|
-
import { IProcessTelemetryContext } from "./IProcessTelemetryContext";
|
|
4
|
+
import { IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "./IProcessTelemetryContext";
|
|
5
5
|
import { ITelemetryPluginChain } from "./ITelemetryPluginChain";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export interface ITelemetryPlugin extends IPlugin {
|
|
6
|
+
import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
|
|
7
|
+
import { ITelemetryUpdateState } from "./ITelemetryUpdateState";
|
|
8
|
+
export interface ITelemetryProcessor {
|
|
10
9
|
/**
|
|
11
10
|
* Call back for telemetry processing before it it is sent
|
|
12
11
|
* @param env - This is the current event being reported
|
|
@@ -15,6 +14,20 @@ export interface ITelemetryPlugin extends IPlugin {
|
|
|
15
14
|
* to later plugins (vs appending items to the telemetry item)
|
|
16
15
|
*/
|
|
17
16
|
processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
|
|
17
|
+
/**
|
|
18
|
+
* The the plugin should re-evaluate configuration and update any cached configuration settings or
|
|
19
|
+
* plugins. If implemented this method will be called whenever a plugin is added or removed and if
|
|
20
|
+
* the configuration has bee updated.
|
|
21
|
+
* @param updateCtx - This is the context that should be used during updating.
|
|
22
|
+
* @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
|
|
23
|
+
* @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
|
|
24
|
+
*/
|
|
25
|
+
update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration provided to SDK core
|
|
29
|
+
*/
|
|
30
|
+
export interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
|
|
18
31
|
/**
|
|
19
32
|
* Set next extension for telemetry processing, this is not optional as plugins should use the
|
|
20
33
|
* processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
|
|
@@ -42,10 +55,14 @@ export interface IPlugin {
|
|
|
42
55
|
*/
|
|
43
56
|
isInitialized?: () => boolean;
|
|
44
57
|
/**
|
|
45
|
-
* Tear down the plugin and remove any hooked value, the plugin should
|
|
46
|
-
* therefore
|
|
58
|
+
* Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
|
|
59
|
+
* therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
|
|
60
|
+
* processTelemetry calls are ignored and it just calls the processNext() with the provided context.
|
|
61
|
+
* @param unloadCtx - This is the context that should be used during unloading.
|
|
62
|
+
* @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.
|
|
63
|
+
* @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
|
|
47
64
|
*/
|
|
48
|
-
teardown?: () => void;
|
|
65
|
+
teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
|
|
49
66
|
/**
|
|
50
67
|
* Extension name
|
|
51
68
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { IProcessTelemetryUnloadContext } from "./IProcessTelemetryContext";
|
|
2
|
+
import { ITelemetryPlugin, ITelemetryProcessor } from "./ITelemetryPlugin";
|
|
3
|
+
import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
|
|
4
4
|
/**
|
|
5
5
|
* Configuration provided to SDK core
|
|
6
6
|
*/
|
|
7
|
-
export interface ITelemetryPluginChain {
|
|
7
|
+
export interface ITelemetryPluginChain extends ITelemetryProcessor {
|
|
8
8
|
/**
|
|
9
9
|
* Returns the underlying plugin that is being proxied for the processTelemetry call
|
|
10
10
|
*/
|
|
@@ -14,11 +14,10 @@ export interface ITelemetryPluginChain {
|
|
|
14
14
|
*/
|
|
15
15
|
getNext: () => ITelemetryPluginChain;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param
|
|
20
|
-
*
|
|
21
|
-
* to later plugins (vs appending items to the telemetry item)
|
|
17
|
+
* This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
|
|
18
|
+
* call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
|
|
19
|
+
* @param unloadCtx - The unload context to use for this call.
|
|
20
|
+
* @param unloadState - The details of the unload operation
|
|
22
21
|
*/
|
|
23
|
-
|
|
22
|
+
unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
|
|
24
23
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
|
|
2
|
+
import { IPlugin } from "./ITelemetryPlugin";
|
|
3
|
+
export interface ITelemetryUpdateState {
|
|
4
|
+
/**
|
|
5
|
+
* Identifies the reason for the update notification, this is a bitwise numeric value
|
|
6
|
+
*/
|
|
7
|
+
reason: TelemetryUpdateReason;
|
|
8
|
+
/**
|
|
9
|
+
* If this is a configuration update this was the previous configuration that was used
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* If this is a configuration update is the new configuration that is being used
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
|
|
16
|
+
*/
|
|
17
|
+
added?: IPlugin[];
|
|
18
|
+
/**
|
|
19
|
+
* This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
|
|
20
|
+
*/
|
|
21
|
+
removed?: IPlugin[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IProcessTelemetryUnloadContext } from "./IProcessTelemetryContext";
|
|
2
|
+
import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
|
|
3
|
+
export interface IUnloadableComponent {
|
|
4
|
+
/**
|
|
5
|
+
* Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
|
|
6
|
+
* finishes it's removal.
|
|
7
|
+
* @param unloadCtx - This is the context that should be used during unloading.
|
|
8
|
+
* @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.
|
|
9
|
+
* @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.
|
|
10
|
+
* @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
|
|
11
|
+
*/
|
|
12
|
+
_doUnload?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
|
|
13
|
+
}
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
export { IConfiguration } from "./JavaScriptSDK.Interfaces/IConfiguration";
|
|
2
2
|
export { IChannelControls, MinChannelPriorty } from "./JavaScriptSDK.Interfaces/IChannelControls";
|
|
3
3
|
export { ITelemetryPlugin, IPlugin } from "./JavaScriptSDK.Interfaces/ITelemetryPlugin";
|
|
4
|
-
export { IAppInsightsCore } from "./JavaScriptSDK.Interfaces/IAppInsightsCore";
|
|
4
|
+
export { IAppInsightsCore, ILoadedPlugin } from "./JavaScriptSDK.Interfaces/IAppInsightsCore";
|
|
5
5
|
export { ITelemetryItem, ICustomProperties, Tags } from "./JavaScriptSDK.Interfaces/ITelemetryItem";
|
|
6
|
-
export { IProcessTelemetryContext } from "./JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
6
|
+
export { IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext, GetExtCfgMergeType } from "./JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
7
7
|
export { INotificationListener } from "./JavaScriptSDK.Interfaces/INotificationListener";
|
|
8
8
|
export { ITelemetryPluginChain } from "./JavaScriptSDK.Interfaces/ITelemetryPluginChain";
|
|
9
9
|
export { IDiagnosticLogger } from "./JavaScriptSDK.Interfaces/IDiagnosticLogger";
|
|
10
10
|
export { InstrumentorHooksCallback, IInstrumentHooksCallbacks, IInstrumentHooks, IInstrumentHook, IInstrumentCallDetails } from "./JavaScriptSDK.Interfaces/IInstrumentHooks";
|
|
11
|
+
export { IUnloadableComponent } from "./JavaScriptSDK.Interfaces/IUnloadableComponent";
|
|
11
12
|
export { EventsDiscardedReason } from "./JavaScriptSDK.Enums/EventsDiscardedReason";
|
|
12
13
|
export { SendRequestReason } from "./JavaScriptSDK.Enums/SendRequestReason";
|
|
14
|
+
export { TelemetryUpdateReason } from "./JavaScriptSDK.Enums/TelemetryUpdateReason";
|
|
15
|
+
export { TelemetryUnloadReason } from "./JavaScriptSDK.Enums/TelemetryUnloadReason";
|
|
13
16
|
export { AppInsightsCore } from "./JavaScriptSDK/AppInsightsCore";
|
|
14
17
|
export { BaseCore } from "./JavaScriptSDK/BaseCore";
|
|
15
18
|
export { BaseTelemetryPlugin } from "./JavaScriptSDK/BaseTelemetryPlugin";
|
|
16
|
-
export { randomValue, random32, mwcRandomSeed, mwcRandom32 } from "./JavaScriptSDK/RandomHelper";
|
|
17
|
-
export { CoreUtils, ICoreUtils, EventHelper, IEventHelper, Undefined,
|
|
18
|
-
export { isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction,
|
|
19
|
+
export { randomValue, random32, mwcRandomSeed, mwcRandom32, newId } from "./JavaScriptSDK/RandomHelper";
|
|
20
|
+
export { CoreUtils, ICoreUtils, EventHelper, IEventHelper, Undefined, newGuid, perfNow, generateW3CId, disableCookies, canUseCookies, getCookie, setCookie, deleteCookie, _legacyCookieMgr } from "./JavaScriptSDK/CoreUtils";
|
|
21
|
+
export { isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction, normalizeJsName, objForEachKey, strEndsWith, strStartsWith, isDate, isArray, isError, isString, isNumber, isBoolean, toISOString, arrForEach, arrIndexOf, arrMap, arrReduce, strTrim, objKeys, objDefineAccessors, dateNow, getExceptionName, throwError, strContains, isSymbol, setValue, getSetValue, isNotTruthy, isTruthy, proxyAssign, proxyFunctions, proxyFunctionAs, createClassFromInterface, optimizeObject, isNotUndefined, isNotNullOrUndefined, objFreeze, objSeal, createEnumStyle, objExtend, objToString } from "./JavaScriptSDK/HelperFuncs";
|
|
22
|
+
export { attachEvent, detachEvent, addEventHandler, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, removeEventHandler, removeEventListeners, removePageUnloadEventListener, removePageHideEventListener, removePageShowEventListener, eventOn, eventOff, mergeEvtNamespace, _IRegisteredEvents, __getRegisteredEvents } from "./JavaScriptSDK/EventHelpers";
|
|
19
23
|
export { getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, getCrypto, getMsCrypto, hasNavigator, getNavigator, hasHistory, getHistory, getLocation, getPerformance, hasJSON, getJSON, isReactNative, getConsole, dumpObj, isIE, getIEVersion, isSafari, setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported } from "./JavaScriptSDK/EnvUtils";
|
|
20
24
|
export { getGlobal, objCreateFn as objCreate, strShimPrototype as strPrototype, strShimFunction as strFunction, strShimUndefined as strUndefined, strShimObject as strObject } from "@microsoft/applicationinsights-shims";
|
|
21
25
|
export { NotificationManager } from "./JavaScriptSDK/NotificationManager";
|
|
@@ -23,13 +27,18 @@ export { INotificationManager } from "./JavaScriptSDK.Interfaces/INotificationMa
|
|
|
23
27
|
export { IPerfEvent } from "./JavaScriptSDK.Interfaces/IPerfEvent";
|
|
24
28
|
export { IPerfManager, IPerfManagerProvider } from "./JavaScriptSDK.Interfaces/IPerfManager";
|
|
25
29
|
export { PerfEvent, PerfManager, doPerf, getGblPerfMgr, setGblPerfMgr } from "./JavaScriptSDK/PerfManager";
|
|
26
|
-
export { safeGetLogger, DiagnosticLogger, _InternalLogMessage } from "./JavaScriptSDK/DiagnosticLogger";
|
|
27
|
-
export { ProcessTelemetryContext } from "./JavaScriptSDK/ProcessTelemetryContext";
|
|
28
|
-
export { initializePlugins, sortPlugins } from "./JavaScriptSDK/TelemetryHelpers";
|
|
29
|
-
export { _InternalMessageId, LoggingSeverity } from "./JavaScriptSDK.Enums/LoggingEnums";
|
|
30
|
+
export { safeGetLogger, DiagnosticLogger, _InternalLogMessage, _throwInternal } from "./JavaScriptSDK/DiagnosticLogger";
|
|
31
|
+
export { ProcessTelemetryContext, createProcessTelemetryContext } from "./JavaScriptSDK/ProcessTelemetryContext";
|
|
32
|
+
export { initializePlugins, sortPlugins, unloadComponents } from "./JavaScriptSDK/TelemetryHelpers";
|
|
33
|
+
export { _InternalMessageId, _eInternalMessageId, LoggingSeverity, eLoggingSeverity } from "./JavaScriptSDK.Enums/LoggingEnums";
|
|
30
34
|
export { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs } from "./JavaScriptSDK/InstrumentHooks";
|
|
31
35
|
export { ICookieMgr, ICookieMgrConfig } from "./JavaScriptSDK.Interfaces/ICookieMgr";
|
|
32
36
|
export { createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesSupported } from "./JavaScriptSDK/CookieMgr";
|
|
33
37
|
export { strIKey, strExtensionConfig } from "./JavaScriptSDK/Constants";
|
|
34
38
|
export { IDbgExtension } from "./JavaScriptSDK.Interfaces/IDbgExtension";
|
|
35
39
|
export { getDebugListener, getDebugExt } from "./JavaScriptSDK/DbgExtensionUtils";
|
|
40
|
+
export { TelemetryInitializerFunction, ITelemetryInitializerHandler, ITelemetryInitializerContainer } from "./JavaScriptSDK.Interfaces/ITelemetryInitializers";
|
|
41
|
+
export { createUniqueNamespace } from "./JavaScriptSDK/DataCacheHelper";
|
|
42
|
+
export { UnloadHandler, IUnloadHandlerContainer, createUnloadHandlerContainer } from "./JavaScriptSDK/UnloadHandlerContainer";
|
|
43
|
+
export { ITelemetryUpdateState } from "./JavaScriptSDK.Interfaces/ITelemetryUpdateState";
|
|
44
|
+
export { ITelemetryUnloadState } from "./JavaScriptSDK.Interfaces/ITelemetryUnloadState";
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Core, 2.8.0-nightly.2202-06
|
|
3
|
-
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"use strict";
|
|
8
|
-
import { doPerf } from "./PerfManager";
|
|
9
|
-
import { LoggingSeverity, _InternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
|
|
10
|
-
import { isFunction } from "./HelperFuncs";
|
|
11
|
-
import { dumpObj } from "./EnvUtils";
|
|
12
|
-
var TelemetryPluginChain = /** @class */ (function () {
|
|
13
|
-
function TelemetryPluginChain(plugin, defItemCtx) {
|
|
14
|
-
var _self = this;
|
|
15
|
-
var _nextProxy = null;
|
|
16
|
-
var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
|
|
17
|
-
var _hasSetNext = isFunction(plugin.setNextPlugin);
|
|
18
|
-
_self._hasRun = false;
|
|
19
|
-
_self.getPlugin = function () {
|
|
20
|
-
return plugin;
|
|
21
|
-
};
|
|
22
|
-
_self.getNext = function () {
|
|
23
|
-
return _nextProxy;
|
|
24
|
-
};
|
|
25
|
-
_self.setNext = function (nextPlugin) {
|
|
26
|
-
_nextProxy = nextPlugin;
|
|
27
|
-
};
|
|
28
|
-
_self.processTelemetry = function (env, itemCtx) {
|
|
29
|
-
if (!itemCtx) {
|
|
30
|
-
// Looks like a plugin didn't pass the (optional) context, so restore to the default
|
|
31
|
-
itemCtx = defItemCtx;
|
|
32
|
-
}
|
|
33
|
-
var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
|
|
34
|
-
doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
|
|
35
|
-
if (plugin && _hasProcessTelemetry) {
|
|
36
|
-
_self._hasRun = true;
|
|
37
|
-
try {
|
|
38
|
-
// Ensure that we keep the context in sync (for processNext()), just in case a plugin
|
|
39
|
-
// doesn't calls processTelemetry() instead of itemContext.processNext() or some
|
|
40
|
-
// other form of error occurred
|
|
41
|
-
itemCtx.setNext(_nextProxy);
|
|
42
|
-
if (_hasSetNext) {
|
|
43
|
-
// Backward compatibility setting the next plugin on the instance
|
|
44
|
-
plugin.setNextPlugin(_nextProxy);
|
|
45
|
-
}
|
|
46
|
-
// Set a flag on the next plugin so we know if it was attempted to be executed
|
|
47
|
-
_nextProxy && (_nextProxy._hasRun = false);
|
|
48
|
-
plugin.processTelemetry(env, itemCtx);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
var hasRun = _nextProxy && _nextProxy._hasRun;
|
|
52
|
-
if (!_nextProxy || !hasRun) {
|
|
53
|
-
// Either we have no next plugin or the current one did not attempt to call the next plugin
|
|
54
|
-
// Which means the current one is the root of the failure so log/report this failure
|
|
55
|
-
itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
|
|
56
|
-
}
|
|
57
|
-
if (_nextProxy && !hasRun) {
|
|
58
|
-
// As part of the failure the current plugin did not attempt to call the next plugin in the cahin
|
|
59
|
-
// So rather than leave the pipeline dead in the water we call the next plugin
|
|
60
|
-
_nextProxy.processTelemetry(env, itemCtx);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else if (_nextProxy) {
|
|
65
|
-
_self._hasRun = true;
|
|
66
|
-
// The underlying plugin is either not defined or does not have a processTelemetry implementation
|
|
67
|
-
// so we still want the next plugin to be executed.
|
|
68
|
-
_nextProxy.processTelemetry(env, itemCtx);
|
|
69
|
-
}
|
|
70
|
-
}, function () { return ({ item: env }); }, !(env.sync));
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return TelemetryPluginChain;
|
|
74
|
-
}());
|
|
75
|
-
export { TelemetryPluginChain };
|
|
76
|
-
//# sourceMappingURL=TelemetryPluginChain.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TelemetryPluginChain.js.map","sources":["TelemetryPluginChain.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\"use strict\";\r\nimport { doPerf } from \"./PerfManager\";\r\nimport { LoggingSeverity, _InternalMessageId } from \"../JavaScriptSDK.Enums/LoggingEnums\";\r\nimport { isFunction } from \"./HelperFuncs\";\r\nimport { dumpObj } from \"./EnvUtils\";\r\nvar TelemetryPluginChain = /** @class */ (function () {\r\n function TelemetryPluginChain(plugin, defItemCtx) {\r\n var _self = this;\r\n var _nextProxy = null;\r\n var _hasProcessTelemetry = isFunction(plugin.processTelemetry);\r\n var _hasSetNext = isFunction(plugin.setNextPlugin);\r\n _self._hasRun = false;\r\n _self.getPlugin = function () {\r\n return plugin;\r\n };\r\n _self.getNext = function () {\r\n return _nextProxy;\r\n };\r\n _self.setNext = function (nextPlugin) {\r\n _nextProxy = nextPlugin;\r\n };\r\n _self.processTelemetry = function (env, itemCtx) {\r\n if (!itemCtx) {\r\n // Looks like a plugin didn't pass the (optional) context, so restore to the default\r\n itemCtx = defItemCtx;\r\n }\r\n var identifier = plugin ? plugin.identifier : \"TelemetryPluginChain\";\r\n doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + \":processTelemetry\"; }, function () {\r\n if (plugin && _hasProcessTelemetry) {\r\n _self._hasRun = true;\r\n try {\r\n // Ensure that we keep the context in sync (for processNext()), just in case a plugin\r\n // doesn't calls processTelemetry() instead of itemContext.processNext() or some\r\n // other form of error occurred\r\n itemCtx.setNext(_nextProxy);\r\n if (_hasSetNext) {\r\n // Backward compatibility setting the next plugin on the instance\r\n plugin.setNextPlugin(_nextProxy);\r\n }\r\n // Set a flag on the next plugin so we know if it was attempted to be executed\r\n _nextProxy && (_nextProxy._hasRun = false);\r\n plugin.processTelemetry(env, itemCtx);\r\n }\r\n catch (error) {\r\n var hasRun = _nextProxy && _nextProxy._hasRun;\r\n if (!_nextProxy || !hasRun) {\r\n // Either we have no next plugin or the current one did not attempt to call the next plugin\r\n // Which means the current one is the root of the failure so log/report this failure\r\n itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, \"Plugin [\" + plugin.identifier + \"] failed during processTelemetry - \" + dumpObj(error));\r\n }\r\n if (_nextProxy && !hasRun) {\r\n // As part of the failure the current plugin did not attempt to call the next plugin in the cahin\r\n // So rather than leave the pipeline dead in the water we call the next plugin\r\n _nextProxy.processTelemetry(env, itemCtx);\r\n }\r\n }\r\n }\r\n else if (_nextProxy) {\r\n _self._hasRun = true;\r\n // The underlying plugin is either not defined or does not have a processTelemetry implementation\r\n // so we still want the next plugin to be executed.\r\n _nextProxy.processTelemetry(env, itemCtx);\r\n }\r\n }, function () { return ({ item: env }); }, !(env.sync));\r\n };\r\n }\r\n return TelemetryPluginChain;\r\n}());\r\nexport { TelemetryPluginChain };\r\n//# sourceMappingURL=TelemetryPluginChain.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
|
|
6
|
-
import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
7
|
-
import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
|
|
8
|
-
import { ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
|
|
9
|
-
import { _InternalLogMessage } from "./DiagnosticLogger";
|
|
10
|
-
import { doPerf } from "./PerfManager";
|
|
11
|
-
import { LoggingSeverity, _InternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
|
|
12
|
-
import { isFunction } from "./HelperFuncs";
|
|
13
|
-
import { dumpObj } from "./EnvUtils";
|
|
14
|
-
|
|
15
|
-
export class TelemetryPluginChain implements ITelemetryPluginChain {
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Returns the underlying plugin that is being proxied for the processTelemetry call
|
|
19
|
-
*/
|
|
20
|
-
getPlugin: () => ITelemetryPlugin;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns the next plugin
|
|
24
|
-
*/
|
|
25
|
-
getNext: () => ITelemetryPluginChain;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Sets the next proxy to be executed as the next plugin
|
|
29
|
-
* (Should only be used during initialization, which is why it's not defined on the interface)
|
|
30
|
-
*/
|
|
31
|
-
setNext: (nextPlugin:ITelemetryPluginChain) => void;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Call back for telemetry processing before it it is sent
|
|
35
|
-
* @param env - This is the current event being reported
|
|
36
|
-
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
|
|
37
|
-
* can optionally use this to access the current core instance or define / pass additional information
|
|
38
|
-
* to later plugins (vs appending items to the telemetry item)
|
|
39
|
-
*/
|
|
40
|
-
processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Internal flag used to try and identify root cause failures
|
|
44
|
-
*/
|
|
45
|
-
private _hasRun: boolean;
|
|
46
|
-
|
|
47
|
-
constructor(plugin:ITelemetryPlugin, defItemCtx:IProcessTelemetryContext) {
|
|
48
|
-
let _self = this;
|
|
49
|
-
let _nextProxy:ITelemetryPluginChain = null;
|
|
50
|
-
let _hasProcessTelemetry = isFunction(plugin.processTelemetry);
|
|
51
|
-
let _hasSetNext = isFunction(plugin.setNextPlugin);
|
|
52
|
-
|
|
53
|
-
_self._hasRun = false;
|
|
54
|
-
|
|
55
|
-
_self.getPlugin = () => {
|
|
56
|
-
return plugin;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
_self.getNext = () => {
|
|
60
|
-
return _nextProxy;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
_self.setNext = (nextPlugin:ITelemetryPluginChain) => {
|
|
64
|
-
_nextProxy = nextPlugin;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
_self.processTelemetry = (env: ITelemetryItem, itemCtx:IProcessTelemetryContext) => {
|
|
68
|
-
if (!itemCtx) {
|
|
69
|
-
// Looks like a plugin didn't pass the (optional) context, so restore to the default
|
|
70
|
-
itemCtx = defItemCtx;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
|
|
74
|
-
|
|
75
|
-
doPerf(itemCtx ? itemCtx.core() : null, () => identifier + ":processTelemetry", () => {
|
|
76
|
-
if (plugin && _hasProcessTelemetry) {
|
|
77
|
-
_self._hasRun = true;
|
|
78
|
-
try {
|
|
79
|
-
|
|
80
|
-
// Ensure that we keep the context in sync (for processNext()), just in case a plugin
|
|
81
|
-
// doesn't calls processTelemetry() instead of itemContext.processNext() or some
|
|
82
|
-
// other form of error occurred
|
|
83
|
-
itemCtx.setNext(_nextProxy);
|
|
84
|
-
if (_hasSetNext) {
|
|
85
|
-
// Backward compatibility setting the next plugin on the instance
|
|
86
|
-
plugin.setNextPlugin(_nextProxy);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Set a flag on the next plugin so we know if it was attempted to be executed
|
|
90
|
-
_nextProxy && ((_nextProxy as TelemetryPluginChain)._hasRun = false);
|
|
91
|
-
|
|
92
|
-
plugin.processTelemetry(env, itemCtx);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
let hasRun = _nextProxy && (_nextProxy as TelemetryPluginChain)._hasRun;
|
|
95
|
-
if (!_nextProxy || !hasRun) {
|
|
96
|
-
// Either we have no next plugin or the current one did not attempt to call the next plugin
|
|
97
|
-
// Which means the current one is the root of the failure so log/report this failure
|
|
98
|
-
itemCtx.diagLog().throwInternal(
|
|
99
|
-
LoggingSeverity.CRITICAL,
|
|
100
|
-
_InternalMessageId.PluginException,
|
|
101
|
-
"Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (_nextProxy && !hasRun) {
|
|
105
|
-
// As part of the failure the current plugin did not attempt to call the next plugin in the cahin
|
|
106
|
-
// So rather than leave the pipeline dead in the water we call the next plugin
|
|
107
|
-
_nextProxy.processTelemetry(env, itemCtx);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} else if (_nextProxy) {
|
|
111
|
-
_self._hasRun = true;
|
|
112
|
-
|
|
113
|
-
// The underlying plugin is either not defined or does not have a processTelemetry implementation
|
|
114
|
-
// so we still want the next plugin to be executed.
|
|
115
|
-
_nextProxy.processTelemetry(env, itemCtx);
|
|
116
|
-
}
|
|
117
|
-
}, () => ({ item: env }), !((env as any).sync));
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
|
|
2
|
-
import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
3
|
-
import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
|
|
4
|
-
import { ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
|
|
5
|
-
export declare class TelemetryPluginChain implements ITelemetryPluginChain {
|
|
6
|
-
/**
|
|
7
|
-
* Returns the underlying plugin that is being proxied for the processTelemetry call
|
|
8
|
-
*/
|
|
9
|
-
getPlugin: () => ITelemetryPlugin;
|
|
10
|
-
/**
|
|
11
|
-
* Returns the next plugin
|
|
12
|
-
*/
|
|
13
|
-
getNext: () => ITelemetryPluginChain;
|
|
14
|
-
/**
|
|
15
|
-
* Sets the next proxy to be executed as the next plugin
|
|
16
|
-
* (Should only be used during initialization, which is why it's not defined on the interface)
|
|
17
|
-
*/
|
|
18
|
-
setNext: (nextPlugin: ITelemetryPluginChain) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Call back for telemetry processing before it it is sent
|
|
21
|
-
* @param env - This is the current event being reported
|
|
22
|
-
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
|
|
23
|
-
* can optionally use this to access the current core instance or define / pass additional information
|
|
24
|
-
* to later plugins (vs appending items to the telemetry item)
|
|
25
|
-
*/
|
|
26
|
-
processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
|
|
27
|
-
/**
|
|
28
|
-
* Internal flag used to try and identify root cause failures
|
|
29
|
-
*/
|
|
30
|
-
private _hasRun;
|
|
31
|
-
constructor(plugin: ITelemetryPlugin, defItemCtx: IProcessTelemetryContext);
|
|
32
|
-
}
|