@microsoft/applicationinsights-core-js 2.8.0-beta.2203-02 → 2.8.0-beta.2203-03
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 +197 -10
- 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 +751 -33
- package/dist/applicationinsights-core-js.api.md +26 -0
- package/dist/applicationinsights-core-js.d.ts +73 -2
- package/dist/applicationinsights-core-js.js +197 -10
- 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 +73 -2
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +183 -10
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +8 -2
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.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 +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 +2 -2
- package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +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 +16 -2
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +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 +32 -0
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.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/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/applicationinsights-core-js.js +2 -1
- package/dist-esm/applicationinsights-core-js.js.map +1 -1
- package/package.json +1 -1
- package/src/JavaScriptSDK/BaseCore.ts +233 -10
- package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +16 -2
- package/src/JavaScriptSDK/HelperFuncs.ts +1 -1
- package/src/JavaScriptSDK/ProcessTelemetryContext.ts +16 -2
- package/src/JavaScriptSDK/UnloadHandlerContainer.ts +44 -0
- package/src/JavaScriptSDK.Enums/SendRequestReason.ts +5 -0
- package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +3 -3
- package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +29 -2
- package/types/JavaScriptSDK/BaseCore.d.ts +17 -1
- package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +6 -0
- package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +2 -0
- package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +11 -0
- package/types/JavaScriptSDK.Enums/SendRequestReason.d.ts +4 -0
- package/types/JavaScriptSDK.Enums/TelemetryUnloadReason.d.ts +13 -1
- package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +24 -1
- package/types/applicationinsights-core-js.d.ts +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Application Insights JavaScript SDK - Core, 2.8.0-beta.2203-03
|
|
3
|
+
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import { dumpObj } from "./EnvUtils";
|
|
8
|
+
import { arrForEach } from "./HelperFuncs";
|
|
9
|
+
export function createUnloadHandlerContainer() {
|
|
10
|
+
var handlers = [];
|
|
11
|
+
function _addHandler(handler) {
|
|
12
|
+
if (handler) {
|
|
13
|
+
handlers.push(handler);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _runHandlers(unloadCtx, unloadState) {
|
|
17
|
+
arrForEach(handlers, function (handler) {
|
|
18
|
+
try {
|
|
19
|
+
handler(unloadCtx, unloadState);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
unloadCtx.diagLog().throwInternal(2 /* WARNING */, 73 /* PluginException */, "Unexpected error calling unload handler - " + dumpObj(e));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
handlers = [];
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
add: _addHandler,
|
|
29
|
+
run: _runHandlers
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=UnloadHandlerContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnloadHandlerContainer.js.map","sources":["UnloadHandlerContainer.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dumpObj } from \"./EnvUtils\";\r\nimport { arrForEach } from \"./HelperFuncs\";\r\nexport function createUnloadHandlerContainer() {\r\n var handlers = [];\r\n function _addHandler(handler) {\r\n if (handler) {\r\n handlers.push(handler);\r\n }\r\n }\r\n function _runHandlers(unloadCtx, unloadState) {\r\n arrForEach(handlers, function (handler) {\r\n try {\r\n handler(unloadCtx, unloadState);\r\n }\r\n catch (e) {\r\n unloadCtx.diagLog().throwInternal(2 /* WARNING */, 73 /* PluginException */, \"Unexpected error calling unload handler - \" + dumpObj(e));\r\n }\r\n });\r\n handlers = [];\r\n }\r\n return {\r\n add: _addHandler,\r\n run: _runHandlers\r\n };\r\n}\r\n//# sourceMappingURL=UnloadHandlerContainer.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Core, 2.8.0-beta.2203-
|
|
2
|
+
* Application Insights JavaScript SDK - Core, 2.8.0-beta.2203-03
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
export { MinChannelPriorty } from "./JavaScriptSDK.Interfaces/IChannelControls";
|
|
@@ -26,4 +26,5 @@ export { createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesS
|
|
|
26
26
|
export { strIKey, strExtensionConfig } from "./JavaScriptSDK/Constants";
|
|
27
27
|
export { getDebugListener, getDebugExt } from "./JavaScriptSDK/DbgExtensionUtils";
|
|
28
28
|
export { createUniqueNamespace } from "./JavaScriptSDK/DataCacheHelper";
|
|
29
|
+
export { createUnloadHandlerContainer } from "./JavaScriptSDK/UnloadHandlerContainer";
|
|
29
30
|
//# sourceMappingURL=applicationinsights-core-js.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationinsights-core-js.js.map","sources":["applicationinsights-core-js.js"],"sourcesContent":["export { MinChannelPriorty } from \"./JavaScriptSDK.Interfaces/IChannelControls\";\r\nexport { EventsDiscardedReason } from \"./JavaScriptSDK.Enums/EventsDiscardedReason\";\r\nexport { AppInsightsCore } from \"./JavaScriptSDK/AppInsightsCore\";\r\nexport { BaseCore } from \"./JavaScriptSDK/BaseCore\";\r\nexport { BaseTelemetryPlugin } from \"./JavaScriptSDK/BaseTelemetryPlugin\";\r\nexport { randomValue, random32, mwcRandomSeed, mwcRandom32, newId } from \"./JavaScriptSDK/RandomHelper\";\r\nexport { CoreUtils, EventHelper, Undefined, newGuid, perfNow, generateW3CId, disableCookies, canUseCookies, getCookie, setCookie, deleteCookie, _legacyCookieMgr } from \"./JavaScriptSDK/CoreUtils\";\r\nexport { isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction, normalizeJsName, objForEachKey, strEndsWith, strStartsWith, isDate, isArray, isError, isString, isNumber, isBoolean, toISOString, arrForEach, arrIndexOf, arrMap, arrReduce, strTrim, objKeys, objDefineAccessors, dateNow, getExceptionName, throwError, strContains, isSymbol, setValue, getSetValue, isNotTruthy, isTruthy, proxyAssign, proxyFunctions, proxyFunctionAs, createClassFromInterface, optimizeObject, isNotUndefined, isNotNullOrUndefined, objFreeze, objSeal, createEnumStyle, objExtend } from \"./JavaScriptSDK/HelperFuncs\";\r\nexport { attachEvent, detachEvent, addEventHandler, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, removeEventHandler, removeEventListeners, removePageUnloadEventListener, removePageHideEventListener, eventOn, eventOff, mergeEvtNamespace, __getRegisteredEvents } from \"./JavaScriptSDK/EventHelpers\";\r\nexport { getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, getCrypto, getMsCrypto, hasNavigator, getNavigator, hasHistory, getHistory, getLocation, getPerformance, hasJSON, getJSON, isReactNative, getConsole, dumpObj, isIE, getIEVersion, isSafari, setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported } from \"./JavaScriptSDK/EnvUtils\";\r\nexport { getGlobal, objCreateFn as objCreate, strShimPrototype as strPrototype, strShimFunction as strFunction, strShimUndefined as strUndefined, strShimObject as strObject } from \"@microsoft/applicationinsights-shims\";\r\nexport { NotificationManager } from \"./JavaScriptSDK/NotificationManager\";\r\nexport { PerfEvent, PerfManager, doPerf, getGblPerfMgr, setGblPerfMgr } from \"./JavaScriptSDK/PerfManager\";\r\nexport { safeGetLogger, DiagnosticLogger, _InternalLogMessage } from \"./JavaScriptSDK/DiagnosticLogger\";\r\nexport { ProcessTelemetryContext, createProcessTelemetryContext\r\n// Explicitly NOT exporting createProcessTelemetryUnloadContext() and createProcessTelemetryUpdateContext() as these should only be created internally\r\n } from \"./JavaScriptSDK/ProcessTelemetryContext\";\r\nexport { initializePlugins, sortPlugins } from \"./JavaScriptSDK/TelemetryHelpers\";\r\nexport { _InternalMessageId, LoggingSeverity } from \"./JavaScriptSDK.Enums/LoggingEnums\";\r\nexport { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs } from \"./JavaScriptSDK/InstrumentHooks\";\r\nexport { createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesSupported } from \"./JavaScriptSDK/CookieMgr\";\r\nexport { strIKey, strExtensionConfig } from \"./JavaScriptSDK/Constants\";\r\nexport { getDebugListener, getDebugExt } from \"./JavaScriptSDK/DbgExtensionUtils\";\r\nexport { createUniqueNamespace } from \"./JavaScriptSDK/DataCacheHelper\";\r\n//# sourceMappingURL=applicationinsights-core-js.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"applicationinsights-core-js.js.map","sources":["applicationinsights-core-js.js"],"sourcesContent":["export { MinChannelPriorty } from \"./JavaScriptSDK.Interfaces/IChannelControls\";\r\nexport { EventsDiscardedReason } from \"./JavaScriptSDK.Enums/EventsDiscardedReason\";\r\nexport { AppInsightsCore } from \"./JavaScriptSDK/AppInsightsCore\";\r\nexport { BaseCore } from \"./JavaScriptSDK/BaseCore\";\r\nexport { BaseTelemetryPlugin } from \"./JavaScriptSDK/BaseTelemetryPlugin\";\r\nexport { randomValue, random32, mwcRandomSeed, mwcRandom32, newId } from \"./JavaScriptSDK/RandomHelper\";\r\nexport { CoreUtils, EventHelper, Undefined, newGuid, perfNow, generateW3CId, disableCookies, canUseCookies, getCookie, setCookie, deleteCookie, _legacyCookieMgr } from \"./JavaScriptSDK/CoreUtils\";\r\nexport { isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction, normalizeJsName, objForEachKey, strEndsWith, strStartsWith, isDate, isArray, isError, isString, isNumber, isBoolean, toISOString, arrForEach, arrIndexOf, arrMap, arrReduce, strTrim, objKeys, objDefineAccessors, dateNow, getExceptionName, throwError, strContains, isSymbol, setValue, getSetValue, isNotTruthy, isTruthy, proxyAssign, proxyFunctions, proxyFunctionAs, createClassFromInterface, optimizeObject, isNotUndefined, isNotNullOrUndefined, objFreeze, objSeal, createEnumStyle, objExtend } from \"./JavaScriptSDK/HelperFuncs\";\r\nexport { attachEvent, detachEvent, addEventHandler, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, removeEventHandler, removeEventListeners, removePageUnloadEventListener, removePageHideEventListener, eventOn, eventOff, mergeEvtNamespace, __getRegisteredEvents } from \"./JavaScriptSDK/EventHelpers\";\r\nexport { getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, getCrypto, getMsCrypto, hasNavigator, getNavigator, hasHistory, getHistory, getLocation, getPerformance, hasJSON, getJSON, isReactNative, getConsole, dumpObj, isIE, getIEVersion, isSafari, setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported } from \"./JavaScriptSDK/EnvUtils\";\r\nexport { getGlobal, objCreateFn as objCreate, strShimPrototype as strPrototype, strShimFunction as strFunction, strShimUndefined as strUndefined, strShimObject as strObject } from \"@microsoft/applicationinsights-shims\";\r\nexport { NotificationManager } from \"./JavaScriptSDK/NotificationManager\";\r\nexport { PerfEvent, PerfManager, doPerf, getGblPerfMgr, setGblPerfMgr } from \"./JavaScriptSDK/PerfManager\";\r\nexport { safeGetLogger, DiagnosticLogger, _InternalLogMessage } from \"./JavaScriptSDK/DiagnosticLogger\";\r\nexport { ProcessTelemetryContext, createProcessTelemetryContext\r\n// Explicitly NOT exporting createProcessTelemetryUnloadContext() and createProcessTelemetryUpdateContext() as these should only be created internally\r\n } from \"./JavaScriptSDK/ProcessTelemetryContext\";\r\nexport { initializePlugins, sortPlugins } from \"./JavaScriptSDK/TelemetryHelpers\";\r\nexport { _InternalMessageId, LoggingSeverity } from \"./JavaScriptSDK.Enums/LoggingEnums\";\r\nexport { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs } from \"./JavaScriptSDK/InstrumentHooks\";\r\nexport { createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesSupported } from \"./JavaScriptSDK/CookieMgr\";\r\nexport { strIKey, strExtensionConfig } from \"./JavaScriptSDK/Constants\";\r\nexport { getDebugListener, getDebugExt } from \"./JavaScriptSDK/DbgExtensionUtils\";\r\nexport { createUniqueNamespace } from \"./JavaScriptSDK/DataCacheHelper\";\r\nexport { createUnloadHandlerContainer } from \"./JavaScriptSDK/UnloadHandlerContainer\";\r\n//# sourceMappingURL=applicationinsights-core-js.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/applicationinsights-core-js",
|
|
3
3
|
"author": "Microsoft Application Insights Team",
|
|
4
|
-
"version": "2.8.0-beta.2203-
|
|
4
|
+
"version": "2.8.0-beta.2203-03",
|
|
5
5
|
"description": "Microsoft Application Insights Core Javascript SDK",
|
|
6
6
|
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
7
7
|
"keywords": [
|
|
@@ -13,14 +13,14 @@ import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationM
|
|
|
13
13
|
import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
|
|
14
14
|
import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
|
|
15
15
|
import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
16
|
-
import { createProcessTelemetryContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
|
|
16
|
+
import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
|
|
17
17
|
import { initializePlugins, sortPlugins, _getPluginState } from "./TelemetryHelpers";
|
|
18
|
-
import { eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
|
|
18
|
+
import { eLoggingSeverity, _eInternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
|
|
19
19
|
import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager";
|
|
20
20
|
import { getGblPerfMgr, PerfManager } from "./PerfManager";
|
|
21
21
|
import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
|
|
22
22
|
import { createCookieMgr } from "./CookieMgr";
|
|
23
|
-
import { arrForEach, isNullOrUndefined, toISOString, getSetValue, setValue, throwError, isNotTruthy, isFunction, objFreeze, proxyFunctions } from "./HelperFuncs";
|
|
23
|
+
import { arrForEach, isNullOrUndefined, toISOString, getSetValue, setValue, throwError, isNotTruthy, isFunction, objFreeze, proxyFunctionAs, proxyFunctions } from "./HelperFuncs";
|
|
24
24
|
import { strExtensionConfig, strIKey } from "./Constants";
|
|
25
25
|
import { DiagnosticLogger, _InternalLogMessage } from "./DiagnosticLogger";
|
|
26
26
|
import { getDebugListener } from "./DbgExtensionUtils";
|
|
@@ -29,10 +29,17 @@ import { ChannelControllerPriority, createChannelControllerPlugin, createChannel
|
|
|
29
29
|
import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../JavaScriptSDK.Interfaces/ITelemetryInitializers";
|
|
30
30
|
import { TelemetryInitializerPlugin } from "./TelemetryInitializerPlugin";
|
|
31
31
|
import { createUniqueNamespace } from "./DataCacheHelper";
|
|
32
|
+
import { createUnloadHandlerContainer, IUnloadHandlerContainer, UnloadHandler } from "./UnloadHandlerContainer";
|
|
33
|
+
import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
|
|
34
|
+
import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
|
|
35
|
+
import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
|
|
32
36
|
import { strAddNotificationListener, strDisabled, strEventsDiscarded, strEventsSendRequest, strEventsSent, strRemoveNotificationListener, strTeardown } from "./InternalConstants";
|
|
33
37
|
|
|
34
38
|
const strValidationError = "Plugins must provide initialize method";
|
|
35
39
|
const strNotificationManager = "_notificationManager";
|
|
40
|
+
const strSdkUnloadingError = "SDK is still unloading...";
|
|
41
|
+
const strSdkNotInitialized = "SDK is not initialized";
|
|
42
|
+
const strPluginUnloadFailed = "Failed to unload plugin";
|
|
36
43
|
|
|
37
44
|
/**
|
|
38
45
|
* Helper to create the default performance manager
|
|
@@ -82,6 +89,19 @@ function _validateExtensions(logger: IDiagnosticLogger, channelPriority: number,
|
|
|
82
89
|
};
|
|
83
90
|
}
|
|
84
91
|
|
|
92
|
+
function _isPluginPresent(thePlugin: IPlugin, plugins: IPlugin[]) {
|
|
93
|
+
let exists = false;
|
|
94
|
+
|
|
95
|
+
arrForEach(plugins, (plugin) => {
|
|
96
|
+
if (plugin === thePlugin) {
|
|
97
|
+
exists = true;
|
|
98
|
+
return -1;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return exists;
|
|
103
|
+
}
|
|
104
|
+
|
|
85
105
|
function _createDummyNotificationManager(): INotificationManager {
|
|
86
106
|
return objCreateFn({
|
|
87
107
|
[strAddNotificationListener]: (listener: INotificationListener) => { },
|
|
@@ -114,9 +134,11 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
114
134
|
let _channelControl: IChannelController;
|
|
115
135
|
let _channelConfig: IChannelControls[][];
|
|
116
136
|
let _channelQueue: _IInternalChannels[];
|
|
137
|
+
let _isUnloading: boolean;
|
|
117
138
|
let _telemetryInitializerPlugin: TelemetryInitializerPlugin;
|
|
118
139
|
let _internalLogsEventName: string;
|
|
119
140
|
let _evtNamespace: string;
|
|
141
|
+
let _unloadHandlers: IUnloadHandlerContainer;
|
|
120
142
|
let _debugListener: INotificationListener;
|
|
121
143
|
|
|
122
144
|
/**
|
|
@@ -132,6 +154,10 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
132
154
|
_self.isInitialized = () => _isInitialized;
|
|
133
155
|
|
|
134
156
|
_self.initialize = (config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void => {
|
|
157
|
+
if (_isUnloading) {
|
|
158
|
+
throwError(strSdkUnloadingError);
|
|
159
|
+
}
|
|
160
|
+
|
|
135
161
|
// Make sure core is only initialized once
|
|
136
162
|
if (_self.isInitialized()) {
|
|
137
163
|
throwError("Core should not be initialized more than once");
|
|
@@ -153,8 +179,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
153
179
|
config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
|
|
154
180
|
|
|
155
181
|
// add notification to the extensions in the config so other plugins can access it
|
|
156
|
-
|
|
157
|
-
extConfig.NotificationManager = notificationManager;
|
|
182
|
+
_initExtConfig(config);
|
|
158
183
|
|
|
159
184
|
if (logger) {
|
|
160
185
|
_self.logger = logger;
|
|
@@ -194,7 +219,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
194
219
|
// Common Schema 4.0
|
|
195
220
|
setValue(telemetryItem, "ver", "4.0", null, isNullOrUndefined);
|
|
196
221
|
|
|
197
|
-
if (_self.isInitialized()) {
|
|
222
|
+
if (!_isUnloading && _self.isInitialized()) {
|
|
198
223
|
// Process the telemetry plugin chain
|
|
199
224
|
_createTelCtx().processNext(telemetryItem);
|
|
200
225
|
} else {
|
|
@@ -223,9 +248,9 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
223
248
|
* called.
|
|
224
249
|
* @param {INotificationListener} listener - An INotificationListener object.
|
|
225
250
|
*/
|
|
226
|
-
_self
|
|
251
|
+
_self[strAddNotificationListener] = (listener: INotificationListener): void => {
|
|
227
252
|
if (_notificationManager) {
|
|
228
|
-
_notificationManager
|
|
253
|
+
_notificationManager[strAddNotificationListener](listener);
|
|
229
254
|
}
|
|
230
255
|
};
|
|
231
256
|
|
|
@@ -233,9 +258,9 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
233
258
|
* Removes all instances of the listener.
|
|
234
259
|
* @param {INotificationListener} listener - INotificationListener to remove.
|
|
235
260
|
*/
|
|
236
|
-
_self
|
|
261
|
+
_self[strRemoveNotificationListener] = (listener: INotificationListener): void => {
|
|
237
262
|
if (_notificationManager) {
|
|
238
|
-
_notificationManager
|
|
263
|
+
_notificationManager[strRemoveNotificationListener](listener);
|
|
239
264
|
}
|
|
240
265
|
}
|
|
241
266
|
|
|
@@ -314,12 +339,103 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
314
339
|
// Add addTelemetryInitializer
|
|
315
340
|
proxyFunctions(_self, () => _telemetryInitializerPlugin, [ "addTelemetryInitializer" ]);
|
|
316
341
|
|
|
342
|
+
_self.unload = (isAsync: boolean = true, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void => {
|
|
343
|
+
if (!_isInitialized) {
|
|
344
|
+
// The SDK is not initialized
|
|
345
|
+
throwError(strSdkNotInitialized);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Check if the SDK still unloading so throw
|
|
349
|
+
if (_isUnloading) {
|
|
350
|
+
// The SDK is already unloading
|
|
351
|
+
throwError(strSdkUnloadingError);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
let unloadState: ITelemetryUnloadState = {
|
|
355
|
+
reason: TelemetryUnloadReason.SdkUnload,
|
|
356
|
+
isAsync: isAsync,
|
|
357
|
+
flushComplete: false
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
let processUnloadCtx = createProcessTelemetryUnloadContext(_getPluginChain(), _self.config, _self);
|
|
361
|
+
processUnloadCtx.onComplete(() => {
|
|
362
|
+
_initDefaults();
|
|
363
|
+
unloadComplete && unloadComplete(unloadState);
|
|
364
|
+
}, _self);
|
|
365
|
+
|
|
366
|
+
function _doUnload(flushComplete: boolean) {
|
|
367
|
+
unloadState.flushComplete = flushComplete;
|
|
368
|
+
_isUnloading = true;
|
|
369
|
+
|
|
370
|
+
// Run all of the unload handlers first (before unloading the plugins)
|
|
371
|
+
_unloadHandlers.run(processUnloadCtx, unloadState);
|
|
372
|
+
|
|
373
|
+
// Stop polling the internal logs
|
|
374
|
+
_self.stopPollingInternalLogs();
|
|
375
|
+
|
|
376
|
+
// Start unloading the components, from this point onwards the SDK should be considered to be in an unstable state
|
|
377
|
+
processUnloadCtx.processNext(unloadState);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (_channelControl) {
|
|
381
|
+
_channelControl.flush(isAsync, _doUnload, SendRequestReason.SdkUnload, cbTimeout);
|
|
382
|
+
} else {
|
|
383
|
+
_doUnload(true);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
|
|
317
387
|
_self.getPlugin = _getPlugin;
|
|
318
388
|
|
|
389
|
+
_self.addPlugin = <T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, isAsync: boolean = true, addCb?: (added?: boolean) => void): void => {
|
|
390
|
+
if (!plugin) {
|
|
391
|
+
addCb && addCb(false);
|
|
392
|
+
_logOrThrowError(strValidationError);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
let existingPlugin = _getPlugin(plugin.identifier);
|
|
397
|
+
if (existingPlugin && !replaceExisting) {
|
|
398
|
+
addCb && addCb(false);
|
|
399
|
+
|
|
400
|
+
_logOrThrowError("Plugin [" + plugin.identifier + "] is already loaded!");
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function _addPlugin(removed: boolean) {
|
|
405
|
+
_configExtensions.push(plugin);
|
|
406
|
+
|
|
407
|
+
// Re-Initialize the plugin chain
|
|
408
|
+
_initPluginChain(_self.config);
|
|
409
|
+
addCb && addCb(true);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (existingPlugin) {
|
|
413
|
+
let removedPlugins: IPlugin[] = [existingPlugin.plugin];
|
|
414
|
+
let unloadState: ITelemetryUnloadState = {
|
|
415
|
+
reason: TelemetryUnloadReason.PluginReplace,
|
|
416
|
+
isAsync: isAsync
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
_removePlugins(removedPlugins, unloadState, (removed) => {
|
|
420
|
+
if (!removed) {
|
|
421
|
+
// Previous plugin was successfully removed or was not installed
|
|
422
|
+
addCb && addCb(false);
|
|
423
|
+
} else {
|
|
424
|
+
_addPlugin(true);
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
} else {
|
|
428
|
+
_addPlugin(false);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
|
|
319
432
|
_self.evtNamespace = (): string => {
|
|
320
433
|
return _evtNamespace;
|
|
321
434
|
};
|
|
322
435
|
|
|
436
|
+
// Create the addUnloadCb
|
|
437
|
+
proxyFunctionAs(_self, "addUnloadCb", () => _unloadHandlers, "add");
|
|
438
|
+
|
|
323
439
|
function _initDefaults() {
|
|
324
440
|
_isInitialized = false;
|
|
325
441
|
|
|
@@ -340,8 +456,10 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
340
456
|
_channelControl = null;
|
|
341
457
|
_channelConfig = null;
|
|
342
458
|
_channelQueue = null;
|
|
459
|
+
_isUnloading = false;
|
|
343
460
|
_internalLogsEventName = null;
|
|
344
461
|
_evtNamespace = createUniqueNamespace("AIBaseCore", true);
|
|
462
|
+
_unloadHandlers = createUnloadHandlerContainer();
|
|
345
463
|
}
|
|
346
464
|
|
|
347
465
|
function _createTelCtx(): IProcessTelemetryContext {
|
|
@@ -422,6 +540,22 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
422
540
|
isEnabled: () => {
|
|
423
541
|
let pluginState = _getPluginState(thePlugin);
|
|
424
542
|
return !pluginState[strTeardown] && !pluginState[strDisabled];
|
|
543
|
+
},
|
|
544
|
+
remove: (isAsync: boolean = true, removeCb?: (removed?: boolean) => void): void => {
|
|
545
|
+
let pluginsToRemove: IPlugin[] = [thePlugin];
|
|
546
|
+
let unloadState: ITelemetryUnloadState = {
|
|
547
|
+
reason: TelemetryUnloadReason.PluginUnload,
|
|
548
|
+
isAsync: isAsync
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
_removePlugins(pluginsToRemove, unloadState, (removed) => {
|
|
552
|
+
if (removed) {
|
|
553
|
+
// Re-Initialize the plugin chain
|
|
554
|
+
_initPluginChain(_self.config);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
removeCb && removeCb(removed);
|
|
558
|
+
});
|
|
425
559
|
}
|
|
426
560
|
}
|
|
427
561
|
}
|
|
@@ -445,6 +579,55 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
445
579
|
return _pluginChain;
|
|
446
580
|
}
|
|
447
581
|
|
|
582
|
+
function _removePlugins(thePlugins: IPlugin[], unloadState: ITelemetryUnloadState, removeComplete: (removed: boolean) => void) {
|
|
583
|
+
|
|
584
|
+
if (thePlugins && thePlugins.length > 0) {
|
|
585
|
+
let unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);
|
|
586
|
+
let unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self.config, _self);
|
|
587
|
+
|
|
588
|
+
unloadCtx.onComplete(() => {
|
|
589
|
+
let removed = false;
|
|
590
|
+
|
|
591
|
+
// Remove the listed config extensions
|
|
592
|
+
let newConfigExtensions: IPlugin[] = [];
|
|
593
|
+
arrForEach(_configExtensions, (plugin, idx) => {
|
|
594
|
+
if (!_isPluginPresent(plugin, thePlugins)) {
|
|
595
|
+
newConfigExtensions.push(plugin);
|
|
596
|
+
} else {
|
|
597
|
+
removed = true;
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
_configExtensions = newConfigExtensions;
|
|
602
|
+
|
|
603
|
+
// Re-Create the channel config
|
|
604
|
+
let newChannelConfig: IChannelControls[][] = [];
|
|
605
|
+
if (_channelConfig) {
|
|
606
|
+
arrForEach(_channelConfig, (queue, idx) => {
|
|
607
|
+
let newQueue: IChannelControls[] = [];
|
|
608
|
+
arrForEach(queue, (channel) => {
|
|
609
|
+
if (!_isPluginPresent(channel, thePlugins)) {
|
|
610
|
+
newQueue.push(channel);
|
|
611
|
+
} else {
|
|
612
|
+
removed = true;
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
newChannelConfig.push(newQueue);
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
_channelConfig = newChannelConfig;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
removeComplete && removeComplete(removed);
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
unloadCtx.processNext(unloadState);
|
|
626
|
+
} else {
|
|
627
|
+
removeComplete(false);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
448
631
|
function _flushInternalLogs() {
|
|
449
632
|
let queue: _InternalLogMessage[] = _self.logger ? _self.logger.queue : [];
|
|
450
633
|
if (queue) {
|
|
@@ -488,6 +671,21 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
488
671
|
setValue(_self.config, "createPerfMgr", _createPerfManager);
|
|
489
672
|
}
|
|
490
673
|
}
|
|
674
|
+
|
|
675
|
+
function _initExtConfig(config: IConfiguration) {
|
|
676
|
+
let extConfig = getSetValue(config, strExtensionConfig);
|
|
677
|
+
extConfig.NotificationManager = _notificationManager;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function _logOrThrowError(message: string) {
|
|
681
|
+
let logger = _self.logger;
|
|
682
|
+
if (logger) {
|
|
683
|
+
// there should always be a logger
|
|
684
|
+
logger.throwInternal(eLoggingSeverity.WARNING, _eInternalMessageId.PluginException, message);
|
|
685
|
+
} else {
|
|
686
|
+
throwError(message);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
491
689
|
});
|
|
492
690
|
}
|
|
493
691
|
|
|
@@ -586,11 +784,28 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
586
784
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
587
785
|
}
|
|
588
786
|
|
|
787
|
+
/**
|
|
788
|
+
* Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
|
|
789
|
+
* to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
|
|
790
|
+
* unload call return `true` stating that all plugins reported that they also unloaded, the recommended
|
|
791
|
+
* approach is to create a new instance and initialize that instance.
|
|
792
|
+
* This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
|
|
793
|
+
* to successfully remove any global references or they may just be completing the unload process asynchronously.
|
|
794
|
+
*/
|
|
795
|
+
public unload(isAsync?: boolean, unloadComplete?: () => void): void {
|
|
796
|
+
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
|
|
589
800
|
public getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T> {
|
|
590
801
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
591
802
|
return null;
|
|
592
803
|
}
|
|
593
804
|
|
|
805
|
+
public addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void {
|
|
806
|
+
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
807
|
+
}
|
|
808
|
+
|
|
594
809
|
/**
|
|
595
810
|
* Returns the unique event namespace that should be used
|
|
596
811
|
*/
|
|
@@ -599,6 +814,14 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
599
814
|
return null;
|
|
600
815
|
}
|
|
601
816
|
|
|
817
|
+
/**
|
|
818
|
+
* Add an unload handler that will be called when the SDK is being unloaded
|
|
819
|
+
* @param handler - the handler
|
|
820
|
+
*/
|
|
821
|
+
public addUnloadCb(handler: UnloadHandler): void {
|
|
822
|
+
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
823
|
+
}
|
|
824
|
+
|
|
602
825
|
protected releaseQueue() {
|
|
603
826
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
604
827
|
}
|