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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +1999 -793
  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 +15679 -8835
  7. package/dist/applicationinsights-core-js.api.md +425 -48
  8. package/dist/applicationinsights-core-js.d.ts +784 -123
  9. package/dist/applicationinsights-core-js.js +1999 -793
  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 +784 -123
  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 +496 -99
  17. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +120 -21
  19. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  20. package/dist-esm/JavaScriptSDK/ChannelController.js +202 -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 +4 -4
  24. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/CoreUtils.js +7 -148
  26. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +93 -0
  28. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -0
  29. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  30. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +25 -12
  31. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  32. package/dist-esm/JavaScriptSDK/EnvUtils.js +13 -12
  33. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/EventHelpers.js +477 -0
  35. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -0
  36. package/dist-esm/JavaScriptSDK/HelperFuncs.js +89 -86
  37. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  38. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +3 -1
  39. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  40. package/dist-esm/JavaScriptSDK/InternalConstants.js +28 -0
  41. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -0
  42. package/dist-esm/JavaScriptSDK/NotificationManager.js +37 -42
  43. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  44. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  45. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +430 -119
  46. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  47. package/dist-esm/JavaScriptSDK/RandomHelper.js +30 -4
  48. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  49. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +60 -14
  50. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  51. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +81 -0
  52. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -0
  53. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +33 -0
  54. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -0
  55. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +90 -96
  57. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  58. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +8 -0
  60. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js.map +1 -0
  61. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +8 -0
  62. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +1 -0
  63. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -2
  64. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js.map +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  70. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +6 -0
  77. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +1 -0
  78. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -2
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js.map +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +8 -0
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js.map +1 -0
  84. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +8 -0
  85. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +1 -0
  86. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +6 -0
  87. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +1 -0
  88. package/dist-esm/applicationinsights-core-js.js +12 -7
  89. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  90. package/package.json +2 -2
  91. package/src/JavaScriptSDK/AppInsightsCore.ts +2 -101
  92. package/src/JavaScriptSDK/BaseCore.ts +696 -120
  93. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +205 -31
  94. package/src/JavaScriptSDK/ChannelController.ts +242 -103
  95. package/src/JavaScriptSDK/CookieMgr.ts +7 -5
  96. package/src/JavaScriptSDK/CoreUtils.ts +8 -172
  97. package/src/JavaScriptSDK/DataCacheHelper.ts +106 -0
  98. package/src/JavaScriptSDK/DiagnosticLogger.ts +27 -12
  99. package/src/JavaScriptSDK/EnvUtils.ts +13 -12
  100. package/src/JavaScriptSDK/EventHelpers.ts +550 -0
  101. package/src/JavaScriptSDK/HelperFuncs.ts +123 -97
  102. package/src/JavaScriptSDK/InstrumentHooks.ts +4 -2
  103. package/src/JavaScriptSDK/InternalConstants.ts +26 -0
  104. package/src/JavaScriptSDK/NotificationManager.ts +34 -37
  105. package/src/JavaScriptSDK/PerfManager.ts +4 -7
  106. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +543 -134
  107. package/src/JavaScriptSDK/RandomHelper.ts +35 -3
  108. package/src/JavaScriptSDK/TelemetryHelpers.ts +83 -21
  109. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +111 -0
  110. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +46 -0
  111. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +184 -87
  112. package/src/JavaScriptSDK.Enums/SendRequestReason.ts +5 -0
  113. package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +27 -0
  114. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +27 -0
  115. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +82 -2
  116. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +16 -5
  117. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +16 -6
  118. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +94 -14
  119. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +16 -0
  120. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +28 -10
  121. package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +9 -11
  122. package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +10 -0
  123. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +34 -0
  124. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +17 -0
  125. package/types/JavaScriptSDK/AppInsightsCore.d.ts +0 -21
  126. package/types/JavaScriptSDK/BaseCore.d.ts +81 -3
  127. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +53 -10
  128. package/types/JavaScriptSDK/ChannelController.d.ts +16 -17
  129. package/types/JavaScriptSDK/CoreUtils.d.ts +1 -48
  130. package/types/JavaScriptSDK/DataCacheHelper.d.ts +13 -0
  131. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +10 -0
  132. package/types/JavaScriptSDK/EventHelpers.d.ts +154 -0
  133. package/types/JavaScriptSDK/HelperFuncs.d.ts +33 -32
  134. package/types/JavaScriptSDK/InternalConstants.d.ts +20 -0
  135. package/types/JavaScriptSDK/PerfManager.d.ts +1 -1
  136. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +69 -6
  137. package/types/JavaScriptSDK/RandomHelper.d.ts +6 -0
  138. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +23 -3
  139. package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +16 -0
  140. package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +11 -0
  141. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +91 -2
  142. package/types/JavaScriptSDK.Enums/SendRequestReason.d.ts +4 -0
  143. package/types/JavaScriptSDK.Enums/TelemetryUnloadReason.d.ts +21 -0
  144. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +20 -0
  145. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +72 -1
  146. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +16 -5
  147. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +9 -0
  148. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +82 -11
  149. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +13 -0
  150. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +25 -8
  151. package/types/JavaScriptSDK.Interfaces/ITelemetryPluginChain.d.ts +9 -10
  152. package/types/JavaScriptSDK.Interfaces/ITelemetryUnloadState.d.ts +6 -0
  153. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +22 -0
  154. package/types/JavaScriptSDK.Interfaces/IUnloadableComponent.d.ts +13 -0
  155. package/types/applicationinsights-core-js.d.ts +18 -9
  156. package/types/tsdoc-metadata.json +1 -1
  157. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +0 -76
  158. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +0 -1
  159. package/src/JavaScriptSDK/TelemetryPluginChain.ts +0 -120
  160. package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +0 -32
