@microsoft/applicationinsights-core-js 2.8.5-nightly.2206-04 → 2.8.5-nightly.2207-02
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 +807 -711
- 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 +400 -336
- package/dist/applicationinsights-core-js.d.ts +1 -1
- package/dist/applicationinsights-core-js.js +807 -711
- 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 +1 -1
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +14 -10
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +158 -139
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +39 -36
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +60 -61
- package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +46 -43
- package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js +16 -15
- package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js +7 -5
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +4 -3
- package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +56 -56
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +21 -20
- package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EventHelpers.js +45 -39
- package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +49 -40
- package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +18 -16
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
- package/dist-esm/JavaScriptSDK/InternalConstants.js +19 -21
- package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
- package/dist-esm/JavaScriptSDK/NotificationManager.js +26 -23
- package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +41 -35
- package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +54 -53
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +5 -4
- package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +34 -34
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +11 -10
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +4 -3
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -1
- package/dist-esm/JavaScriptSDK/W3cTraceParent.js +26 -23
- package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +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 +103 -86
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +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/IUnloadableComponent.js +1 -1
- package/dist-esm/__DynamicConstants.js +70 -0
- package/dist-esm/__DynamicConstants.js.map +1 -0
- package/dist-esm/applicationinsights-core-js.js +1 -1
- package/package.json +5 -2
- package/src/JavaScriptSDK/AppInsightsCore.ts +17 -17
- package/src/JavaScriptSDK/BaseCore.ts +112 -97
- package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +36 -32
- package/src/JavaScriptSDK/ChannelController.ts +39 -37
- package/src/JavaScriptSDK/CookieMgr.ts +27 -27
- package/src/JavaScriptSDK/CoreUtils.ts +19 -20
- package/src/JavaScriptSDK/DataCacheHelper.ts +12 -11
- package/src/JavaScriptSDK/DbgExtensionUtils.ts +9 -9
- package/src/JavaScriptSDK/DiagnosticLogger.ts +49 -50
- package/src/JavaScriptSDK/EnvUtils.ts +15 -17
- package/src/JavaScriptSDK/EventHelpers.ts +15 -14
- package/src/JavaScriptSDK/HelperFuncs.ts +20 -11
- package/src/JavaScriptSDK/InstrumentHooks.ts +11 -13
- package/src/JavaScriptSDK/InternalConstants.ts +20 -20
- package/src/JavaScriptSDK/NotificationManager.ts +27 -27
- package/src/JavaScriptSDK/PerfManager.ts +21 -19
- package/src/JavaScriptSDK/ProcessTelemetryContext.ts +38 -34
- package/src/JavaScriptSDK/RandomHelper.ts +8 -9
- package/src/JavaScriptSDK/TelemetryHelpers.ts +33 -34
- package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +17 -16
- package/src/JavaScriptSDK/UnloadHandlerContainer.ts +11 -11
- package/src/JavaScriptSDK/W3cTraceParent.ts +6 -6
- package/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts +1 -1
- package/src/JavaScriptSDK.Enums/LoggingEnums.ts +72 -56
- package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +1 -1
- package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +2 -2
- package/types/JavaScriptSDK/AppInsightsCore.d.ts +4 -4
- package/types/JavaScriptSDK/BaseCore.d.ts +11 -11
- package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +4 -4
- package/types/JavaScriptSDK/ChannelController.d.ts +1 -2
- package/types/JavaScriptSDK/CookieMgr.d.ts +3 -3
- package/types/JavaScriptSDK/DiagnosticLogger.d.ts +2 -2
- package/types/JavaScriptSDK/HelperFuncs.d.ts +6 -0
- package/types/JavaScriptSDK/InstrumentHooks.d.ts +1 -1
- package/types/JavaScriptSDK/InternalConstants.d.ts +16 -20
- package/types/JavaScriptSDK/NotificationManager.d.ts +1 -1
- package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +2 -2
- package/types/JavaScriptSDK/TelemetryHelpers.d.ts +4 -4
- package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +2 -2
- package/types/__DynamicConstants.d.ts +56 -0
- package/types/tsdoc-metadata.json +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +0 -9
- package/dist-esm/JavaScriptSDK/Constants.js.map +0 -1
- package/src/JavaScriptSDK/Constants.ts +0 -5
- package/types/JavaScriptSDK/Constants.d.ts +0 -2
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
4
|
+
import { eEventsDiscardedReason } from "../JavaScriptSDK.Enums/EventsDiscardedReason";
|
|
5
|
+
import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
|
|
6
|
+
import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
|
|
7
|
+
import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
|
|
8
|
+
import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
|
|
9
|
+
import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
|
|
10
|
+
import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
|
|
11
|
+
import { BaseCore } from "./BaseCore";
|
|
12
|
+
import { DiagnosticLogger } from "./DiagnosticLogger";
|
|
13
|
+
import { isNullOrUndefined, throwError } from "./HelperFuncs";
|
|
14
|
+
import { NotificationManager } from "./NotificationManager";
|
|
15
|
+
import { doPerf } from "./PerfManager";
|
|
16
|
+
|
|
17
17
|
export class AppInsightsCore extends BaseCore implements IAppInsightsCore {
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
@@ -62,4 +62,4 @@ export class AppInsightsCore extends BaseCore implements IAppInsightsCore {
|
|
|
62
62
|
public track(telemetryItem: ITelemetryItem) {
|
|
63
63
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
64
64
|
}
|
|
65
|
-
}
|
|
65
|
+
}
|
|
@@ -1,47 +1,50 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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 { objCreateFn } from "@microsoft/applicationinsights-shims";
|
|
7
|
+
import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
|
|
8
|
+
import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
|
|
9
|
+
import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
|
|
10
|
+
import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
|
|
11
|
+
import { IAppInsightsCore, ILoadedPlugin } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
|
|
12
|
+
import { IChannelControls } from "../JavaScriptSDK.Interfaces/IChannelControls";
|
|
13
|
+
import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
|
|
14
|
+
import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
|
|
15
|
+
import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
|
|
16
|
+
import { IDistributedTraceContext } from "../JavaScriptSDK.Interfaces/IDistributedTraceContext";
|
|
17
|
+
import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
|
|
18
|
+
import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
|
|
19
|
+
import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager";
|
|
20
|
+
import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
21
|
+
import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../JavaScriptSDK.Interfaces/ITelemetryInitializers";
|
|
22
|
+
import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
|
|
23
|
+
import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
|
|
24
|
+
import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
|
|
25
|
+
import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
|
|
26
|
+
import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
|
|
27
|
+
import {
|
|
28
|
+
ChannelControllerPriority, IChannelController, IInternalChannelController, _IInternalChannels, createChannelControllerPlugin,
|
|
29
|
+
createChannelQueues
|
|
30
|
+
} from "./ChannelController";
|
|
31
|
+
import { createCookieMgr } from "./CookieMgr";
|
|
32
|
+
import { createUniqueNamespace } from "./DataCacheHelper";
|
|
33
|
+
import { getDebugListener } from "./DbgExtensionUtils";
|
|
34
|
+
import { DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole } from "./DiagnosticLogger";
|
|
35
|
+
import {
|
|
36
|
+
arrForEach, arrIndexOf, getCfgValue, getSetValue, isFunction, isNullOrUndefined, objExtend, objFreeze, proxyFunctionAs, proxyFunctions,
|
|
37
|
+
throwError, toISOString
|
|
38
|
+
} from "./HelperFuncs";
|
|
39
|
+
import { STR_CHANNELS, STR_CREATE_PERF_MGR, STR_DISABLED, STR_EXTENSIONS, STR_EXTENSION_CONFIG } from "./InternalConstants";
|
|
40
|
+
import { PerfManager, getGblPerfMgr } from "./PerfManager";
|
|
41
|
+
import {
|
|
42
|
+
createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext, createTelemetryProxyChain
|
|
43
|
+
} from "./ProcessTelemetryContext";
|
|
44
|
+
import { _getPluginState, createDistributedTraceContext, initializePlugins, sortPlugins } from "./TelemetryHelpers";
|
|
45
|
+
import { TelemetryInitializerPlugin } from "./TelemetryInitializerPlugin";
|
|
46
|
+
import { IUnloadHandlerContainer, UnloadHandler, createUnloadHandlerContainer } from "./UnloadHandlerContainer";
|
|
47
|
+
|
|
45
48
|
const strValidationError = "Plugins must provide initialize method";
|
|
46
49
|
const strNotificationManager = "_notificationManager";
|
|
47
50
|
const strSdkUnloadingError = "SDK is still unloading...";
|
|
@@ -72,6 +75,7 @@ function _validateExtensions(logger: IDiagnosticLogger, channelPriority: number,
|
|
|
72
75
|
|
|
73
76
|
// Extension validation
|
|
74
77
|
arrForEach(allExtensions, (ext: ITelemetryPlugin) => {
|
|
78
|
+
// Check for ext.initialize
|
|
75
79
|
if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {
|
|
76
80
|
throwError(strValidationError);
|
|
77
81
|
}
|
|
@@ -116,11 +120,11 @@ function _isPluginPresent(thePlugin: IPlugin, plugins: IPlugin[]) {
|
|
|
116
120
|
|
|
117
121
|
function _createDummyNotificationManager(): INotificationManager {
|
|
118
122
|
return objCreateFn({
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
addNotificationListener: (listener: INotificationListener) => { },
|
|
124
|
+
removeNotificationListener: (listener: INotificationListener) => { },
|
|
125
|
+
eventsSent: (events: ITelemetryItem[]) => { },
|
|
126
|
+
eventsDiscarded: (events: ITelemetryItem[], reason: number) => { },
|
|
127
|
+
eventsSendRequest: (sendReason: number, isAsync: boolean) => { }
|
|
124
128
|
});
|
|
125
129
|
}
|
|
126
130
|
|
|
@@ -134,6 +138,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
134
138
|
|
|
135
139
|
constructor() {
|
|
136
140
|
// NOTE!: DON'T set default values here, instead set them in the _initDefaults() function as it is also called during teardown()
|
|
141
|
+
let _config: IConfiguration;
|
|
137
142
|
let _isInitialized: boolean;
|
|
138
143
|
let _eventQueue: ITelemetryItem[];
|
|
139
144
|
let _notificationManager: INotificationManager | null | undefined;
|
|
@@ -166,6 +171,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
166
171
|
|
|
167
172
|
_self.isInitialized = () => _isInitialized;
|
|
168
173
|
|
|
174
|
+
// Creating the self.initialize = ()
|
|
169
175
|
_self.initialize = (config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void => {
|
|
170
176
|
if (_isUnloading) {
|
|
171
177
|
throwError(strSdkUnloadingError);
|
|
@@ -176,7 +182,10 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
176
182
|
throwError("Core should not be initialized more than once");
|
|
177
183
|
}
|
|
178
184
|
|
|
179
|
-
|
|
185
|
+
_config = config || {};
|
|
186
|
+
_self.config = _config;
|
|
187
|
+
|
|
188
|
+
if (isNullOrUndefined(config.instrumentationKey)) {
|
|
180
189
|
throwError("Please provide instrumentation key");
|
|
181
190
|
}
|
|
182
191
|
|
|
@@ -184,29 +193,28 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
184
193
|
|
|
185
194
|
// For backward compatibility only
|
|
186
195
|
_self[strNotificationManager] = notificationManager;
|
|
187
|
-
_self.config = config || {};
|
|
188
196
|
|
|
189
|
-
_initDebugListener(
|
|
190
|
-
_initPerfManager(
|
|
197
|
+
_initDebugListener();
|
|
198
|
+
_initPerfManager();
|
|
191
199
|
|
|
192
|
-
config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
|
|
193
|
-
|
|
194
200
|
// add notification to the extensions in the config so other plugins can access it
|
|
195
|
-
_initExtConfig(
|
|
201
|
+
_initExtConfig();
|
|
196
202
|
|
|
197
203
|
if (logger) {
|
|
198
204
|
_self.logger = logger;
|
|
199
205
|
}
|
|
200
206
|
|
|
207
|
+
let cfgExtensions = getSetValue(_config, STR_EXTENSIONS, []);
|
|
208
|
+
|
|
201
209
|
// Extension validation
|
|
202
210
|
_configExtensions = [];
|
|
203
|
-
_configExtensions.push(...extensions, ...
|
|
204
|
-
_channelConfig = (
|
|
211
|
+
_configExtensions.push(...extensions, ...cfgExtensions);
|
|
212
|
+
_channelConfig = getSetValue(_config, STR_CHANNELS, []);
|
|
205
213
|
|
|
206
|
-
_initPluginChain(
|
|
214
|
+
_initPluginChain(null);
|
|
207
215
|
|
|
208
216
|
if (!_channelQueue || _channelQueue.length === 0) {
|
|
209
|
-
throwError("No
|
|
217
|
+
throwError("No " + STR_CHANNELS + " available");
|
|
210
218
|
}
|
|
211
219
|
|
|
212
220
|
_isInitialized = true;
|
|
@@ -226,13 +234,13 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
226
234
|
|
|
227
235
|
_self.track = (telemetryItem: ITelemetryItem) => {
|
|
228
236
|
// setup default iKey if not passed in
|
|
229
|
-
|
|
237
|
+
telemetryItem.iKey = telemetryItem.iKey || _config.instrumentationKey;
|
|
230
238
|
|
|
231
239
|
// add default timestamp if not passed in
|
|
232
|
-
|
|
240
|
+
telemetryItem.time = telemetryItem.time || toISOString(new Date());
|
|
233
241
|
|
|
234
242
|
// Common Schema 4.0
|
|
235
|
-
|
|
243
|
+
telemetryItem.ver = telemetryItem.ver || "4.0";
|
|
236
244
|
|
|
237
245
|
if (!_isUnloading && _self.isInitialized()) {
|
|
238
246
|
// Process the telemetry plugin chain
|
|
@@ -263,9 +271,9 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
263
271
|
* called.
|
|
264
272
|
* @param {INotificationListener} listener - An INotificationListener object.
|
|
265
273
|
*/
|
|
266
|
-
_self
|
|
274
|
+
_self.addNotificationListener = (listener: INotificationListener): void => {
|
|
267
275
|
if (_notificationManager) {
|
|
268
|
-
_notificationManager
|
|
276
|
+
_notificationManager.addNotificationListener(listener);
|
|
269
277
|
}
|
|
270
278
|
};
|
|
271
279
|
|
|
@@ -273,15 +281,15 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
273
281
|
* Removes all instances of the listener.
|
|
274
282
|
* @param {INotificationListener} listener - INotificationListener to remove.
|
|
275
283
|
*/
|
|
276
|
-
_self
|
|
284
|
+
_self.removeNotificationListener = (listener: INotificationListener): void => {
|
|
277
285
|
if (_notificationManager) {
|
|
278
|
-
_notificationManager
|
|
286
|
+
_notificationManager.removeNotificationListener(listener);
|
|
279
287
|
}
|
|
280
288
|
}
|
|
281
289
|
|
|
282
290
|
_self.getCookieMgr = (): ICookieMgr => {
|
|
283
291
|
if (!_cookieManager) {
|
|
284
|
-
_cookieManager = createCookieMgr(
|
|
292
|
+
_cookieManager = createCookieMgr(_config, _self.logger);
|
|
285
293
|
}
|
|
286
294
|
|
|
287
295
|
return _cookieManager;
|
|
@@ -293,8 +301,11 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
293
301
|
|
|
294
302
|
_self.getPerfMgr = (): IPerfManager => {
|
|
295
303
|
if (!_perfManager && !_cfgPerfManager) {
|
|
296
|
-
if (
|
|
297
|
-
|
|
304
|
+
if (getCfgValue(_config.enablePerfMgr)) {
|
|
305
|
+
let createPerfMgr = getCfgValue(_config.createPerfMgr);
|
|
306
|
+
if (isFunction(createPerfMgr)) {
|
|
307
|
+
_cfgPerfManager = createPerfMgr(_self, _self.getNotifyMgr());
|
|
308
|
+
}
|
|
298
309
|
}
|
|
299
310
|
}
|
|
300
311
|
|
|
@@ -326,7 +337,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
326
337
|
_self.pollInternalLogs = (eventName?: string): number => {
|
|
327
338
|
_internalLogsEventName = eventName || null;
|
|
328
339
|
|
|
329
|
-
let interval =
|
|
340
|
+
let interval: number = getCfgValue(_config.diagnosticLogInterval);
|
|
330
341
|
if (!interval || !(interval > 0)) {
|
|
331
342
|
interval = 10000;
|
|
332
343
|
}
|
|
@@ -423,7 +434,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
423
434
|
updateState.added = [plugin];
|
|
424
435
|
|
|
425
436
|
// Re-Initialize the plugin chain
|
|
426
|
-
_initPluginChain(
|
|
437
|
+
_initPluginChain(updateState);
|
|
427
438
|
addCb && addCb(true);
|
|
428
439
|
}
|
|
429
440
|
|
|
@@ -474,8 +485,9 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
474
485
|
_isInitialized = false;
|
|
475
486
|
|
|
476
487
|
// Use a default logger so initialization errors are not dropped on the floor with full logging
|
|
477
|
-
|
|
478
|
-
_self.
|
|
488
|
+
_config = objExtend(true, {}, defaultInitConfig);
|
|
489
|
+
_self.config = _config;
|
|
490
|
+
_self.logger = new DiagnosticLogger(_config);
|
|
479
491
|
_self._extensions = [];
|
|
480
492
|
|
|
481
493
|
_telemetryInitializerPlugin = new TelemetryInitializerPlugin();
|
|
@@ -498,11 +510,11 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
498
510
|
}
|
|
499
511
|
|
|
500
512
|
function _createTelCtx(): IProcessTelemetryContext {
|
|
501
|
-
return createProcessTelemetryContext(_getPluginChain(),
|
|
513
|
+
return createProcessTelemetryContext(_getPluginChain(), _config, _self);
|
|
502
514
|
}
|
|
503
515
|
|
|
504
516
|
// Initialize or Re-initialize the plugins
|
|
505
|
-
function _initPluginChain(
|
|
517
|
+
function _initPluginChain(updateState: ITelemetryUpdateState | null) {
|
|
506
518
|
// Extension validation
|
|
507
519
|
let theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
|
|
508
520
|
|
|
@@ -513,7 +525,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
513
525
|
let allExtensions = theExtensions.all;
|
|
514
526
|
|
|
515
527
|
// Initialize the Channel Queues and the channel plugins first
|
|
516
|
-
_channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions,
|
|
528
|
+
_channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, _self));
|
|
517
529
|
if (_channelControl) {
|
|
518
530
|
// During add / remove of a plugin this may get called again, so don't re-add if already present
|
|
519
531
|
// But we also want the controller as the last, so remove if already present
|
|
@@ -542,7 +554,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
542
554
|
_self._extensions = sortPlugins(allExtensions);
|
|
543
555
|
|
|
544
556
|
// Initialize the controls
|
|
545
|
-
_channelControl.initialize(
|
|
557
|
+
_channelControl.initialize(_config, _self, allExtensions);
|
|
546
558
|
|
|
547
559
|
initializePlugins(_createTelCtx(), allExtensions);
|
|
548
560
|
|
|
@@ -574,11 +586,11 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
574
586
|
theExt = {
|
|
575
587
|
plugin: thePlugin as T,
|
|
576
588
|
setEnabled: (enabled: boolean) => {
|
|
577
|
-
_getPluginState(thePlugin)[
|
|
589
|
+
_getPluginState(thePlugin)[STR_DISABLED] = !enabled;
|
|
578
590
|
},
|
|
579
591
|
isEnabled: () => {
|
|
580
592
|
let pluginState = _getPluginState(thePlugin);
|
|
581
|
-
return !pluginState
|
|
593
|
+
return !pluginState.teardown && !pluginState[STR_DISABLED];
|
|
582
594
|
},
|
|
583
595
|
remove: (isAsync: boolean = true, removeCb?: (removed?: boolean) => void): void => {
|
|
584
596
|
let pluginsToRemove: IPlugin[] = [thePlugin];
|
|
@@ -590,7 +602,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
590
602
|
_removePlugins(pluginsToRemove, unloadState, (removed) => {
|
|
591
603
|
if (removed) {
|
|
592
604
|
// Re-Initialize the plugin chain
|
|
593
|
-
_initPluginChain(
|
|
605
|
+
_initPluginChain({
|
|
594
606
|
reason: TelemetryUpdateReason.PluginRemoved,
|
|
595
607
|
removed: pluginsToRemove
|
|
596
608
|
});
|
|
@@ -615,7 +627,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
615
627
|
extensions.push(_telemetryInitializerPlugin);
|
|
616
628
|
}
|
|
617
629
|
|
|
618
|
-
_pluginChain = createTelemetryProxyChain(sortPlugins(extensions),
|
|
630
|
+
_pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _config, _self);
|
|
619
631
|
}
|
|
620
632
|
|
|
621
633
|
return _pluginChain;
|
|
@@ -624,7 +636,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
624
636
|
function _removePlugins(thePlugins: IPlugin[], unloadState: ITelemetryUnloadState, removeComplete: (removed: boolean) => void) {
|
|
625
637
|
|
|
626
638
|
if (thePlugins && thePlugins.length > 0) {
|
|
627
|
-
let unloadChain = createTelemetryProxyChain(thePlugins,
|
|
639
|
+
let unloadChain = createTelemetryProxyChain(thePlugins, _config, _self);
|
|
628
640
|
let unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self);
|
|
629
641
|
|
|
630
642
|
unloadCtx.onComplete(() => {
|
|
@@ -676,7 +688,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
676
688
|
arrForEach(queue, (logMessage: _InternalLogMessage) => {
|
|
677
689
|
const item: ITelemetryItem = {
|
|
678
690
|
name: _internalLogsEventName ? _internalLogsEventName : "InternalMessageId: " + logMessage.messageId,
|
|
679
|
-
iKey:
|
|
691
|
+
iKey: getCfgValue(_config.instrumentationKey),
|
|
680
692
|
time: toISOString(new Date()),
|
|
681
693
|
baseType: _InternalLogMessage.dataType,
|
|
682
694
|
baseData: { message: logMessage.message }
|
|
@@ -697,34 +709,37 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
697
709
|
return true;
|
|
698
710
|
}
|
|
699
711
|
|
|
700
|
-
function _initDebugListener(
|
|
712
|
+
function _initDebugListener() {
|
|
713
|
+
let disableDbgExt = getCfgValue(_config.disableDbgExt);
|
|
701
714
|
|
|
702
|
-
if (
|
|
715
|
+
if (disableDbgExt === true && _debugListener) {
|
|
703
716
|
// Remove any previously loaded debug listener
|
|
704
|
-
_notificationManager
|
|
717
|
+
_notificationManager.removeNotificationListener(_debugListener);
|
|
705
718
|
_debugListener = null;
|
|
706
719
|
}
|
|
707
720
|
|
|
708
|
-
if (_notificationManager && !_debugListener &&
|
|
709
|
-
_debugListener = getDebugListener(
|
|
710
|
-
_notificationManager
|
|
721
|
+
if (_notificationManager && !_debugListener && disableDbgExt !== true) {
|
|
722
|
+
_debugListener = getDebugListener(_config);
|
|
723
|
+
_notificationManager.addNotificationListener(_debugListener);
|
|
711
724
|
}
|
|
712
725
|
}
|
|
713
726
|
|
|
714
|
-
function _initPerfManager(
|
|
715
|
-
|
|
727
|
+
function _initPerfManager() {
|
|
728
|
+
let enablePerfMgr = getCfgValue(_config.enablePerfMgr);
|
|
729
|
+
|
|
730
|
+
if (!enablePerfMgr && _cfgPerfManager) {
|
|
716
731
|
// Remove any existing config based performance manager
|
|
717
732
|
_cfgPerfManager = null;
|
|
718
733
|
}
|
|
719
734
|
|
|
720
|
-
if (
|
|
735
|
+
if (enablePerfMgr) {
|
|
721
736
|
// Set the performance manager creation function if not defined
|
|
722
|
-
|
|
737
|
+
getSetValue(_config, STR_CREATE_PERF_MGR, _createPerfManager);
|
|
723
738
|
}
|
|
724
739
|
}
|
|
725
740
|
|
|
726
|
-
function _initExtConfig(
|
|
727
|
-
let extConfig = getSetValue(
|
|
741
|
+
function _initExtConfig() {
|
|
742
|
+
let extConfig = getSetValue(_config, STR_EXTENSION_CONFIG, {});
|
|
728
743
|
extConfig.NotificationManager = _notificationManager;
|
|
729
744
|
}
|
|
730
745
|
|
|
@@ -932,4 +947,4 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
932
947
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
933
948
|
return false;
|
|
934
949
|
}
|
|
935
|
-
}
|
|
950
|
+
}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
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 { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
|
|
7
|
+
import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
|
|
8
|
+
import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
|
|
9
|
+
import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
|
|
10
|
+
import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
|
|
11
|
+
import { IInstrumentHook } from "../JavaScriptSDK.Interfaces/IInstrumentHooks";
|
|
12
|
+
import {
|
|
13
|
+
IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext
|
|
14
|
+
} from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
15
|
+
import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
|
|
16
|
+
import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
|
|
17
|
+
import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
|
|
18
|
+
import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
|
|
19
|
+
import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
|
|
20
|
+
import { arrForEach, isArray, isFunction, isNullOrUndefined, proxyFunctionAs, setValue } from "./HelperFuncs";
|
|
21
|
+
import { STR_EXTENSION_CONFIG } from "./InternalConstants";
|
|
22
|
+
import {
|
|
23
|
+
createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext
|
|
24
|
+
} from "./ProcessTelemetryContext";
|
|
25
|
+
import { IUnloadHandlerContainer, UnloadHandler, createUnloadHandlerContainer } from "./UnloadHandlerContainer";
|
|
26
|
+
|
|
25
27
|
let strGetPlugin = "getPlugin";
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -140,11 +142,13 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
140
142
|
|
|
141
143
|
_unloadHandlerContainer.run(theUnloadCtx, unloadState);
|
|
142
144
|
|
|
145
|
+
let oldHooks = _hooks;
|
|
146
|
+
_hooks = [];
|
|
147
|
+
|
|
143
148
|
// Remove all instrumentation hooks
|
|
144
|
-
arrForEach(
|
|
149
|
+
arrForEach(oldHooks, (fn) => {
|
|
145
150
|
fn.rm();
|
|
146
151
|
});
|
|
147
|
-
_hooks = [];
|
|
148
152
|
|
|
149
153
|
if (result === true) {
|
|
150
154
|
theUnloadCtx.processNext(theUnloadState);
|
|
@@ -154,7 +158,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
if (!_self
|
|
161
|
+
if (!_self._doTeardown || _self._doTeardown(theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
|
|
158
162
|
_unloadCallback();
|
|
159
163
|
} else {
|
|
160
164
|
// Tell the caller that we will be calling processNext()
|
|
@@ -215,7 +219,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
215
219
|
return _getTelCtx(itemCtx).diagLog();
|
|
216
220
|
}
|
|
217
221
|
|
|
218
|
-
_self
|
|
222
|
+
_self.isInitialized = () => {
|
|
219
223
|
return _isinitialized;
|
|
220
224
|
}
|
|
221
225
|
|
|
@@ -228,7 +232,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
228
232
|
// should use processNext() function. If you require access to the plugin use the
|
|
229
233
|
// IProcessTelemetryContext.getNext().getPlugin() while in the pipeline, Note getNext() may return null.
|
|
230
234
|
|
|
231
|
-
_self
|
|
235
|
+
_self.setNextPlugin = (next: ITelemetryPlugin | ITelemetryPluginChain) => {
|
|
232
236
|
_nextPlugin = next;
|
|
233
237
|
};
|
|
234
238
|
|
|
@@ -245,7 +249,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
245
249
|
|
|
246
250
|
_self._getTelCtx = _getTelCtx;
|
|
247
251
|
|
|
248
|
-
function _getTelCtx(currentCtx:IProcessTelemetryContext = null) {
|
|
252
|
+
function _getTelCtx(currentCtx: IProcessTelemetryContext = null) {
|
|
249
253
|
let itemCtx:IProcessTelemetryContext = currentCtx;
|
|
250
254
|
if (!itemCtx) {
|
|
251
255
|
let rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
|
|
@@ -264,7 +268,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
264
268
|
function _setDefaults(config: IConfiguration, core: IAppInsightsCore, pluginChain: ITelemetryPluginChain) {
|
|
265
269
|
if (config) {
|
|
266
270
|
// Make sure the extensionConfig exists
|
|
267
|
-
setValue(config,
|
|
271
|
+
setValue(config, STR_EXTENSION_CONFIG, [], null, isNullOrUndefined);
|
|
268
272
|
}
|
|
269
273
|
|
|
270
274
|
if (!pluginChain && core) {
|
|
@@ -337,4 +341,4 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
337
341
|
protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void {
|
|
338
342
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
339
343
|
}
|
|
340
|
-
}
|
|
344
|
+
}
|