@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,1322 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
6
|
-
import {
|
|
7
|
-
ITimerHandler, arrAppend, arrForEach, arrIndexOf, deepExtend, hasDocument, isFunction, isNullOrUndefined, isPlainObject, objDeepFreeze,
|
|
8
|
-
objDefineProp, objForEachKey, objFreeze, objHasOwn, scheduleInterval, scheduleTimeout, throwError
|
|
9
|
-
} from "@nevware21/ts-utils";
|
|
10
|
-
import { createDynamicConfig, onConfigChange } from "../Config/DynamicConfig";
|
|
11
|
-
import { IConfigDefaults } from "../Config/IConfigDefaults";
|
|
12
|
-
import { IDynamicConfigHandler, _IInternalDynamicConfigHandler } from "../Config/IDynamicConfigHandler";
|
|
13
|
-
import { IWatchDetails, WatcherFunction } from "../Config/IDynamicWatcher";
|
|
14
|
-
import { eEventsDiscardedReason } from "../JavaScriptSDK.Enums/EventsDiscardedReason";
|
|
15
|
-
import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
|
|
16
|
-
import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
|
|
17
|
-
import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
|
|
18
|
-
import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
|
|
19
|
-
import { IAppInsightsCore, ILoadedPlugin } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
|
|
20
|
-
import { IChannelControls } from "../JavaScriptSDK.Interfaces/IChannelControls";
|
|
21
|
-
import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
|
|
22
|
-
import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
|
|
23
|
-
import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
|
|
24
|
-
import { IDistributedTraceContext } from "../JavaScriptSDK.Interfaces/IDistributedTraceContext";
|
|
25
|
-
import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
|
|
26
|
-
import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
|
|
27
|
-
import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager";
|
|
28
|
-
import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
29
|
-
import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../JavaScriptSDK.Interfaces/ITelemetryInitializers";
|
|
30
|
-
import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
|
|
31
|
-
import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
|
|
32
|
-
import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
|
|
33
|
-
import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
|
|
34
|
-
import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
|
|
35
|
-
import { ILegacyUnloadHook, IUnloadHook } from "../JavaScriptSDK.Interfaces/IUnloadHook";
|
|
36
|
-
import { ChannelControllerPriority } from "./Constants";
|
|
37
|
-
import { createCookieMgr } from "./CookieMgr";
|
|
38
|
-
import { createUniqueNamespace } from "./DataCacheHelper";
|
|
39
|
-
import { getDebugListener } from "./DbgExtensionUtils";
|
|
40
|
-
import { DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole } from "./DiagnosticLogger";
|
|
41
|
-
import { getSetValue, proxyFunctionAs, proxyFunctions, toISOString } from "./HelperFuncs";
|
|
42
|
-
import {
|
|
43
|
-
STR_CHANNELS, STR_CREATE_PERF_MGR, STR_DISABLED, STR_EMPTY, STR_EXTENSIONS, STR_EXTENSION_CONFIG, UNDEFINED_VALUE
|
|
44
|
-
} from "./InternalConstants";
|
|
45
|
-
import { NotificationManager } from "./NotificationManager";
|
|
46
|
-
import { PerfManager, doPerf, getGblPerfMgr } from "./PerfManager";
|
|
47
|
-
import {
|
|
48
|
-
createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext, createTelemetryProxyChain
|
|
49
|
-
} from "./ProcessTelemetryContext";
|
|
50
|
-
import { _getPluginState, createDistributedTraceContext, initializePlugins, sortPlugins } from "./TelemetryHelpers";
|
|
51
|
-
import { TelemetryInitializerPlugin } from "./TelemetryInitializerPlugin";
|
|
52
|
-
import { IUnloadHandlerContainer, UnloadHandler, createUnloadHandlerContainer } from "./UnloadHandlerContainer";
|
|
53
|
-
import { IUnloadHookContainer, createUnloadHookContainer } from "./UnloadHookContainer";
|
|
54
|
-
|
|
55
|
-
const strValidationError = "Plugins must provide initialize method";
|
|
56
|
-
const strNotificationManager = "_notificationManager";
|
|
57
|
-
const strSdkUnloadingError = "SDK is still unloading...";
|
|
58
|
-
const strSdkNotInitialized = "SDK is not initialized";
|
|
59
|
-
// const strPluginUnloadFailed = "Failed to unload plugin";
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The default settings for the config.
|
|
63
|
-
* WE MUST include all defaults here to ensure that the config is created with all of the properties
|
|
64
|
-
* defined as dynamic.
|
|
65
|
-
*/
|
|
66
|
-
const defaultConfig: IConfigDefaults<IConfiguration> = objDeepFreeze({
|
|
67
|
-
cookieCfg: {},
|
|
68
|
-
[STR_EXTENSIONS]: [],
|
|
69
|
-
[STR_CHANNELS]: [],
|
|
70
|
-
[STR_EXTENSION_CONFIG]: {},
|
|
71
|
-
[STR_CREATE_PERF_MGR]: UNDEFINED_VALUE,
|
|
72
|
-
loggingLevelConsole: eLoggingSeverity.DISABLED,
|
|
73
|
-
diagnosticLogInterval: UNDEFINED_VALUE
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Helper to create the default performance manager
|
|
78
|
-
* @param core
|
|
79
|
-
* @param notificationMgr
|
|
80
|
-
*/
|
|
81
|
-
function _createPerfManager (core: IAppInsightsCore, notificationMgr: INotificationManager) {
|
|
82
|
-
return new PerfManager(notificationMgr);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function _validateExtensions(logger: IDiagnosticLogger, channelPriority: number, allExtensions: IPlugin[]): { core: IPlugin[], channels: IChannelControls[] } {
|
|
86
|
-
// Concat all available extensions
|
|
87
|
-
let coreExtensions: ITelemetryPlugin[] = [];
|
|
88
|
-
let channels: IChannelControls[] = [];
|
|
89
|
-
|
|
90
|
-
// Check if any two extensions have the same priority, then warn to console
|
|
91
|
-
// And extract the local extensions from the
|
|
92
|
-
let extPriorities = {};
|
|
93
|
-
|
|
94
|
-
// Extension validation
|
|
95
|
-
arrForEach(allExtensions, (ext: ITelemetryPlugin) => {
|
|
96
|
-
// Check for ext.initialize
|
|
97
|
-
if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
|
|
98
|
-
throwError(strValidationError);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const extPriority = ext.priority;
|
|
102
|
-
const identifier = ext.identifier;
|
|
103
|
-
|
|
104
|
-
if (ext && extPriority) {
|
|
105
|
-
if (!isNullOrUndefined(extPriorities[extPriority])) {
|
|
106
|
-
_warnToConsole(logger, "Two extensions have same priority #" + extPriority + " - " + extPriorities[extPriority] + ", " + identifier);
|
|
107
|
-
} else {
|
|
108
|
-
// set a value
|
|
109
|
-
extPriorities[extPriority] = identifier;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Split extensions to core and channels
|
|
114
|
-
if (!extPriority || extPriority < channelPriority) {
|
|
115
|
-
// Add to core extension that will be managed by AppInsightsCore
|
|
116
|
-
coreExtensions.push(ext);
|
|
117
|
-
} else {
|
|
118
|
-
channels.push(ext);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
core: coreExtensions,
|
|
124
|
-
channels: channels
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function _isPluginPresent(thePlugin: IPlugin, plugins: IPlugin[]) {
|
|
129
|
-
let exists = false;
|
|
130
|
-
|
|
131
|
-
arrForEach(plugins, (plugin) => {
|
|
132
|
-
if (plugin === thePlugin) {
|
|
133
|
-
exists = true;
|
|
134
|
-
return -1;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
return exists;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function _deepMergeConfig(details: IWatchDetails<IConfiguration>, target: any, newValues: any, merge: boolean) {
|
|
142
|
-
// Lets assign the new values to the existing config
|
|
143
|
-
if (newValues) {
|
|
144
|
-
objForEachKey(newValues, (key, value) => {
|
|
145
|
-
if (merge) {
|
|
146
|
-
if (isPlainObject(value) && isPlainObject(target[key])) {
|
|
147
|
-
// The target is an object and it has a value
|
|
148
|
-
_deepMergeConfig(details, target[key], value, merge);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (merge && isPlainObject(value) && isPlainObject(target[key])) {
|
|
153
|
-
// The target is an object and it has a value
|
|
154
|
-
_deepMergeConfig(details, target[key], value, merge);
|
|
155
|
-
} else {
|
|
156
|
-
// Just Assign (replace) and/or make the property dynamic
|
|
157
|
-
details.set(target, key, value);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function _findWatcher(listeners: { rm: () => void, w: WatcherFunction<IConfiguration>}[], newWatcher: WatcherFunction<IConfiguration>) {
|
|
164
|
-
let theListener: { rm: () => void, w: WatcherFunction<IConfiguration>} = null;
|
|
165
|
-
let idx: number = -1;
|
|
166
|
-
arrForEach(listeners, (listener, lp) => {
|
|
167
|
-
if (listener.w === newWatcher) {
|
|
168
|
-
theListener = listener;
|
|
169
|
-
idx = lp;
|
|
170
|
-
return -1;
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
return { i: idx, l: theListener };
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function _addDelayedCfgListener(listeners: { rm: () => void, w: WatcherFunction<IConfiguration>}[], newWatcher: WatcherFunction<IConfiguration>) {
|
|
178
|
-
let theListener = _findWatcher(listeners, newWatcher).l;
|
|
179
|
-
|
|
180
|
-
if (!theListener) {
|
|
181
|
-
theListener ={
|
|
182
|
-
w: newWatcher,
|
|
183
|
-
rm: () => {
|
|
184
|
-
let fnd = _findWatcher(listeners, newWatcher);
|
|
185
|
-
if (fnd.i !== -1) {
|
|
186
|
-
listeners.splice(fnd.i, 1);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
listeners.push(theListener);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return theListener;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function _registerDelayedCfgListener(config: IConfiguration, listeners: { rm: () => void, w: WatcherFunction<IConfiguration>}[], logger: IDiagnosticLogger) {
|
|
197
|
-
arrForEach(listeners, (listener) => {
|
|
198
|
-
let unloadHdl = onConfigChange(config, listener.w, logger);
|
|
199
|
-
delete listener.w; // Clear the listener reference so it will get garbage collected.
|
|
200
|
-
// replace the remove function
|
|
201
|
-
listener.rm = () => {
|
|
202
|
-
unloadHdl.rm();
|
|
203
|
-
};
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export class AppInsightsCore implements IAppInsightsCore {
|
|
208
|
-
public static defaultConfig: IConfiguration;
|
|
209
|
-
public config: IConfiguration;
|
|
210
|
-
public logger: IDiagnosticLogger;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* An array of the installed plugins that provide a version
|
|
214
|
-
*/
|
|
215
|
-
public readonly pluginVersionStringArr: string[];
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* The formatted string of the installed plugins that contain a version number
|
|
219
|
-
*/
|
|
220
|
-
public readonly pluginVersionString: string;
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Returns a value that indicates whether the instance has already been previously initialized.
|
|
224
|
-
*/
|
|
225
|
-
public isInitialized: () => boolean;
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Function used to identify the get w parameter used to identify status bit to some channels
|
|
229
|
-
*/
|
|
230
|
-
public getWParam: () => number;
|
|
231
|
-
|
|
232
|
-
constructor() {
|
|
233
|
-
// NOTE!: DON'T set default values here, instead set them in the _initDefaults() function as it is also called during teardown()
|
|
234
|
-
let _configHandler: IDynamicConfigHandler<IConfiguration>;
|
|
235
|
-
let _isInitialized: boolean;
|
|
236
|
-
let _eventQueue: ITelemetryItem[];
|
|
237
|
-
let _notificationManager: INotificationManager | null | undefined;
|
|
238
|
-
let _perfManager: IPerfManager | null;
|
|
239
|
-
let _cfgPerfManager: IPerfManager | null;
|
|
240
|
-
let _cookieManager: ICookieMgr | null;
|
|
241
|
-
let _pluginChain: ITelemetryPluginChain | null;
|
|
242
|
-
let _configExtensions: IPlugin[];
|
|
243
|
-
let _channelConfig: IChannelControls[][] | null | undefined;
|
|
244
|
-
let _channels: IChannelControls[] | null;
|
|
245
|
-
let _isUnloading: boolean;
|
|
246
|
-
let _telemetryInitializerPlugin: TelemetryInitializerPlugin;
|
|
247
|
-
let _internalLogsEventName: string | null;
|
|
248
|
-
let _evtNamespace: string;
|
|
249
|
-
let _unloadHandlers: IUnloadHandlerContainer;
|
|
250
|
-
let _hookContainer: IUnloadHookContainer;
|
|
251
|
-
let _debugListener: INotificationListener | null;
|
|
252
|
-
let _traceCtx: IDistributedTraceContext | null;
|
|
253
|
-
let _instrumentationKey: string | null;
|
|
254
|
-
let _cfgListeners: { rm: () => void, w: WatcherFunction<IConfiguration>}[];
|
|
255
|
-
let _extensions: IPlugin[];
|
|
256
|
-
let _pluginVersionStringArr: string[];
|
|
257
|
-
let _pluginVersionString: string;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Internal log poller
|
|
261
|
-
*/
|
|
262
|
-
let _internalLogPoller: ITimerHandler;
|
|
263
|
-
let _internalLogPollerListening: boolean;
|
|
264
|
-
|
|
265
|
-
dynamicProto(AppInsightsCore, this, (_self) => {
|
|
266
|
-
|
|
267
|
-
// Set the default values (also called during teardown)
|
|
268
|
-
_initDefaults();
|
|
269
|
-
|
|
270
|
-
// Special internal method to allow the unit tests and DebugPlugin to hook embedded objects
|
|
271
|
-
_self["_getDbgPlgTargets"] = () => {
|
|
272
|
-
return [_extensions];
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
_self.isInitialized = () => _isInitialized;
|
|
276
|
-
|
|
277
|
-
// Creating the self.initialize = ()
|
|
278
|
-
_self.initialize = (config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void => {
|
|
279
|
-
if (_isUnloading) {
|
|
280
|
-
throwError(strSdkUnloadingError);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Make sure core is only initialized once
|
|
284
|
-
if (_self.isInitialized()) {
|
|
285
|
-
throwError("Core cannot be initialized more than once");
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
_configHandler = createDynamicConfig(config, defaultConfig, logger || _self.logger, false);
|
|
289
|
-
|
|
290
|
-
// Re-assigning the local config property so we don't have any references to the passed value and it can be garbage collected
|
|
291
|
-
config = _configHandler.cfg;
|
|
292
|
-
|
|
293
|
-
// This will be "re-run" if the referenced config properties are changed
|
|
294
|
-
_addUnloadHook(_configHandler.watch((details) => {
|
|
295
|
-
_instrumentationKey = details.cfg.instrumentationKey;
|
|
296
|
-
|
|
297
|
-
// Mark the extensionConfig and all first level keys as referenced
|
|
298
|
-
// This is so that calls to getExtCfg() will always return the same object
|
|
299
|
-
// Even when a user may "re-assign" the plugin properties (or it's unloaded/reloaded)
|
|
300
|
-
let extCfg = details.ref(details.cfg, STR_EXTENSION_CONFIG);
|
|
301
|
-
objForEachKey(extCfg, (key) => {
|
|
302
|
-
details.ref(extCfg, key);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
if (isNullOrUndefined(_instrumentationKey)) {
|
|
306
|
-
throwError("Please provide instrumentation key");
|
|
307
|
-
}
|
|
308
|
-
}));
|
|
309
|
-
|
|
310
|
-
_notificationManager = notificationManager;
|
|
311
|
-
|
|
312
|
-
_initDebugListener();
|
|
313
|
-
_initPerfManager();
|
|
314
|
-
|
|
315
|
-
_self.logger = logger || new DiagnosticLogger(config);
|
|
316
|
-
_configHandler.logger = _self.logger;
|
|
317
|
-
|
|
318
|
-
let cfgExtensions = config.extensions;
|
|
319
|
-
|
|
320
|
-
// Extension validation
|
|
321
|
-
_configExtensions = [];
|
|
322
|
-
_configExtensions.push(...extensions, ...cfgExtensions);
|
|
323
|
-
_channelConfig = config.channels;
|
|
324
|
-
|
|
325
|
-
_initPluginChain(null);
|
|
326
|
-
|
|
327
|
-
if (!_channels || _channels.length === 0) {
|
|
328
|
-
throwError("No " + STR_CHANNELS + " available");
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if (_channels.length > 1) {
|
|
332
|
-
let teeController = _self.getPlugin("TeeChannelController");
|
|
333
|
-
if (!teeController || !teeController.plugin) {
|
|
334
|
-
_throwInternal(_self.logger, eLoggingSeverity.CRITICAL, _eInternalMessageId.SenderNotInitialized, "TeeChannel required");
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
_registerDelayedCfgListener(config, _cfgListeners, _self.logger);
|
|
339
|
-
_cfgListeners = null;
|
|
340
|
-
|
|
341
|
-
_isInitialized = true;
|
|
342
|
-
_self.releaseQueue();
|
|
343
|
-
|
|
344
|
-
_self.pollInternalLogs();
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
_self.getChannels = (): IChannelControls[] => {
|
|
348
|
-
let controls: IChannelControls[] = [];
|
|
349
|
-
if (_channels) {
|
|
350
|
-
arrForEach(_channels, (channel) => {
|
|
351
|
-
controls.push(channel);
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return objFreeze(controls);
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
_self.track = (telemetryItem: ITelemetryItem) => {
|
|
359
|
-
doPerf(_self.getPerfMgr(), () => "AppInsightsCore:track", () => {
|
|
360
|
-
if (telemetryItem === null) {
|
|
361
|
-
_notifyInvalidEvent(telemetryItem);
|
|
362
|
-
// throw error
|
|
363
|
-
throwError("Invalid telemetry item");
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// do basic validation before sending it through the pipeline
|
|
367
|
-
if (!telemetryItem.name && isNullOrUndefined(telemetryItem.name)) {
|
|
368
|
-
_notifyInvalidEvent(telemetryItem);
|
|
369
|
-
throwError("telemetry name required");
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// setup default iKey if not passed in
|
|
373
|
-
telemetryItem.iKey = telemetryItem.iKey || _instrumentationKey;
|
|
374
|
-
|
|
375
|
-
// add default timestamp if not passed in
|
|
376
|
-
telemetryItem.time = telemetryItem.time || toISOString(new Date());
|
|
377
|
-
|
|
378
|
-
// Common Schema 4.0
|
|
379
|
-
telemetryItem.ver = telemetryItem.ver || "4.0";
|
|
380
|
-
|
|
381
|
-
if (!_isUnloading && _self.isInitialized()) {
|
|
382
|
-
// Process the telemetry plugin chain
|
|
383
|
-
_createTelCtx().processNext(telemetryItem);
|
|
384
|
-
} else {
|
|
385
|
-
// Queue events until all extensions are initialized
|
|
386
|
-
_eventQueue.push(telemetryItem);
|
|
387
|
-
}
|
|
388
|
-
}, () => ({ item: telemetryItem }), !((telemetryItem as any).sync));
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
_self.getProcessTelContext = _createTelCtx;
|
|
392
|
-
|
|
393
|
-
_self.getNotifyMgr = (): INotificationManager => {
|
|
394
|
-
if (!_notificationManager) {
|
|
395
|
-
_addUnloadHook(_configHandler.watch((details) => {
|
|
396
|
-
_notificationManager = new NotificationManager(details.cfg);
|
|
397
|
-
// For backward compatibility only
|
|
398
|
-
_self[strNotificationManager] = _notificationManager;
|
|
399
|
-
}));
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
return _notificationManager;
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
|
|
407
|
-
* The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
|
|
408
|
-
* called.
|
|
409
|
-
* @param listener - An INotificationListener object.
|
|
410
|
-
*/
|
|
411
|
-
_self.addNotificationListener = (listener: INotificationListener): void => {
|
|
412
|
-
_self.getNotifyMgr().addNotificationListener(listener);
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Removes all instances of the listener.
|
|
417
|
-
* @param listener - INotificationListener to remove.
|
|
418
|
-
*/
|
|
419
|
-
_self.removeNotificationListener = (listener: INotificationListener): void => {
|
|
420
|
-
if (_notificationManager) {
|
|
421
|
-
_notificationManager.removeNotificationListener(listener);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
_self.getCookieMgr = (): ICookieMgr => {
|
|
426
|
-
if (!_cookieManager) {
|
|
427
|
-
_addUnloadHook(_configHandler.watch((details) => {
|
|
428
|
-
_cookieManager = createCookieMgr(details.cfg, _self.logger);
|
|
429
|
-
}));
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
return _cookieManager;
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
_self.setCookieMgr = (cookieMgr: ICookieMgr) => {
|
|
436
|
-
_cookieManager = cookieMgr;
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
_self.getPerfMgr = (): IPerfManager => {
|
|
440
|
-
if (!_perfManager && !_cfgPerfManager) {
|
|
441
|
-
_addUnloadHook(_configHandler.watch((details) => {
|
|
442
|
-
if (details.cfg.enablePerfMgr) {
|
|
443
|
-
let createPerfMgr = details.cfg.createPerfMgr;
|
|
444
|
-
if (isFunction(createPerfMgr)) {
|
|
445
|
-
_cfgPerfManager = createPerfMgr(_self, _self.getNotifyMgr());
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}));
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return _perfManager || _cfgPerfManager || getGblPerfMgr();
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
_self.setPerfMgr = (perfMgr: IPerfManager) => {
|
|
455
|
-
_perfManager = perfMgr;
|
|
456
|
-
};
|
|
457
|
-
|
|
458
|
-
_self.eventCnt = (): number => {
|
|
459
|
-
return _eventQueue.length;
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
_self.releaseQueue = () => {
|
|
463
|
-
if (_isInitialized && _eventQueue.length > 0) {
|
|
464
|
-
let eventQueue = _eventQueue;
|
|
465
|
-
_eventQueue = [];
|
|
466
|
-
|
|
467
|
-
arrForEach(eventQueue, (event: ITelemetryItem) => {
|
|
468
|
-
_createTelCtx().processNext(event);
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Periodically check logger.queue for log messages to be flushed
|
|
475
|
-
*/
|
|
476
|
-
_self.pollInternalLogs = (eventName?: string): ITimerHandler => {
|
|
477
|
-
_internalLogsEventName = eventName || null;
|
|
478
|
-
|
|
479
|
-
function _startLogPoller(config: IConfiguration) {
|
|
480
|
-
let interval: number = config.diagnosticLogInterval;
|
|
481
|
-
if (!interval || !(interval > 0)) {
|
|
482
|
-
interval = 10000;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
_internalLogPoller && _internalLogPoller.cancel();
|
|
486
|
-
_internalLogPoller = scheduleInterval(() => {
|
|
487
|
-
_flushInternalLogs();
|
|
488
|
-
}, interval) as any;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
if (!_internalLogPollerListening) {
|
|
492
|
-
_internalLogPollerListening = true;
|
|
493
|
-
// listen to the configuration
|
|
494
|
-
_addUnloadHook(_configHandler.watch((details) => {
|
|
495
|
-
_startLogPoller(details.cfg);
|
|
496
|
-
}));
|
|
497
|
-
} else {
|
|
498
|
-
// We are being called again, so make sure the poller is running
|
|
499
|
-
_startLogPoller(_configHandler.cfg);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return _internalLogPoller;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* Stop polling log messages from logger.queue
|
|
507
|
-
*/
|
|
508
|
-
_self.stopPollingInternalLogs = (): void => {
|
|
509
|
-
if (_internalLogPoller) {
|
|
510
|
-
_internalLogPoller.cancel();
|
|
511
|
-
_internalLogPoller = null;
|
|
512
|
-
_flushInternalLogs();
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
// Add addTelemetryInitializer
|
|
517
|
-
proxyFunctions(_self, () => _telemetryInitializerPlugin, [ "addTelemetryInitializer" ]);
|
|
518
|
-
|
|
519
|
-
_self.unload = (isAsync: boolean = true, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void => {
|
|
520
|
-
if (!_isInitialized) {
|
|
521
|
-
// The SDK is not initialized
|
|
522
|
-
throwError(strSdkNotInitialized);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
// Check if the SDK still unloading so throw
|
|
526
|
-
if (_isUnloading) {
|
|
527
|
-
// The SDK is already unloading
|
|
528
|
-
throwError(strSdkUnloadingError);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
let unloadState: ITelemetryUnloadState = {
|
|
532
|
-
reason: TelemetryUnloadReason.SdkUnload,
|
|
533
|
-
isAsync: isAsync,
|
|
534
|
-
flushComplete: false
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
let processUnloadCtx = createProcessTelemetryUnloadContext(_getPluginChain(), _self);
|
|
538
|
-
processUnloadCtx.onComplete(() => {
|
|
539
|
-
_hookContainer.run(_self.logger);
|
|
540
|
-
|
|
541
|
-
_initDefaults();
|
|
542
|
-
unloadComplete && unloadComplete(unloadState);
|
|
543
|
-
}, _self);
|
|
544
|
-
|
|
545
|
-
function _doUnload(flushComplete: boolean) {
|
|
546
|
-
unloadState.flushComplete = flushComplete;
|
|
547
|
-
_isUnloading = true;
|
|
548
|
-
|
|
549
|
-
// Run all of the unload handlers first (before unloading the plugins)
|
|
550
|
-
_unloadHandlers.run(processUnloadCtx, unloadState);
|
|
551
|
-
|
|
552
|
-
// Stop polling the internal logs
|
|
553
|
-
_self.stopPollingInternalLogs();
|
|
554
|
-
|
|
555
|
-
// Start unloading the components, from this point onwards the SDK should be considered to be in an unstable state
|
|
556
|
-
processUnloadCtx.processNext(unloadState);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
if (!_flushChannels(isAsync, _doUnload, SendRequestReason.SdkUnload, cbTimeout)) {
|
|
560
|
-
_doUnload(false);
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
_self.getPlugin = _getPlugin;
|
|
565
|
-
|
|
566
|
-
_self.addPlugin = <T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, isAsync?: boolean, addCb?: (added?: boolean) => void): void => {
|
|
567
|
-
if (!plugin) {
|
|
568
|
-
addCb && addCb(false);
|
|
569
|
-
_logOrThrowError(strValidationError);
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
let existingPlugin = _getPlugin(plugin.identifier);
|
|
574
|
-
if (existingPlugin && !replaceExisting) {
|
|
575
|
-
addCb && addCb(false);
|
|
576
|
-
|
|
577
|
-
_logOrThrowError("Plugin [" + plugin.identifier + "] is already loaded!");
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
let updateState: ITelemetryUpdateState = {
|
|
582
|
-
reason: TelemetryUpdateReason.PluginAdded
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
function _addPlugin(removed: boolean) {
|
|
586
|
-
_configExtensions.push(plugin);
|
|
587
|
-
updateState.added = [plugin];
|
|
588
|
-
|
|
589
|
-
// Re-Initialize the plugin chain
|
|
590
|
-
_initPluginChain(updateState);
|
|
591
|
-
addCb && addCb(true);
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
if (existingPlugin) {
|
|
595
|
-
let removedPlugins: IPlugin[] = [existingPlugin.plugin];
|
|
596
|
-
let unloadState: ITelemetryUnloadState = {
|
|
597
|
-
reason: TelemetryUnloadReason.PluginReplace,
|
|
598
|
-
isAsync: !!isAsync
|
|
599
|
-
};
|
|
600
|
-
|
|
601
|
-
_removePlugins(removedPlugins, unloadState, (removed) => {
|
|
602
|
-
if (!removed) {
|
|
603
|
-
// Previous plugin was successfully removed or was not installed
|
|
604
|
-
addCb && addCb(false);
|
|
605
|
-
} else {
|
|
606
|
-
updateState.removed = removedPlugins
|
|
607
|
-
updateState.reason |= TelemetryUpdateReason.PluginRemoved;
|
|
608
|
-
_addPlugin(true);
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
} else {
|
|
612
|
-
_addPlugin(false);
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
_self.updateCfg = <T extends IConfiguration = IConfiguration>(newConfig: T, mergeExisting: boolean = true) => {
|
|
617
|
-
let updateState: ITelemetryUpdateState;
|
|
618
|
-
if (_self.isInitialized()) {
|
|
619
|
-
updateState = {
|
|
620
|
-
reason: TelemetryUpdateReason.ConfigurationChanged,
|
|
621
|
-
cfg: _configHandler.cfg,
|
|
622
|
-
oldCfg: deepExtend({}, _configHandler.cfg),
|
|
623
|
-
newConfig: deepExtend({}, newConfig),
|
|
624
|
-
merge: mergeExisting
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
newConfig = updateState.newConfig as T;
|
|
628
|
-
let cfg = _configHandler.cfg;
|
|
629
|
-
|
|
630
|
-
// replace the immutable (if initialized) values
|
|
631
|
-
newConfig.extensions = cfg.extensions;
|
|
632
|
-
newConfig.channels = cfg.channels;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
// We don't currently allow updating the extensions and channels via the update config
|
|
636
|
-
// So overwriting any user provided values to reuse the existing values
|
|
637
|
-
// Explicitly blocking any previous config watchers so that they don't get called because
|
|
638
|
-
// of this bulk update (Probably not necessary)
|
|
639
|
-
(_configHandler as _IInternalDynamicConfigHandler<IConfiguration>)._block((details) => {
|
|
640
|
-
|
|
641
|
-
// Lets assign the new values to the existing config either overwriting or re-assigning
|
|
642
|
-
let theConfig = details.cfg;
|
|
643
|
-
_deepMergeConfig(details, theConfig, newConfig, mergeExisting);
|
|
644
|
-
|
|
645
|
-
if (!mergeExisting) {
|
|
646
|
-
// Remove (unassign) the values "missing" from the newConfig and also not in the default config
|
|
647
|
-
objForEachKey(theConfig, (key) => {
|
|
648
|
-
if (!objHasOwn(newConfig, key)) {
|
|
649
|
-
// Set the value to undefined
|
|
650
|
-
details.set(theConfig, key, UNDEFINED_VALUE);
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
// Apply defaults to the new config
|
|
656
|
-
details.setDf(theConfig, defaultConfig as any);
|
|
657
|
-
});
|
|
658
|
-
|
|
659
|
-
// Now execute all of the listeners (synchronously) so they update their values immediately
|
|
660
|
-
_configHandler.notify();
|
|
661
|
-
|
|
662
|
-
if (updateState) {
|
|
663
|
-
_doUpdate(updateState);
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
_self.evtNamespace = (): string => {
|
|
668
|
-
return _evtNamespace;
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
_self.flush = _flushChannels;
|
|
672
|
-
|
|
673
|
-
_self.getTraceCtx = (createNew?: boolean): IDistributedTraceContext | null => {
|
|
674
|
-
if (!_traceCtx) {
|
|
675
|
-
_traceCtx = createDistributedTraceContext();
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
return _traceCtx;
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
_self.setTraceCtx = (traceCtx: IDistributedTraceContext): void => {
|
|
682
|
-
_traceCtx = traceCtx || null;
|
|
683
|
-
};
|
|
684
|
-
|
|
685
|
-
_self.addUnloadHook = _addUnloadHook;
|
|
686
|
-
|
|
687
|
-
// Create the addUnloadCb
|
|
688
|
-
proxyFunctionAs(_self, "addUnloadCb", () => _unloadHandlers, "add");
|
|
689
|
-
|
|
690
|
-
_self.onCfgChange = <T extends IConfiguration = IConfiguration>(handler: WatcherFunction<T>): IUnloadHook => {
|
|
691
|
-
let unloadHook: IUnloadHook;
|
|
692
|
-
if (!_isInitialized) {
|
|
693
|
-
unloadHook = _addDelayedCfgListener(_cfgListeners, handler);
|
|
694
|
-
} else {
|
|
695
|
-
unloadHook = onConfigChange(_configHandler.cfg, handler, _self.logger);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
return {
|
|
699
|
-
rm: () => {
|
|
700
|
-
unloadHook.rm();
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
_self.getWParam = () => {
|
|
706
|
-
return (hasDocument() || !!_configHandler.cfg.enableWParam) ? 0 : -1;
|
|
707
|
-
};
|
|
708
|
-
|
|
709
|
-
function _setPluginVersions() {
|
|
710
|
-
_pluginVersionStringArr = [];
|
|
711
|
-
|
|
712
|
-
if (_channelConfig) {
|
|
713
|
-
arrForEach(_channelConfig, (channels) => {
|
|
714
|
-
if (channels) {
|
|
715
|
-
arrForEach(channels, (channel) => {
|
|
716
|
-
if (channel.identifier && channel.version) {
|
|
717
|
-
let ver = channel.identifier + "=" + channel.version;
|
|
718
|
-
_pluginVersionStringArr.push(ver);
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
if (_configExtensions) {
|
|
726
|
-
arrForEach(_configExtensions, (ext) => {
|
|
727
|
-
if (ext && ext.identifier && ext.version) {
|
|
728
|
-
let ver = ext.identifier + "=" + ext.version;
|
|
729
|
-
_pluginVersionStringArr.push(ver);
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
function _initDefaults() {
|
|
736
|
-
_isInitialized = false;
|
|
737
|
-
|
|
738
|
-
// Use a default logger so initialization errors are not dropped on the floor with full logging
|
|
739
|
-
_configHandler = createDynamicConfig({}, defaultConfig, _self.logger);
|
|
740
|
-
|
|
741
|
-
// Set the logging level to critical so that any critical initialization failures are displayed on the console
|
|
742
|
-
_configHandler.cfg.loggingLevelConsole = eLoggingSeverity.CRITICAL;
|
|
743
|
-
|
|
744
|
-
// Define _self.config
|
|
745
|
-
objDefineProp(_self, "config", {
|
|
746
|
-
configurable: true,
|
|
747
|
-
enumerable: true,
|
|
748
|
-
get: () => _configHandler.cfg,
|
|
749
|
-
set: (newValue) => {
|
|
750
|
-
_self.updateCfg(newValue, false);
|
|
751
|
-
}
|
|
752
|
-
});
|
|
753
|
-
|
|
754
|
-
objDefineProp(_self, "pluginVersionStringArr", {
|
|
755
|
-
configurable: true,
|
|
756
|
-
enumerable: true,
|
|
757
|
-
get: () => {
|
|
758
|
-
if (!_pluginVersionStringArr) {
|
|
759
|
-
_setPluginVersions();
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
return _pluginVersionStringArr;
|
|
763
|
-
}
|
|
764
|
-
});
|
|
765
|
-
|
|
766
|
-
objDefineProp(_self, "pluginVersionString", {
|
|
767
|
-
configurable: true,
|
|
768
|
-
enumerable: true,
|
|
769
|
-
get: () => {
|
|
770
|
-
if (!_pluginVersionString) {
|
|
771
|
-
if (!_pluginVersionStringArr) {
|
|
772
|
-
_setPluginVersions();
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
_pluginVersionString = _pluginVersionStringArr.join(";");
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
return _pluginVersionString || STR_EMPTY;
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
_self.logger = new DiagnosticLogger(_configHandler.cfg);
|
|
783
|
-
_extensions = [];
|
|
784
|
-
|
|
785
|
-
_telemetryInitializerPlugin = new TelemetryInitializerPlugin();
|
|
786
|
-
_eventQueue = [];
|
|
787
|
-
_notificationManager = null;
|
|
788
|
-
_perfManager = null;
|
|
789
|
-
_cfgPerfManager = null;
|
|
790
|
-
_cookieManager = null;
|
|
791
|
-
_pluginChain = null;
|
|
792
|
-
_configExtensions = [];
|
|
793
|
-
_channelConfig = null;
|
|
794
|
-
_channels = null;
|
|
795
|
-
_isUnloading = false;
|
|
796
|
-
_internalLogsEventName = null;
|
|
797
|
-
_evtNamespace = createUniqueNamespace("AIBaseCore", true);
|
|
798
|
-
_unloadHandlers = createUnloadHandlerContainer();
|
|
799
|
-
_traceCtx = null;
|
|
800
|
-
_instrumentationKey = null;
|
|
801
|
-
_hookContainer = createUnloadHookContainer();
|
|
802
|
-
_cfgListeners = [];
|
|
803
|
-
_pluginVersionString = null;
|
|
804
|
-
_pluginVersionStringArr = null;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
function _createTelCtx(): IProcessTelemetryContext {
|
|
808
|
-
return createProcessTelemetryContext(_getPluginChain(), _configHandler.cfg, _self);
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
// Initialize or Re-initialize the plugins
|
|
812
|
-
function _initPluginChain(updateState: ITelemetryUpdateState | null) {
|
|
813
|
-
// Extension validation
|
|
814
|
-
let theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
|
|
815
|
-
|
|
816
|
-
_pluginChain = null;
|
|
817
|
-
_pluginVersionString = null;
|
|
818
|
-
_pluginVersionStringArr = null;
|
|
819
|
-
|
|
820
|
-
// Get the primary channel queue and include as part of the normal extensions
|
|
821
|
-
_channels = (_channelConfig || [])[0] ||[];
|
|
822
|
-
|
|
823
|
-
// Add any channels provided in the extensions and sort them
|
|
824
|
-
_channels = sortPlugins(arrAppend(_channels, theExtensions.channels));
|
|
825
|
-
|
|
826
|
-
// Create an array of all extensions, including the _channels
|
|
827
|
-
let allExtensions = arrAppend(sortPlugins(theExtensions.core), _channels);
|
|
828
|
-
|
|
829
|
-
// Required to allow plugins to call core.getPlugin() during their own initialization
|
|
830
|
-
_extensions = objFreeze(allExtensions);
|
|
831
|
-
|
|
832
|
-
let rootCtx = _createTelCtx();
|
|
833
|
-
|
|
834
|
-
// Initializing the channels first
|
|
835
|
-
if (_channels && _channels.length > 0) {
|
|
836
|
-
initializePlugins(rootCtx.createNew(_channels), allExtensions);
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
// Now initialize the normal extensions (explicitly not including the _channels as this can cause duplicate initialization)
|
|
840
|
-
initializePlugins(rootCtx, allExtensions);
|
|
841
|
-
|
|
842
|
-
if (updateState) {
|
|
843
|
-
_doUpdate(updateState);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
function _getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T> {
|
|
848
|
-
let theExt: ILoadedPlugin<T> = null;
|
|
849
|
-
let thePlugin: IPlugin = null;
|
|
850
|
-
|
|
851
|
-
arrForEach(_extensions, (ext: any) => {
|
|
852
|
-
if (ext.identifier === pluginIdentifier && ext !== _telemetryInitializerPlugin) {
|
|
853
|
-
thePlugin = ext;
|
|
854
|
-
return -1;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// TODO: Check if the extension is an extension "host" (like the TeeChannel)
|
|
858
|
-
// So that if the extension is not found we can ask the "host" plugins for the plugin
|
|
859
|
-
});
|
|
860
|
-
|
|
861
|
-
// if (!thePlugin && _channelControl) {
|
|
862
|
-
// // Check the channel Controller
|
|
863
|
-
// thePlugin = _channelControl.getChannel(pluginIdentifier);
|
|
864
|
-
// }
|
|
865
|
-
|
|
866
|
-
if (thePlugin) {
|
|
867
|
-
theExt = {
|
|
868
|
-
plugin: thePlugin as T,
|
|
869
|
-
setEnabled: (enabled: boolean) => {
|
|
870
|
-
_getPluginState(thePlugin)[STR_DISABLED] = !enabled;
|
|
871
|
-
},
|
|
872
|
-
isEnabled: () => {
|
|
873
|
-
let pluginState = _getPluginState(thePlugin);
|
|
874
|
-
return !pluginState.teardown && !pluginState[STR_DISABLED];
|
|
875
|
-
},
|
|
876
|
-
remove: (isAsync: boolean = true, removeCb?: (removed?: boolean) => void): void => {
|
|
877
|
-
let pluginsToRemove: IPlugin[] = [thePlugin];
|
|
878
|
-
let unloadState: ITelemetryUnloadState = {
|
|
879
|
-
reason: TelemetryUnloadReason.PluginUnload,
|
|
880
|
-
isAsync: isAsync
|
|
881
|
-
};
|
|
882
|
-
|
|
883
|
-
_removePlugins(pluginsToRemove, unloadState, (removed) => {
|
|
884
|
-
if (removed) {
|
|
885
|
-
// Re-Initialize the plugin chain
|
|
886
|
-
_initPluginChain({
|
|
887
|
-
reason: TelemetryUpdateReason.PluginRemoved,
|
|
888
|
-
removed: pluginsToRemove
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
removeCb && removeCb(removed);
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
return theExt;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
function _getPluginChain() {
|
|
902
|
-
if (!_pluginChain) {
|
|
903
|
-
// copy the collection of extensions
|
|
904
|
-
let extensions = (_extensions || []).slice();
|
|
905
|
-
|
|
906
|
-
// During add / remove this may get called again, so don't read if already present
|
|
907
|
-
if (arrIndexOf(extensions, _telemetryInitializerPlugin) === -1) {
|
|
908
|
-
extensions.push(_telemetryInitializerPlugin);
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
_pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _configHandler.cfg, _self);
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
return _pluginChain;
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
function _removePlugins(thePlugins: IPlugin[], unloadState: ITelemetryUnloadState, removeComplete: (removed: boolean) => void) {
|
|
918
|
-
|
|
919
|
-
if (thePlugins && thePlugins.length > 0) {
|
|
920
|
-
let unloadChain = createTelemetryProxyChain(thePlugins, _configHandler.cfg, _self);
|
|
921
|
-
let unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self);
|
|
922
|
-
|
|
923
|
-
unloadCtx.onComplete(() => {
|
|
924
|
-
let removed = false;
|
|
925
|
-
|
|
926
|
-
// Remove the listed config extensions
|
|
927
|
-
let newConfigExtensions: IPlugin[] = [];
|
|
928
|
-
arrForEach(_configExtensions, (plugin, idx) => {
|
|
929
|
-
if (!_isPluginPresent(plugin, thePlugins)) {
|
|
930
|
-
newConfigExtensions.push(plugin);
|
|
931
|
-
} else {
|
|
932
|
-
removed = true;
|
|
933
|
-
}
|
|
934
|
-
});
|
|
935
|
-
|
|
936
|
-
_configExtensions = newConfigExtensions;
|
|
937
|
-
_pluginVersionString = null;
|
|
938
|
-
_pluginVersionStringArr = null;
|
|
939
|
-
|
|
940
|
-
// Re-Create the channel config
|
|
941
|
-
let newChannelConfig: IChannelControls[][] = [];
|
|
942
|
-
if (_channelConfig) {
|
|
943
|
-
arrForEach(_channelConfig, (queue, idx) => {
|
|
944
|
-
let newQueue: IChannelControls[] = [];
|
|
945
|
-
arrForEach(queue, (channel) => {
|
|
946
|
-
if (!_isPluginPresent(channel, thePlugins)) {
|
|
947
|
-
newQueue.push(channel);
|
|
948
|
-
} else {
|
|
949
|
-
removed = true;
|
|
950
|
-
}
|
|
951
|
-
});
|
|
952
|
-
|
|
953
|
-
newChannelConfig.push(newQueue);
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
_channelConfig = newChannelConfig;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
removeComplete && removeComplete(removed);
|
|
960
|
-
});
|
|
961
|
-
|
|
962
|
-
unloadCtx.processNext(unloadState);
|
|
963
|
-
} else {
|
|
964
|
-
removeComplete(false);
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
function _flushInternalLogs() {
|
|
969
|
-
let queue: _InternalLogMessage[] = _self.logger ? _self.logger.queue : [];
|
|
970
|
-
if (queue) {
|
|
971
|
-
arrForEach(queue, (logMessage: _InternalLogMessage) => {
|
|
972
|
-
const item: ITelemetryItem = {
|
|
973
|
-
name: _internalLogsEventName ? _internalLogsEventName : "InternalMessageId: " + logMessage.messageId,
|
|
974
|
-
iKey: _instrumentationKey,
|
|
975
|
-
time: toISOString(new Date()),
|
|
976
|
-
baseType: _InternalLogMessage.dataType,
|
|
977
|
-
baseData: { message: logMessage.message }
|
|
978
|
-
};
|
|
979
|
-
_self.track(item);
|
|
980
|
-
});
|
|
981
|
-
|
|
982
|
-
queue.length = 0;
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
function _flushChannels(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number) {
|
|
987
|
-
// Setting waiting to one so that we don't call the callBack until we finish iterating
|
|
988
|
-
let waiting = 1;
|
|
989
|
-
let doneIterating = false;
|
|
990
|
-
let cbTimer: ITimerHandler = null;
|
|
991
|
-
cbTimeout = cbTimeout || 5000;
|
|
992
|
-
|
|
993
|
-
function doCallback() {
|
|
994
|
-
waiting--;
|
|
995
|
-
if (doneIterating && waiting === 0) {
|
|
996
|
-
cbTimer && cbTimer.cancel();
|
|
997
|
-
cbTimer = null;
|
|
998
|
-
|
|
999
|
-
callBack && callBack(doneIterating);
|
|
1000
|
-
callBack = null;
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
if (_channels && _channels.length > 0) {
|
|
1005
|
-
let flushCtx = _createTelCtx().createNew(_channels);
|
|
1006
|
-
flushCtx.iterate<IChannelControls>((plugin) => {
|
|
1007
|
-
if (plugin.flush) {
|
|
1008
|
-
waiting ++;
|
|
1009
|
-
|
|
1010
|
-
let handled = false;
|
|
1011
|
-
// Not all channels will call this callback for every scenario
|
|
1012
|
-
if (!plugin.flush(isAsync, () => {
|
|
1013
|
-
handled = true;
|
|
1014
|
-
doCallback();
|
|
1015
|
-
}, sendReason)) {
|
|
1016
|
-
if (!handled) {
|
|
1017
|
-
// If any channel doesn't return true and it didn't call the callback, then we should assume that the callback
|
|
1018
|
-
// will never be called, so use a timeout to allow the channel(s) some time to "finish" before triggering any
|
|
1019
|
-
// followup function (such as unloading)
|
|
1020
|
-
if (isAsync && cbTimer == null) {
|
|
1021
|
-
cbTimer = scheduleTimeout(() => {
|
|
1022
|
-
cbTimer = null;
|
|
1023
|
-
doCallback();
|
|
1024
|
-
}, cbTimeout);
|
|
1025
|
-
} else {
|
|
1026
|
-
doCallback();
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
doneIterating = true;
|
|
1035
|
-
doCallback();
|
|
1036
|
-
|
|
1037
|
-
return true;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
function _initDebugListener() {
|
|
1041
|
-
// Lazily ensure that the notification manager is created
|
|
1042
|
-
!_notificationManager && _self.getNotifyMgr();
|
|
1043
|
-
|
|
1044
|
-
// Will get recalled if any referenced config values are changed
|
|
1045
|
-
_addUnloadHook(_configHandler.watch((details) => {
|
|
1046
|
-
let disableDbgExt = details.cfg.disableDbgExt;
|
|
1047
|
-
|
|
1048
|
-
if (disableDbgExt === true && _debugListener) {
|
|
1049
|
-
// Remove any previously loaded debug listener
|
|
1050
|
-
_notificationManager.removeNotificationListener(_debugListener);
|
|
1051
|
-
_debugListener = null;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
if (_notificationManager && !_debugListener && disableDbgExt !== true) {
|
|
1055
|
-
_debugListener = getDebugListener(details.cfg);
|
|
1056
|
-
_notificationManager.addNotificationListener(_debugListener);
|
|
1057
|
-
}
|
|
1058
|
-
}));
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
function _initPerfManager() {
|
|
1062
|
-
// Will get recalled if any referenced config values are changed
|
|
1063
|
-
_addUnloadHook(_configHandler.watch((details) => {
|
|
1064
|
-
let enablePerfMgr = details.cfg.enablePerfMgr;
|
|
1065
|
-
|
|
1066
|
-
if (!enablePerfMgr && _cfgPerfManager) {
|
|
1067
|
-
// Remove any existing config based performance manager
|
|
1068
|
-
_cfgPerfManager = null;
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
if (enablePerfMgr) {
|
|
1072
|
-
// Set the performance manager creation function if not defined
|
|
1073
|
-
getSetValue(details.cfg, STR_CREATE_PERF_MGR, _createPerfManager);
|
|
1074
|
-
}
|
|
1075
|
-
}));
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
function _doUpdate(updateState: ITelemetryUpdateState): void {
|
|
1079
|
-
let updateCtx = createProcessTelemetryUpdateContext(_getPluginChain(), _self);
|
|
1080
|
-
|
|
1081
|
-
if (!_self._updateHook || _self._updateHook(updateCtx, updateState) !== true) {
|
|
1082
|
-
updateCtx.processNext(updateState);
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
function _logOrThrowError(message: string) {
|
|
1087
|
-
let logger = _self.logger;
|
|
1088
|
-
if (logger) {
|
|
1089
|
-
// there should always be a logger
|
|
1090
|
-
_throwInternal(logger, eLoggingSeverity.WARNING, _eInternalMessageId.PluginException, message);
|
|
1091
|
-
} else {
|
|
1092
|
-
throwError(message);
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
function _notifyInvalidEvent(telemetryItem: ITelemetryItem): void {
|
|
1097
|
-
let manager = _self.getNotifyMgr();
|
|
1098
|
-
if (manager) {
|
|
1099
|
-
manager.eventsDiscarded([telemetryItem], eEventsDiscardedReason.InvalidEvent);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
function _addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>) {
|
|
1104
|
-
_hookContainer.add(hooks);
|
|
1105
|
-
}
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
public initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void {
|
|
1110
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
public getChannels(): IChannelControls[] {
|
|
1114
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1115
|
-
return null;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
public track(telemetryItem: ITelemetryItem) {
|
|
1119
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
public getProcessTelContext(): IProcessTelemetryContext {
|
|
1123
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1124
|
-
return null;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
public getNotifyMgr(): INotificationManager {
|
|
1128
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1129
|
-
return null;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
/**
|
|
1133
|
-
* Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
|
|
1134
|
-
* The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
|
|
1135
|
-
* called.
|
|
1136
|
-
* @param listener - An INotificationListener object.
|
|
1137
|
-
*/
|
|
1138
|
-
public addNotificationListener(listener: INotificationListener): void {
|
|
1139
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
/**
|
|
1143
|
-
* Removes all instances of the listener.
|
|
1144
|
-
* @param listener - INotificationListener to remove.
|
|
1145
|
-
*/
|
|
1146
|
-
public removeNotificationListener(listener: INotificationListener): void {
|
|
1147
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
/**
|
|
1151
|
-
* Get the current cookie manager for this instance
|
|
1152
|
-
*/
|
|
1153
|
-
public getCookieMgr(): ICookieMgr {
|
|
1154
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1155
|
-
return null;
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
/**
|
|
1159
|
-
* Set the current cookie manager for this instance
|
|
1160
|
-
* @param cookieMgr - The manager, if set to null/undefined will cause the default to be created
|
|
1161
|
-
*/
|
|
1162
|
-
public setCookieMgr(cookieMgr: ICookieMgr) {
|
|
1163
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
public getPerfMgr(): IPerfManager {
|
|
1167
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1168
|
-
return null;
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
public setPerfMgr(perfMgr: IPerfManager) {
|
|
1172
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
public eventCnt(): number {
|
|
1176
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1177
|
-
return 0;
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
* Periodically check logger.queue for
|
|
1182
|
-
*/
|
|
1183
|
-
public pollInternalLogs(eventName?: string): ITimerHandler {
|
|
1184
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1185
|
-
return null;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
/**
|
|
1189
|
-
* Periodically check logger.queue for
|
|
1190
|
-
*/
|
|
1191
|
-
public stopPollingInternalLogs(): void {
|
|
1192
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
/**
|
|
1196
|
-
* Add a telemetry processor to decorate or drop telemetry events.
|
|
1197
|
-
* @param telemetryInitializer - The Telemetry Initializer function
|
|
1198
|
-
* @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
|
|
1199
|
-
*/
|
|
1200
|
-
public addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler {
|
|
1201
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1202
|
-
return null;
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
/**
|
|
1206
|
-
* Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
|
|
1207
|
-
* to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
|
|
1208
|
-
* unload call return `true` stating that all plugins reported that they also unloaded, the recommended
|
|
1209
|
-
* approach is to create a new instance and initialize that instance.
|
|
1210
|
-
* This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
|
|
1211
|
-
* to successfully remove any global references or they may just be completing the unload process asynchronously.
|
|
1212
|
-
* @param isAsync - Can the unload be performed asynchronously (default)
|
|
1213
|
-
* @param unloadComplete - An optional callback that will be called once the unload has completed
|
|
1214
|
-
* @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
|
|
1215
|
-
*/
|
|
1216
|
-
public unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void {
|
|
1217
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
public getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T> {
|
|
1221
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1222
|
-
return null;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
/**
|
|
1226
|
-
* Add a new plugin to the installation
|
|
1227
|
-
* @param plugin - The new plugin to add
|
|
1228
|
-
* @param replaceExisting - should any existing plugin be replaced, default is false
|
|
1229
|
-
* @param doAsync - Should the add be performed asynchronously
|
|
1230
|
-
* @param addCb - [Optional] callback to call after the plugin has been added
|
|
1231
|
-
*/
|
|
1232
|
-
public addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void {
|
|
1233
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
/**
|
|
1237
|
-
* Update the configuration used and broadcast the changes to all loaded plugins
|
|
1238
|
-
* @param newConfig - The new configuration is apply
|
|
1239
|
-
* @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to true.
|
|
1240
|
-
*/
|
|
1241
|
-
public updateCfg<T extends IConfiguration = IConfiguration>(newConfig: T, mergeExisting?: boolean): void {
|
|
1242
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
/**
|
|
1246
|
-
* Returns the unique event namespace that should be used
|
|
1247
|
-
*/
|
|
1248
|
-
public evtNamespace(): string {
|
|
1249
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1250
|
-
return null;
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
/**
|
|
1254
|
-
* Add an unload handler that will be called when the SDK is being unloaded
|
|
1255
|
-
* @param handler - the handler
|
|
1256
|
-
*/
|
|
1257
|
-
public addUnloadCb(handler: UnloadHandler): void {
|
|
1258
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
/**
|
|
1262
|
-
* Flush and send any batched / cached data immediately
|
|
1263
|
-
* @param async - send data asynchronously when true (defaults to true)
|
|
1264
|
-
* @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
|
|
1265
|
-
* If the caller doesn't return true the caller should assume that it may never be called.
|
|
1266
|
-
* @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
|
|
1267
|
-
* @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
|
|
1268
|
-
*/
|
|
1269
|
-
public flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void {
|
|
1270
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
/**
|
|
1274
|
-
* Gets the current distributed trace context for this instance if available
|
|
1275
|
-
* @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
|
|
1276
|
-
*/
|
|
1277
|
-
public getTraceCtx(createNew?: boolean): IDistributedTraceContext | null {
|
|
1278
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1279
|
-
return null;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
/**
|
|
1283
|
-
* Sets the current distributed trace context for this instance if available
|
|
1284
|
-
*/
|
|
1285
|
-
public setTraceCtx(newTracectx: IDistributedTraceContext): void {
|
|
1286
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
/**
|
|
1290
|
-
* Add this hook so that it is automatically removed during unloading
|
|
1291
|
-
* @param hooks - The single hook or an array of IInstrumentHook objects
|
|
1292
|
-
*/
|
|
1293
|
-
public addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void {
|
|
1294
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
/**
|
|
1298
|
-
* Watches and tracks changes for accesses to the current config, and if the accessed config changes the
|
|
1299
|
-
* handler will be recalled.
|
|
1300
|
-
* @param handler
|
|
1301
|
-
* @returns A watcher handler instance that can be used to remove itself when being unloaded
|
|
1302
|
-
*/
|
|
1303
|
-
public onCfgChange<T extends IConfiguration = IConfiguration>(handler: WatcherFunction<T>): IUnloadHook {
|
|
1304
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1305
|
-
return null;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
protected releaseQueue() {
|
|
1309
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
/**
|
|
1313
|
-
* Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
|
|
1314
|
-
* @param updateCtx - The plugin update context
|
|
1315
|
-
* @param updateState - The Update State
|
|
1316
|
-
* @returns boolean - True means the extension class will call updateState otherwise the Core will
|
|
1317
|
-
*/
|
|
1318
|
-
protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean {
|
|
1319
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1320
|
-
return false;
|
|
1321
|
-
}
|
|
1322
|
-
}
|