@microsoft/applicationinsights-core-js 2.7.5-nightly.2203-03 → 2.7.5

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 (160) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +766 -1967
  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 +9840 -16439
  7. package/dist/applicationinsights-core-js.api.md +48 -425
  8. package/dist/applicationinsights-core-js.d.ts +123 -784
  9. package/dist/applicationinsights-core-js.js +766 -1967
  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 +123 -784
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +69 -3
  15. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  16. package/dist-esm/JavaScriptSDK/BaseCore.js +99 -496
  17. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +21 -120
  19. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  20. package/dist-esm/JavaScriptSDK/ChannelController.js +87 -202
  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 +4 -4
  24. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/CoreUtils.js +148 -7
  26. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  28. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +14 -27
  29. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  30. package/dist-esm/JavaScriptSDK/EnvUtils.js +12 -13
  31. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  32. package/dist-esm/JavaScriptSDK/HelperFuncs.js +86 -89
  33. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -3
  35. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  36. package/dist-esm/JavaScriptSDK/NotificationManager.js +42 -37
  37. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  38. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  39. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +119 -430
  40. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/RandomHelper.js +4 -30
  42. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +14 -60
  44. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +76 -0
  46. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +1 -0
  47. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  48. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +96 -90
  49. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  50. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  51. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +2 -1
  52. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js.map +1 -1
  53. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  54. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  55. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  57. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  60. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +2 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js.map +1 -1
  68. package/dist-esm/applicationinsights-core-js.js +7 -12
  69. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  70. package/package.json +67 -70
  71. package/src/JavaScriptSDK/AppInsightsCore.ts +101 -2
  72. package/src/JavaScriptSDK/BaseCore.ts +120 -696
  73. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +31 -205
  74. package/src/JavaScriptSDK/ChannelController.ts +103 -242
  75. package/src/JavaScriptSDK/CookieMgr.ts +5 -7
  76. package/src/JavaScriptSDK/CoreUtils.ts +172 -8
  77. package/src/JavaScriptSDK/DiagnosticLogger.ts +14 -29
  78. package/src/JavaScriptSDK/EnvUtils.ts +12 -13
  79. package/src/JavaScriptSDK/HelperFuncs.ts +97 -123
  80. package/src/JavaScriptSDK/InstrumentHooks.ts +2 -4
  81. package/src/JavaScriptSDK/NotificationManager.ts +37 -34
  82. package/src/JavaScriptSDK/PerfManager.ts +7 -4
  83. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +134 -543
  84. package/src/JavaScriptSDK/RandomHelper.ts +3 -35
  85. package/src/JavaScriptSDK/TelemetryHelpers.ts +21 -83
  86. package/src/JavaScriptSDK/TelemetryPluginChain.ts +120 -0
  87. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +87 -184
  88. package/src/JavaScriptSDK.Enums/SendRequestReason.ts +0 -5
  89. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +2 -82
  90. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +5 -16
  91. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +6 -16
  92. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +14 -94
  93. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +10 -28
  94. package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +11 -9
  95. package/types/JavaScriptSDK/AppInsightsCore.d.ts +21 -0
  96. package/types/JavaScriptSDK/BaseCore.d.ts +3 -81
  97. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +10 -53
  98. package/types/JavaScriptSDK/ChannelController.d.ts +17 -16
  99. package/types/JavaScriptSDK/CoreUtils.d.ts +48 -1
  100. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +0 -10
  101. package/types/JavaScriptSDK/HelperFuncs.d.ts +32 -33
  102. package/types/JavaScriptSDK/PerfManager.d.ts +1 -1
  103. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +6 -69
  104. package/types/JavaScriptSDK/RandomHelper.d.ts +0 -6
  105. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +3 -23
  106. package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +32 -0
  107. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +2 -91
  108. package/types/JavaScriptSDK.Enums/SendRequestReason.d.ts +0 -4
  109. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +1 -72
  110. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +5 -16
  111. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +0 -9
  112. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +11 -82
  113. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +8 -25
  114. package/types/JavaScriptSDK.Interfaces/ITelemetryPluginChain.d.ts +10 -9
  115. package/types/applicationinsights-core-js.d.ts +9 -18
  116. package/types/tsdoc-metadata.json +1 -1
  117. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +0 -93
  118. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +0 -1
  119. package/dist-esm/JavaScriptSDK/EventHelpers.js +0 -477
  120. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +0 -1
  121. package/dist-esm/JavaScriptSDK/InternalConstants.js +0 -28
  122. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +0 -1
  123. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +0 -81
  124. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +0 -1
  125. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +0 -33
  126. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +0 -1
  127. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +0 -8
  128. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js.map +0 -1
  129. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +0 -8
  130. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +0 -1
  131. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +0 -6
  132. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +0 -1
  133. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +0 -8
  134. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js.map +0 -1
  135. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +0 -8
  136. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +0 -1
  137. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +0 -6
  138. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +0 -1
  139. package/src/JavaScriptSDK/DataCacheHelper.ts +0 -106
  140. package/src/JavaScriptSDK/EventHelpers.ts +0 -550
  141. package/src/JavaScriptSDK/InternalConstants.ts +0 -26
  142. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +0 -111
  143. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +0 -46
  144. package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +0 -27
  145. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +0 -27
  146. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +0 -16
  147. package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +0 -10
  148. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +0 -34
  149. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +0 -17
  150. package/types/JavaScriptSDK/DataCacheHelper.d.ts +0 -13
  151. package/types/JavaScriptSDK/EventHelpers.d.ts +0 -154
  152. package/types/JavaScriptSDK/InternalConstants.d.ts +0 -20
  153. package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +0 -16
  154. package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +0 -11
  155. package/types/JavaScriptSDK.Enums/TelemetryUnloadReason.d.ts +0 -21
  156. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +0 -20
  157. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +0 -13
  158. package/types/JavaScriptSDK.Interfaces/ITelemetryUnloadState.d.ts +0 -6
  159. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +0 -22
  160. package/types/JavaScriptSDK.Interfaces/IUnloadableComponent.d.ts +0 -13
