@microsoft/applicationinsights-core-js 2.7.4-nightly.2202-07 → 2.8.0-beta.2202-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.
Files changed (108) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +860 -457
  3. package/browser/applicationinsights-core-js.js.map +1 -1
  4. package/browser/applicationinsights-core-js.min.js +2 -2
  5. package/browser/applicationinsights-core-js.min.js.map +1 -1
  6. package/dist/applicationinsights-core-js.api.json +1193 -267
  7. package/dist/applicationinsights-core-js.api.md +54 -14
  8. package/dist/applicationinsights-core-js.d.ts +133 -45
  9. package/dist/applicationinsights-core-js.js +860 -457
  10. package/dist/applicationinsights-core-js.js.map +1 -1
  11. package/dist/applicationinsights-core-js.min.js +2 -2
  12. package/dist/applicationinsights-core-js.min.js.map +1 -1
  13. package/dist/applicationinsights-core-js.rollup.d.ts +133 -45
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +3 -69
  15. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  16. package/dist-esm/JavaScriptSDK/BaseCore.js +237 -82
  17. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +45 -19
  19. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  20. package/dist-esm/JavaScriptSDK/ChannelController.js +155 -87
  21. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  22. package/dist-esm/JavaScriptSDK/Constants.js +1 -1
  23. package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
  24. package/dist-esm/JavaScriptSDK/CoreUtils.js +2 -27
  25. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  26. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  27. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
  28. package/dist-esm/JavaScriptSDK/EnvUtils.js +6 -6
  29. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  30. package/dist-esm/JavaScriptSDK/HelperFuncs.js +51 -11
  31. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  32. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +3 -1
  33. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/NotificationManager.js +34 -36
  35. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  36. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  37. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +289 -119
  38. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  39. package/dist-esm/JavaScriptSDK/RandomHelper.js +29 -4
  40. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +2 -2
  42. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +82 -0
  44. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -0
  45. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  46. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  47. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  48. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -2
  49. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js.map +1 -1
  50. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  51. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  52. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  53. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  54. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  55. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  57. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  60. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +6 -0
  62. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +1 -0
  63. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  66. package/dist-esm/applicationinsights-core-js.js +4 -4
  67. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  68. package/package.json +2 -2
  69. package/src/JavaScriptSDK/AppInsightsCore.ts +2 -101
  70. package/src/JavaScriptSDK/BaseCore.ts +330 -100
  71. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +69 -32
  72. package/src/JavaScriptSDK/ChannelController.ts +175 -103
  73. package/src/JavaScriptSDK/CoreUtils.ts +1 -28
  74. package/src/JavaScriptSDK/EnvUtils.ts +5 -5
  75. package/src/JavaScriptSDK/HelperFuncs.ts +57 -14
  76. package/src/JavaScriptSDK/InstrumentHooks.ts +3 -1
  77. package/src/JavaScriptSDK/NotificationManager.ts +32 -31
  78. package/src/JavaScriptSDK/PerfManager.ts +1 -1
  79. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +350 -133
  80. package/src/JavaScriptSDK/RandomHelper.ts +34 -3
  81. package/src/JavaScriptSDK/TelemetryHelpers.ts +4 -6
  82. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +119 -0
  83. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +17 -1
  84. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +7 -3
  85. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +5 -0
  86. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +23 -5
  87. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +16 -0
  88. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +1 -1
  89. package/types/JavaScriptSDK/AppInsightsCore.d.ts +0 -21
  90. package/types/JavaScriptSDK/BaseCore.d.ts +30 -1
  91. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +13 -11
  92. package/types/JavaScriptSDK/ChannelController.d.ts +12 -17
  93. package/types/JavaScriptSDK/CoreUtils.d.ts +0 -6
  94. package/types/JavaScriptSDK/HelperFuncs.d.ts +14 -5
  95. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +49 -3
  96. package/types/JavaScriptSDK/RandomHelper.d.ts +6 -0
  97. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +3 -3
  98. package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +23 -0
  99. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +15 -0
  100. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +7 -3
  101. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +4 -0
  102. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +18 -3
  103. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +13 -0
  104. package/types/applicationinsights-core-js.d.ts +5 -4
  105. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +0 -76
  106. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +0 -1
  107. package/src/JavaScriptSDK/TelemetryPluginChain.ts +0 -120
  108. package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +0 -32
