@microsoft/applicationinsights-core-js 2.7.5-nightly.2203-03 → 2.7.5
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 +766 -1967
- 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 +9840 -16439
- package/dist/applicationinsights-core-js.api.md +48 -425
- package/dist/applicationinsights-core-js.d.ts +123 -784
- package/dist/applicationinsights-core-js.js +766 -1967
- 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 +123 -784
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +69 -3
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +99 -496
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +21 -120
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +87 -202
- 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 +148 -7
- package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +14 -27
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +12 -13
- package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +86 -89
- package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -3
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
- package/dist-esm/JavaScriptSDK/NotificationManager.js +42 -37
- package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +119 -430
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +4 -30
- package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +14 -60
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +76 -0
- package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +96 -90
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +2 -1
- 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/ITelemetryItem.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +2 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js.map +1 -1
- package/dist-esm/applicationinsights-core-js.js +7 -12
- package/dist-esm/applicationinsights-core-js.js.map +1 -1
- package/package.json +67 -70
- package/src/JavaScriptSDK/AppInsightsCore.ts +101 -2
- package/src/JavaScriptSDK/BaseCore.ts +120 -696
- package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +31 -205
- package/src/JavaScriptSDK/ChannelController.ts +103 -242
- package/src/JavaScriptSDK/CookieMgr.ts +5 -7
- package/src/JavaScriptSDK/CoreUtils.ts +172 -8
- package/src/JavaScriptSDK/DiagnosticLogger.ts +14 -29
- package/src/JavaScriptSDK/EnvUtils.ts +12 -13
- package/src/JavaScriptSDK/HelperFuncs.ts +97 -123
- package/src/JavaScriptSDK/InstrumentHooks.ts +2 -4
- package/src/JavaScriptSDK/NotificationManager.ts +37 -34
- package/src/JavaScriptSDK/PerfManager.ts +7 -4
- package/src/JavaScriptSDK/ProcessTelemetryContext.ts +134 -543
- package/src/JavaScriptSDK/RandomHelper.ts +3 -35
- package/src/JavaScriptSDK/TelemetryHelpers.ts +21 -83
- package/src/JavaScriptSDK/TelemetryPluginChain.ts +120 -0
- package/src/JavaScriptSDK.Enums/LoggingEnums.ts +87 -184
- package/src/JavaScriptSDK.Enums/SendRequestReason.ts +0 -5
- package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +2 -82
- package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +5 -16
- package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +6 -16
- package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +14 -94
- package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +10 -28
- package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +11 -9
- package/types/JavaScriptSDK/AppInsightsCore.d.ts +21 -0
- package/types/JavaScriptSDK/BaseCore.d.ts +3 -81
- package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +10 -53
- package/types/JavaScriptSDK/ChannelController.d.ts +17 -16
- package/types/JavaScriptSDK/CoreUtils.d.ts +48 -1
- package/types/JavaScriptSDK/DiagnosticLogger.d.ts +0 -10
- package/types/JavaScriptSDK/HelperFuncs.d.ts +32 -33
- package/types/JavaScriptSDK/PerfManager.d.ts +1 -1
- package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +6 -69
- package/types/JavaScriptSDK/RandomHelper.d.ts +0 -6
- package/types/JavaScriptSDK/TelemetryHelpers.d.ts +3 -23
- package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +32 -0
- package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +2 -91
- package/types/JavaScriptSDK.Enums/SendRequestReason.d.ts +0 -4
- package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +1 -72
- package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +5 -16
- package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +0 -9
- package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +11 -82
- package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +8 -25
- package/types/JavaScriptSDK.Interfaces/ITelemetryPluginChain.d.ts +10 -9
- package/types/applicationinsights-core-js.d.ts +9 -18
- package/types/tsdoc-metadata.json +1 -1
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js +0 -93
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +0 -1
- package/dist-esm/JavaScriptSDK/EventHelpers.js +0 -477
- package/dist-esm/JavaScriptSDK/EventHelpers.js.map +0 -1
- package/dist-esm/JavaScriptSDK/InternalConstants.js +0 -28
- package/dist-esm/JavaScriptSDK/InternalConstants.js.map +0 -1
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +0 -81
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +0 -1
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +0 -33
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +0 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +0 -8
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js.map +0 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +0 -8
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +0 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +0 -6
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +0 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +0 -8
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js.map +0 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +0 -8
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +0 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +0 -6
- package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +0 -1
- package/src/JavaScriptSDK/DataCacheHelper.ts +0 -106
- package/src/JavaScriptSDK/EventHelpers.ts +0 -550
- package/src/JavaScriptSDK/InternalConstants.ts +0 -26
- package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +0 -111
- package/src/JavaScriptSDK/UnloadHandlerContainer.ts +0 -46
- package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +0 -27
- package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +0 -27
- package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +0 -16
- package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +0 -10
- package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +0 -34
- package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +0 -17
- package/types/JavaScriptSDK/DataCacheHelper.d.ts +0 -13
- package/types/JavaScriptSDK/EventHelpers.d.ts +0 -154
- package/types/JavaScriptSDK/InternalConstants.d.ts +0 -20
- package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +0 -16
- package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +0 -11
- package/types/JavaScriptSDK.Enums/TelemetryUnloadReason.d.ts +0 -21
- package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +0 -20
- package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +0 -13
- package/types/JavaScriptSDK.Interfaces/ITelemetryUnloadState.d.ts +0 -6
- package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +0 -22
- package/types/JavaScriptSDK.Interfaces/IUnloadableComponent.d.ts +0 -13
|
@@ -3,24 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
-
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
7
6
|
import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"
|
|
8
7
|
import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
|
|
9
8
|
import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
|
|
10
9
|
import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
|
|
11
10
|
import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
|
|
12
|
-
import { IProcessTelemetryContext
|
|
11
|
+
import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
13
12
|
import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import { ProcessTelemetryContext } from "./ProcessTelemetryContext";
|
|
14
|
+
import { isFunction, isNullOrUndefined, setValue } from "./HelperFuncs";
|
|
16
15
|
import { strExtensionConfig } from "./Constants";
|
|
17
|
-
import { createUnloadHandlerContainer, IUnloadHandlerContainer, UnloadHandler } from "./UnloadHandlerContainer";
|
|
18
|
-
import { IInstrumentHook } from "../JavaScriptSDK.Interfaces/IInstrumentHooks";
|
|
19
|
-
import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
|
|
20
|
-
import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
|
|
21
|
-
import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
|
|
22
|
-
import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
|
|
23
|
-
import { strDoTeardown, strIsInitialized, strSetNextPlugin } from "./InternalConstants";
|
|
24
16
|
|
|
25
17
|
let strGetPlugin = "getPlugin";
|
|
26
18
|
|
|
@@ -30,16 +22,6 @@ let strGetPlugin = "getPlugin";
|
|
|
30
22
|
* implementation so that new default implementations can be added without breaking all plugins.
|
|
31
23
|
*/
|
|
32
24
|
export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
33
|
-
|
|
34
|
-
public identifier: string;
|
|
35
|
-
public version?: string;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Holds the core instance that was used during initialization
|
|
39
|
-
*/
|
|
40
|
-
public core: IAppInsightsCore;
|
|
41
|
-
|
|
42
|
-
priority: number;
|
|
43
25
|
|
|
44
26
|
/**
|
|
45
27
|
* Call back for telemetry processing before it it is sent
|
|
@@ -53,7 +35,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
53
35
|
/**
|
|
54
36
|
* Set next extension for telemetry processing
|
|
55
37
|
*/
|
|
56
|
-
public setNextPlugin: (next: ITelemetryPlugin
|
|
38
|
+
public setNextPlugin: (next: ITelemetryPlugin|ITelemetryPluginChain) => void;
|
|
57
39
|
|
|
58
40
|
/**
|
|
59
41
|
* Returns the current diagnostic logger that can be used to log issues, if no logger is currently
|
|
@@ -66,6 +48,16 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
66
48
|
*/
|
|
67
49
|
public isInitialized: () => boolean;
|
|
68
50
|
|
|
51
|
+
public identifier: string;
|
|
52
|
+
public version?: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Holds the core instance that was used during initialization
|
|
56
|
+
*/
|
|
57
|
+
public core: IAppInsightsCore;
|
|
58
|
+
|
|
59
|
+
priority: number;
|
|
60
|
+
|
|
69
61
|
/**
|
|
70
62
|
* Helper to return the current IProcessTelemetryContext, if the passed argument exists this just
|
|
71
63
|
* returns that value (helps with minification for callers), otherwise it will return the configured
|
|
@@ -80,140 +72,23 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
80
72
|
protected setInitialized: (isInitialized: boolean) => void;
|
|
81
73
|
|
|
82
74
|
/**
|
|
83
|
-
*
|
|
84
|
-
* finishes it's removal.
|
|
85
|
-
* @param unloadCtx - This is the context that should be used during unloading.
|
|
86
|
-
* @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.
|
|
87
|
-
* @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.
|
|
88
|
-
* @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
|
|
89
|
-
*/
|
|
90
|
-
protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
|
|
94
|
-
* @param updateCtx - This is the context that should be used during updating.
|
|
95
|
-
* @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
|
|
96
|
-
* @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async update operations.
|
|
97
|
-
* @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
|
|
75
|
+
* Internal helper to initialize the instance
|
|
98
76
|
*/
|
|
99
|
-
|
|
77
|
+
private _baseTelInit: (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) => void;
|
|
100
78
|
|
|
101
79
|
constructor() {
|
|
102
|
-
let _self = this;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
let
|
|
106
|
-
let _rootCtx: IProcessTelemetryContext; // Used as the root context, holding the current config and initialized core
|
|
107
|
-
let _nextPlugin: ITelemetryPlugin | ITelemetryPluginChain; // Used for backward compatibility where plugins don't call the main pipeline
|
|
108
|
-
let _unloadHandlerContainer: IUnloadHandlerContainer;
|
|
109
|
-
let _hooks: IInstrumentHook[];
|
|
110
|
-
|
|
111
|
-
_initDefaults();
|
|
112
|
-
|
|
113
|
-
dynamicProto(BaseTelemetryPlugin, _self, (_self) => {
|
|
114
|
-
|
|
115
|
-
_self.initialize = (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain): void => {
|
|
116
|
-
_setDefaults(config, core, pluginChain);
|
|
117
|
-
_isinitialized = true;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
_self.teardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => {
|
|
121
|
-
// If this plugin has already been torn down (not operational) or is not initialized (core is not set)
|
|
122
|
-
// or the core being used for unload was not the same core used for initialization.
|
|
123
|
-
if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
|
|
124
|
-
// Do Nothing as either the plugin is not initialized or was not initialized by the current core
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let result: void | boolean;
|
|
129
|
-
let unloadDone = false;
|
|
130
|
-
let theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
|
|
131
|
-
let theUnloadState: ITelemetryUnloadState = unloadState || {
|
|
132
|
-
reason: TelemetryUnloadReason.ManualTeardown,
|
|
133
|
-
isAsync: false
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
function _unloadCallback() {
|
|
137
|
-
if (!unloadDone) {
|
|
138
|
-
unloadDone = true;
|
|
139
|
-
|
|
140
|
-
_unloadHandlerContainer.run(theUnloadCtx, unloadState);
|
|
141
|
-
|
|
142
|
-
// Remove all instrumentation hooks
|
|
143
|
-
arrForEach(_hooks, (fn) => {
|
|
144
|
-
fn.rm();
|
|
145
|
-
});
|
|
146
|
-
_hooks = [];
|
|
147
|
-
|
|
148
|
-
if (result === true) {
|
|
149
|
-
theUnloadCtx.processNext(theUnloadState);
|
|
150
|
-
}
|
|
80
|
+
let _self = this;
|
|
81
|
+
let _isinitialized = false;
|
|
82
|
+
let _rootCtx: IProcessTelemetryContext = null; // Used as the root context, holding the current config and initialized core
|
|
83
|
+
let _nextPlugin:ITelemetryPlugin|ITelemetryPluginChain = null; // Used for backward compatibility where plugins don't call the main pipeline
|
|
151
84
|
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
|
|
157
|
-
_unloadCallback();
|
|
158
|
-
} else {
|
|
159
|
-
// Tell the caller that we will be calling processNext()
|
|
160
|
-
result = true;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return result;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
_self.update = (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => {
|
|
167
|
-
// If this plugin has already been torn down (not operational) or is not initialized (core is not set)
|
|
168
|
-
// or the core being used for unload was not the same core used for initialization.
|
|
169
|
-
if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
|
|
170
|
-
// Do Nothing
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
let result: void | boolean;
|
|
175
|
-
let updateDone = false;
|
|
176
|
-
let theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
|
|
177
|
-
let theUpdateState: ITelemetryUpdateState = updateState || {
|
|
178
|
-
reason: TelemetryUpdateReason.Unknown
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
function _updateCallback() {
|
|
182
|
-
if (!updateDone) {
|
|
183
|
-
updateDone = true;
|
|
184
|
-
_setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
|
|
189
|
-
_updateCallback();
|
|
190
|
-
} else {
|
|
191
|
-
result = true;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return result;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
_self._addHook = (hooks: IInstrumentHook | IInstrumentHook[]) => {
|
|
198
|
-
if (hooks) {
|
|
199
|
-
if (isArray(hooks)) {
|
|
200
|
-
_hooks = _hooks.concat(hooks);
|
|
201
|
-
} else {
|
|
202
|
-
_hooks.push(hooks);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
proxyFunctionAs(_self, "_addUnloadCb", () => _unloadHandlerContainer, "add");
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// These are added after the dynamicProto so that are not moved to the prototype
|
|
85
|
+
_self.core = null;
|
|
211
86
|
|
|
212
87
|
_self.diagLog = (itemCtx:IProcessTelemetryContext): IDiagnosticLogger => {
|
|
213
|
-
return _getTelCtx(itemCtx).diagLog();
|
|
88
|
+
return _self._getTelCtx(itemCtx).diagLog();
|
|
214
89
|
}
|
|
215
90
|
|
|
216
|
-
_self
|
|
91
|
+
_self.isInitialized = () => {
|
|
217
92
|
return _isinitialized;
|
|
218
93
|
}
|
|
219
94
|
|
|
@@ -226,7 +101,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
226
101
|
// should use processNext() function. If you require access to the plugin use the
|
|
227
102
|
// IProcessTelemetryContext.getNext().getPlugin() while in the pipeline, Note getNext() may return null.
|
|
228
103
|
|
|
229
|
-
_self
|
|
104
|
+
_self.setNextPlugin = (next: ITelemetryPlugin|ITelemetryPluginChain) => {
|
|
230
105
|
_nextPlugin = next;
|
|
231
106
|
};
|
|
232
107
|
|
|
@@ -241,12 +116,10 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
241
116
|
}
|
|
242
117
|
};
|
|
243
118
|
|
|
244
|
-
_self._getTelCtx =
|
|
245
|
-
|
|
246
|
-
function _getTelCtx(currentCtx:IProcessTelemetryContext = null) {
|
|
119
|
+
_self._getTelCtx = (currentCtx:IProcessTelemetryContext = null) => {
|
|
247
120
|
let itemCtx:IProcessTelemetryContext = currentCtx;
|
|
248
121
|
if (!itemCtx) {
|
|
249
|
-
let rootCtx = _rootCtx ||
|
|
122
|
+
let rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
|
|
250
123
|
// tslint:disable-next-line: prefer-conditional-expression
|
|
251
124
|
if (_nextPlugin && _nextPlugin[strGetPlugin]) {
|
|
252
125
|
// Looks like a chain object
|
|
@@ -259,7 +132,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
259
132
|
return itemCtx;
|
|
260
133
|
}
|
|
261
134
|
|
|
262
|
-
|
|
135
|
+
_self._baseTelInit = (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) => {
|
|
263
136
|
if (config) {
|
|
264
137
|
// Make sure the extensionConfig exists
|
|
265
138
|
setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
|
|
@@ -270,7 +143,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
270
143
|
pluginChain = core.getProcessTelContext().getNext();
|
|
271
144
|
}
|
|
272
145
|
|
|
273
|
-
let nextPlugin:
|
|
146
|
+
let nextPlugin:IPlugin = _nextPlugin as IPlugin;
|
|
274
147
|
if (_nextPlugin && _nextPlugin[strGetPlugin]) {
|
|
275
148
|
// If it looks like a proxy/chain then get the plugin
|
|
276
149
|
nextPlugin = _nextPlugin[strGetPlugin]();
|
|
@@ -278,61 +151,14 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
278
151
|
|
|
279
152
|
// Support legacy plugins where core was defined as a property
|
|
280
153
|
_self.core = core;
|
|
281
|
-
_rootCtx =
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
function _initDefaults() {
|
|
285
|
-
_isinitialized = false;
|
|
286
|
-
_self.core = null;
|
|
287
|
-
_rootCtx = null;
|
|
288
|
-
_nextPlugin = null;
|
|
289
|
-
_hooks = [];
|
|
290
|
-
_unloadHandlerContainer = createUnloadHandlerContainer();
|
|
154
|
+
_rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
|
|
155
|
+
_isinitialized = true;
|
|
291
156
|
}
|
|
292
157
|
}
|
|
293
158
|
|
|
294
159
|
public initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain): void {
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
|
|
300
|
-
* therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
|
|
301
|
-
* processTelemetry calls are ignored and it just calls the processNext() with the provided context.
|
|
302
|
-
* @param unloadCtx - This is the context that should be used during unloading.
|
|
303
|
-
* @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.
|
|
304
|
-
* @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
|
|
305
|
-
*/
|
|
306
|
-
public teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean {
|
|
307
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
308
|
-
return false;
|
|
160
|
+
this._baseTelInit(config, core, extensions, pluginChain);
|
|
309
161
|
}
|
|
310
162
|
|
|
311
163
|
public abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* The the plugin should re-evaluate configuration and update any cached configuration settings.
|
|
315
|
-
* @param updateCtx - This is the context that should be used during updating.
|
|
316
|
-
* @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
|
|
317
|
-
* @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
|
|
318
|
-
*/
|
|
319
|
-
public update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean{
|
|
320
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Add an unload handler that will be called when the SDK is being unloaded
|
|
325
|
-
* @param handler - the handler
|
|
326
|
-
*/
|
|
327
|
-
protected _addUnloadCb(handler: UnloadHandler): void {
|
|
328
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Add this hook so that it is automatically removed during unloading
|
|
333
|
-
* @param hooks - The single hook or an array of IInstrumentHook objects
|
|
334
|
-
*/
|
|
335
|
-
protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void {
|
|
336
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
337
|
-
}
|
|
338
164
|
}
|