@@ -2,7 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  import { ITelemetryItem } from "./ITelemetryItem";
4
4
  import { IChannelControls } from "./IChannelControls";
5
- import { IPlugin, ITelemetryPlugin } from "./ITelemetryPlugin";
5
+ import { IPlugin } from "./ITelemetryPlugin";
6
6
  import { IConfiguration } from "./IConfiguration";
7
7
  import { INotificationManager } from "./INotificationManager";
8
8
  import { INotificationListener } from "./INotificationListener";
@@ -10,31 +10,8 @@ import { IDiagnosticLogger } from "./IDiagnosticLogger";
10
10
  import { IProcessTelemetryContext } from "./IProcessTelemetryContext";
11
11
  import { IPerfManagerProvider } from "./IPerfManager";
12
12
  import { ICookieMgr } from "./ICookieMgr";
13
- import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "./ITelemetryInitializers";
14
- import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
15
- import { UnloadHandler } from "../JavaScriptSDK/UnloadHandlerContainer";
16
- import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
17
13
 
18
- export interface ILoadedPlugin<T extends IPlugin> {
19
- plugin: T;
20
-
21
- /**
22
- * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
23
- * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
24
- * @returns boolean = true if the plugin is in a state where it is operational.
25
- */
26
- isEnabled: () => boolean;
27
-
28
- /**
29
- * You can optionally enable / disable a plugin from processing events.
30
- * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
31
- * as the plugin must also have been successfully initialized and not had it's `teardown` method called
32
- * (unless it's also been re-initialized)
33
- */
34
- setEnabled: (isEnabled: boolean) => void;
35
-
36
- remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
37
- }
14
+ "use strict";
38
15
 