@@ -0,0 +1,23 @@
1
+ import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
2
+ import { ITelemetryInitializerContainer, ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../JavaScriptSDK.Interfaces/ITelemetryInitializers";
3
+ import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
4
+ import { BaseTelemetryPlugin } from "./BaseTelemetryPlugin";
5
+ export declare class TelemetryInitializerPlugin extends BaseTelemetryPlugin implements ITelemetryInitializerContainer {
6
+ identifier: string;
7
+ priority: number;
8
+ constructor();
9
+ /**
10
+ * Add a telemetry processor to decorate or drop telemetry events.
11
+ * @param telemetryInitializer - The Telemetry Initializer function
12
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
13
+ */
14
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
15
+ processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
16
+ /**
17
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
18
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
19
+ * @param itemCtx - This is the context that should be used during unloading if required to flush any cached events.
20
+ * @param isAsync - Should the plugin attempt to unload synchronously or can it complete asynchronously
21
+ */
22
+ unload(itemCtx: IProcessTelemetryContext, isAsync: boolean): void;
23
+ }
@@ -8,6 +8,10 @@ import { IDiagnosticLogger } from "./IDiagnosticLogger";
8
8
  import { IProcessTelemetryContext } from "./IProcessTelemetryContext";
9
9
  import { IPerfManagerProvider } from "./IPerfManager";
10
10
  import { ICookieMgr } from "./ICookieMgr";
11
+ import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "./ITelemetryInitializers";
12
+ export interface ILoadedPlugin<T extends IPlugin> {
13
+ plugin: T;
14
+ }
11
15
  export interface IAppInsightsCore extends IPerfManagerProvider {
12
16
  config: IConfiguration;
13
17
  logger: IDiagnosticLogger;
@@ -43,10 +47,21 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
43
47
  * @param {INotificationListener} listener - INotificationListener to remove.
44
48
  */
45
49
  removeNotificationListener?(listener: INotificationListener): void;
50
+ /**
51
+ * Add a telemetry processor to decorate or drop telemetry events.
52
+ * @param telemetryInitializer - The Telemetry Initializer function
53
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
54
+ */
55
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
46
56
  pollInternalLogs?(eventName?: string): number;
47
57
  stopPollingInternalLogs?(): void;
48
58
  /**
49
59
  * Return a new instance of the IProcessTelemetryContext for processing events
50
60
  */
51
61
  getProcessTelContext(): IProcessTelemetryContext;
62
+ /**
63
+ * Find and return the (first) plugin with the specified identifier if present
64
+ * @param pluginIdentifier
65
+ */
66
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
52
67
  }
@@ -1,3 +1,4 @@
1
+ import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
1
2
  import { ITelemetryPlugin } from "./ITelemetryPlugin";
2
3
  /**
3
4
  * Provides data transmission capabilities
@@ -17,9 +18,12 @@ export interface IChannelControls extends ITelemetryPlugin {
17
18
  teardown(): void;
18
19
  /**
19
20
  * Flush to send data immediately; channel should default to sending data asynchronously
20
- * @param async: send data asynchronously when true
21
- * @param callBack: if specified, notify caller when send is complete
21
+ * @param async - send data asynchronously when true
22
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
23
+ * If the caller doesn't return true the caller should assume that it may never be called.
24
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
25
+ * @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
22
26
  */
23
- flush(async: boolean, callBack?: () => void): void;
27
+ flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
24
28
  }
25
29
  export declare const MinChannelPriorty: number;
@@ -68,4 +68,8 @@ export interface IInstrumentCallDetails {
68
68
  * The error (exception) which occurred while executing the original method
69
69
  */
70
70
  err?: Error;
71
+ /**
72
+ * The Event object from (window.event) at the start of the original call
73
+ */
74
+ evt?: Event;
71
75
  }
