@microsoft/applicationinsights-core-js 2.8.0-beta.2203-03 → 2.8.0-beta.2203-06
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 +129 -26
- 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 +1667 -177
- package/dist/applicationinsights-core-js.api.md +62 -8
- package/dist/applicationinsights-core-js.d.ts +121 -7
- package/dist/applicationinsights-core-js.js +129 -26
- 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 +124 -10
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +29 -10
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +30 -2
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +14 -2
- package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +3 -2
- package/dist-esm/JavaScriptSDK/CookieMgr.js.map +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 +14 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/EventHelpers.js +18 -13
- package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +2 -12
- 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 +56 -5
- 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 +3 -2
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +3 -2
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +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 +8 -0
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +1 -0
- 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/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +8 -0
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +1 -0
- package/dist-esm/applicationinsights-core-js.js +2 -2
- package/dist-esm/applicationinsights-core-js.js.map +1 -1
- package/package.json +1 -1
- package/src/JavaScriptSDK/BaseCore.ts +44 -9
- package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +54 -2
- package/src/JavaScriptSDK/ChannelController.ts +18 -1
- package/src/JavaScriptSDK/CookieMgr.ts +3 -1
- package/src/JavaScriptSDK/DiagnosticLogger.ts +14 -0
- package/src/JavaScriptSDK/EventHelpers.ts +18 -12
- package/src/JavaScriptSDK/HelperFuncs.ts +3 -1
- package/src/JavaScriptSDK/ProcessTelemetryContext.ts +71 -8
- package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +3 -1
- package/src/JavaScriptSDK/UnloadHandlerContainer.ts +3 -1
- package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +27 -0
- package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +11 -6
- package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +25 -2
- package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +12 -1
- package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +34 -0
- package/types/JavaScriptSDK/BaseCore.d.ts +11 -2
- package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +17 -1
- package/types/JavaScriptSDK/DiagnosticLogger.d.ts +10 -0
- package/types/JavaScriptSDK/EventHelpers.d.ts +4 -2
- package/types/JavaScriptSDK/HelperFuncs.d.ts +2 -1
- package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +9 -1
- package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +20 -0
- package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +5 -0
- package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +23 -2
- package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +11 -1
- package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +22 -0
- package/types/applicationinsights-core-js.d.ts +5 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft Application Insights Core Javascript SDK, 2.8.0-beta.2203-
|
|
2
|
+
* Microsoft Application Insights Core Javascript SDK, 2.8.0-beta.2203-06
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -24,9 +24,11 @@ import { strShimUndefined as strUndefined } from '@microsoft/applicationinsights
|
|
|
24
24
|
* Get all of the registered events on the target object, this is primarily used for testing cleanup but may also be used by
|
|
25
25
|
* applications to remove their own events
|
|
26
26
|
* @param target - The EventTarget that has registered events
|
|
27
|
-
* @param
|
|
27
|
+
* @param eventName - [Optional] The name of the event to return the registered handlers and full name (with namespaces)
|
|
28
|
+
* @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
|
|
29
|
+
* if the eventName also includes a namespace the namespace(s) are merged into a single namespace
|
|
28
30
|
*/
|
|
29
|
-
export declare function __getRegisteredEvents(target: any,
|
|
31
|
+
export declare function __getRegisteredEvents(target: any, eventName?: string, evtNamespace?: string | string[]): _IRegisteredEvents[];
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* Trys to add an event handler for the specified event to the window, body and document
|
|
@@ -203,7 +205,7 @@ export declare class BaseCore implements IAppInsightsCore {
|
|
|
203
205
|
* This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
|
|
204
206
|
* to successfully remove any global references or they may just be completing the unload process asynchronously.
|
|
205
207
|
*/
|
|
206
|
-
unload(isAsync?: boolean, unloadComplete?: () => void): void;
|
|
208
|
+
unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
|
|
207
209
|
getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
|
|
208
210
|
addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
|
|
209
211
|
/**
|
|
@@ -216,6 +218,13 @@ export declare class BaseCore implements IAppInsightsCore {
|
|
|
216
218
|
*/
|
|
217
219
|
addUnloadCb(handler: UnloadHandler): void;
|
|
218
220
|
protected releaseQueue(): void;
|
|
221
|
+
/**
|
|
222
|
+
* Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
|
|
223
|
+
* @param updateCtx - The plugin update context
|
|
224
|
+
* @param updateState - The Update State
|
|
225
|
+
* @returns boolean - True means the extension class will call updateState otherwise the Core will
|
|
226
|
+
*/
|
|
227
|
+
protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
|
|
219
228
|
}
|
|
220
229
|
|
|
221
230
|
/**
|
|
@@ -272,6 +281,14 @@ export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
272
281
|
* @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
|
|
273
282
|
*/
|
|
274
283
|
protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
|
|
286
|
+
* @param updateCtx - This is the context that should be used during updating.
|
|
287
|
+
* @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
|
|
288
|
+
* @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async update operations.
|
|
289
|
+
* @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
|
|
290
|
+
*/
|
|
291
|
+
protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
|
|
275
292
|
constructor();
|
|
276
293
|
initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
277
294
|
/**
|
|
@@ -284,6 +301,13 @@ export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
|
|
|
284
301
|
*/
|
|
285
302
|
teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
|
|
286
303
|
abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
304
|
+
/**
|
|
305
|
+
* The the plugin should re-evaluate configuration and update any cached configuration settings.
|
|
306
|
+
* @param updateCtx - This is the context that should be used during updating.
|
|
307
|
+
* @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
|
|
308
|
+
* @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
|
|
309
|
+
*/
|
|
310
|
+
update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
|
|
287
311
|
/**
|
|
288
312
|
* Add an unload handler that will be called when the SDK is being unloaded
|
|
289
313
|
* @param handler - the handler
|
|
@@ -845,7 +869,7 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
|
|
|
845
869
|
addUnloadCb(handler: UnloadHandler): void;
|
|
846
870
|
}
|
|
847
871
|
|
|
848
|
-
declare interface IBaseProcessingContext {
|
|
872
|
+
export declare interface IBaseProcessingContext {
|
|
849
873
|
/**
|
|
850
874
|
* The current core instance for the request
|
|
851
875
|
*/
|
|
@@ -1510,6 +1534,11 @@ export declare interface IInstrumentHooks {
|
|
|
1510
1534
|
* You must always supply the error callback
|
|
1511
1535
|
*/
|
|
1512
1536
|
export declare interface IInstrumentHooksCallbacks {
|
|
1537
|
+
/**
|
|
1538
|
+
* [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
|
|
1539
|
+
* identify the source of the instrumented hooks
|
|
1540
|
+
*/
|
|
1541
|
+
ns?: string | string[];
|
|
1513
1542
|
/**
|
|
1514
1543
|
* The hook callback to call before the original function is called
|
|
1515
1544
|
*/
|
|
@@ -1924,10 +1953,10 @@ export declare interface IProcessTelemetryContext extends IBaseProcessingContext
|
|
|
1924
1953
|
}
|
|
1925
1954
|
|
|
1926
1955
|
/**
|
|
1927
|
-
* The current context for the current call to
|
|
1928
|
-
*
|
|
1956
|
+
* The current context for the current call to teardown() implementations, used to support when plugins are being removed
|
|
1957
|
+
* or the SDK is being unloaded.
|
|
1929
1958
|
*/
|
|
1930
|
-
declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
|
|
1959
|
+
export declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
|
|
1931
1960
|
/**
|
|
1932
1961
|
* This Plugin has finished unloading, so unload the next one
|
|
1933
1962
|
* @param uploadState - The state of the unload process
|
|
@@ -1944,6 +1973,27 @@ declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext
|
|
|
1944
1973
|
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
|
|
1945
1974
|
}
|
|
1946
1975
|
|
|
1976
|
+
/**
|
|
1977
|
+
* The current context for the current call to the plugin update() implementations, used to support the notifications
|
|
1978
|
+
* for when plugins are added, removed or the configuration was changed.
|
|
1979
|
+
*/
|
|
1980
|
+
export declare interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
|
|
1981
|
+
/**
|
|
1982
|
+
* This Plugin has finished unloading, so unload the next one
|
|
1983
|
+
* @param updateState - The update State
|
|
1984
|
+
* @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
|
|
1985
|
+
*/
|
|
1986
|
+
processNext: (updateState: ITelemetryUpdateState) => boolean | void;
|
|
1987
|
+
/**
|
|
1988
|
+
* Create a new context using the core and config from the current instance, returns a new instance of the same type
|
|
1989
|
+
* @param plugins - The execution order to process the plugins, if null or not supplied
|
|
1990
|
+
* then the current execution order will be copied.
|
|
1991
|
+
* @param startAt - The plugin to start processing from, if missing from the execution
|
|
1992
|
+
* order then the next plugin will be NOT set.
|
|
1993
|
+
*/
|
|
1994
|
+
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1947
1997
|
export declare interface _IRegisteredEvents {
|
|
1948
1998
|
name: string;
|
|
1949
1999
|
handler: any;
|
|
@@ -2148,6 +2198,15 @@ declare interface ITelemetryProcessor {
|
|
|
2148
2198
|
* to later plugins (vs appending items to the telemetry item)
|
|
2149
2199
|
*/
|
|
2150
2200
|
processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
|
|
2201
|
+
/**
|
|
2202
|
+
* The the plugin should re-evaluate configuration and update any cached configuration settings or
|
|
2203
|
+
* plugins. If implemented this method will be called whenever a plugin is added or removed and if
|
|
2204
|
+
* the configuration has bee updated.
|
|
2205
|
+
* @param updateCtx - This is the context that should be used during updating.
|
|
2206
|
+
* @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
|
|
2207
|
+
* @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
|
|
2208
|
+
*/
|
|
2209
|
+
update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
|
|
2151
2210
|
}
|
|
2152
2211
|
|
|
2153
2212
|
export declare interface ITelemetryUnloadState {
|
|
@@ -2156,6 +2215,27 @@ export declare interface ITelemetryUnloadState {
|
|
|
2156
2215
|
flushComplete?: boolean;
|
|
2157
2216
|
}
|
|
2158
2217
|
|
|
2218
|
+
export declare interface ITelemetryUpdateState {
|
|
2219
|
+
/**
|
|
2220
|
+
* Identifies the reason for the update notification, this is a bitwise numeric value
|
|
2221
|
+
*/
|
|
2222
|
+
reason: TelemetryUpdateReason;
|
|
2223
|
+
/**
|
|
2224
|
+
* If this is a configuration update this was the previous configuration that was used
|
|
2225
|
+
*/
|
|
2226
|
+
/**
|
|
2227
|
+
* If this is a configuration update is the new configuration that is being used
|
|
2228
|
+
*/
|
|
2229
|
+
/**
|
|
2230
|
+
* This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
|
|
2231
|
+
*/
|
|
2232
|
+
added?: IPlugin[];
|
|
2233
|
+
/**
|
|
2234
|
+
* This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
|
|
2235
|
+
*/
|
|
2236
|
+
removed?: IPlugin[];
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2159
2239
|
export declare interface IUnloadHandlerContainer {
|
|
2160
2240
|
add: (handler: UnloadHandler) => void;
|
|
2161
2241
|
run: (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
|
|
@@ -2282,7 +2362,9 @@ export declare function objDefineAccessors<T>(target: any, prop: string, getProp
|
|
|
2282
2362
|
* @param obj5 - object to merge.
|
|
2283
2363
|
* @returns The extended first object.
|
|
2284
2364
|
*/
|
|
2285
|
-
export declare function objExtend<
|
|
2365
|
+
export declare function objExtend<T2, T3, T4, T5, T6>(deepExtend?: boolean, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T2 & T3 & T4 & T5 & T6;
|
|
2366
|
+
|
|
2367
|
+
export declare function objExtend<T1, T2, T3, T4, T5, T6>(obj1?: T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6;
|
|
2286
2368
|
|
|
2287
2369
|
/**
|
|
2288
2370
|
* This is a helper function for the equivalent of arForEach(objKeys(target), callbackFn), this is a
|
|
@@ -2676,7 +2758,7 @@ export declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(it
|
|
|
2676
2758
|
/**
|
|
2677
2759
|
* The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
|
|
2678
2760
|
*/
|
|
2679
|
-
declare const enum TelemetryUnloadReason {
|
|
2761
|
+
export declare const enum TelemetryUnloadReason {
|
|
2680
2762
|
/**
|
|
2681
2763
|
* Teardown has been called without any context.
|
|
2682
2764
|
*/
|
|
@@ -2695,8 +2777,40 @@ declare const enum TelemetryUnloadReason {
|
|
|
2695
2777
|
SdkUnload = 50
|
|
2696
2778
|
}
|
|
2697
2779
|
|
|
2780
|
+
/**
|
|
2781
|
+
* The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
|
|
2782
|
+
*/
|
|
2783
|
+
export declare const enum TelemetryUpdateReason {
|
|
2784
|
+
/**
|
|
2785
|
+
* Unknown.
|
|
2786
|
+
*/
|
|
2787
|
+
Unknown = 0,
|
|
2788
|
+
/**
|
|
2789
|
+
* The configuration has ben updated or changed
|
|
2790
|
+
*/
|
|
2791
|
+
/**
|
|
2792
|
+
* One or more plugins have been added
|
|
2793
|
+
*/
|
|
2794
|
+
PluginAdded = 16,
|
|
2795
|
+
/**
|
|
2796
|
+
* One or more plugins have been removed
|
|
2797
|
+
*/
|
|
2798
|
+
PluginRemoved = 32
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2698
2801
|
export declare function throwError(message: string): never;
|
|
2699
2802
|
|
|
2803
|
+
/**
|
|
2804
|
+
* This is a helper method which will call throwInternal on the passed logger, will throw exceptions in
|
|
2805
|
+
* debug mode or attempt to log the error as a console warning. This helper is provided mostly to better
|
|
2806
|
+
* support minification as logger.throwInternal() will not compress the publish "throwInternal" used throughout
|
|
2807
|
+
* the code.
|
|
2808
|
+
* @param logger - The Diagnostic Logger instance to use.
|
|
2809
|
+
* @param severity {LoggingSeverity} - The severity of the log message
|
|
2810
|
+
* @param message {_InternalLogMessage} - The log message.
|
|
2811
|
+
*/
|
|
2812
|
+
export declare function _throwInternal(logger: IDiagnosticLogger, severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
|
|
2813
|
+
|
|
2700
2814
|
/**
|
|
2701
2815
|
* Convert a date to I.S.O. format in IE8
|
|
2702
2816
|
*/
|
|
@@ -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-06
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
@@ -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-06
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
import { __spreadArrayFn as __spreadArray } from "@microsoft/applicationinsights-shims";
|
|
9
9
|
import { objCreateFn } from "@microsoft/applicationinsights-shims";
|
|
10
10
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
11
|
-
import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
|
|
11
|
+
import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
|
|
12
12
|
import { initializePlugins, sortPlugins, _getPluginState } from "./TelemetryHelpers";
|
|
13
13
|
import { getGblPerfMgr, PerfManager } from "./PerfManager";
|
|
14
14
|
import { createCookieMgr } from "./CookieMgr";
|
|
15
15
|
import { arrForEach, isNullOrUndefined, toISOString, getSetValue, setValue, throwError, isNotTruthy, isFunction, objFreeze, proxyFunctionAs, proxyFunctions } from "./HelperFuncs";
|
|
16
16
|
import { strExtensionConfig, strIKey } from "./Constants";
|
|
17
|
-
import { DiagnosticLogger, _InternalLogMessage } from "./DiagnosticLogger";
|
|
17
|
+
import { DiagnosticLogger, _InternalLogMessage, _throwInternal } from "./DiagnosticLogger";
|
|
18
18
|
import { getDebugListener } from "./DbgExtensionUtils";
|
|
19
19
|
import { ChannelControllerPriority, createChannelControllerPlugin, createChannelQueues } from "./ChannelController";
|
|
20
20
|
import { TelemetryInitializerPlugin } from "./TelemetryInitializerPlugin";
|
|
@@ -143,7 +143,7 @@ var BaseCore = /** @class */ (function () {
|
|
|
143
143
|
_configExtensions = [];
|
|
144
144
|
_configExtensions.push.apply(_configExtensions, __spreadArray(__spreadArray([], extensions, false), config.extensions, false));
|
|
145
145
|
_channelConfig = (config || {}).channels;
|
|
146
|
-
_initPluginChain(config);
|
|
146
|
+
_initPluginChain(config, null);
|
|
147
147
|
if (_self.getTransmissionControls().length === 0) {
|
|
148
148
|
throwError("No channels available");
|
|
149
149
|
}
|
|
@@ -316,24 +316,30 @@ var BaseCore = /** @class */ (function () {
|
|
|
316
316
|
_logOrThrowError("Plugin [" + plugin.identifier + "] is already loaded!");
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
|
+
var updateState = {
|
|
320
|
+
reason: 16 /* PluginAdded */
|
|
321
|
+
};
|
|
319
322
|
function _addPlugin(removed) {
|
|
320
323
|
_configExtensions.push(plugin);
|
|
324
|
+
updateState.added = [plugin];
|
|
321
325
|
// Re-Initialize the plugin chain
|
|
322
|
-
_initPluginChain(_self.config);
|
|
326
|
+
_initPluginChain(_self.config, updateState);
|
|
323
327
|
addCb && addCb(true);
|
|
324
328
|
}
|
|
325
329
|
if (existingPlugin) {
|
|
326
|
-
var
|
|
330
|
+
var removedPlugins_1 = [existingPlugin.plugin];
|
|
327
331
|
var unloadState = {
|
|
328
332
|
reason: 2 /* PluginReplace */,
|
|
329
333
|
isAsync: isAsync
|
|
330
334
|
};
|
|
331
|
-
_removePlugins(
|
|
335
|
+
_removePlugins(removedPlugins_1, unloadState, function (removed) {
|
|
332
336
|
if (!removed) {
|
|
333
337
|
// Previous plugin was successfully removed or was not installed
|
|
334
338
|
addCb && addCb(false);
|
|
335
339
|
}
|
|
336
340
|
else {
|
|
341
|
+
updateState.removed = removedPlugins_1;
|
|
342
|
+
updateState.reason |= 32 /* PluginRemoved */;
|
|
337
343
|
_addPlugin(true);
|
|
338
344
|
}
|
|
339
345
|
});
|
|
@@ -374,7 +380,7 @@ var BaseCore = /** @class */ (function () {
|
|
|
374
380
|
return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
|
|
375
381
|
}
|
|
376
382
|
// Initialize or Re-initialize the plugins
|
|
377
|
-
function _initPluginChain(config) {
|
|
383
|
+
function _initPluginChain(config, updateState) {
|
|
378
384
|
// Extension validation
|
|
379
385
|
var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
|
|
380
386
|
_coreExtensions = theExtensions.core;
|
|
@@ -411,6 +417,9 @@ var BaseCore = /** @class */ (function () {
|
|
|
411
417
|
initializePlugins(_createTelCtx(), allExtensions);
|
|
412
418
|
// Now reset the extensions to just those being managed by Basecore
|
|
413
419
|
_self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
|
|
420
|
+
if (updateState) {
|
|
421
|
+
_doUpdate(updateState);
|
|
422
|
+
}
|
|
414
423
|
}
|
|
415
424
|
function _getPlugin(pluginIdentifier) {
|
|
416
425
|
var theExt = null;
|
|
@@ -445,7 +454,10 @@ var BaseCore = /** @class */ (function () {
|
|
|
445
454
|
_removePlugins(pluginsToRemove, unloadState, function (removed) {
|
|
446
455
|
if (removed) {
|
|
447
456
|
// Re-Initialize the plugin chain
|
|
448
|
-
_initPluginChain(_self.config
|
|
457
|
+
_initPluginChain(_self.config, {
|
|
458
|
+
reason: 32 /* PluginRemoved */,
|
|
459
|
+
removed: pluginsToRemove
|
|
460
|
+
});
|
|
449
461
|
}
|
|
450
462
|
removeCb && removeCb(removed);
|
|
451
463
|
});
|
|
@@ -549,11 +561,17 @@ var BaseCore = /** @class */ (function () {
|
|
|
549
561
|
var extConfig = getSetValue(config, strExtensionConfig);
|
|
550
562
|
extConfig.NotificationManager = _notificationManager;
|
|
551
563
|
}
|
|
564
|
+
function _doUpdate(updateState) {
|
|
565
|
+
var updateCtx = createProcessTelemetryUpdateContext(_getPluginChain(), _self.config, _self);
|
|
566
|
+
if (!_self._updateHook || _self._updateHook(updateCtx, updateState) !== true) {
|
|
567
|
+
updateCtx.processNext(updateState);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
552
570
|
function _logOrThrowError(message) {
|
|
553
571
|
var logger = _self.logger;
|
|
554
572
|
if (logger) {
|
|
555
573
|
// there should always be a logger
|
|
556
|
-
logger
|
|
574
|
+
_throwInternal(logger, 2 /* WARNING */, 73 /* PluginException */, message);
|
|
557
575
|
}
|
|
558
576
|
else {
|
|
559
577
|
throwError(message);
|
|
@@ -582,6 +600,7 @@ var BaseCore = /** @class */ (function () {
|
|
|
582
600
|
// Removed Stub for BaseCore.prototype.evtNamespace.
|
|
583
601
|
// Removed Stub for BaseCore.prototype.addUnloadCb.
|
|
584
602
|
// Removed Stub for BaseCore.prototype.releaseQueue.
|
|
603
|
+
// Removed Stub for BaseCore.prototype._updateHook.
|
|
585
604
|
return BaseCore;
|
|
586
605
|
}());
|
|
587
606
|
export { BaseCore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCore.js.map","sources":["BaseCore.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\"use strict\";\r\nimport { __spreadArray } from \"tslib\";\r\nimport { objCreateFn } from \"@microsoft/applicationinsights-shims\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createTelemetryProxyChain } from \"./ProcessTelemetryContext\";\r\nimport { initializePlugins, sortPlugins, _getPluginState } from \"./TelemetryHelpers\";\r\nimport { getGblPerfMgr, PerfManager } from \"./PerfManager\";\r\nimport { createCookieMgr } from \"./CookieMgr\";\r\nimport { arrForEach, isNullOrUndefined, toISOString, getSetValue, setValue, throwError, isNotTruthy, isFunction, objFreeze, proxyFunctionAs, proxyFunctions } from \"./HelperFuncs\";\r\nimport { strExtensionConfig, strIKey } from \"./Constants\";\r\nimport { DiagnosticLogger, _InternalLogMessage } from \"./DiagnosticLogger\";\r\nimport { getDebugListener } from \"./DbgExtensionUtils\";\r\nimport { ChannelControllerPriority, createChannelControllerPlugin, createChannelQueues } from \"./ChannelController\";\r\nimport { TelemetryInitializerPlugin } from \"./TelemetryInitializerPlugin\";\r\nimport { createUniqueNamespace } from \"./DataCacheHelper\";\r\nimport { createUnloadHandlerContainer } from \"./UnloadHandlerContainer\";\r\nimport { strAddNotificationListener, strDisabled, strEventsDiscarded, strEventsSendRequest, strEventsSent, strRemoveNotificationListener, strTeardown } from \"./InternalConstants\";\r\nvar strValidationError = \"Plugins must provide initialize method\";\r\nvar strNotificationManager = \"_notificationManager\";\r\nvar strSdkUnloadingError = \"SDK is still unloading...\";\r\nvar strSdkNotInitialized = \"SDK is not initialized\";\r\nvar strPluginUnloadFailed = \"Failed to unload plugin\";\r\n/**\r\n * Helper to create the default performance manager\r\n * @param core\r\n * @param notificationMgr\r\n */\r\nfunction _createPerfManager(core, notificationMgr) {\r\n return new PerfManager(notificationMgr);\r\n}\r\nfunction _validateExtensions(logger, channelPriority, allExtensions) {\r\n // Concat all available extensions\r\n var coreExtensions = [];\r\n // Check if any two extensions have the same priority, then warn to console\r\n // And extract the local extensions from the\r\n var extPriorities = {};\r\n // Extension validation\r\n arrForEach(allExtensions, function (ext) {\r\n if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {\r\n throwError(strValidationError);\r\n }\r\n var extPriority = ext.priority;\r\n var identifier = ext.identifier;\r\n if (ext && extPriority) {\r\n if (!isNullOrUndefined(extPriorities[extPriority])) {\r\n logger.warnToConsole(\"Two extensions have same priority #\" + extPriority + \" - \" + extPriorities[extPriority] + \", \" + identifier);\r\n }\r\n else {\r\n // set a value\r\n extPriorities[extPriority] = identifier;\r\n }\r\n }\r\n // Split extensions to core and channelController\r\n if (!extPriority || extPriority < channelPriority) {\r\n // Add to core extension that will be managed by BaseCore\r\n coreExtensions.push(ext);\r\n }\r\n });\r\n return {\r\n all: allExtensions,\r\n core: coreExtensions\r\n };\r\n}\r\nfunction _isPluginPresent(thePlugin, plugins) {\r\n var exists = false;\r\n arrForEach(plugins, function (plugin) {\r\n if (plugin === thePlugin) {\r\n exists = true;\r\n return -1;\r\n }\r\n });\r\n return exists;\r\n}\r\nfunction _createDummyNotificationManager() {\r\n var _a;\r\n return objCreateFn((_a = {},\r\n _a[strAddNotificationListener] = function (listener) { },\r\n _a[strRemoveNotificationListener] = function (listener) { },\r\n _a[strEventsSent] = function (events) { },\r\n _a[strEventsDiscarded] = function (events, reason) { },\r\n _a[strEventsSendRequest] = function (sendReason, isAsync) { },\r\n _a));\r\n}\r\nvar BaseCore = /** @class */ (function () {\r\n function BaseCore() {\r\n // NOTE!: DON'T set default values here, instead set them in the _initDefaults() function as it is also called during teardown()\r\n var _isInitialized;\r\n var _eventQueue;\r\n var _notificationManager;\r\n var _perfManager;\r\n var _cfgPerfManager;\r\n var _cookieManager;\r\n var _pluginChain;\r\n var _configExtensions;\r\n var _coreExtensions;\r\n var _channelControl;\r\n var _channelConfig;\r\n var _channelQueue;\r\n var _isUnloading;\r\n var _telemetryInitializerPlugin;\r\n var _internalLogsEventName;\r\n var _evtNamespace;\r\n var _unloadHandlers;\r\n var _debugListener;\r\n /**\r\n * Internal log poller\r\n */\r\n var _internalLogPoller = 0;\r\n dynamicProto(BaseCore, this, function (_self) {\r\n // Set the default values (also called during teardown)\r\n _initDefaults();\r\n _self.isInitialized = function () { return _isInitialized; };\r\n _self.initialize = function (config, extensions, logger, notificationManager) {\r\n if (_isUnloading) {\r\n throwError(strSdkUnloadingError);\r\n }\r\n // Make sure core is only initialized once\r\n if (_self.isInitialized()) {\r\n throwError(\"Core should not be initialized more than once\");\r\n }\r\n if (!config || isNullOrUndefined(config.instrumentationKey)) {\r\n throwError(\"Please provide instrumentation key\");\r\n }\r\n _notificationManager = notificationManager;\r\n // For backward compatibility only\r\n _self[strNotificationManager] = notificationManager;\r\n _self.config = config || {};\r\n _initDebugListener(config);\r\n _initPerfManager(config);\r\n config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;\r\n // add notification to the extensions in the config so other plugins can access it\r\n _initExtConfig(config);\r\n if (logger) {\r\n _self.logger = logger;\r\n }\r\n // Extension validation\r\n _configExtensions = [];\r\n _configExtensions.push.apply(_configExtensions, __spreadArray(__spreadArray([], extensions, false), config.extensions, false));\r\n _channelConfig = (config || {}).channels;\r\n _initPluginChain(config);\r\n if (_self.getTransmissionControls().length === 0) {\r\n throwError(\"No channels available\");\r\n }\r\n _isInitialized = true;\r\n _self.releaseQueue();\r\n };\r\n _self.getTransmissionControls = function () {\r\n var controls = [];\r\n arrForEach(_channelQueue, function (channels) {\r\n controls.push(channels.queue);\r\n });\r\n return objFreeze(controls);\r\n };\r\n _self.track = function (telemetryItem) {\r\n // setup default iKey if not passed in\r\n setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);\r\n // add default timestamp if not passed in\r\n setValue(telemetryItem, \"time\", toISOString(new Date()), null, isNotTruthy);\r\n // Common Schema 4.0\r\n setValue(telemetryItem, \"ver\", \"4.0\", null, isNullOrUndefined);\r\n if (!_isUnloading && _self.isInitialized()) {\r\n // Process the telemetry plugin chain\r\n _createTelCtx().processNext(telemetryItem);\r\n }\r\n else {\r\n // Queue events until all extensions are initialized\r\n _eventQueue.push(telemetryItem);\r\n }\r\n };\r\n _self.getProcessTelContext = _createTelCtx;\r\n _self.getNotifyMgr = function () {\r\n if (!_notificationManager) {\r\n // Create Dummy notification manager\r\n _notificationManager = _createDummyNotificationManager();\r\n // For backward compatibility only\r\n _self[strNotificationManager] = _notificationManager;\r\n }\r\n return _notificationManager;\r\n };\r\n /**\r\n * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.\r\n * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be\r\n * called.\r\n * @param {INotificationListener} listener - An INotificationListener object.\r\n */\r\n _self[strAddNotificationListener] = function (listener) {\r\n if (_notificationManager) {\r\n _notificationManager[strAddNotificationListener](listener);\r\n }\r\n };\r\n /**\r\n * Removes all instances of the listener.\r\n * @param {INotificationListener} listener - INotificationListener to remove.\r\n */\r\n _self[strRemoveNotificationListener] = function (listener) {\r\n if (_notificationManager) {\r\n _notificationManager[strRemoveNotificationListener](listener);\r\n }\r\n };\r\n _self.getCookieMgr = function () {\r\n if (!_cookieManager) {\r\n _cookieManager = createCookieMgr(_self.config, _self.logger);\r\n }\r\n return _cookieManager;\r\n };\r\n _self.setCookieMgr = function (cookieMgr) {\r\n _cookieManager = cookieMgr;\r\n };\r\n _self.getPerfMgr = function () {\r\n if (!_perfManager && !_cfgPerfManager) {\r\n if (_self.config && _self.config.enablePerfMgr && isFunction(_self.config.createPerfMgr)) {\r\n _cfgPerfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());\r\n }\r\n }\r\n return _perfManager || _cfgPerfManager || getGblPerfMgr();\r\n };\r\n _self.setPerfMgr = function (perfMgr) {\r\n _perfManager = perfMgr;\r\n };\r\n _self.eventCnt = function () {\r\n return _eventQueue.length;\r\n };\r\n _self.releaseQueue = function () {\r\n if (_isInitialized && _eventQueue.length > 0) {\r\n var eventQueue = _eventQueue;\r\n _eventQueue = [];\r\n arrForEach(eventQueue, function (event) {\r\n _createTelCtx().processNext(event);\r\n });\r\n }\r\n };\r\n /**\r\n * Periodically check logger.queue for log messages to be flushed\r\n */\r\n _self.pollInternalLogs = function (eventName) {\r\n _internalLogsEventName = eventName;\r\n var interval = _self.config.diagnosticLogInterval;\r\n if (!interval || !(interval > 0)) {\r\n interval = 10000;\r\n }\r\n if (_internalLogPoller) {\r\n clearInterval(_internalLogPoller);\r\n }\r\n _internalLogPoller = setInterval(function () {\r\n _flushInternalLogs();\r\n }, interval);\r\n return _internalLogPoller;\r\n };\r\n /**\r\n * Stop polling log messages from logger.queue\r\n */\r\n _self.stopPollingInternalLogs = function () {\r\n if (_internalLogPoller) {\r\n clearInterval(_internalLogPoller);\r\n _internalLogPoller = 0;\r\n _flushInternalLogs();\r\n }\r\n };\r\n // Add addTelemetryInitializer\r\n proxyFunctions(_self, function () { return _telemetryInitializerPlugin; }, [\"addTelemetryInitializer\"]);\r\n _self.unload = function (isAsync, unloadComplete, cbTimeout) {\r\n if (isAsync === void 0) { isAsync = true; }\r\n if (!_isInitialized) {\r\n // The SDK is not initialized\r\n throwError(strSdkNotInitialized);\r\n }\r\n // Check if the SDK still unloading so throw\r\n if (_isUnloading) {\r\n // The SDK is already unloading\r\n throwError(strSdkUnloadingError);\r\n }\r\n var unloadState = {\r\n reason: 50 /* SdkUnload */,\r\n isAsync: isAsync,\r\n flushComplete: false\r\n };\r\n var processUnloadCtx = createProcessTelemetryUnloadContext(_getPluginChain(), _self.config, _self);\r\n processUnloadCtx.onComplete(function () {\r\n _initDefaults();\r\n unloadComplete && unloadComplete(unloadState);\r\n }, _self);\r\n function _doUnload(flushComplete) {\r\n unloadState.flushComplete = flushComplete;\r\n _isUnloading = true;\r\n // Run all of the unload handlers first (before unloading the plugins)\r\n _unloadHandlers.run(processUnloadCtx, unloadState);\r\n // Stop polling the internal logs\r\n _self.stopPollingInternalLogs();\r\n // Start unloading the components, from this point onwards the SDK should be considered to be in an unstable state\r\n processUnloadCtx.processNext(unloadState);\r\n }\r\n if (_channelControl) {\r\n _channelControl.flush(isAsync, _doUnload, 6 /* SdkUnload */, cbTimeout);\r\n }\r\n else {\r\n _doUnload(true);\r\n }\r\n };\r\n _self.getPlugin = _getPlugin;\r\n _self.addPlugin = function (plugin, replaceExisting, isAsync, addCb) {\r\n if (isAsync === void 0) { isAsync = true; }\r\n if (!plugin) {\r\n addCb && addCb(false);\r\n _logOrThrowError(strValidationError);\r\n return;\r\n }\r\n var existingPlugin = _getPlugin(plugin.identifier);\r\n if (existingPlugin && !replaceExisting) {\r\n addCb && addCb(false);\r\n _logOrThrowError(\"Plugin [\" + plugin.identifier + \"] is already loaded!\");\r\n return;\r\n }\r\n function _addPlugin(removed) {\r\n _configExtensions.push(plugin);\r\n // Re-Initialize the plugin chain\r\n _initPluginChain(_self.config);\r\n addCb && addCb(true);\r\n }\r\n if (existingPlugin) {\r\n var removedPlugins = [existingPlugin.plugin];\r\n var unloadState = {\r\n reason: 2 /* PluginReplace */,\r\n isAsync: isAsync\r\n };\r\n _removePlugins(removedPlugins, unloadState, function (removed) {\r\n if (!removed) {\r\n // Previous plugin was successfully removed or was not installed\r\n addCb && addCb(false);\r\n }\r\n else {\r\n _addPlugin(true);\r\n }\r\n });\r\n }\r\n else {\r\n _addPlugin(false);\r\n }\r\n };\r\n _self.evtNamespace = function () {\r\n return _evtNamespace;\r\n };\r\n // Create the addUnloadCb\r\n proxyFunctionAs(_self, \"addUnloadCb\", function () { return _unloadHandlers; }, \"add\");\r\n function _initDefaults() {\r\n _isInitialized = false;\r\n // Use a default logger so initialization errors are not dropped on the floor with full logging\r\n _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 /* CRITICAL */ });\r\n _self.config = null;\r\n _self._extensions = [];\r\n _telemetryInitializerPlugin = new TelemetryInitializerPlugin();\r\n _eventQueue = [];\r\n _notificationManager = null;\r\n _perfManager = null;\r\n _cfgPerfManager = null;\r\n _cookieManager = null;\r\n _pluginChain = null;\r\n _coreExtensions = null;\r\n _configExtensions = null;\r\n _channelControl = null;\r\n _channelConfig = null;\r\n _channelQueue = null;\r\n _isUnloading = false;\r\n _internalLogsEventName = null;\r\n _evtNamespace = createUniqueNamespace(\"AIBaseCore\", true);\r\n _unloadHandlers = createUnloadHandlerContainer();\r\n }\r\n function _createTelCtx() {\r\n return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);\r\n }\r\n // Initialize or Re-initialize the plugins\r\n function _initPluginChain(config) {\r\n // Extension validation\r\n var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);\r\n _coreExtensions = theExtensions.core;\r\n _pluginChain = null;\r\n // Sort the complete set of extensions by priority\r\n var allExtensions = theExtensions.all;\r\n // Initialize the Channel Queues and the channel plugins first\r\n _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));\r\n if (_channelControl) {\r\n // During add / remove of a plugin this may get called again, so don't re-add if already present\r\n // But we also want the controller as the last, so remove if already present\r\n // And reusing the existing instance, just in case an installed plugin has a reference and\r\n // is using it.\r\n var idx = allExtensions.indexOf(_channelControl);\r\n if (idx !== -1) {\r\n allExtensions.splice(idx, 1);\r\n }\r\n idx = _coreExtensions.indexOf(_channelControl);\r\n if (idx !== -1) {\r\n _coreExtensions.splice(idx, 1);\r\n }\r\n _channelControl._setQueue(_channelQueue);\r\n }\r\n else {\r\n _channelControl = createChannelControllerPlugin(_channelQueue, _self);\r\n }\r\n // Add on \"channelController\" as the last \"plugin\"\r\n allExtensions.push(_channelControl);\r\n _coreExtensions.push(_channelControl);\r\n // Required to allow plugins to call core.getPlugin() during their own initialization\r\n _self._extensions = sortPlugins(allExtensions);\r\n // Initialize the controls\r\n _channelControl.initialize(config, _self, allExtensions);\r\n initializePlugins(_createTelCtx(), allExtensions);\r\n // Now reset the extensions to just those being managed by Basecore\r\n _self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();\r\n }\r\n function _getPlugin(pluginIdentifier) {\r\n var theExt = null;\r\n var thePlugin = null;\r\n arrForEach(_self._extensions, function (ext) {\r\n if (ext.identifier === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {\r\n thePlugin = ext;\r\n return -1;\r\n }\r\n });\r\n if (!thePlugin && _channelControl) {\r\n // Check the channel Controller\r\n thePlugin = _channelControl.getChannel(pluginIdentifier);\r\n }\r\n if (thePlugin) {\r\n theExt = {\r\n plugin: thePlugin,\r\n setEnabled: function (enabled) {\r\n _getPluginState(thePlugin)[strDisabled] = !enabled;\r\n },\r\n isEnabled: function () {\r\n var pluginState = _getPluginState(thePlugin);\r\n return !pluginState[strTeardown] && !pluginState[strDisabled];\r\n },\r\n remove: function (isAsync, removeCb) {\r\n if (isAsync === void 0) { isAsync = true; }\r\n var pluginsToRemove = [thePlugin];\r\n var unloadState = {\r\n reason: 1 /* PluginUnload */,\r\n isAsync: isAsync\r\n };\r\n _removePlugins(pluginsToRemove, unloadState, function (removed) {\r\n if (removed) {\r\n // Re-Initialize the plugin chain\r\n _initPluginChain(_self.config);\r\n }\r\n removeCb && removeCb(removed);\r\n });\r\n }\r\n };\r\n }\r\n return theExt;\r\n }\r\n function _getPluginChain() {\r\n if (!_pluginChain) {\r\n // copy the collection of extensions\r\n var extensions = (_coreExtensions || []).slice();\r\n // During add / remove this may get called again, so don't readd if already present\r\n if (extensions.indexOf(_telemetryInitializerPlugin) === -1) {\r\n extensions.push(_telemetryInitializerPlugin);\r\n }\r\n _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);\r\n }\r\n return _pluginChain;\r\n }\r\n function _removePlugins(thePlugins, unloadState, removeComplete) {\r\n if (thePlugins && thePlugins.length > 0) {\r\n var unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);\r\n var unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self.config, _self);\r\n unloadCtx.onComplete(function () {\r\n var removed = false;\r\n // Remove the listed config extensions\r\n var newConfigExtensions = [];\r\n arrForEach(_configExtensions, function (plugin, idx) {\r\n if (!_isPluginPresent(plugin, thePlugins)) {\r\n newConfigExtensions.push(plugin);\r\n }\r\n else {\r\n removed = true;\r\n }\r\n });\r\n _configExtensions = newConfigExtensions;\r\n // Re-Create the channel config\r\n var newChannelConfig = [];\r\n if (_channelConfig) {\r\n arrForEach(_channelConfig, function (queue, idx) {\r\n var newQueue = [];\r\n arrForEach(queue, function (channel) {\r\n if (!_isPluginPresent(channel, thePlugins)) {\r\n newQueue.push(channel);\r\n }\r\n else {\r\n removed = true;\r\n }\r\n });\r\n newChannelConfig.push(newQueue);\r\n });\r\n _channelConfig = newChannelConfig;\r\n }\r\n removeComplete && removeComplete(removed);\r\n });\r\n unloadCtx.processNext(unloadState);\r\n }\r\n else {\r\n removeComplete(false);\r\n }\r\n }\r\n function _flushInternalLogs() {\r\n var queue = _self.logger ? _self.logger.queue : [];\r\n if (queue) {\r\n arrForEach(queue, function (logMessage) {\r\n var item = {\r\n name: _internalLogsEventName ? _internalLogsEventName : \"InternalMessageId: \" + logMessage.messageId,\r\n iKey: _self.config.instrumentationKey,\r\n time: toISOString(new Date()),\r\n baseType: _InternalLogMessage.dataType,\r\n baseData: { message: logMessage.message }\r\n };\r\n _self.track(item);\r\n });\r\n queue.length = 0;\r\n }\r\n }\r\n function _initDebugListener(config) {\r\n if (config.disableDbgExt === true && _debugListener) {\r\n // Remove any previously loaded debug listener\r\n _notificationManager[strRemoveNotificationListener](_debugListener);\r\n _debugListener = null;\r\n }\r\n if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {\r\n _debugListener = getDebugListener(config);\r\n _notificationManager[strAddNotificationListener](_debugListener);\r\n }\r\n }\r\n function _initPerfManager(config) {\r\n if (!config.enablePerfMgr && _cfgPerfManager) {\r\n // Remove any existing config based performance manager\r\n _cfgPerfManager = null;\r\n }\r\n if (config.enablePerfMgr) {\r\n // Set the performance manager creation function if not defined\r\n setValue(_self.config, \"createPerfMgr\", _createPerfManager);\r\n }\r\n }\r\n function _initExtConfig(config) {\r\n var extConfig = getSetValue(config, strExtensionConfig);\r\n extConfig.NotificationManager = _notificationManager;\r\n }\r\n function _logOrThrowError(message) {\r\n var logger = _self.logger;\r\n if (logger) {\r\n // there should always be a logger\r\n logger.throwInternal(2 /* WARNING */, 73 /* PluginException */, message);\r\n }\r\n else {\r\n throwError(message);\r\n }\r\n }\r\n });\r\n }\r\n BaseCore.prototype.initialize = function (config, extensions, logger, notificationManager) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.getTransmissionControls = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.track = function (telemetryItem) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.getProcessTelContext = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.getNotifyMgr = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.\r\n * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be\r\n * called.\r\n * @param {INotificationListener} listener - An INotificationListener object.\r\n */\r\n BaseCore.prototype.addNotificationListener = function (listener) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Removes all instances of the listener.\r\n * @param {INotificationListener} listener - INotificationListener to remove.\r\n */\r\n BaseCore.prototype.removeNotificationListener = function (listener) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Get the current cookie manager for this instance\r\n */\r\n BaseCore.prototype.getCookieMgr = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Set the current cookie manager for this instance\r\n * @param cookieMgr - The manager, if set to null/undefined will cause the default to be created\r\n */\r\n BaseCore.prototype.setCookieMgr = function (cookieMgr) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.getPerfMgr = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.setPerfMgr = function (perfMgr) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.eventCnt = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return 0;\r\n };\r\n /**\r\n * Periodically check logger.queue for\r\n */\r\n BaseCore.prototype.pollInternalLogs = function (eventName) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return 0;\r\n };\r\n /**\r\n * Periodically check logger.queue for\r\n */\r\n BaseCore.prototype.stopPollingInternalLogs = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add a telemetry processor to decorate or drop telemetry events.\r\n * @param telemetryInitializer - The Telemetry Initializer function\r\n * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed\r\n */\r\n BaseCore.prototype.addTelemetryInitializer = function (telemetryInitializer) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered\r\n * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous\r\n * unload call return `true` stating that all plugins reported that they also unloaded, the recommended\r\n * approach is to create a new instance and initialize that instance.\r\n * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable\r\n * to successfully remove any global references or they may just be completing the unload process asynchronously.\r\n */\r\n BaseCore.prototype.unload = function (isAsync, unloadComplete) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.getPlugin = function (pluginIdentifier) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.addPlugin = function (plugin, replaceExisting, doAsync, addCb) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Returns the unique event namespace that should be used\r\n */\r\n BaseCore.prototype.evtNamespace = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Add an unload handler that will be called when the SDK is being unloaded\r\n * @param handler - the handler\r\n */\r\n BaseCore.prototype.addUnloadCb = function (handler) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.releaseQueue = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return BaseCore;\r\n}());\r\nexport { BaseCore };\r\n//# sourceMappingURL=BaseCore.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA,wFAAsC;AACtC;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;oDAmHM;AACN;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"BaseCore.js.map","sources":["BaseCore.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\"use strict\";\r\nimport { __spreadArray } from \"tslib\";\r\nimport { objCreateFn } from \"@microsoft/applicationinsights-shims\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext, createTelemetryProxyChain } from \"./ProcessTelemetryContext\";\r\nimport { initializePlugins, sortPlugins, _getPluginState } from \"./TelemetryHelpers\";\r\nimport { getGblPerfMgr, PerfManager } from \"./PerfManager\";\r\nimport { createCookieMgr } from \"./CookieMgr\";\r\nimport { arrForEach, isNullOrUndefined, toISOString, getSetValue, setValue, throwError, isNotTruthy, isFunction, objFreeze, proxyFunctionAs, proxyFunctions } from \"./HelperFuncs\";\r\nimport { strExtensionConfig, strIKey } from \"./Constants\";\r\nimport { DiagnosticLogger, _InternalLogMessage, _throwInternal } from \"./DiagnosticLogger\";\r\nimport { getDebugListener } from \"./DbgExtensionUtils\";\r\nimport { ChannelControllerPriority, createChannelControllerPlugin, createChannelQueues } from \"./ChannelController\";\r\nimport { TelemetryInitializerPlugin } from \"./TelemetryInitializerPlugin\";\r\nimport { createUniqueNamespace } from \"./DataCacheHelper\";\r\nimport { createUnloadHandlerContainer } from \"./UnloadHandlerContainer\";\r\nimport { strAddNotificationListener, strDisabled, strEventsDiscarded, strEventsSendRequest, strEventsSent, strRemoveNotificationListener, strTeardown } from \"./InternalConstants\";\r\nvar strValidationError = \"Plugins must provide initialize method\";\r\nvar strNotificationManager = \"_notificationManager\";\r\nvar strSdkUnloadingError = \"SDK is still unloading...\";\r\nvar strSdkNotInitialized = \"SDK is not initialized\";\r\nvar strPluginUnloadFailed = \"Failed to unload plugin\";\r\n/**\r\n * Helper to create the default performance manager\r\n * @param core\r\n * @param notificationMgr\r\n */\r\nfunction _createPerfManager(core, notificationMgr) {\r\n return new PerfManager(notificationMgr);\r\n}\r\nfunction _validateExtensions(logger, channelPriority, allExtensions) {\r\n // Concat all available extensions\r\n var coreExtensions = [];\r\n // Check if any two extensions have the same priority, then warn to console\r\n // And extract the local extensions from the\r\n var extPriorities = {};\r\n // Extension validation\r\n arrForEach(allExtensions, function (ext) {\r\n if (isNullOrUndefined(ext) || isNullOrUndefined(ext.initialize)) {\r\n throwError(strValidationError);\r\n }\r\n var extPriority = ext.priority;\r\n var identifier = ext.identifier;\r\n if (ext && extPriority) {\r\n if (!isNullOrUndefined(extPriorities[extPriority])) {\r\n logger.warnToConsole(\"Two extensions have same priority #\" + extPriority + \" - \" + extPriorities[extPriority] + \", \" + identifier);\r\n }\r\n else {\r\n // set a value\r\n extPriorities[extPriority] = identifier;\r\n }\r\n }\r\n // Split extensions to core and channelController\r\n if (!extPriority || extPriority < channelPriority) {\r\n // Add to core extension that will be managed by BaseCore\r\n coreExtensions.push(ext);\r\n }\r\n });\r\n return {\r\n all: allExtensions,\r\n core: coreExtensions\r\n };\r\n}\r\nfunction _isPluginPresent(thePlugin, plugins) {\r\n var exists = false;\r\n arrForEach(plugins, function (plugin) {\r\n if (plugin === thePlugin) {\r\n exists = true;\r\n return -1;\r\n }\r\n });\r\n return exists;\r\n}\r\nfunction _createDummyNotificationManager() {\r\n var _a;\r\n return objCreateFn((_a = {},\r\n _a[strAddNotificationListener] = function (listener) { },\r\n _a[strRemoveNotificationListener] = function (listener) { },\r\n _a[strEventsSent] = function (events) { },\r\n _a[strEventsDiscarded] = function (events, reason) { },\r\n _a[strEventsSendRequest] = function (sendReason, isAsync) { },\r\n _a));\r\n}\r\nvar BaseCore = /** @class */ (function () {\r\n function BaseCore() {\r\n // NOTE!: DON'T set default values here, instead set them in the _initDefaults() function as it is also called during teardown()\r\n var _isInitialized;\r\n var _eventQueue;\r\n var _notificationManager;\r\n var _perfManager;\r\n var _cfgPerfManager;\r\n var _cookieManager;\r\n var _pluginChain;\r\n var _configExtensions;\r\n var _coreExtensions;\r\n var _channelControl;\r\n var _channelConfig;\r\n var _channelQueue;\r\n var _isUnloading;\r\n var _telemetryInitializerPlugin;\r\n var _internalLogsEventName;\r\n var _evtNamespace;\r\n var _unloadHandlers;\r\n var _debugListener;\r\n /**\r\n * Internal log poller\r\n */\r\n var _internalLogPoller = 0;\r\n dynamicProto(BaseCore, this, function (_self) {\r\n // Set the default values (also called during teardown)\r\n _initDefaults();\r\n _self.isInitialized = function () { return _isInitialized; };\r\n _self.initialize = function (config, extensions, logger, notificationManager) {\r\n if (_isUnloading) {\r\n throwError(strSdkUnloadingError);\r\n }\r\n // Make sure core is only initialized once\r\n if (_self.isInitialized()) {\r\n throwError(\"Core should not be initialized more than once\");\r\n }\r\n if (!config || isNullOrUndefined(config.instrumentationKey)) {\r\n throwError(\"Please provide instrumentation key\");\r\n }\r\n _notificationManager = notificationManager;\r\n // For backward compatibility only\r\n _self[strNotificationManager] = notificationManager;\r\n _self.config = config || {};\r\n _initDebugListener(config);\r\n _initPerfManager(config);\r\n config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;\r\n // add notification to the extensions in the config so other plugins can access it\r\n _initExtConfig(config);\r\n if (logger) {\r\n _self.logger = logger;\r\n }\r\n // Extension validation\r\n _configExtensions = [];\r\n _configExtensions.push.apply(_configExtensions, __spreadArray(__spreadArray([], extensions, false), config.extensions, false));\r\n _channelConfig = (config || {}).channels;\r\n _initPluginChain(config, null);\r\n if (_self.getTransmissionControls().length === 0) {\r\n throwError(\"No channels available\");\r\n }\r\n _isInitialized = true;\r\n _self.releaseQueue();\r\n };\r\n _self.getTransmissionControls = function () {\r\n var controls = [];\r\n arrForEach(_channelQueue, function (channels) {\r\n controls.push(channels.queue);\r\n });\r\n return objFreeze(controls);\r\n };\r\n _self.track = function (telemetryItem) {\r\n // setup default iKey if not passed in\r\n setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);\r\n // add default timestamp if not passed in\r\n setValue(telemetryItem, \"time\", toISOString(new Date()), null, isNotTruthy);\r\n // Common Schema 4.0\r\n setValue(telemetryItem, \"ver\", \"4.0\", null, isNullOrUndefined);\r\n if (!_isUnloading && _self.isInitialized()) {\r\n // Process the telemetry plugin chain\r\n _createTelCtx().processNext(telemetryItem);\r\n }\r\n else {\r\n // Queue events until all extensions are initialized\r\n _eventQueue.push(telemetryItem);\r\n }\r\n };\r\n _self.getProcessTelContext = _createTelCtx;\r\n _self.getNotifyMgr = function () {\r\n if (!_notificationManager) {\r\n // Create Dummy notification manager\r\n _notificationManager = _createDummyNotificationManager();\r\n // For backward compatibility only\r\n _self[strNotificationManager] = _notificationManager;\r\n }\r\n return _notificationManager;\r\n };\r\n /**\r\n * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.\r\n * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be\r\n * called.\r\n * @param {INotificationListener} listener - An INotificationListener object.\r\n */\r\n _self[strAddNotificationListener] = function (listener) {\r\n if (_notificationManager) {\r\n _notificationManager[strAddNotificationListener](listener);\r\n }\r\n };\r\n /**\r\n * Removes all instances of the listener.\r\n * @param {INotificationListener} listener - INotificationListener to remove.\r\n */\r\n _self[strRemoveNotificationListener] = function (listener) {\r\n if (_notificationManager) {\r\n _notificationManager[strRemoveNotificationListener](listener);\r\n }\r\n };\r\n _self.getCookieMgr = function () {\r\n if (!_cookieManager) {\r\n _cookieManager = createCookieMgr(_self.config, _self.logger);\r\n }\r\n return _cookieManager;\r\n };\r\n _self.setCookieMgr = function (cookieMgr) {\r\n _cookieManager = cookieMgr;\r\n };\r\n _self.getPerfMgr = function () {\r\n if (!_perfManager && !_cfgPerfManager) {\r\n if (_self.config && _self.config.enablePerfMgr && isFunction(_self.config.createPerfMgr)) {\r\n _cfgPerfManager = _self.config.createPerfMgr(_self, _self.getNotifyMgr());\r\n }\r\n }\r\n return _perfManager || _cfgPerfManager || getGblPerfMgr();\r\n };\r\n _self.setPerfMgr = function (perfMgr) {\r\n _perfManager = perfMgr;\r\n };\r\n _self.eventCnt = function () {\r\n return _eventQueue.length;\r\n };\r\n _self.releaseQueue = function () {\r\n if (_isInitialized && _eventQueue.length > 0) {\r\n var eventQueue = _eventQueue;\r\n _eventQueue = [];\r\n arrForEach(eventQueue, function (event) {\r\n _createTelCtx().processNext(event);\r\n });\r\n }\r\n };\r\n /**\r\n * Periodically check logger.queue for log messages to be flushed\r\n */\r\n _self.pollInternalLogs = function (eventName) {\r\n _internalLogsEventName = eventName;\r\n var interval = _self.config.diagnosticLogInterval;\r\n if (!interval || !(interval > 0)) {\r\n interval = 10000;\r\n }\r\n if (_internalLogPoller) {\r\n clearInterval(_internalLogPoller);\r\n }\r\n _internalLogPoller = setInterval(function () {\r\n _flushInternalLogs();\r\n }, interval);\r\n return _internalLogPoller;\r\n };\r\n /**\r\n * Stop polling log messages from logger.queue\r\n */\r\n _self.stopPollingInternalLogs = function () {\r\n if (_internalLogPoller) {\r\n clearInterval(_internalLogPoller);\r\n _internalLogPoller = 0;\r\n _flushInternalLogs();\r\n }\r\n };\r\n // Add addTelemetryInitializer\r\n proxyFunctions(_self, function () { return _telemetryInitializerPlugin; }, [\"addTelemetryInitializer\"]);\r\n _self.unload = function (isAsync, unloadComplete, cbTimeout) {\r\n if (isAsync === void 0) { isAsync = true; }\r\n if (!_isInitialized) {\r\n // The SDK is not initialized\r\n throwError(strSdkNotInitialized);\r\n }\r\n // Check if the SDK still unloading so throw\r\n if (_isUnloading) {\r\n // The SDK is already unloading\r\n throwError(strSdkUnloadingError);\r\n }\r\n var unloadState = {\r\n reason: 50 /* SdkUnload */,\r\n isAsync: isAsync,\r\n flushComplete: false\r\n };\r\n var processUnloadCtx = createProcessTelemetryUnloadContext(_getPluginChain(), _self.config, _self);\r\n processUnloadCtx.onComplete(function () {\r\n _initDefaults();\r\n unloadComplete && unloadComplete(unloadState);\r\n }, _self);\r\n function _doUnload(flushComplete) {\r\n unloadState.flushComplete = flushComplete;\r\n _isUnloading = true;\r\n // Run all of the unload handlers first (before unloading the plugins)\r\n _unloadHandlers.run(processUnloadCtx, unloadState);\r\n // Stop polling the internal logs\r\n _self.stopPollingInternalLogs();\r\n // Start unloading the components, from this point onwards the SDK should be considered to be in an unstable state\r\n processUnloadCtx.processNext(unloadState);\r\n }\r\n if (_channelControl) {\r\n _channelControl.flush(isAsync, _doUnload, 6 /* SdkUnload */, cbTimeout);\r\n }\r\n else {\r\n _doUnload(true);\r\n }\r\n };\r\n _self.getPlugin = _getPlugin;\r\n _self.addPlugin = function (plugin, replaceExisting, isAsync, addCb) {\r\n if (isAsync === void 0) { isAsync = true; }\r\n if (!plugin) {\r\n addCb && addCb(false);\r\n _logOrThrowError(strValidationError);\r\n return;\r\n }\r\n var existingPlugin = _getPlugin(plugin.identifier);\r\n if (existingPlugin && !replaceExisting) {\r\n addCb && addCb(false);\r\n _logOrThrowError(\"Plugin [\" + plugin.identifier + \"] is already loaded!\");\r\n return;\r\n }\r\n var updateState = {\r\n reason: 16 /* PluginAdded */\r\n };\r\n function _addPlugin(removed) {\r\n _configExtensions.push(plugin);\r\n updateState.added = [plugin];\r\n // Re-Initialize the plugin chain\r\n _initPluginChain(_self.config, updateState);\r\n addCb && addCb(true);\r\n }\r\n if (existingPlugin) {\r\n var removedPlugins_1 = [existingPlugin.plugin];\r\n var unloadState = {\r\n reason: 2 /* PluginReplace */,\r\n isAsync: isAsync\r\n };\r\n _removePlugins(removedPlugins_1, unloadState, function (removed) {\r\n if (!removed) {\r\n // Previous plugin was successfully removed or was not installed\r\n addCb && addCb(false);\r\n }\r\n else {\r\n updateState.removed = removedPlugins_1;\r\n updateState.reason |= 32 /* PluginRemoved */;\r\n _addPlugin(true);\r\n }\r\n });\r\n }\r\n else {\r\n _addPlugin(false);\r\n }\r\n };\r\n _self.evtNamespace = function () {\r\n return _evtNamespace;\r\n };\r\n // Create the addUnloadCb\r\n proxyFunctionAs(_self, \"addUnloadCb\", function () { return _unloadHandlers; }, \"add\");\r\n function _initDefaults() {\r\n _isInitialized = false;\r\n // Use a default logger so initialization errors are not dropped on the floor with full logging\r\n _self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 /* CRITICAL */ });\r\n _self.config = null;\r\n _self._extensions = [];\r\n _telemetryInitializerPlugin = new TelemetryInitializerPlugin();\r\n _eventQueue = [];\r\n _notificationManager = null;\r\n _perfManager = null;\r\n _cfgPerfManager = null;\r\n _cookieManager = null;\r\n _pluginChain = null;\r\n _coreExtensions = null;\r\n _configExtensions = null;\r\n _channelControl = null;\r\n _channelConfig = null;\r\n _channelQueue = null;\r\n _isUnloading = false;\r\n _internalLogsEventName = null;\r\n _evtNamespace = createUniqueNamespace(\"AIBaseCore\", true);\r\n _unloadHandlers = createUnloadHandlerContainer();\r\n }\r\n function _createTelCtx() {\r\n return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);\r\n }\r\n // Initialize or Re-initialize the plugins\r\n function _initPluginChain(config, updateState) {\r\n // Extension validation\r\n var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);\r\n _coreExtensions = theExtensions.core;\r\n _pluginChain = null;\r\n // Sort the complete set of extensions by priority\r\n var allExtensions = theExtensions.all;\r\n // Initialize the Channel Queues and the channel plugins first\r\n _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, config, _self));\r\n if (_channelControl) {\r\n // During add / remove of a plugin this may get called again, so don't re-add if already present\r\n // But we also want the controller as the last, so remove if already present\r\n // And reusing the existing instance, just in case an installed plugin has a reference and\r\n // is using it.\r\n var idx = allExtensions.indexOf(_channelControl);\r\n if (idx !== -1) {\r\n allExtensions.splice(idx, 1);\r\n }\r\n idx = _coreExtensions.indexOf(_channelControl);\r\n if (idx !== -1) {\r\n _coreExtensions.splice(idx, 1);\r\n }\r\n _channelControl._setQueue(_channelQueue);\r\n }\r\n else {\r\n _channelControl = createChannelControllerPlugin(_channelQueue, _self);\r\n }\r\n // Add on \"channelController\" as the last \"plugin\"\r\n allExtensions.push(_channelControl);\r\n _coreExtensions.push(_channelControl);\r\n // Required to allow plugins to call core.getPlugin() during their own initialization\r\n _self._extensions = sortPlugins(allExtensions);\r\n // Initialize the controls\r\n _channelControl.initialize(config, _self, allExtensions);\r\n initializePlugins(_createTelCtx(), allExtensions);\r\n // Now reset the extensions to just those being managed by Basecore\r\n _self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();\r\n if (updateState) {\r\n _doUpdate(updateState);\r\n }\r\n }\r\n function _getPlugin(pluginIdentifier) {\r\n var theExt = null;\r\n var thePlugin = null;\r\n arrForEach(_self._extensions, function (ext) {\r\n if (ext.identifier === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {\r\n thePlugin = ext;\r\n return -1;\r\n }\r\n });\r\n if (!thePlugin && _channelControl) {\r\n // Check the channel Controller\r\n thePlugin = _channelControl.getChannel(pluginIdentifier);\r\n }\r\n if (thePlugin) {\r\n theExt = {\r\n plugin: thePlugin,\r\n setEnabled: function (enabled) {\r\n _getPluginState(thePlugin)[strDisabled] = !enabled;\r\n },\r\n isEnabled: function () {\r\n var pluginState = _getPluginState(thePlugin);\r\n return !pluginState[strTeardown] && !pluginState[strDisabled];\r\n },\r\n remove: function (isAsync, removeCb) {\r\n if (isAsync === void 0) { isAsync = true; }\r\n var pluginsToRemove = [thePlugin];\r\n var unloadState = {\r\n reason: 1 /* PluginUnload */,\r\n isAsync: isAsync\r\n };\r\n _removePlugins(pluginsToRemove, unloadState, function (removed) {\r\n if (removed) {\r\n // Re-Initialize the plugin chain\r\n _initPluginChain(_self.config, {\r\n reason: 32 /* PluginRemoved */,\r\n removed: pluginsToRemove\r\n });\r\n }\r\n removeCb && removeCb(removed);\r\n });\r\n }\r\n };\r\n }\r\n return theExt;\r\n }\r\n function _getPluginChain() {\r\n if (!_pluginChain) {\r\n // copy the collection of extensions\r\n var extensions = (_coreExtensions || []).slice();\r\n // During add / remove this may get called again, so don't readd if already present\r\n if (extensions.indexOf(_telemetryInitializerPlugin) === -1) {\r\n extensions.push(_telemetryInitializerPlugin);\r\n }\r\n _pluginChain = createTelemetryProxyChain(sortPlugins(extensions), _self.config, _self);\r\n }\r\n return _pluginChain;\r\n }\r\n function _removePlugins(thePlugins, unloadState, removeComplete) {\r\n if (thePlugins && thePlugins.length > 0) {\r\n var unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);\r\n var unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self.config, _self);\r\n unloadCtx.onComplete(function () {\r\n var removed = false;\r\n // Remove the listed config extensions\r\n var newConfigExtensions = [];\r\n arrForEach(_configExtensions, function (plugin, idx) {\r\n if (!_isPluginPresent(plugin, thePlugins)) {\r\n newConfigExtensions.push(plugin);\r\n }\r\n else {\r\n removed = true;\r\n }\r\n });\r\n _configExtensions = newConfigExtensions;\r\n // Re-Create the channel config\r\n var newChannelConfig = [];\r\n if (_channelConfig) {\r\n arrForEach(_channelConfig, function (queue, idx) {\r\n var newQueue = [];\r\n arrForEach(queue, function (channel) {\r\n if (!_isPluginPresent(channel, thePlugins)) {\r\n newQueue.push(channel);\r\n }\r\n else {\r\n removed = true;\r\n }\r\n });\r\n newChannelConfig.push(newQueue);\r\n });\r\n _channelConfig = newChannelConfig;\r\n }\r\n removeComplete && removeComplete(removed);\r\n });\r\n unloadCtx.processNext(unloadState);\r\n }\r\n else {\r\n removeComplete(false);\r\n }\r\n }\r\n function _flushInternalLogs() {\r\n var queue = _self.logger ? _self.logger.queue : [];\r\n if (queue) {\r\n arrForEach(queue, function (logMessage) {\r\n var item = {\r\n name: _internalLogsEventName ? _internalLogsEventName : \"InternalMessageId: \" + logMessage.messageId,\r\n iKey: _self.config.instrumentationKey,\r\n time: toISOString(new Date()),\r\n baseType: _InternalLogMessage.dataType,\r\n baseData: { message: logMessage.message }\r\n };\r\n _self.track(item);\r\n });\r\n queue.length = 0;\r\n }\r\n }\r\n function _initDebugListener(config) {\r\n if (config.disableDbgExt === true && _debugListener) {\r\n // Remove any previously loaded debug listener\r\n _notificationManager[strRemoveNotificationListener](_debugListener);\r\n _debugListener = null;\r\n }\r\n if (_notificationManager && !_debugListener && config.disableDbgExt !== true) {\r\n _debugListener = getDebugListener(config);\r\n _notificationManager[strAddNotificationListener](_debugListener);\r\n }\r\n }\r\n function _initPerfManager(config) {\r\n if (!config.enablePerfMgr && _cfgPerfManager) {\r\n // Remove any existing config based performance manager\r\n _cfgPerfManager = null;\r\n }\r\n if (config.enablePerfMgr) {\r\n // Set the performance manager creation function if not defined\r\n setValue(_self.config, \"createPerfMgr\", _createPerfManager);\r\n }\r\n }\r\n function _initExtConfig(config) {\r\n var extConfig = getSetValue(config, strExtensionConfig);\r\n extConfig.NotificationManager = _notificationManager;\r\n }\r\n function _doUpdate(updateState) {\r\n var updateCtx = createProcessTelemetryUpdateContext(_getPluginChain(), _self.config, _self);\r\n if (!_self._updateHook || _self._updateHook(updateCtx, updateState) !== true) {\r\n updateCtx.processNext(updateState);\r\n }\r\n }\r\n function _logOrThrowError(message) {\r\n var logger = _self.logger;\r\n if (logger) {\r\n // there should always be a logger\r\n _throwInternal(logger, 2 /* WARNING */, 73 /* PluginException */, message);\r\n }\r\n else {\r\n throwError(message);\r\n }\r\n }\r\n });\r\n }\r\n BaseCore.prototype.initialize = function (config, extensions, logger, notificationManager) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.getTransmissionControls = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.track = function (telemetryItem) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.getProcessTelContext = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.getNotifyMgr = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.\r\n * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be\r\n * called.\r\n * @param {INotificationListener} listener - An INotificationListener object.\r\n */\r\n BaseCore.prototype.addNotificationListener = function (listener) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Removes all instances of the listener.\r\n * @param {INotificationListener} listener - INotificationListener to remove.\r\n */\r\n BaseCore.prototype.removeNotificationListener = function (listener) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Get the current cookie manager for this instance\r\n */\r\n BaseCore.prototype.getCookieMgr = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Set the current cookie manager for this instance\r\n * @param cookieMgr - The manager, if set to null/undefined will cause the default to be created\r\n */\r\n BaseCore.prototype.setCookieMgr = function (cookieMgr) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.getPerfMgr = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.setPerfMgr = function (perfMgr) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.eventCnt = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return 0;\r\n };\r\n /**\r\n * Periodically check logger.queue for\r\n */\r\n BaseCore.prototype.pollInternalLogs = function (eventName) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return 0;\r\n };\r\n /**\r\n * Periodically check logger.queue for\r\n */\r\n BaseCore.prototype.stopPollingInternalLogs = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add a telemetry processor to decorate or drop telemetry events.\r\n * @param telemetryInitializer - The Telemetry Initializer function\r\n * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed\r\n */\r\n BaseCore.prototype.addTelemetryInitializer = function (telemetryInitializer) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered\r\n * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous\r\n * unload call return `true` stating that all plugins reported that they also unloaded, the recommended\r\n * approach is to create a new instance and initialize that instance.\r\n * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable\r\n * to successfully remove any global references or they may just be completing the unload process asynchronously.\r\n */\r\n BaseCore.prototype.unload = function (isAsync, unloadComplete, cbTimeout) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.getPlugin = function (pluginIdentifier) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n BaseCore.prototype.addPlugin = function (plugin, replaceExisting, doAsync, addCb) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Returns the unique event namespace that should be used\r\n */\r\n BaseCore.prototype.evtNamespace = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Add an unload handler that will be called when the SDK is being unloaded\r\n * @param handler - the handler\r\n */\r\n BaseCore.prototype.addUnloadCb = function (handler) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n BaseCore.prototype.releaseQueue = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.\r\n * @param updateCtx - The plugin update context\r\n * @param updateState - The Update State\r\n * @returns boolean - True means the extension class will call updateState otherwise the Core will\r\n */\r\n BaseCore.prototype._updateHook = function (updateCtx, updateState) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n return BaseCore;\r\n}());\r\nexport { BaseCore };\r\n//# sourceMappingURL=BaseCore.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA,wFAAsC;AACtC;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;mDA6HM;AACN;AACA;AACA;AACA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Core, 2.8.0-beta.2203-
|
|
2
|
+
* Application Insights JavaScript SDK - Core, 2.8.0-beta.2203-06
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
"use strict";
|
|
8
8
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
9
|
-
import { createProcessTelemetryContext, createProcessTelemetryUnloadContext } from "./ProcessTelemetryContext";
|
|
9
|
+
import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext } from "./ProcessTelemetryContext";
|
|
10
10
|
import { arrForEach, isArray, isFunction, isNullOrUndefined, proxyFunctionAs, setValue } from "./HelperFuncs";
|
|
11
11
|
import { strExtensionConfig } from "./Constants";
|
|
12
12
|
import { createUnloadHandlerContainer } from "./UnloadHandlerContainer";
|
|
@@ -70,6 +70,33 @@ var BaseTelemetryPlugin = /** @class */ (function () {
|
|
|
70
70
|
}
|
|
71
71
|
return result;
|
|
72
72
|
};
|
|
73
|
+
_self.update = function (updateCtx, updateState) {
|
|
74
|
+
// If this plugin has already been torn down (not operational) or is not initialized (core is not set)
|
|
75
|
+
// or the core being used for unload was not the same core used for initialization.
|
|
76
|
+
if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
|
|
77
|
+
// Do Nothing
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
var result;
|
|
81
|
+
var updateDone = false;
|
|
82
|
+
var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
|
|
83
|
+
var theUpdateState = updateState || {
|
|
84
|
+
reason: 0 /* Unknown */
|
|
85
|
+
};
|
|
86
|
+
function _updateCallback() {
|
|
87
|
+
if (!updateDone) {
|
|
88
|
+
updateDone = true;
|
|
89
|
+
_setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
|
|
93
|
+
_updateCallback();
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
result = true;
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
73
100
|
_self._addHook = function (hooks) {
|
|
74
101
|
if (hooks) {
|
|
75
102
|
if (isArray(hooks)) {
|
|
@@ -156,6 +183,7 @@ var BaseTelemetryPlugin = /** @class */ (function () {
|
|
|
156
183
|
}
|
|
157
184
|
// Removed Stub for BaseTelemetryPlugin.prototype.initialize.
|
|
158
185
|
// Removed Stub for BaseTelemetryPlugin.prototype.teardown.
|
|
186
|
+
// Removed Stub for BaseTelemetryPlugin.prototype.update.
|
|
159
187
|
// Removed Stub for BaseTelemetryPlugin.prototype._addUnloadCb.
|
|
160
188
|
// Removed Stub for BaseTelemetryPlugin.prototype._addHook.
|
|
161
189
|
return BaseTelemetryPlugin;
|