39
16
  export interface IAppInsightsCore extends IPerfManagerProvider {
40
17
 
@@ -95,13 +72,6 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
95
72
  */
96
73
  removeNotificationListener?(listener: INotificationListener): void;
97
74
 
98
- /**
99
- * Add a telemetry processor to decorate or drop telemetry events.
100
- * @param telemetryInitializer - The Telemetry Initializer function
101
- * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
102
- */
103
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
104
-
105
75
  pollInternalLogs?(eventName?: string): number;
106
76
 
107
77
  stopPollingInternalLogs?(): void;
@@ -110,54 +80,4 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
110
80
  * Return a new instance of the IProcessTelemetryContext for processing events
111
81
  */
112
82
  getProcessTelContext() : IProcessTelemetryContext;
113
-
114
- /**
115
- * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
116
- * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
117
- * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
118
- * approach is to create a new instance and initialize that instance.
119
- * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
120
- * to successfully remove any global references or they may just be completing the unload process asynchronously.
121
- * @param isAsync - Can the unload be performed asynchronously (default)
122
- * @param unloadComplete - An optional callback that will be called once the unload has completed
123
- * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
124
- */
125
- unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
126
-
127
- /**
128
- * Find and return the (first) plugin with the specified identifier if present
129
- * @param pluginIdentifier
130
- */
131
- getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
132
-
133
- /**
134
- * Add a new plugin to the installation
135
- * @param plugin - The new plugin to add
136
- * @param replaceExisting - should any existing plugin be replaced, default is false
137
- * @param doAsync - Should the add be performed asynchronously
138
- * @param addCb - [Optional] callback to call after the plugin has been added
139
- */
140
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
141
-
142
- /**
143
- * Returns the unique event namespace that should be used when registering events
144
- */
145
- evtNamespace(): string;
146
-
147
- /**
148
- * Add a handler that will be called when the SDK is being unloaded
149
- * @param handler - the handler
150
- */
151
- addUnloadCb(handler: UnloadHandler): void;
152
-
153
- /**
154
- * Flush and send any batched / cached data immediately
155
- * @param async - send data asynchronously when true (defaults to true)
156
- * @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.
157
- * If the caller doesn't return true the caller should assume that it may never be called.
158
- * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
159
- * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
160
- * @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
161
- */
162
- flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
163
83
  }
@@ -1,9 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
- import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
4
- import { IProcessTelemetryUnloadContext } from "./IProcessTelemetryContext";
5
3
  import { ITelemetryPlugin } from "./ITelemetryPlugin";
6
- import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
7
4
 
8
5
  "use strict";
9
6
 
@@ -23,24 +20,16 @@ export interface IChannelControls extends ITelemetryPlugin {
23
20
  resume(): void;
24
21
 
25
22
  /**
26
- * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
27
- * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
28
- * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
29
- * @param unloadCtx - This is the context that should be used during unloading.
30
- * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
31
- * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
23
+ * Tear down transmission pipeline
32
24
  */
33
- teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
25
+ teardown(): void;
34
26
 
35
27
  /**
36
28
  * Flush to send data immediately; channel should default to sending data asynchronously
37
- * @param async - send data asynchronously when true
38
- * @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.
39
- * If the caller doesn't return true the caller should assume that it may never be called.
40
- * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
41
- * @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
29
+ * @param async: send data asynchronously when true
30
+ * @param callBack: if specified, notify caller when send is complete
42
31
  */
43
- flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
32
+ flush(async: boolean, callBack?: () => void): void;
44
33
  }
45
34
 
46
35
  export const MinChannelPriorty: number = 100;