@@ -2,8 +2,13 @@ import { IAppInsightsCore } from "./IAppInsightsCore";
2
2
  import { IDiagnosticLogger } from "./IDiagnosticLogger";
3
3
  import { IConfiguration } from "./IConfiguration";
4
4
  import { ITelemetryItem } from "./ITelemetryItem";
5
- import { IPlugin } from "./ITelemetryPlugin";
5
+ import { IPlugin, ITelemetryPlugin } from "./ITelemetryPlugin";
6
6
  import { ITelemetryPluginChain } from "./ITelemetryPluginChain";
7
+ export declare const enum GetExtCfgMergeType {
8
+ None = 0,
9
+ MergeDefaultOnly = 1,
10
+ MergeDefaultFromRootOrDefault = 2
11
+ }
7
12
  /**
8
13
  * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
9
14
  * between multiple AppInsights instances
@@ -24,7 +29,7 @@ export interface IProcessTelemetryContext {
24
29
  /**
25
30
  * Gets the named extension config
26
31
  */
27
- getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
32
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
28
33
  /**
29
34
  * Gets the named config from either the named identifier extension or core config if neither exist then the
30
35
  * default value is returned
@@ -32,7 +37,7 @@ export interface IProcessTelemetryContext {
32
37
  * @param field The config field name
33
38
  * @param defaultValue The default value to return if no defined config exists
34
39
  */
35
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
40
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
36
41
  /**
37
42
  * Helper to allow plugins to check and possibly shortcut executing code only
38
43
  * required if there is a nextPlugin
@@ -51,6 +56,12 @@ export interface IProcessTelemetryContext {
51
56
  * @param env - This is the current event being reported
52
57
  */
53
58
  processNext: (env: ITelemetryItem) => void;
59
+ /**
60
+ * Synchronously iterate over the context chain running the callback for each plugin, once
61
+ * every plugin has been executed via the callback, any associated onComplete will be called.
62
+ * @param callback - The function call for each plugin in the context chain
63
+ */
64
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
54
65
  /**
55
66
  * Create a new context using the core and config from the current instance
56
67
  * @param plugins - The execution order to process the plugins, if null or not supplied
@@ -59,4 +70,8 @@ export interface IProcessTelemetryContext {
59
70
  * order then the next plugin will be NOT set.
60
71
  */
61
72
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
73
+ /**
74
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
75
+ */
76
+ onComplete: (onComplete: () => void) => void;
62
77
  }
@@ -0,0 +1,13 @@
1
+ import { ITelemetryItem } from "./ITelemetryItem";
2
+ export declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
3
+ export interface ITelemetryInitializerHandler {
4
+ remove(): void;
5
+ }
6
+ export interface ITelemetryInitializerContainer {
7
+ /**
8
+ * Add a telemetry processor to decorate or drop telemetry events.
9
+ * @param telemetryInitializer - The Telemetry Initializer function
10
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
11
+ */
12
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
13
+ }
@@ -3,7 +3,7 @@ export { IChannelControls, MinChannelPriorty } from "./JavaScriptSDK.Interfaces/
3
3
  export { ITelemetryPlugin, IPlugin } from "./JavaScriptSDK.Interfaces/ITelemetryPlugin";
4
4
  export { IAppInsightsCore } from "./JavaScriptSDK.Interfaces/IAppInsightsCore";
5
5
  export { ITelemetryItem, ICustomProperties, Tags } from "./JavaScriptSDK.Interfaces/ITelemetryItem";
6
- export { IProcessTelemetryContext } from "./JavaScriptSDK.Interfaces/IProcessTelemetryContext";
6
+ export { IProcessTelemetryContext, GetExtCfgMergeType } from "./JavaScriptSDK.Interfaces/IProcessTelemetryContext";
7
7
  export { INotificationListener } from "./JavaScriptSDK.Interfaces/INotificationListener";
8
8
  export { ITelemetryPluginChain } from "./JavaScriptSDK.Interfaces/ITelemetryPluginChain";