@@ -0,0 +1,20 @@
1
+ export declare const strEmpty = "";
2
+ export declare const strProcessTelemetry = "processTelemetry";
3
+ export declare const strPriority = "priority";
4
+ export declare const strSetNextPlugin = "setNextPlugin";
5
+ export declare const strIsInitialized = "isInitialized";
6
+ export declare const strTeardown = "teardown";
7
+ export declare const strCore = "core";
8
+ export declare const strUpdate = "update";
9
+ export declare const strDisabled = "disabled";
10
+ export declare const strDoTeardown = "_doTeardown";
11
+ export declare const strProcessNext = "processNext";
12
+ export declare const strResume = "resume";
13
+ export declare const strPause = "pause";
14
+ export declare const strNotificationListener = "NotificationListener";
15
+ export declare const strAddNotificationListener: string;
16
+ export declare const strRemoveNotificationListener: string;
17
+ export declare const strEventsSent = "eventsSent";
18
+ export declare const strEventsDiscarded = "eventsDiscarded";
19
+ export declare const strEventsSendRequest = "eventsSendRequest";
20
+ export declare const strPerfEvent = "perfEvent";
@@ -46,7 +46,7 @@ export declare class PerfManager implements IPerfManager {
46
46
  * Defined as private so it can be visualized via the DebugPlugin
47
47
  */
48
48
  private ctx;
49
- constructor(manager: INotificationManager);
49
+ constructor(manager?: INotificationManager);
50
50
  /**
51
51
  * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
52
52
  * want to monitor this source event.
@@ -1,17 +1,65 @@
1
1
  import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
2
- import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
3
2
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
4
3
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
5
- import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
6
- import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
4
+ import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
5
+ import { IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
7
6
  import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
7
+ import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
8
+ /**
9
+ * Creates a new Telemetry Item context with the current config, core and plugin execution chain
10
+ * @param plugins - The plugin instances that will be executed
11
+ * @param config - The current config
12
+ * @param core - The current core instance
13
+ * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
14
+ */
15
+ export declare function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain | null, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext;
16
+ /**
17
+ * Creates a new Telemetry Item context with the current config, core and plugin execution chain for handling the unloading of the chain
18
+ * @param plugins - The plugin instances that will be executed
19
+ * @param config - The current config
20
+ * @param core - The current core instance
21
+ * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
22
+ */
23
+ export declare function createProcessTelemetryUnloadContext(telemetryChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryUnloadContext;
24
+ /**
25
+ * Creates a new Telemetry Item context with the current config, core and plugin execution chain for updating the configuration
26
+ * @param plugins - The plugin instances that will be executed
27
+ * @param config - The current config
28
+ * @param core - The current core instance
29
+ * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
30
+ */
31
+ export declare function createProcessTelemetryUpdateContext(telemetryChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryUpdateContext;
32
+ /**
33
+ * Creates an execution chain from the array of plugins
34
+ * @param plugins - The array of plugins that will be executed in this order
35
+ * @param defItemCtx - The default execution context to use when no telemetry context is passed to processTelemetry(), this
36
+ * should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error
37
+ * reporting (hasRun) when errors occur.
38
+ */
39
+ export declare function createTelemetryProxyChain(plugins: IPlugin[], config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): ITelemetryPluginChain;
40
+ /**
41
+ * Create the processing telemetry proxy instance, the proxy is used to abstract the current plugin to allow monitoring and
42
+ * execution plugins while passing around the dynamic execution state (IProcessTelemetryContext), the proxy instance no longer
43
+ * contains any execution state and can be reused between requests (this was not the case for 2.7.2 and earlier with the
44
+ * TelemetryPluginChain class).
45
+ * @param plugin - The plugin instance to proxy
46
+ * @param config - The default execution context to use when no telemetry context is passed to processTelemetry(), this
47
+ * should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error
48
+ * reporting (hasRun) when errors occur.
49
+ * @returns
50
+ */
51
+ export declare function createTelemetryPluginProxy(plugin: ITelemetryPlugin, config: IConfiguration, core: IAppInsightsCore): ITelemetryPluginChain;
52
+ /**
53
+ * This class will be removed!
54
+ * @deprecated use createProcessTelemetryContext() instead
55
+ */
8
56
  export declare class ProcessTelemetryContext implements IProcessTelemetryContext {
9
57
  /**
10
58
  * Gets the current core config instance
11
59
  */
12
60
  getCfg: () => IConfiguration;
13
61
  getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
14
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
62
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
15
63
  /**
16
64
  * Returns the IAppInsightsCore instance for the current request
17
65
  */
@@ -39,17 +87,32 @@ export declare class ProcessTelemetryContext implements IProcessTelemetryContext
39
87
  * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
40
88
  * can optionally use this to access the current core instance or define / pass additional information
41
89
  * to later plugins (vs appending items to the telemetry item)
90
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
91
+ */
92
+ processNext: (env: ITelemetryItem) => boolean | void;
93
+ /**
94
+ * Synchronously iterate over the context chain running the callback for each plugin, once
95
+ * every plugin has been executed via the callback, any associated onComplete will be called.
96
+ * @param callback - The function call for each plugin in the context chain
42
97
  */
43
- processNext: (env: ITelemetryItem) => void;
98
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
44
99
  /**
45
100
  * Create a new context using the core and config from the current instance
101
+ * @param plugins - The execution order to process the plugins, if null or not supplied
102
+ * then the current execution order will be copied.
103
+ * @param startAt - The plugin to start processing from, if missing from the execution
104
+ * order then the next plugin will be NOT set.
46
105
  */
47
106
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
107
+ /**
108
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
109
+ */
110
+ onComplete: (onComplete: () => void) => void;
48
111
  /**
49
112
  * Creates a new Telemetry Item context with the current config, core and plugin execution chain
50
113
  * @param plugins - The plugin instances that will be executed
51
114
  * @param config - The current config
52
115
  * @param core - The current core instance
53
116
  */
54
- constructor(plugins: IPlugin[] | ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin);
117
+ constructor(pluginChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin);
55
118
  }
@@ -21,3 +21,9 @@ export declare function mwcRandomSeed(value?: number): void;
21
21
  * @param signed - True to return a signed 32-bit number (-0x80000000..0x7FFFFFFF) otherwise an unsigned one (0x000000..0xFFFFFFFF)
22
22
  */
23
23
  export declare function mwcRandom32(signed?: boolean): number;
24
+ /**
25
+ * Generate random base64 id string.
26
+ * The default length is 22 which is 132-bits so almost the same as a GUID but as base64 (the previous default was 5)
27
+ * @param maxLength - Optional value to specify the length of the id to be generated, defaults to 22
28
+ */
29
+ export declare function newId(maxLength?: number): string;
@@ -1,5 +1,15 @@
1
1
  import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
2
- import { ProcessTelemetryContext } from "./ProcessTelemetryContext";
2
+ import { IProcessTelemetryContext, IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
3
+ import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
4
+ import { IUnloadableComponent } from "../JavaScriptSDK.Interfaces/IUnloadableComponent";
5
+ import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
6
+ export interface IPluginState {
7
+ core?: IAppInsightsCore;
8
+ isInitialized?: boolean;
9
+ tearDown?: boolean;
10
+ disabled?: boolean;
11
+ }
12
+ export declare function _getPluginState(plugin: IPlugin): IPluginState;
3
13
  /**
4
14
  * Initialize the queue of plugins
5
15
  * @param plugins - The array of plugins to initialize and setting of the next plugin
@@ -7,5 +17,15 @@ import { ProcessTelemetryContext } from "./ProcessTelemetryContext";
7
17
  * @param core THe current core instance
8
18
  * @param extensions The extensions
9
19
  */
10
- export declare function initializePlugins(processContext: ProcessTelemetryContext, extensions: IPlugin[]): void;
11
- export declare function sortPlugins(plugins: IPlugin[]): IPlugin[];
20
+ export declare function initializePlugins(processContext: IProcessTelemetryContext, extensions: IPlugin[]): void;
21
+ export declare function sortPlugins<T = IPlugin>(plugins: T[]): T[];
22
+ /**
23
+ * Teardown / Unload helper to perform teardown/unloading operations for the provided components synchronously or asynchronously, this will call any
24
+ * _doTeardown() or _doUnload() functions on the provided components to allow them to finish removal.
25
+ * @param components - The components you want to unload
26
+ * @param unloadCtx - This is the context that should be used during unloading.
27
+ * @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.
28
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async unload/teardown operations.
29
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
30
+ */
31
+ export declare function unloadComponents(components: any | IUnloadableComponent[], unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void): void | boolean;
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,11 @@
1
+ import { IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
2
+ import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
3
+ export declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
4
+ export interface IUnloadHandlerContainer {
5
+ add: (handler: UnloadHandler) => void;
6
+ run: (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
7
+ }
8
+ export declare function createUnloadHandlerContainer(): {
9
+ add: (handler: UnloadHandler) => void;
10
+ run: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
11
+ };
@@ -1,4 +1,4 @@
1
- export declare enum LoggingSeverity {
1
+ export declare const enum eLoggingSeverity {
2
2
  /**
3
3
  * Error will be sent as internal telemetry
4
4
  */
@@ -8,6 +8,95 @@ export declare enum LoggingSeverity {
8
8
  */
9
9
  WARNING = 2
10
10
  }
11
+ export declare const LoggingSeverity: {
12
+ CRITICAL: number;
13
+ WARNING: number;
14
+ };
15
+ export declare type LoggingSeverity = number | eLoggingSeverity;
16
+ export declare const enum _eInternalMessageId {
17
+ BrowserDoesNotSupportLocalStorage = 0,
18
+ BrowserCannotReadLocalStorage = 1,
19
+ BrowserCannotReadSessionStorage = 2,
20
+ BrowserCannotWriteLocalStorage = 3,
21
+ BrowserCannotWriteSessionStorage = 4,
22
+ BrowserFailedRemovalFromLocalStorage = 5,
23
+ BrowserFailedRemovalFromSessionStorage = 6,
24
+ CannotSendEmptyTelemetry = 7,
25
+ ClientPerformanceMathError = 8,
26
+ ErrorParsingAISessionCookie = 9,
27
+ ErrorPVCalc = 10,
28
+ ExceptionWhileLoggingError = 11,
29
+ FailedAddingTelemetryToBuffer = 12,
30
+ FailedMonitorAjaxAbort = 13,
31
+ FailedMonitorAjaxDur = 14,
32
+ FailedMonitorAjaxOpen = 15,
33
+ FailedMonitorAjaxRSC = 16,
34
+ FailedMonitorAjaxSend = 17,
35
+ FailedMonitorAjaxGetCorrelationHeader = 18,
36
+ FailedToAddHandlerForOnBeforeUnload = 19,
37
+ FailedToSendQueuedTelemetry = 20,
38
+ FailedToReportDataLoss = 21,
39
+ FlushFailed = 22,
40
+ MessageLimitPerPVExceeded = 23,
41
+ MissingRequiredFieldSpecification = 24,
42
+ NavigationTimingNotSupported = 25,
43
+ OnError = 26,
44
+ SessionRenewalDateIsZero = 27,
45
+ SenderNotInitialized = 28,
46
+ StartTrackEventFailed = 29,
47
+ StopTrackEventFailed = 30,
48
+ StartTrackFailed = 31,
49
+ StopTrackFailed = 32,
50
+ TelemetrySampledAndNotSent = 33,
51
+ TrackEventFailed = 34,
52
+ TrackExceptionFailed = 35,
53
+ TrackMetricFailed = 36,
54
+ TrackPVFailed = 37,
55
+ TrackPVFailedCalc = 38,
56
+ TrackTraceFailed = 39,
57
+ TransmissionFailed = 40,
58
+ FailedToSetStorageBuffer = 41,
59
+ FailedToRestoreStorageBuffer = 42,
60
+ InvalidBackendResponse = 43,
61
+ FailedToFixDepricatedValues = 44,
62
+ InvalidDurationValue = 45,
63
+ TelemetryEnvelopeInvalid = 46,
64
+ CreateEnvelopeError = 47,
65
+ CannotSerializeObject = 48,
66
+ CannotSerializeObjectNonSerializable = 49,
67
+ CircularReferenceDetected = 50,
68
+ ClearAuthContextFailed = 51,
69
+ ExceptionTruncated = 52,
70
+ IllegalCharsInName = 53,
71
+ ItemNotInArray = 54,
72
+ MaxAjaxPerPVExceeded = 55,
73
+ MessageTruncated = 56,
74
+ NameTooLong = 57,
75
+ SampleRateOutOfRange = 58,
76
+ SetAuthContextFailed = 59,
77
+ SetAuthContextFailedAccountName = 60,
78
+ StringValueTooLong = 61,
79
+ StartCalledMoreThanOnce = 62,
80
+ StopCalledWithoutStart = 63,
81
+ TelemetryInitializerFailed = 64,
82
+ TrackArgumentsNotSpecified = 65,
83
+ UrlTooLong = 66,
84
+ SessionStorageBufferFull = 67,
85
+ CannotAccessCookie = 68,
86
+ IdTooLong = 69,
87
+ InvalidEvent = 70,
88
+ FailedMonitorAjaxSetRequestHeader = 71,
89
+ SendBrowserInfoOnUserInit = 72,
90
+ PluginException = 73,
91
+ NotificationException = 74,
92
+ SnippetScriptLoadFailure = 99,
93
+ InvalidInstrumentationKey = 100,
94
+ CannotParseAiBlobValue = 101,
95
+ InvalidContentBlob = 102,
96
+ TrackPageActionEventFailed = 103,
97
+ FailedAddingCustomDefinedRequestContext = 104,
98
+ InMemoryStorageBufferFull = 105
99
+ }
11
100
  /**
12
101
  * Internal message ID. Please create a new one for every conceptually different message. Please keep alphabetically ordered
13
102
  */
@@ -95,4 +184,4 @@ export declare const _InternalMessageId: {
95
184
  FailedAddingCustomDefinedRequestContext: number;
96
185
  InMemoryStorageBufferFull: number;
97
186
  };
98
- export declare type _InternalMessageId = number | typeof _InternalMessageId;
187
+ export declare type _InternalMessageId = number | _eInternalMessageId;
@@ -30,6 +30,10 @@ export declare const enum SendRequestReason {
30
30
  * The event(s) being sent as a retry
31
31
  */
32
32
  Retry = 5,
33
+ /**
34
+ * The SDK is unloading
35
+ */
36
+ SdkUnload = 6,
33
37
  /**
34
38
  * Maximum batch size would be exceeded
35
39
  */
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
3
+ */
4
+ export declare const enum TelemetryUnloadReason {
5
+ /**
6
+ * Teardown has been called without any context.
7
+ */
8
+ ManualTeardown = 0,
9
+ /**
10
+ * Just this plugin is being removed
11
+ */
12
+ PluginUnload = 1,
13
+ /**
14
+ * This instance of the plugin is being removed and replaced
15
+ */
16
+ PluginReplace = 2,
17
+ /**
18
+ * The entire SDK is being unloaded
19
+ */
20
+ SdkUnload = 50
21
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
3
+ */
4
+ export declare const enum TelemetryUpdateReason {
5
+ /**
6
+ * Unknown.
7
+ */
8
+ Unknown = 0,
9
+ /**
10
+ * The configuration has ben updated or changed
11
+ */
12
+ /**
13
+ * One or more plugins have been added
14
+ */
15
+ PluginAdded = 16,
16
+ /**
17
+ * One or more plugins have been removed
18
+ */
19
+ PluginRemoved = 32
20
+ }
@@ -1,6 +1,6 @@
1
1
  import { ITelemetryItem } from "./ITelemetryItem";
2
2
  import { IChannelControls } from "./IChannelControls";
3
- import { IPlugin } from "./ITelemetryPlugin";
3
+ import { IPlugin, ITelemetryPlugin } from "./ITelemetryPlugin";
4
4
  import { IConfiguration } from "./IConfiguration";
5
5
  import { INotificationManager } from "./INotificationManager";
6
6
  import { INotificationListener } from "./INotificationListener";
@@ -8,6 +8,27 @@ 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
+ import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
13
+ import { UnloadHandler } from "../JavaScriptSDK/UnloadHandlerContainer";
14
+ import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
15
+ export interface ILoadedPlugin<T extends IPlugin> {
16
+ plugin: T;
17
+ /**
18
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
19
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
20
+ * @returns boolean = true if the plugin is in a state where it is operational.
21
+ */
22
+ isEnabled: () => boolean;
23
+ /**
24
+ * You can optionally enable / disable a plugin from processing events.
25
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
26
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
27
+ * (unless it's also been re-initialized)
28
+ */
29
+ setEnabled: (isEnabled: boolean) => void;
30
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
31
+ }
11
32
  export interface IAppInsightsCore extends IPerfManagerProvider {
12
33
  config: IConfiguration;
13
34
  logger: IDiagnosticLogger;
@@ -43,10 +64,60 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
43
64
  * @param {INotificationListener} listener - INotificationListener to remove.
44
65
  */
45
66
  removeNotificationListener?(listener: INotificationListener): void;
67
+ /**
68
+ * Add a telemetry processor to decorate or drop telemetry events.
69
+ * @param telemetryInitializer - The Telemetry Initializer function
70
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
71
+ */
72
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
46
73
  pollInternalLogs?(eventName?: string): number;
47
74
  stopPollingInternalLogs?(): void;
48
75
  /**
49
76
  * Return a new instance of the IProcessTelemetryContext for processing events
50
77
  */
51
78
  getProcessTelContext(): IProcessTelemetryContext;
79
+ /**
80
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
81
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
82
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
83
+ * approach is to create a new instance and initialize that instance.
84
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
85
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
86
+ * @param isAsync - Can the unload be performed asynchronously (default)
87
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
88
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
89
+ */
90
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
91
+ /**
92
+ * Find and return the (first) plugin with the specified identifier if present
93
+ * @param pluginIdentifier
94
+ */
95
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
96
+ /**
97
+ * Add a new plugin to the installation
98
+ * @param plugin - The new plugin to add
99
+ * @param replaceExisting - should any existing plugin be replaced, default is false
100
+ * @param doAsync - Should the add be performed asynchronously
101
+ * @param addCb - [Optional] callback to call after the plugin has been added
102
+ */
103
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
104
+ /**
105
+ * Returns the unique event namespace that should be used when registering events
106
+ */
107
+ evtNamespace(): string;
108
+ /**
109
+ * Add a handler that will be called when the SDK is being unloaded
110
+ * @param handler - the handler
111
+ */
112
+ addUnloadCb(handler: UnloadHandler): void;
113
+ /**
114
+ * Flush and send any batched / cached data immediately
115
+ * @param async - send data asynchronously when true (defaults to true)
116
+ * @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.
117
+ * If the caller doesn't return true the caller should assume that it may never be called.
118
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
119
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
120
+ * @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
121
+ */
122
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
52
123
  }
@@ -1,4 +1,7 @@
1
+ import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
2
+ import { IProcessTelemetryUnloadContext } from "./IProcessTelemetryContext";
1
3
  import { ITelemetryPlugin } from "./ITelemetryPlugin";
4
+ import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
2
5
  /**
3
6
  * Provides data transmission capabilities
4
7
  */
@@ -12,14 +15,22 @@ export interface IChannelControls extends ITelemetryPlugin {
12
15
  */
13
16
  resume(): void;
14
17
  /**
15
- * Tear down transmission pipeline
18
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
19
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
20
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
21
+ * @param unloadCtx - This is the context that should be used during unloading.
22
+ * @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.
23
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
16
24
  */
17
- teardown(): void;
25
+ teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
18
26
  /**
19
27
  * 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
28
+ * @param async - send data asynchronously when true
29
+ * @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.
30
+ * If the caller doesn't return true the caller should assume that it may never be called.
31
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
32
+ * @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
33
  */
23
- flush(async: boolean, callBack?: () => void): void;
34
+ flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
24
35
  }
25
36
  export declare const MinChannelPriorty: number;
@@ -8,6 +8,11 @@ export declare type InstrumentorHooksCallback = (funcArgs: IInstrumentCallDetail
8
8
  * You must always supply the error callback
9
9
  */
10
10
  export interface IInstrumentHooksCallbacks {
11
+ /**
12
+ * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
13
+ * identify the source of the instrumented hooks
14
+ */
15
+ ns?: string | string[];
11
16
  /**
12
17
  * The hook callback to call before the original function is called
13
18
  */
@@ -68,4 +73,8 @@ export interface IInstrumentCallDetails {
68
73
  * The error (exception) which occurred while executing the original method
69
74
  */
70
75
  err?: Error;
76
+ /**
77
+ * The Event object from (window.event) at the start of the original call
78
+ */
79
+ evt?: Event;
71
80
  }