@@ -12,11 +12,6 @@ export type InstrumentorHooksCallback = (funcArgs:IInstrumentCallDetails, ...org
12
12
  * You must always supply the error callback
13
13
  */
14
14
  export interface IInstrumentHooksCallbacks {
15
- /**
16
- * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
17
- * identify the source of the instrumented hooks
18
- */
19
- ns?: string | string[];
20
15
 
21
16
  /**
22
17
  * The hook callback to call before the original function is called
@@ -45,20 +40,20 @@ export interface IInstrumentHooksCallbacks {
45
40
  */
46
41
  export interface IInstrumentHook {
47
42
  /** Unique Id for this callback on the hooked method */
48
- id: number;
43
+ id:number;
49
44
 
50
45
  /** Holds the callbacks */
51
- cbks: IInstrumentHooksCallbacks;
46
+ cbks:IInstrumentHooksCallbacks;
52
47
 
53
48
  /** Remove this hook from the function */
54
49
  rm: () => void;
55
50
  }
56
51
 
57
52
  export interface IInstrumentHooks {
58
- i: number; // Used to create unique ids
59
- n: string; // Function name
60
- f: any; // Original Function
61
- h: IInstrumentHook[]; // The hook
53
+ i:number; // Used to create unique ids
54
+ n:string; // Function name
55
+ f:any; // Original Function
56
+ h:IInstrumentHook[]; // The hook
62
57
  }
63
58
 
64
59
  export interface IInstrumentCallDetails {
@@ -90,9 +85,4 @@ export interface IInstrumentCallDetails {
90
85
  * The error (exception) which occurred while executing the original method
91
86
  */
92
87
  err?: Error;
93
-
94
- /**
95
- * The Event object from (window.event) at the start of the original call
96
- */
97
- evt?: Event;
98
88
  }
@@ -3,21 +3,17 @@
3
3
  "use strict";
4
4
 
5
5
  import { IAppInsightsCore } from "./IAppInsightsCore";
6
- import { IConfiguration } from "./IConfiguration";
7
6
  import { IDiagnosticLogger } from "./IDiagnosticLogger";
7
+ import { IConfiguration } from "./IConfiguration";
8
8
  import { ITelemetryItem } from "./ITelemetryItem";
9
- import { IPlugin, ITelemetryPlugin } from "./ITelemetryPlugin";
9
+ import { IPlugin } from "./ITelemetryPlugin";
10
10
  import { ITelemetryPluginChain } from "./ITelemetryPluginChain";
11
- import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
12
- import { ITelemetryUpdateState } from "./ITelemetryUpdateState";
13
-
14
- export const enum GetExtCfgMergeType {
15
- None = 0,
16
- MergeDefaultOnly = 1,
17
- MergeDefaultFromRootOrDefault = 2,
18
- }
19
11
 
20
- export interface IBaseProcessingContext {
12
+ /**
13
+ * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
14
+ * between multiple AppInsights instances
15
+ */
16
+ export interface IProcessTelemetryContext {
21
17
  /**
22
18
  * The current core instance for the request
23
19
  */
@@ -31,12 +27,12 @@ export interface IBaseProcessingContext {
31
27
  /**
32
28
  * Gets the current core config instance
33
29
  */
34
- getCfg: () => IConfiguration;
30
+ getCfg: ()=> IConfiguration;
35
31
 
36
32
  /**
37
33
  * Gets the named extension config
38
34
  */
39
- getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
35
+ getExtCfg: <T>(identifier: string, defaultValue?:T|any) => T;
40
36
 
41
37
  /**
42
38
  * Gets the named config from either the named identifier extension or core config if neither exist then the
@@ -45,7 +41,7 @@ export interface IBaseProcessingContext {
45
41
  * @param field The config field name
46
42
  * @param defaultValue The default value to return if no defined config exists
47
43
  */
48
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
44
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
49
45
 
50
46
  /**
51
47
  * Helper to allow plugins to check and possibly shortcut executing code only
@@ -61,96 +57,20 @@ export interface IBaseProcessingContext {
61
57
  /**
62
58
  * Helper to set the next plugin proxy
63
59
  */
64
- setNext: (nextCtx: ITelemetryPluginChain) => void;
65
-
66
- /**
67
- * Synchronously iterate over the context chain running the callback for each plugin, once
68
- * every plugin has been executed via the callback, any associated onComplete will be called.
69
- * @param callback - The function call for each plugin in the context chain
70
- */
71
- iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
72
-
73
- /**
74
- * Set the function to call when the current chain has executed all processNext or unloadNext items.
75
- * @param onComplete - The onComplete to call
76
- * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
77
- * @param args - Any additional arguments to pass to the onComplete function
78
- */
79
- onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
60
+ setNext: (nextCtx:ITelemetryPluginChain) => void;
80
61
 
81
- /**
82
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
83
- * @param plugins - The execution order to process the plugins, if null or not supplied
84
- * then the current execution order will be copied.
85
- * @param startAt - The plugin to start processing from, if missing from the execution
86
- * order then the next plugin will be NOT set.
87
- */
88
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
89
- }
90
-
91
- /**
92
- * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
93
- * between multiple AppInsights instances
94
- */
95
- export interface IProcessTelemetryContext extends IBaseProcessingContext {
96
62
  /**
97
63
  * Call back for telemetry processing before it it is sent
98
64
  * @param env - This is the current event being reported
99
- * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
100
- */
101
- processNext: (env: ITelemetryItem) => boolean | void;
102
-
103
- /**
104
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
105
- * @param plugins - The execution order to process the plugins, if null or not supplied
106
- * then the current execution order will be copied.
107
- * @param startAt - The plugin to start processing from, if missing from the execution
108
- * order then the next plugin will be NOT set.
109
- */
110
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
111
- }
112
-
113
- /**
114
- * The current context for the current call to teardown() implementations, used to support when plugins are being removed
115
- * or the SDK is being unloaded.
116
- */
117
- export interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
118
-
119
- /**
120
- * This Plugin has finished unloading, so unload the next one
121
- * @param uploadState - The state of the unload process
122
- * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
123
- */
124
- processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
125
-
126
- /**
127
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
128
- * @param plugins - The execution order to process the plugins, if null or not supplied
129
- * then the current execution order will be copied.
130
- * @param startAt - The plugin to start processing from, if missing from the execution
131
- * order then the next plugin will be NOT set.
132
- */
133
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
134
- }
135
-
136
- /**
137
- * The current context for the current call to the plugin update() implementations, used to support the notifications
138
- * for when plugins are added, removed or the configuration was changed.
139
- */
140
- export interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
141
- /**
142
- * This Plugin has finished unloading, so unload the next one
143
- * @param updateState - The update State
144
- * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
145
65
  */
146
- processNext: (updateState: ITelemetryUpdateState) => boolean | void;
66
+ processNext: (env: ITelemetryItem) => void;
147
67
 
148
68
  /**
149
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
69
+ * Create a new context using the core and config from the current instance
150
70
  * @param plugins - The execution order to process the plugins, if null or not supplied
151
71
  * then the current execution order will be copied.
152
72
  * @param startAt - The plugin to start processing from, if missing from the execution
153
73
  * order then the next plugin will be NOT set.
154
74
  */
155
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
75
+ createNew: (plugins?:IPlugin[]|ITelemetryPluginChain, startAt?:IPlugin) => IProcessTelemetryContext;
156
76
  }
@@ -5,12 +5,13 @@
5
5
  import { ITelemetryItem } from "./ITelemetryItem";
6
6
  import { IConfiguration } from "./IConfiguration";
7
7
  import { IAppInsightsCore } from "./IAppInsightsCore";
8
- import { IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "./IProcessTelemetryContext";
8
+ import { IProcessTelemetryContext } from "./IProcessTelemetryContext";
9
9
  import { ITelemetryPluginChain } from "./ITelemetryPluginChain";
10
- import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
11
- import { ITelemetryUpdateState } from "./ITelemetryUpdateState";
12
10
 
13
- export interface ITelemetryProcessor {
11
+ /**
12
+ * Configuration provided to SDK core
13
+ */
14
+ export interface ITelemetryPlugin extends IPlugin {
14
15
  /**
15
16
  * Call back for telemetry processing before it it is sent
16
17
  * @param env - This is the current event being reported
@@ -19,22 +20,7 @@ export interface ITelemetryProcessor {
19
20
  * to later plugins (vs appending items to the telemetry item)
20
21
  */
21
22
  processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
22
-
23
- /**
24
- * The the plugin should re-evaluate configuration and update any cached configuration settings or
25
- * plugins. If implemented this method will be called whenever a plugin is added or removed and if
26
- * the configuration has bee updated.
27
- * @param updateCtx - This is the context that should be used during updating.
28
- * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
29
- * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
30
- */
31
- update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
32
- }
33
-
34
- /**
35
- * Configuration provided to SDK core
36
- */
37
- export interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
23
+
38
24
  /**
39
25
  * Set next extension for telemetry processing, this is not optional as plugins should use the
40
26
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
@@ -57,7 +43,7 @@ export interface IPlugin {
57
43
  * @param pluginChain - [Optional] specifies the current plugin chain which identifies the
58
44
  * set of plugins and the order they should be executed for the current request.
59
45
  */
60
- initialize: (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain) => void;
46
+ initialize: (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) => void;
61
47
 
62
48
  /**
63
49
  * Returns a value that indicates whether the plugin has already been previously initialized.
@@ -66,14 +52,10 @@ export interface IPlugin {
66
52
  isInitialized?: () => boolean;
67
53
 
68
54
  /**
69
- * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
70
- * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
71
- * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
72
- * @param unloadCtx - This is the context that should be used during unloading.
73
- * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
74
- * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
55
+ * Tear down the plugin and remove any hooked value, the plugin should remove that it is no longer initialized and
56
+ * therefore can be re-initialized after being torn down.
75
57
  */
76
- teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
58
+ teardown?: () => void;
77
59
 
78
60
  /**
79
61
  * Extension name
@@ -1,14 +1,15 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
+ "use strict";
3
4
 
4
- import { IProcessTelemetryUnloadContext } from "./IProcessTelemetryContext";
5
- import { ITelemetryPlugin, ITelemetryProcessor } from "./ITelemetryPlugin";
6
- import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
5
+ import { ITelemetryItem } from "./ITelemetryItem";
6
+ import { IProcessTelemetryContext } from "./IProcessTelemetryContext";
7
+ import { ITelemetryPlugin } from "./ITelemetryPlugin";
7
8
 
8
9
  /**
9
10
  * Configuration provided to SDK core
10
11
  */
11
- export interface ITelemetryPluginChain extends ITelemetryProcessor {
12
+ export interface ITelemetryPluginChain {
12
13
 
13
14
  /**
14
15
  * Returns the underlying plugin that is being proxied for the processTelemetry call
@@ -21,10 +22,11 @@ export interface ITelemetryPluginChain extends ITelemetryProcessor {
21
22
  getNext: () => ITelemetryPluginChain;
22
23
 
23
24
  /**
24
- * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
25
- * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
26
- * @param unloadCtx - The unload context to use for this call.
27
- * @param unloadState - The details of the unload operation
25
+ * Call back for telemetry processing before it it is sent
26
+ * @param env - This is the current event being reported
27
+ * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
28
+ * can optionally use this to access the current core instance or define / pass additional information
29
+ * to later plugins (vs appending items to the telemetry item)
28
30
  */
29
- unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
31
+ processTelemetry: (env: ITelemetryItem, itemCtx:IProcessTelemetryContext) => void;
30
32
  }
@@ -3,10 +3,31 @@ import { BaseCore } from "./BaseCore";
3
3
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
4
4
  import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
5
5
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
6
+ import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
6
7
  import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
7
8
  import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
8
9
  export declare class AppInsightsCore extends BaseCore implements IAppInsightsCore {
9
10
  constructor();
10
11
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
11
12
  track(telemetryItem: ITelemetryItem): void;
13
+ /**
14
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
15
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
16
+ * called.
17
+ * @param {INotificationListener} listener - An INotificationListener object.
18
+ */
19
+ addNotificationListener(listener: INotificationListener): void;
20
+ /**
21
+ * Removes all instances of the listener.
22
+ * @param {INotificationListener} listener - INotificationListener to remove.
23
+ */
24
+ removeNotificationListener(listener: INotificationListener): void;
25
+ /**
26
+ * Periodically check logger.queue for
27
+ */
28
+ pollInternalLogs(eventName?: string): number;
29
+ /**
30
+ * Periodically check logger.queue for
31
+ */
32
+ stopPollingInternalLogs(): void;
12
33
  }
@@ -1,19 +1,13 @@
1
- import { IAppInsightsCore, ILoadedPlugin } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
1
+ import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
2
2
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
3
- import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
3
+ import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
4
4
  import { IChannelControls } from "../JavaScriptSDK.Interfaces/IChannelControls";
5
5
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
6
6
  import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
7
- import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
8
7
  import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
9
- import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
8
+ import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
10
9
  import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager";
11
10
  import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
12
- import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../JavaScriptSDK.Interfaces/ITelemetryInitializers";
13
- import { UnloadHandler } from "./UnloadHandlerContainer";
14
- import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
15
- import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
16
- import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
17
11
  export declare class BaseCore implements IAppInsightsCore {
18
12
  static defaultConfig: IConfiguration;
19
13
  config: IConfiguration;
@@ -26,18 +20,6 @@ export declare class BaseCore implements IAppInsightsCore {
26
20
  track(telemetryItem: ITelemetryItem): void;
27
21
  getProcessTelContext(): IProcessTelemetryContext;
28
22
  getNotifyMgr(): INotificationManager;
29
- /**
30
- * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
31
- * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
32
- * called.
33
- * @param {INotificationListener} listener - An INotificationListener object.
34
- */
35
- addNotificationListener(listener: INotificationListener): void;
36
- /**
37
- * Removes all instances of the listener.
38
- * @param {INotificationListener} listener - INotificationListener to remove.
39
- */
40
- removeNotificationListener(listener: INotificationListener): void;
41
23
  /**
42
24
  * Get the current cookie manager for this instance
43
25
  */
@@ -50,65 +32,5 @@ export declare class BaseCore implements IAppInsightsCore {
50
32
  getPerfMgr(): IPerfManager;
51
33
  setPerfMgr(perfMgr: IPerfManager): void;
52
34
  eventCnt(): number;
53
- /**
54
- * Periodically check logger.queue for
55
- */
56
- pollInternalLogs(eventName?: string): number;
57
- /**
58
- * Periodically check logger.queue for
59
- */
60
- stopPollingInternalLogs(): void;
61
- /**
62
- * Add a telemetry processor to decorate or drop telemetry events.
63
- * @param telemetryInitializer - The Telemetry Initializer function
64
- * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
65
- */
66
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
67
- /**
68
- * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
69
- * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
70
- * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
71
- * approach is to create a new instance and initialize that instance.
72
- * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
73
- * to successfully remove any global references or they may just be completing the unload process asynchronously.
74
- * @param isAsync - Can the unload be performed asynchronously (default)
75
- * @param unloadComplete - An optional callback that will be called once the unload has completed
76
- * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
77
- */
78
- unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
79
- getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
80
- /**
81
- * Add a new plugin to the installation
82
- * @param plugin - The new plugin to add
83
- * @param replaceExisting - should any existing plugin be replaced, default is false
84
- * @param doAsync - Should the add be performed asynchronously
85
- * @param addCb - [Optional] callback to call after the plugin has been added
86
- */
87
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
88
- /**
89
- * Returns the unique event namespace that should be used
90
- */
91
- evtNamespace(): string;
92
- /**
93
- * Add an unload handler that will be called when the SDK is being unloaded
94
- * @param handler - the handler
95
- */
96
- addUnloadCb(handler: UnloadHandler): void;
97
- /**
98
- * Flush and send any batched / cached data immediately
99
- * @param async - send data asynchronously when true (defaults to true)
100
- * @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.
101
- * If the caller doesn't return true the caller should assume that it may never be called.
102
- * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
103
- * @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
104
- */
105
- flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void;
106
35
  protected releaseQueue(): void;
107
- /**
108
- * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
109
- * @param updateCtx - The plugin update context
110
- * @param updateState - The Update State
111
- * @returns boolean - True means the extension class will call updateState otherwise the Core will
112
- */
113
- protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
114
36
  }