9
9
  export { IDiagnosticLogger } from "./JavaScriptSDK.Interfaces/IDiagnosticLogger";
@@ -13,8 +13,8 @@ export { SendRequestReason } from "./JavaScriptSDK.Enums/SendRequestReason";
13
13
  export { AppInsightsCore } from "./JavaScriptSDK/AppInsightsCore";
14
14
  export { BaseCore } from "./JavaScriptSDK/BaseCore";
15
15
  export { BaseTelemetryPlugin } from "./JavaScriptSDK/BaseTelemetryPlugin";
16
- export { randomValue, random32, mwcRandomSeed, mwcRandom32 } from "./JavaScriptSDK/RandomHelper";
17
- export { CoreUtils, ICoreUtils, EventHelper, IEventHelper, Undefined, addEventHandler, newGuid, perfNow, newId, generateW3CId, disableCookies, canUseCookies, getCookie, setCookie, deleteCookie, _legacyCookieMgr, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener } from "./JavaScriptSDK/CoreUtils";
16
+ export { randomValue, random32, mwcRandomSeed, mwcRandom32, newId } from "./JavaScriptSDK/RandomHelper";
17
+ export { CoreUtils, ICoreUtils, EventHelper, IEventHelper, Undefined, addEventHandler, newGuid, perfNow, generateW3CId, disableCookies, canUseCookies, getCookie, setCookie, deleteCookie, _legacyCookieMgr, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener } from "./JavaScriptSDK/CoreUtils";
18
18
  export { isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction, attachEvent, detachEvent, 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, createClassFromInterface, optimizeObject, isNotUndefined, isNotNullOrUndefined, objFreeze, objSeal } from "./JavaScriptSDK/HelperFuncs";
