@microsoft/applicationinsights-core-js 3.0.0-beta.2303-02 → 3.0.0-beta.2303-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 +2 -2
- 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 +113 -206
- package/dist/applicationinsights-core-js.api.md +11 -14
- package/dist/applicationinsights-core-js.d.ts +15 -13
- package/dist/applicationinsights-core-js.js +2 -2
- 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 +15 -13
- package/dist-esm/Config/ConfigDefaultHelpers.js +1 -1
- package/dist-esm/Config/ConfigDefaults.js +1 -1
- package/dist-esm/Config/DynamicConfig.js +1 -1
- package/dist-esm/Config/DynamicProperty.js +1 -1
- package/dist-esm/Config/DynamicState.js +1 -1
- package/dist-esm/Config/DynamicSupport.js +1 -1
- package/dist-esm/Config/IConfigDefaults.js +1 -1
- package/dist-esm/Config/IDynamicConfigHandler.js +1 -1
- package/dist-esm/Config/IDynamicPropertyHandler.js +1 -1
- package/dist-esm/Config/IDynamicWatcher.js +1 -1
- package/dist-esm/Config/_IDynamicConfigHandlerState.js +1 -1
- package/dist-esm/JavaScriptSDK/AggregationError.js +1 -1
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js +2 -2
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/EventHelpers.js +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK/InternalConstants.js +1 -1
- package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
- package/dist-esm/JavaScriptSDK/UnloadHookContainer.js +1 -1
- package/dist-esm/JavaScriptSDK/W3cTraceParent.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
- 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/IDistributedTraceContext.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 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
- package/dist-esm/__DynamicConstants.js +1 -1
- package/dist-esm/applicationinsights-core-js.js +1 -1
- package/package.json +1 -1
- package/types/JavaScriptSDK/AppInsightsCore.d.ts +5 -6
- package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +9 -6
- package/src/JavaScriptSDK/AggregationError.ts +0 -36
- package/src/JavaScriptSDK/AppInsightsCore.ts +0 -1322
- package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +0 -343
- package/src/JavaScriptSDK/Constants.ts +0 -4
- package/src/JavaScriptSDK/CookieMgr.ts +0 -449
- package/src/JavaScriptSDK/CoreUtils.ts +0 -58
- package/src/JavaScriptSDK/DataCacheHelper.ts +0 -107
- package/src/JavaScriptSDK/DbgExtensionUtils.ts +0 -56
- package/src/JavaScriptSDK/DiagnosticLogger.ts +0 -380
- package/src/JavaScriptSDK/EnvUtils.ts +0 -312
- package/src/JavaScriptSDK/EventHelpers.ts +0 -550
- package/src/JavaScriptSDK/HelperFuncs.ts +0 -351
- package/src/JavaScriptSDK/InstrumentHooks.ts +0 -280
- package/src/JavaScriptSDK/InternalConstants.ts +0 -31
- package/src/JavaScriptSDK/NotificationManager.ts +0 -165
- package/src/JavaScriptSDK/PerfManager.ts +0 -288
- package/src/JavaScriptSDK/ProcessTelemetryContext.ts +0 -674
- package/src/JavaScriptSDK/RandomHelper.ts +0 -145
- package/src/JavaScriptSDK/TelemetryHelpers.ts +0 -184
- package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +0 -112
- package/src/JavaScriptSDK/UnloadHandlerContainer.ts +0 -45
- package/src/JavaScriptSDK/UnloadHookContainer.ts +0 -52
- package/src/JavaScriptSDK/W3cTraceParent.ts +0 -197
- package/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts +0 -24
- package/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts +0 -71
- package/src/JavaScriptSDK.Enums/LoggingEnums.ts +0 -121
- package/src/JavaScriptSDK.Enums/SendRequestReason.ts +0 -56
- package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +0 -27
- package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +0 -27
- package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +0 -216
- package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +0 -46
- package/src/JavaScriptSDK.Interfaces/IConfiguration.ts +0 -176
- package/src/JavaScriptSDK.Interfaces/ICookieMgr.ts +0 -116
- package/src/JavaScriptSDK.Interfaces/IDbgExtension.ts +0 -14
- package/src/JavaScriptSDK.Interfaces/IDiagnosticLogger.ts +0 -75
- package/src/JavaScriptSDK.Interfaces/IDistributedTraceContext.ts +0 -54
- package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +0 -100
- package/src/JavaScriptSDK.Interfaces/INotificationListener.ts +0 -39
- package/src/JavaScriptSDK.Interfaces/INotificationManager.ts +0 -52
- package/src/JavaScriptSDK.Interfaces/IPerfEvent.ts +0 -69
- package/src/JavaScriptSDK.Interfaces/IPerfManager.ts +0 -53
- package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +0 -157
- package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +0 -17
- package/src/JavaScriptSDK.Interfaces/ITelemetryItem.ts +0 -62
- package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +0 -94
- package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +0 -30
- package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +0 -10
- package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +0 -44
- package/src/JavaScriptSDK.Interfaces/ITraceParent.ts +0 -38
- package/src/JavaScriptSDK.Interfaces/IUnloadHook.ts +0 -22
- package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +0 -17
|
@@ -1,674 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
arrForEach, dumpObj, isArray, isFunction, isNullOrUndefined, isUndefined, objForEachKey, objFreeze, objKeys
|
|
7
|
-
} from "@nevware21/ts-utils";
|
|
8
|
-
import { _applyDefaultValue } from "../Config/ConfigDefaults";
|
|
9
|
-
import { createDynamicConfig } from "../Config/DynamicConfig";
|
|
10
|
-
import { IConfigDefaults } from "../Config/IConfigDefaults";
|
|
11
|
-
import { IDynamicConfigHandler } from "../Config/IDynamicConfigHandler";
|
|
12
|
-
import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
|
|
13
|
-
import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
|
|
14
|
-
import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
|
|
15
|
-
import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
|
|
16
|
-
import {
|
|
17
|
-
IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext
|
|
18
|
-
} from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
19
|
-
import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
|
|
20
|
-
import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
|
|
21
|
-
import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
|
|
22
|
-
import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
|
|
23
|
-
import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
|
|
24
|
-
import { _throwInternal, safeGetLogger } from "./DiagnosticLogger";
|
|
25
|
-
import { proxyFunctions } from "./HelperFuncs";
|
|
26
|
-
import { STR_CORE, STR_DISABLED, STR_EMPTY, STR_EXTENSION_CONFIG } from "./InternalConstants";
|
|
27
|
-
import { doPerf } from "./PerfManager";
|
|
28
|
-
import { _getPluginState } from "./TelemetryHelpers";
|
|
29
|
-
|
|
30
|
-
const strTelemetryPluginChain = "TelemetryPluginChain";
|
|
31
|
-
const strHasRunFlags = "_hasRun";
|
|
32
|
-
const strGetTelCtx = "_getTelCtx";
|
|
33
|
-
|
|
34
|
-
let _chainId = 0;
|
|
35
|
-
|
|
36
|
-
interface OnCompleteCallback {
|
|
37
|
-
func: () => void;
|
|
38
|
-
self: any; // This for the function
|
|
39
|
-
args: any[]; // Additional arguments for the function
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface IInternalTelemetryPluginChain extends ITelemetryPluginChain {
|
|
43
|
-
_id: string;
|
|
44
|
-
_setNext: (nextPlugin: IInternalTelemetryPluginChain) => void;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface IInternalContext<T extends IBaseProcessingContext> {
|
|
48
|
-
_next: () => ITelemetryPluginChain,
|
|
49
|
-
|
|
50
|
-
// The public context that will be exposed
|
|
51
|
-
ctx: T
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function _getNextProxyStart(proxy: ITelemetryPluginChain, core: IAppInsightsCore, startAt: IPlugin): ITelemetryPluginChain {
|
|
55
|
-
while (proxy) {
|
|
56
|
-
if (proxy.getPlugin() === startAt) {
|
|
57
|
-
return proxy;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
proxy = proxy.getNext();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// This wasn't found in the existing chain so create an isolated one with just this plugin
|
|
64
|
-
return createTelemetryProxyChain([startAt], core.config || {}, core);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @ignore
|
|
69
|
-
* @param telemetryChain
|
|
70
|
-
* @param dynamicHandler
|
|
71
|
-
* @param core
|
|
72
|
-
* @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
|
|
73
|
-
* @returns
|
|
74
|
-
*/
|
|
75
|
-
function _createInternalContext<T extends IBaseProcessingContext>(telemetryChain: ITelemetryPluginChain, dynamicHandler: IDynamicConfigHandler<IConfiguration>, core: IAppInsightsCore, startAt?: IPlugin): IInternalContext<T> {
|
|
76
|
-
// We have a special case where we want to start execution from this specific plugin
|
|
77
|
-
// or we simply reuse the existing telemetry plugin chain (normal execution case)
|
|
78
|
-
let _nextProxy: ITelemetryPluginChain | null = null; // By Default set as no next plugin
|
|
79
|
-
let _onComplete: OnCompleteCallback[] = [];
|
|
80
|
-
|
|
81
|
-
if (!dynamicHandler) {
|
|
82
|
-
dynamicHandler = createDynamicConfig({}, null, core.logger);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (startAt !== null) {
|
|
86
|
-
// There is no next element (null) vs not defined (undefined) so use the full chain
|
|
87
|
-
_nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
let context: IInternalContext<T> = {
|
|
91
|
-
_next: _moveNext,
|
|
92
|
-
ctx: {
|
|
93
|
-
core: () => {
|
|
94
|
-
return core
|
|
95
|
-
},
|
|
96
|
-
diagLog: () => {
|
|
97
|
-
return safeGetLogger(core, dynamicHandler.cfg);
|
|
98
|
-
},
|
|
99
|
-
getCfg: () => {
|
|
100
|
-
return dynamicHandler.cfg;
|
|
101
|
-
},
|
|
102
|
-
getExtCfg: _resolveExtCfg,
|
|
103
|
-
getConfig: _getConfig,
|
|
104
|
-
hasNext: () => {
|
|
105
|
-
return !!_nextProxy;
|
|
106
|
-
},
|
|
107
|
-
getNext: () => {
|
|
108
|
-
return _nextProxy;
|
|
109
|
-
},
|
|
110
|
-
setNext: (nextPlugin:ITelemetryPluginChain) => {
|
|
111
|
-
_nextProxy = nextPlugin;
|
|
112
|
-
},
|
|
113
|
-
iterate: _iterateChain,
|
|
114
|
-
onComplete: _addOnComplete
|
|
115
|
-
} as T
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
function _addOnComplete(onComplete: () => void, that?: any, ...args: any[]) {
|
|
119
|
-
if (onComplete) {
|
|
120
|
-
_onComplete.push({
|
|
121
|
-
func: onComplete,
|
|
122
|
-
self: !isUndefined(that) ? that : context.ctx,
|
|
123
|
-
args: args
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function _moveNext() {
|
|
129
|
-
let nextProxy = _nextProxy;
|
|
130
|
-
|
|
131
|
-
// Automatically move to the next plugin
|
|
132
|
-
_nextProxy = nextProxy ? nextProxy.getNext() : null;
|
|
133
|
-
|
|
134
|
-
if (!nextProxy) {
|
|
135
|
-
let onComplete = _onComplete;
|
|
136
|
-
if (onComplete && onComplete.length > 0) {
|
|
137
|
-
arrForEach(onComplete, (completeDetails) => {
|
|
138
|
-
try {
|
|
139
|
-
completeDetails.func.call(completeDetails.self, completeDetails.args);
|
|
140
|
-
} catch (e) {
|
|
141
|
-
_throwInternal(
|
|
142
|
-
core.logger,
|
|
143
|
-
eLoggingSeverity.WARNING,
|
|
144
|
-
_eInternalMessageId.PluginException,
|
|
145
|
-
"Unexpected Exception during onComplete - " + dumpObj(e));
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
_onComplete = [];
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return nextProxy;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function _getExtCfg<T>(identifier: string, createIfMissing: boolean) {
|
|
157
|
-
let idCfg: T = null;
|
|
158
|
-
let cfg = dynamicHandler.cfg;
|
|
159
|
-
if (cfg && identifier) {
|
|
160
|
-
let extCfg = cfg.extensionConfig;
|
|
161
|
-
if (!extCfg && createIfMissing) {
|
|
162
|
-
extCfg = {};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// Always set the value so that the property always exists
|
|
166
|
-
cfg[STR_EXTENSION_CONFIG] = extCfg; // Note: it is valid for the "value" to be undefined
|
|
167
|
-
|
|
168
|
-
// Calling `ref()` has a side effect of causing the referenced property to become dynamic (if not already)
|
|
169
|
-
extCfg = dynamicHandler.ref(cfg, STR_EXTENSION_CONFIG);
|
|
170
|
-
if (extCfg) {
|
|
171
|
-
idCfg = extCfg[identifier];
|
|
172
|
-
if (!idCfg && createIfMissing) {
|
|
173
|
-
idCfg = {} as T;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Always set the value so that the property always exists
|
|
177
|
-
extCfg[identifier] = idCfg; // Note: it is valid for the "value" to be undefined
|
|
178
|
-
|
|
179
|
-
// Calling `ref()` has a side effect of causing the referenced property to become dynamic (if not already)
|
|
180
|
-
idCfg = dynamicHandler.ref(extCfg, identifier);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return idCfg;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function _resolveExtCfg<T>(identifier: string, defaultValues: IConfigDefaults<T>): T {
|
|
188
|
-
let newConfig: T = _getExtCfg(identifier, true);
|
|
189
|
-
|
|
190
|
-
if (defaultValues) {
|
|
191
|
-
// Enumerate over the defaultValues and if not already populated attempt to
|
|
192
|
-
// find a value from the root config or use the default value
|
|
193
|
-
objForEachKey(defaultValues, (field, defaultValue) => {
|
|
194
|
-
// for each unspecified field, set the default value
|
|
195
|
-
if (isNullOrUndefined(newConfig[field])) {
|
|
196
|
-
let cfgValue = dynamicHandler.cfg[field];
|
|
197
|
-
if (cfgValue || !isNullOrUndefined(cfgValue)) {
|
|
198
|
-
newConfig[field] = cfgValue;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
_applyDefaultValue(dynamicHandler, newConfig, field, defaultValue);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return dynamicHandler.setDf(newConfig, defaultValues);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function _getConfig(identifier:string, field: string, defaultValue: number | string | boolean | string[] | RegExp[] | Function = false) {
|
|
210
|
-
let theValue;
|
|
211
|
-
let extConfig: T = _getExtCfg(identifier, false);
|
|
212
|
-
let rootConfig = dynamicHandler.cfg;
|
|
213
|
-
|
|
214
|
-
if (extConfig && (extConfig[field] || !isNullOrUndefined(extConfig[field]))) {
|
|
215
|
-
theValue = extConfig[field];
|
|
216
|
-
} else if (rootConfig[field] || !isNullOrUndefined(rootConfig[field])) {
|
|
217
|
-
theValue = rootConfig[field];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return (theValue || !isNullOrUndefined(theValue)) ? theValue : defaultValue;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function _iterateChain<T extends ITelemetryPlugin = ITelemetryPlugin>(cb: (plugin: T) => void) {
|
|
224
|
-
// Keep processing until we reach the end of the chain
|
|
225
|
-
let nextPlugin: ITelemetryPluginChain;
|
|
226
|
-
while(!!(nextPlugin = context._next())) {
|
|
227
|
-
let plugin = nextPlugin.getPlugin();
|
|
228
|
-
if (plugin) {
|
|
229
|
-
// callback with the current on
|
|
230
|
-
cb(plugin as T);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return context;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Creates a new Telemetry Item context with the current config, core and plugin execution chain
|
|
240
|
-
* @param plugins - The plugin instances that will be executed
|
|
241
|
-
* @param config - The current config
|
|
242
|
-
* @param core - The current core instance
|
|
243
|
-
* @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
|
|
244
|
-
*/
|
|
245
|
-
export function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain | null, cfg: IConfiguration, core:IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext {
|
|
246
|
-
let config = createDynamicConfig(cfg);
|
|
247
|
-
let internalContext: IInternalContext<IProcessTelemetryContext> = _createInternalContext<IProcessTelemetryContext>(telemetryChain, config, core, startAt);
|
|
248
|
-
let context = internalContext.ctx;
|
|
249
|
-
|
|
250
|
-
function _processNext(env: ITelemetryItem) {
|
|
251
|
-
let nextPlugin: ITelemetryPluginChain = internalContext._next();
|
|
252
|
-
|
|
253
|
-
if (nextPlugin) {
|
|
254
|
-
// Run the next plugin which will call "processNext()"
|
|
255
|
-
nextPlugin.processTelemetry(env, context);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return !nextPlugin;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function _createNew(plugins: IPlugin[] | ITelemetryPluginChain | null = null, startAt?: IPlugin) {
|
|
262
|
-
if (isArray(plugins)) {
|
|
263
|
-
plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return createProcessTelemetryContext(plugins || context.getNext(), config.cfg, core, startAt);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
context.processNext = _processNext;
|
|
270
|
-
context.createNew = _createNew;
|
|
271
|
-
|
|
272
|
-
return context;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Creates a new Telemetry Item context with the current config, core and plugin execution chain for handling the unloading of the chain
|
|
277
|
-
* @param plugins - The plugin instances that will be executed
|
|
278
|
-
* @param config - The current config
|
|
279
|
-
* @param core - The current core instance
|
|
280
|
-
* @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
|
|
281
|
-
*/
|
|
282
|
-
export function createProcessTelemetryUnloadContext(telemetryChain: ITelemetryPluginChain, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryUnloadContext {
|
|
283
|
-
let config = createDynamicConfig(core.config);
|
|
284
|
-
let internalContext: IInternalContext<IProcessTelemetryUnloadContext> = _createInternalContext<IProcessTelemetryUnloadContext>(telemetryChain, config, core, startAt);
|
|
285
|
-
let context = internalContext.ctx;
|
|
286
|
-
|
|
287
|
-
function _processNext(unloadState: ITelemetryUnloadState) {
|
|
288
|
-
let nextPlugin: ITelemetryPluginChain = internalContext._next();
|
|
289
|
-
nextPlugin && nextPlugin.unload(context, unloadState);
|
|
290
|
-
|
|
291
|
-
return !nextPlugin;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function _createNew(plugins: IPlugin[] | ITelemetryPluginChain = null, startAt?: IPlugin): IProcessTelemetryUnloadContext {
|
|
295
|
-
if (isArray(plugins)) {
|
|
296
|
-
plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
context.processNext = _processNext;
|
|
303
|
-
context.createNew = _createNew
|
|
304
|
-
|
|
305
|
-
return context;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Creates a new Telemetry Item context with the current config, core and plugin execution chain for updating the configuration
|
|
310
|
-
* @param plugins - The plugin instances that will be executed
|
|
311
|
-
* @param config - The current config
|
|
312
|
-
* @param core - The current core instance
|
|
313
|
-
* @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
|
|
314
|
-
*/
|
|
315
|
-
export function createProcessTelemetryUpdateContext(telemetryChain: ITelemetryPluginChain, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryUpdateContext {
|
|
316
|
-
let config = createDynamicConfig(core.config);
|
|
317
|
-
let internalContext: IInternalContext<IProcessTelemetryUpdateContext> = _createInternalContext<IProcessTelemetryUpdateContext>(telemetryChain, config, core, startAt);
|
|
318
|
-
let context = internalContext.ctx;
|
|
319
|
-
|
|
320
|
-
function _processNext(updateState: ITelemetryUpdateState) {
|
|
321
|
-
return context.iterate((plugin) => {
|
|
322
|
-
if (isFunction(plugin.update)) {
|
|
323
|
-
plugin.update(context, updateState);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function _createNew(plugins: IPlugin[] | ITelemetryPluginChain = null, startAt?: IPlugin) {
|
|
329
|
-
if (isArray(plugins)) {
|
|
330
|
-
plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
context.processNext = _processNext;
|
|
337
|
-
context.createNew = _createNew;
|
|
338
|
-
|
|
339
|
-
return context;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Creates an execution chain from the array of plugins
|
|
344
|
-
* @param plugins - The array of plugins that will be executed in this order
|
|
345
|
-
* @param defItemCtx - The default execution context to use when no telemetry context is passed to processTelemetry(), this
|
|
346
|
-
* should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error
|
|
347
|
-
* reporting (hasRun) when errors occur.
|
|
348
|
-
*/
|
|
349
|
-
export function createTelemetryProxyChain(plugins: IPlugin[], config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): ITelemetryPluginChain {
|
|
350
|
-
let firstProxy: ITelemetryPluginChain = null;
|
|
351
|
-
let add = startAt ? false : true;
|
|
352
|
-
|
|
353
|
-
if (isArray(plugins) && plugins.length > 0) {
|
|
354
|
-
// Create the proxies and wire up the next plugin chain
|
|
355
|
-
let lastProxy: IInternalTelemetryPluginChain = null;
|
|
356
|
-
arrForEach(plugins, (thePlugin: ITelemetryPlugin) => {
|
|
357
|
-
if (!add && startAt === thePlugin) {
|
|
358
|
-
add = true;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
|
|
362
|
-
// Only add plugins that are processors
|
|
363
|
-
let newProxy = createTelemetryPluginProxy(thePlugin, config, core);
|
|
364
|
-
if (!firstProxy) {
|
|
365
|
-
firstProxy = newProxy;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (lastProxy) {
|
|
369
|
-
// Set this new proxy as the next for the previous one
|
|
370
|
-
lastProxy._setNext(newProxy as IInternalTelemetryPluginChain);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
lastProxy = newProxy as IInternalTelemetryPluginChain;
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (startAt && !firstProxy) {
|
|
379
|
-
// Special case where the "startAt" was not in the original list of plugins
|
|
380
|
-
return createTelemetryProxyChain([startAt], config, core);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
return firstProxy;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Create the processing telemetry proxy instance, the proxy is used to abstract the current plugin to allow monitoring and
|
|
388
|
-
* execution plugins while passing around the dynamic execution state (IProcessTelemetryContext), the proxy instance no longer
|
|
389
|
-
* contains any execution state and can be reused between requests (this was not the case for 2.7.2 and earlier with the
|
|
390
|
-
* TelemetryPluginChain class).
|
|
391
|
-
* @param plugin - The plugin instance to proxy
|
|
392
|
-
* @param config - The default execution context to use when no telemetry context is passed to processTelemetry(), this
|
|
393
|
-
* should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error
|
|
394
|
-
* reporting (hasRun) when errors occur.
|
|
395
|
-
* @returns
|
|
396
|
-
*/
|
|
397
|
-
export function createTelemetryPluginProxy(plugin: ITelemetryPlugin, config: IConfiguration, core: IAppInsightsCore): ITelemetryPluginChain {
|
|
398
|
-
let nextProxy: IInternalTelemetryPluginChain = null;
|
|
399
|
-
let hasProcessTelemetry = isFunction(plugin.processTelemetry);
|
|
400
|
-
let hasSetNext = isFunction(plugin.setNextPlugin);
|
|
401
|
-
let chainId: string;
|
|
402
|
-
if (plugin) {
|
|
403
|
-
chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
|
|
404
|
-
} else {
|
|
405
|
-
chainId = "Unknown-0-" + _chainId++;
|
|
406
|
-
}
|
|
407
|
-
let proxyChain: IInternalTelemetryPluginChain = {
|
|
408
|
-
getPlugin: () => {
|
|
409
|
-
return plugin;
|
|
410
|
-
},
|
|
411
|
-
getNext: () => {
|
|
412
|
-
return nextProxy;
|
|
413
|
-
},
|
|
414
|
-
processTelemetry: _processTelemetry,
|
|
415
|
-
unload: _unloadPlugin,
|
|
416
|
-
update: _updatePlugin,
|
|
417
|
-
_id: chainId,
|
|
418
|
-
_setNext: (nextPlugin: IInternalTelemetryPluginChain) => {
|
|
419
|
-
nextProxy = nextPlugin;
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
function _getTelCtx() {
|
|
424
|
-
let itemCtx: IProcessTelemetryContext;
|
|
425
|
-
|
|
426
|
-
// Looks like a plugin didn't pass the (optional) context, so create a new one
|
|
427
|
-
if (plugin && isFunction(plugin[strGetTelCtx])) {
|
|
428
|
-
// This plugin extends from the BaseTelemetryPlugin so lets use it
|
|
429
|
-
itemCtx = plugin[strGetTelCtx]();
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (!itemCtx) {
|
|
433
|
-
// Create a temporary one
|
|
434
|
-
itemCtx = createProcessTelemetryContext(proxyChain, config, core);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
return itemCtx;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
function _processChain<T extends IBaseProcessingContext>(
|
|
441
|
-
itemCtx: T,
|
|
442
|
-
processPluginFn: (itemCtx: T) => boolean,
|
|
443
|
-
name: string,
|
|
444
|
-
details: () => any,
|
|
445
|
-
isAsync: boolean) {
|
|
446
|
-
|
|
447
|
-
let hasRun = false;
|
|
448
|
-
let identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
|
|
449
|
-
let hasRunContext = itemCtx[strHasRunFlags];
|
|
450
|
-
if (!hasRunContext) {
|
|
451
|
-
// Assign and populate
|
|
452
|
-
hasRunContext = itemCtx[strHasRunFlags] = {};
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// Ensure that we keep the context in sync
|
|
456
|
-
itemCtx.setNext(nextProxy);
|
|
457
|
-
|
|
458
|
-
if (plugin) {
|
|
459
|
-
doPerf(itemCtx.core(), () => identifier + ":" + name, () => {
|
|
460
|
-
// Mark this component as having run
|
|
461
|
-
hasRunContext[chainId] = true;
|
|
462
|
-
|
|
463
|
-
try {
|
|
464
|
-
// Set a flag on the next plugin so we know if it was attempted to be executed
|
|
465
|
-
let nextId = nextProxy ? nextProxy._id : STR_EMPTY;
|
|
466
|
-
if (nextId) {
|
|
467
|
-
hasRunContext[nextId] = false;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
hasRun = processPluginFn(itemCtx);
|
|
471
|
-
} catch (error) {
|
|
472
|
-
let hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
|
|
473
|
-
if (hasNextRun) {
|
|
474
|
-
// The next plugin after us has already run so set this one as complete
|
|
475
|
-
hasRun = true;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
if (!nextProxy || !hasNextRun) {
|
|
479
|
-
|
|
480
|
-
// Either we have no next plugin or the current one did not attempt to call the next plugin
|
|
481
|
-
// Which means the current one is the root of the failure so log/report this failure
|
|
482
|
-
_throwInternal(
|
|
483
|
-
itemCtx.diagLog(),
|
|
484
|
-
eLoggingSeverity.CRITICAL,
|
|
485
|
-
_eInternalMessageId.PluginException,
|
|
486
|
-
"Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}, details, isAsync);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
return hasRun;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
function _processTelemetry(env: ITelemetryItem, itemCtx: IProcessTelemetryContext) {
|
|
496
|
-
itemCtx = itemCtx || _getTelCtx();
|
|
497
|
-
|
|
498
|
-
function _callProcessTelemetry(itemCtx: IProcessTelemetryContext) {
|
|
499
|
-
if (!plugin || !hasProcessTelemetry) {
|
|
500
|
-
return false;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
let pluginState = _getPluginState(plugin);
|
|
504
|
-
if (pluginState.teardown || pluginState[STR_DISABLED]) {
|
|
505
|
-
return false;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// Ensure that we keep the context in sync (for processNext()), just in case a plugin
|
|
509
|
-
// doesn't calls processTelemetry() instead of itemContext.processNext() or some
|
|
510
|
-
// other form of error occurred
|
|
511
|
-
if (hasSetNext) {
|
|
512
|
-
// Backward compatibility setting the next plugin on the instance
|
|
513
|
-
plugin.setNextPlugin(nextProxy);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
plugin.processTelemetry(env, itemCtx);
|
|
517
|
-
|
|
518
|
-
// Process Telemetry is expected to call itemCtx.processNext() or nextPlugin.processTelemetry()
|
|
519
|
-
return true;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", () => ({ item: env }), !((env as any).sync))) {
|
|
523
|
-
// The underlying plugin is either not defined, not enabled or does not have a processTelemetry implementation
|
|
524
|
-
// so we still want the next plugin to be executed.
|
|
525
|
-
itemCtx.processNext(env);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
function _unloadPlugin(unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) {
|
|
530
|
-
|
|
531
|
-
function _callTeardown() {
|
|
532
|
-
// Setting default of hasRun as false so the proxyProcessFn() is called as teardown() doesn't have to exist or call unloadNext().
|
|
533
|
-
let hasRun = false;
|
|
534
|
-
if (plugin) {
|
|
535
|
-
let pluginState = _getPluginState(plugin);
|
|
536
|
-
let pluginCore = plugin[STR_CORE] || pluginState.core;
|
|
537
|
-
// Only teardown the plugin if it was initialized by the current core (i.e. It's not a shared plugin)
|
|
538
|
-
if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState.teardown) {
|
|
539
|
-
// Handle plugins that don't extend from the BaseTelemetryPlugin
|
|
540
|
-
pluginState.core = null;
|
|
541
|
-
pluginState.teardown = true;
|
|
542
|
-
pluginState.isInitialized = false;
|
|
543
|
-
|
|
544
|
-
if (plugin.teardown && plugin.teardown(unloadCtx, unloadState) === true) {
|
|
545
|
-
// plugin told us that it was going to (or has) call unloadCtx.processNext()
|
|
546
|
-
hasRun = true;
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
return hasRun;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
if (!_processChain(unloadCtx, _callTeardown, "unload", () => {}, unloadState.isAsync)) {
|
|
555
|
-
// Only called if we hasRun was not true
|
|
556
|
-
unloadCtx.processNext(unloadState);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
function _updatePlugin(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) {
|
|
561
|
-
|
|
562
|
-
function _callUpdate() {
|
|
563
|
-
// Setting default of hasRun as false so the proxyProcessFn() is called as teardown() doesn't have to exist or call unloadNext().
|
|
564
|
-
let hasRun = false;
|
|
565
|
-
if (plugin) {
|
|
566
|
-
let pluginState = _getPluginState(plugin);
|
|
567
|
-
let pluginCore = plugin[STR_CORE] || pluginState.core;
|
|
568
|
-
|
|
569
|
-
// Only update the plugin if it was initialized by the current core (i.e. It's not a shared plugin)
|
|
570
|
-
if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState.teardown) {
|
|
571
|
-
if (plugin.update && plugin.update(updateCtx, updateState) === true) {
|
|
572
|
-
// plugin told us that it was going to (or has) call unloadCtx.processNext()
|
|
573
|
-
hasRun = true;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
return hasRun;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
if (!_processChain(updateCtx, _callUpdate, "update", () => {}, false)) {
|
|
582
|
-
// Only called if we hasRun was not true
|
|
583
|
-
updateCtx.processNext(updateState);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
return objFreeze(proxyChain);
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* This class will be removed!
|
|
592
|
-
* @deprecated use createProcessTelemetryContext() instead
|
|
593
|
-
*/
|
|
594
|
-
export class ProcessTelemetryContext implements IProcessTelemetryContext {
|
|
595
|
-
/**
|
|
596
|
-
* Gets the current core config instance
|
|
597
|
-
*/
|
|
598
|
-
public getCfg: () => IConfiguration;
|
|
599
|
-
|
|
600
|
-
public getExtCfg: <T>(identifier:string, defaultValue?: IConfigDefaults<T>) => T;
|
|
601
|
-
|
|
602
|
-
public getConfig: (identifier:string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Returns the IAppInsightsCore instance for the current request
|
|
606
|
-
*/
|
|
607
|
-
public core: () => IAppInsightsCore;
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* Returns the current IDiagnosticsLogger for the current request
|
|
611
|
-
*/
|
|
612
|
-
public diagLog: () => IDiagnosticLogger;
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* Helper to allow inherited classes to check and possibly shortcut executing code only
|
|
616
|
-
* required if there is a nextPlugin
|
|
617
|
-
*/
|
|
618
|
-
public hasNext: () => boolean;
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Returns the next configured plugin proxy
|
|
622
|
-
*/
|
|
623
|
-
public getNext: () => ITelemetryPluginChain;
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* Helper to set the next plugin proxy
|
|
627
|
-
*/
|
|
628
|
-
public setNext: (nextCtx:ITelemetryPluginChain) => void;
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
* Call back for telemetry processing before it it is sent
|
|
632
|
-
* @param env - This is the current event being reported
|
|
633
|
-
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
|
|
634
|
-
* can optionally use this to access the current core instance or define / pass additional information
|
|
635
|
-
* to later plugins (vs appending items to the telemetry item)
|
|
636
|
-
* @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
|
|
637
|
-
*/
|
|
638
|
-
public processNext: (env: ITelemetryItem) => boolean | void;
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Synchronously iterate over the context chain running the callback for each plugin, once
|
|
642
|
-
* every plugin has been executed via the callback, any associated onComplete will be called.
|
|
643
|
-
* @param callback - The function call for each plugin in the context chain
|
|
644
|
-
*/
|
|
645
|
-
public iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* Create a new context using the core and config from the current instance
|
|
649
|
-
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
650
|
-
* then the current execution order will be copied.
|
|
651
|
-
* @param startAt - The plugin to start processing from, if missing from the execution
|
|
652
|
-
* order then the next plugin will be NOT set.
|
|
653
|
-
*/
|
|
654
|
-
public createNew: (plugins?:IPlugin[]|ITelemetryPluginChain, startAt?:IPlugin) => IProcessTelemetryContext;
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Set the function to call when the current chain has executed all processNext or unloadNext items.
|
|
658
|
-
*/
|
|
659
|
-
public onComplete: (onComplete: () => void) => void;
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* Creates a new Telemetry Item context with the current config, core and plugin execution chain
|
|
663
|
-
* @param plugins - The plugin instances that will be executed
|
|
664
|
-
* @param config - The current config
|
|
665
|
-
* @param core - The current core instance
|
|
666
|
-
*/
|
|
667
|
-
constructor(pluginChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?:IPlugin) {
|
|
668
|
-
let _self = this;
|
|
669
|
-
|
|
670
|
-
let context = createProcessTelemetryContext(pluginChain, config, core, startAt);
|
|
671
|
-
// Proxy all functions of the context to this object
|
|
672
|
-
proxyFunctions(_self, context, objKeys(context) as any);
|
|
673
|
-
}
|
|
674
|
-
}
|