19
19
  export { 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";
20
20
  export { getGlobal, objCreateFn as objCreate, strShimPrototype as strPrototype, strShimFunction as strFunction, strShimUndefined as strUndefined, strShimObject as strObject } from "@microsoft/applicationinsights-shims";
@@ -24,7 +24,7 @@ export { IPerfEvent } from "./JavaScriptSDK.Interfaces/IPerfEvent";
24
24
  export { IPerfManager, IPerfManagerProvider } from "./JavaScriptSDK.Interfaces/IPerfManager";
25
25
  export { PerfEvent, PerfManager, doPerf, getGblPerfMgr, setGblPerfMgr } from "./JavaScriptSDK/PerfManager";
26
26
  export { safeGetLogger, DiagnosticLogger, _InternalLogMessage } from "./JavaScriptSDK/DiagnosticLogger";
27
- export { ProcessTelemetryContext } from "./JavaScriptSDK/ProcessTelemetryContext";
27
+ export { ProcessTelemetryContext, createProcessTelemetryContext } from "./JavaScriptSDK/ProcessTelemetryContext";
28
28
  export { initializePlugins, sortPlugins } from "./JavaScriptSDK/TelemetryHelpers";
29
29
  export { _InternalMessageId, LoggingSeverity } from "./JavaScriptSDK.Enums/LoggingEnums";
30
30
  export { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs } from "./JavaScriptSDK/InstrumentHooks";
@@ -33,3 +33,4 @@ export { createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesS
33
33
  export { strIKey, strExtensionConfig } from "./JavaScriptSDK/Constants";
34
34
  export { IDbgExtension } from "./JavaScriptSDK.Interfaces/IDbgExtension";
35
35
  export { getDebugListener, getDebugExt } from "./JavaScriptSDK/DbgExtensionUtils";
36
+ export { TelemetryInitializerFunction, ITelemetryInitializerHandler, ITelemetryInitializerContainer } from "./JavaScriptSDK.Interfaces/ITelemetryInitializers";
@@ -1,76 +0,0 @@
1
- /*
2
- * Application Insights JavaScript SDK - Core, 2.7.4-nightly.2202-07
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- */
5
-
6
-
7
- "use strict";
8
- import { doPerf } from "./PerfManager";
9
- import { LoggingSeverity, _InternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
10
- import { isFunction } from "./HelperFuncs";
11
- import { dumpObj } from "./EnvUtils";
12
- var TelemetryPluginChain = /** @class */ (function () {
13
- function TelemetryPluginChain(plugin, defItemCtx) {
14
- var _self = this;
15
- var _nextProxy = null;
16
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
17
- var _hasSetNext = isFunction(plugin.setNextPlugin);
18
- _self._hasRun = false;
19
- _self.getPlugin = function () {
20
- return plugin;
21
- };
22
- _self.getNext = function () {
23
- return _nextProxy;
24
- };
25
- _self.setNext = function (nextPlugin) {
26
- _nextProxy = nextPlugin;
27
- };
28
- _self.processTelemetry = function (env, itemCtx) {
29
- if (!itemCtx) {
30
- // Looks like a plugin didn't pass the (optional) context, so restore to the default
31
- itemCtx = defItemCtx;
32
- }
33
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
34
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
35
- if (plugin && _hasProcessTelemetry) {
36
- _self._hasRun = true;
37
- try {
38
- // Ensure that we keep the context in sync (for processNext()), just in case a plugin
39
- // doesn't calls processTelemetry() instead of itemContext.processNext() or some
40
- // other form of error occurred
41
- itemCtx.setNext(_nextProxy);
42
- if (_hasSetNext) {
43
- // Backward compatibility setting the next plugin on the instance
44
- plugin.setNextPlugin(_nextProxy);
45
- }
46
- // Set a flag on the next plugin so we know if it was attempted to be executed
47
- _nextProxy && (_nextProxy._hasRun = false);
48
- plugin.processTelemetry(env, itemCtx);
49
- }
50
- catch (error) {
51
- var hasRun = _nextProxy && _nextProxy._hasRun;
52
- if (!_nextProxy || !hasRun) {
53
- // Either we have no next plugin or the current one did not attempt to call the next plugin
54
- // Which means the current one is the root of the failure so log/report this failure
55
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
56
- }
57
- if (_nextProxy && !hasRun) {
58
- // As part of the failure the current plugin did not attempt to call the next plugin in the cahin
59
- // So rather than leave the pipeline dead in the water we call the next plugin
60
- _nextProxy.processTelemetry(env, itemCtx);
61
- }
62
- }
63
- }
64
- else if (_nextProxy) {
65
- _self._hasRun = true;
66
- // The underlying plugin is either not defined or does not have a processTelemetry implementation
67
- // so we still want the next plugin to be executed.
68
- _nextProxy.processTelemetry(env, itemCtx);
69
- }
70
- }, function () { return ({ item: env }); }, !(env.sync));
71
- };
72
- }
73
- return TelemetryPluginChain;
74
- }());
75
- export { TelemetryPluginChain };
76
- //# sourceMappingURL=TelemetryPluginChain.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TelemetryPluginChain.js.map","sources":["TelemetryPluginChain.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\"use strict\";\r\nimport { doPerf } from \"./PerfManager\";\r\nimport { LoggingSeverity, _InternalMessageId } from \"../JavaScriptSDK.Enums/LoggingEnums\";\r\nimport { isFunction } from \"./HelperFuncs\";\r\nimport { dumpObj } from \"./EnvUtils\";\r\nvar TelemetryPluginChain = /** @class */ (function () {\r\n function TelemetryPluginChain(plugin, defItemCtx) {\r\n var _self = this;\r\n var _nextProxy = null;\r\n var _hasProcessTelemetry = isFunction(plugin.processTelemetry);\r\n var _hasSetNext = isFunction(plugin.setNextPlugin);\r\n _self._hasRun = false;\r\n _self.getPlugin = function () {\r\n return plugin;\r\n };\r\n _self.getNext = function () {\r\n return _nextProxy;\r\n };\r\n _self.setNext = function (nextPlugin) {\r\n _nextProxy = nextPlugin;\r\n };\r\n _self.processTelemetry = function (env, itemCtx) {\r\n if (!itemCtx) {\r\n // Looks like a plugin didn't pass the (optional) context, so restore to the default\r\n itemCtx = defItemCtx;\r\n }\r\n var identifier = plugin ? plugin.identifier : \"TelemetryPluginChain\";\r\n doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + \":processTelemetry\"; }, function () {\r\n if (plugin && _hasProcessTelemetry) {\r\n _self._hasRun = true;\r\n try {\r\n // Ensure that we keep the context in sync (for processNext()), just in case a plugin\r\n // doesn't calls processTelemetry() instead of itemContext.processNext() or some\r\n // other form of error occurred\r\n itemCtx.setNext(_nextProxy);\r\n if (_hasSetNext) {\r\n // Backward compatibility setting the next plugin on the instance\r\n plugin.setNextPlugin(_nextProxy);\r\n }\r\n // Set a flag on the next plugin so we know if it was attempted to be executed\r\n _nextProxy && (_nextProxy._hasRun = false);\r\n plugin.processTelemetry(env, itemCtx);\r\n }\r\n catch (error) {\r\n var hasRun = _nextProxy && _nextProxy._hasRun;\r\n if (!_nextProxy || !hasRun) {\r\n // Either we have no next plugin or the current one did not attempt to call the next plugin\r\n // Which means the current one is the root of the failure so log/report this failure\r\n itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, \"Plugin [\" + plugin.identifier + \"] failed during processTelemetry - \" + dumpObj(error));\r\n }\r\n if (_nextProxy && !hasRun) {\r\n // As part of the failure the current plugin did not attempt to call the next plugin in the cahin\r\n // So rather than leave the pipeline dead in the water we call the next plugin\r\n _nextProxy.processTelemetry(env, itemCtx);\r\n }\r\n }\r\n }\r\n else if (_nextProxy) {\r\n _self._hasRun = true;\r\n // The underlying plugin is either not defined or does not have a processTelemetry implementation\r\n // so we still want the next plugin to be executed.\r\n _nextProxy.processTelemetry(env, itemCtx);\r\n }\r\n }, function () { return ({ item: env }); }, !(env.sync));\r\n };\r\n }\r\n return TelemetryPluginChain;\r\n}());\r\nexport { TelemetryPluginChain };\r\n//# sourceMappingURL=TelemetryPluginChain.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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,120 +0,0 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
- "use strict";
4
-
5
- import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
6
- import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
7
- import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
8
- import { ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
9
- import { _InternalLogMessage } from "./DiagnosticLogger";
10
- import { doPerf } from "./PerfManager";
11
- import { LoggingSeverity, _InternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
12
- import { isFunction } from "./HelperFuncs";
13
- import { dumpObj } from "./EnvUtils";
14
-
15
- export class TelemetryPluginChain implements ITelemetryPluginChain {
16
-
17
- /**
18
- * Returns the underlying plugin that is being proxied for the processTelemetry call
19
- */
20
- getPlugin: () => ITelemetryPlugin;
21
-
22
- /**
23
- * Returns the next plugin
24
- */
25
- getNext: () => ITelemetryPluginChain;
26
-
27
- /**
28
- * Sets the next proxy to be executed as the next plugin
29
- * (Should only be used during initialization, which is why it's not defined on the interface)
30
- */
31
- setNext: (nextPlugin:ITelemetryPluginChain) => void;
32
-
33
- /**
34
- * Call back for telemetry processing before it it is sent
35
- * @param env - This is the current event being reported
36
- * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
37
- * can optionally use this to access the current core instance or define / pass additional information
38
- * to later plugins (vs appending items to the telemetry item)
39
- */
40
- processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
41
-
42
- /**
43
- * Internal flag used to try and identify root cause failures
44
- */
45
- private _hasRun: boolean;
46
-
47
- constructor(plugin:ITelemetryPlugin, defItemCtx:IProcessTelemetryContext) {
48
- let _self = this;
49
- let _nextProxy:ITelemetryPluginChain = null;
50
- let _hasProcessTelemetry = isFunction(plugin.processTelemetry);
51
- let _hasSetNext = isFunction(plugin.setNextPlugin);
52
-
53
- _self._hasRun = false;
54
-
55
- _self.getPlugin = () => {
56
- return plugin;
57
- };
58
-
59
- _self.getNext = () => {
60
- return _nextProxy;
61
- };
62
-
63
- _self.setNext = (nextPlugin:ITelemetryPluginChain) => {
64
- _nextProxy = nextPlugin;
65
- }
66
-
67
- _self.processTelemetry = (env: ITelemetryItem, itemCtx:IProcessTelemetryContext) => {
68
- if (!itemCtx) {
69
- // Looks like a plugin didn't pass the (optional) context, so restore to the default
70
- itemCtx = defItemCtx;
71
- }
72
-
73
- let identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
74
-
75
- doPerf(itemCtx ? itemCtx.core() : null, () => identifier + ":processTelemetry", () => {
76
- if (plugin && _hasProcessTelemetry) {
77
- _self._hasRun = true;
78
- try {
79
-
80
- // Ensure that we keep the context in sync (for processNext()), just in case a plugin
81
- // doesn't calls processTelemetry() instead of itemContext.processNext() or some
82
- // other form of error occurred
83
- itemCtx.setNext(_nextProxy);
84
- if (_hasSetNext) {
85
- // Backward compatibility setting the next plugin on the instance
86
- plugin.setNextPlugin(_nextProxy);
87
- }
88
-
89
- // Set a flag on the next plugin so we know if it was attempted to be executed
90
- _nextProxy && ((_nextProxy as TelemetryPluginChain)._hasRun = false);
91
-
92
- plugin.processTelemetry(env, itemCtx);
93
- } catch (error) {
94
- let hasRun = _nextProxy && (_nextProxy as TelemetryPluginChain)._hasRun;
95
- if (!_nextProxy || !hasRun) {
96
- // Either we have no next plugin or the current one did not attempt to call the next plugin
97
- // Which means the current one is the root of the failure so log/report this failure
98
- itemCtx.diagLog().throwInternal(
99
- LoggingSeverity.CRITICAL,
100
- _InternalMessageId.PluginException,
101
- "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
102
- }
103
-
104
- if (_nextProxy && !hasRun) {
105
- // As part of the failure the current plugin did not attempt to call the next plugin in the cahin
106
- // So rather than leave the pipeline dead in the water we call the next plugin
107
- _nextProxy.processTelemetry(env, itemCtx);
108
- }
109
- }
110
- } else if (_nextProxy) {
111
- _self._hasRun = true;
112
-
113
- // The underlying plugin is either not defined or does not have a processTelemetry implementation
114
- // so we still want the next plugin to be executed.
115
- _nextProxy.processTelemetry(env, itemCtx);
116
- }
117
- }, () => ({ item: env }), !((env as any).sync));
118
- };
119
- }
120
- }
@@ -1,32 +0,0 @@
1
- import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
2
- import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
3
- import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
4
- import { ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
5
- export declare class TelemetryPluginChain implements ITelemetryPluginChain {
6
- /**
7
- * Returns the underlying plugin that is being proxied for the processTelemetry call
8
- */
9
- getPlugin: () => ITelemetryPlugin;
10
- /**
11
- * Returns the next plugin
12
- */
13
- getNext: () => ITelemetryPluginChain;
14
- /**
15
- * Sets the next proxy to be executed as the next plugin
16
- * (Should only be used during initialization, which is why it's not defined on the interface)
17
- */
18
- setNext: (nextPlugin: ITelemetryPluginChain) => void;
19
- /**
20
- * Call back for telemetry processing before it it is sent
21
- * @param env - This is the current event being reported
22
- * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
23
- * can optionally use this to access the current core instance or define / pass additional information
24
- * to later plugins (vs appending items to the telemetry item)
25
- */
26
- processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
27
- /**
28
- * Internal flag used to try and identify root cause failures
29
- */
30
- private _hasRun;
31
- constructor(plugin: ITelemetryPlugin, defItemCtx: IProcessTelemetryContext);
32
- }