@microsoft/applicationinsights-core-js 3.0.0-beta.2209-03 → 3.0.0-beta.2210-02

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 (179) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +1249 -675
  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 +3669 -1713
  7. package/dist/applicationinsights-core-js.api.md +131 -54
  8. package/dist/applicationinsights-core-js.d.ts +332 -131
  9. package/dist/applicationinsights-core-js.js +1249 -675
  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 +332 -131
  14. package/dist-esm/Config/ConfigDefaults.js +114 -0
  15. package/dist-esm/Config/ConfigDefaults.js.map +1 -0
  16. package/dist-esm/Config/DynamicConfig.js +129 -0
  17. package/dist-esm/Config/DynamicConfig.js.map +1 -0
  18. package/dist-esm/Config/DynamicProperty.js +139 -0
  19. package/dist-esm/Config/DynamicProperty.js.map +1 -0
  20. package/dist-esm/Config/DynamicState.js +109 -0
  21. package/dist-esm/Config/DynamicState.js.map +1 -0
  22. package/dist-esm/Config/DynamicSupport.js +57 -0
  23. package/dist-esm/Config/DynamicSupport.js.map +1 -0
  24. package/dist-esm/Config/IConfigDefaults.js +8 -0
  25. package/dist-esm/Config/IConfigDefaults.js.map +1 -0
  26. package/dist-esm/Config/IDynamicConfigHandler.js +8 -0
  27. package/dist-esm/Config/IDynamicConfigHandler.js.map +1 -0
  28. package/dist-esm/Config/IDynamicPropertyHandler.js +8 -0
  29. package/dist-esm/Config/IDynamicPropertyHandler.js.map +1 -0
  30. package/dist-esm/Config/IDynamicWatcher.js +8 -0
  31. package/dist-esm/Config/IDynamicWatcher.js.map +1 -0
  32. package/dist-esm/Config/_IDynamicConfigHandlerState.js +6 -0
  33. package/dist-esm/Config/_IDynamicConfigHandlerState.js.map +1 -0
  34. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +808 -23
  35. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  36. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +22 -18
  37. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  38. package/dist-esm/JavaScriptSDK/ChannelController.js +1 -1
  39. package/dist-esm/JavaScriptSDK/CookieMgr.js +78 -38
  40. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/CoreUtils.js +6 -5
  42. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +10 -8
  44. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  46. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +40 -23
  47. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  48. package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -115
  49. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  50. package/dist-esm/JavaScriptSDK/EventHelpers.js +30 -29
  51. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  52. package/dist-esm/JavaScriptSDK/HelperFuncs.js +19 -34
  53. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  54. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
  55. package/dist-esm/JavaScriptSDK/InternalConstants.js +5 -1
  56. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
  57. package/dist-esm/JavaScriptSDK/NotificationManager.js +18 -11
  58. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  59. package/dist-esm/JavaScriptSDK/PerfManager.js +2 -3
  60. package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
  61. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +62 -53
  62. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  63. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  64. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +8 -10
  65. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  66. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +3 -4
  67. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  68. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  69. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +12 -10
  70. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  71. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -2
  72. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js.map +1 -1
  73. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +2 -107
  75. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  76. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  85. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  86. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  87. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  88. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  89. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  90. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  91. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  92. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  93. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  94. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  95. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  96. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  97. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  98. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  99. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js +8 -0
  100. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js.map +1 -0
  101. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +3 -1
  102. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +1 -1
  103. package/dist-esm/__DynamicConstants.js +26 -23
  104. package/dist-esm/__DynamicConstants.js.map +1 -1
  105. package/dist-esm/applicationinsights-core-js.js +6 -4
  106. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  107. package/package.json +2 -2
  108. package/src/JavaScriptSDK/AppInsightsCore.ts +1156 -16
  109. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +25 -17
  110. package/src/JavaScriptSDK/CookieMgr.ts +88 -41
  111. package/src/JavaScriptSDK/CoreUtils.ts +4 -3
  112. package/src/JavaScriptSDK/DiagnosticLogger.ts +51 -29
  113. package/src/JavaScriptSDK/EnvUtils.ts +0 -133
  114. package/src/JavaScriptSDK/EventHelpers.ts +29 -28
  115. package/src/JavaScriptSDK/HelperFuncs.ts +22 -39
  116. package/src/JavaScriptSDK/InternalConstants.ts +5 -0
  117. package/src/JavaScriptSDK/NotificationManager.ts +25 -14
  118. package/src/JavaScriptSDK/PerfManager.ts +2 -2
  119. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +73 -56
  120. package/src/JavaScriptSDK/TelemetryHelpers.ts +8 -9
  121. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +2 -2
  122. package/src/JavaScriptSDK/W3cTraceParent.ts +7 -6
  123. package/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts +0 -1
  124. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +9 -108
  125. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +1 -1
  126. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +28 -3
  127. package/src/JavaScriptSDK.Interfaces/ICookieMgr.ts +8 -0
  128. package/src/JavaScriptSDK.Interfaces/IDiagnosticLogger.ts +15 -8
  129. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +3 -1
  130. package/src/JavaScriptSDK.Interfaces/INotificationListener.ts +5 -5
  131. package/src/JavaScriptSDK.Interfaces/INotificationManager.ts +8 -8
  132. package/src/JavaScriptSDK.Interfaces/IPerfManager.ts +3 -3
  133. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +10 -9
  134. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +2 -1
  135. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +15 -5
  136. package/src/JavaScriptSDK.Interfaces/IUnloadHook.ts +22 -0
  137. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +3 -3
  138. package/tsconfig.json +3 -2
  139. package/types/Config/ConfigDefaults.d.ts +10 -0
  140. package/types/Config/DynamicConfig.d.ts +23 -0
  141. package/types/Config/DynamicProperty.d.ts +3 -0
  142. package/types/Config/DynamicState.d.ts +3 -0
  143. package/types/Config/DynamicSupport.d.ts +15 -0
  144. package/types/Config/IConfigDefaults.d.ts +42 -0
  145. package/types/Config/IDynamicConfigHandler.d.ts +46 -0
  146. package/types/Config/IDynamicPropertyHandler.d.ts +11 -0
  147. package/types/Config/IDynamicWatcher.d.ts +28 -0
  148. package/types/Config/_IDynamicConfigHandlerState.d.ts +35 -0
  149. package/types/JavaScriptSDK/AppInsightsCore.d.ts +136 -4
  150. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +2 -2
  151. package/types/JavaScriptSDK/CookieMgr.d.ts +0 -10
  152. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +18 -16
  153. package/types/JavaScriptSDK/EventHelpers.d.ts +24 -24
  154. package/types/JavaScriptSDK/HelperFuncs.d.ts +13 -11
  155. package/types/JavaScriptSDK/InternalConstants.d.ts +4 -0
  156. package/types/JavaScriptSDK/NotificationManager.d.ts +7 -7
  157. package/types/JavaScriptSDK/PerfManager.d.ts +2 -2
  158. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +3 -2
  159. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +3 -3
  160. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +7 -5
  161. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +1 -0
  162. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +25 -3
  163. package/types/JavaScriptSDK.Interfaces/ICookieMgr.d.ts +6 -0
  164. package/types/JavaScriptSDK.Interfaces/IDiagnosticLogger.d.ts +14 -8
  165. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +2 -1
  166. package/types/JavaScriptSDK.Interfaces/INotificationListener.d.ts +5 -5
  167. package/types/JavaScriptSDK.Interfaces/INotificationManager.d.ts +8 -8
  168. package/types/JavaScriptSDK.Interfaces/IPerfManager.d.ts +3 -3
  169. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +5 -9
  170. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +2 -1
  171. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +13 -2
  172. package/types/JavaScriptSDK.Interfaces/IUnloadHook.d.ts +18 -0
  173. package/types/__DynamicConstants.d.ts +18 -15
  174. package/types/applicationinsights-core-js.d.ts +11 -4
  175. package/types/tsdoc-metadata.json +1 -1
  176. package/dist-esm/JavaScriptSDK/BaseCore.js +0 -654
  177. package/dist-esm/JavaScriptSDK/BaseCore.js.map +0 -1
  178. package/src/JavaScriptSDK/BaseCore.ts +0 -948
  179. package/types/JavaScriptSDK/BaseCore.d.ts +0 -124
@@ -1,7 +1,8 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
- import { _InternalMessageId, LoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
3
+ import { _eInternalMessageId, LoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
4
4
  import { _InternalLogMessage } from "../JavaScriptSDK/DiagnosticLogger";
5
+ import { ITelemetryUpdateState } from "./ITelemetryUpdateState";
5
6
 
6
7
  "use strict"
7
8
 
@@ -37,14 +38,14 @@ export interface IDiagnosticLogger {
37
38
 
38
39
  /**
39
40
  * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
40
- * @param severity {LoggingSeverity} - The severity of the log message
41
- * @param message {_InternalLogMessage} - The log message.
41
+ * @param severity - {LoggingSeverity} - The severity of the log message
42
+ * @param message - {_InternalLogMessage} - The log message.
42
43
  */
43
- throwInternal(severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
44
+ throwInternal(severity: LoggingSeverity, msgId: _eInternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
44
45
 
45
46
  /**
46
47
  * This will write a warning to the console if possible
47
- * @param message {string} - The warning message
48
+ * @param message - {string} - The warning message
48
49
  */
49
50
  warnToConsole(message: string): void;
50
51
 
@@ -52,7 +53,7 @@ export interface IDiagnosticLogger {
52
53
  * This will write an error to the console if possible.
53
54
  * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
54
55
  * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
55
- * @param message {string} - The error message
56
+ * @param message - {string} - The error message
56
57
  */
57
58
  errorToConsole?(message: string): void;
58
59
 
@@ -63,8 +64,14 @@ export interface IDiagnosticLogger {
63
64
 
64
65
  /**
65
66
  * Logs a message to the internal queue.
66
- * @param severity {LoggingSeverity} - The severity of the log message
67
- * @param message {_InternalLogMessage} - The message to log.
67
+ * @param severity - {LoggingSeverity} - The severity of the log message
68
+ * @param message - {_InternalLogMessage} - The message to log.
68
69
  */
69
70
  logInternalMessage?(severity: LoggingSeverity, message: _InternalLogMessage): void;
71
+
72
+ /**
73
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
74
+ * @param updateState
75
+ */
76
+ update?(updateState: ITelemetryUpdateState): void;
70
77
  }
@@ -1,6 +1,8 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
+ import { IUnloadHook } from "./IUnloadHook";
5
+
4
6
  /**
5
7
  * A callback function that will be called for the wrapped instrumentation function
6
8
  * before the original function is executed.
@@ -43,7 +45,7 @@ export interface IInstrumentHooksCallbacks {
43
45
  /**
44
46
  * The holder of the specific instance callback
45
47
  */
46
- export interface IInstrumentHook {
48
+ export interface IInstrumentHook extends IUnloadHook {
47
49
  /** Unique Id for this callback on the hooked method */
48
50
  id: number;
49
51
 
@@ -12,21 +12,21 @@ import { IPerfEvent } from "./IPerfEvent";
12
12
  export interface INotificationListener {
13
13
  /**
14
14
  * [Optional] A function called when events are sent.
15
- * @param {ITelemetryItem[]} events - The array of events that have been sent.
15
+ * @param events - The array of events that have been sent.
16
16
  */
17
17
  eventsSent?: (events: ITelemetryItem[]) => void;
18
18
  /**
19
19
  * [Optional] A function called when events are discarded.
20
- * @param {ITelemetryItem[]} events - The array of events that have been discarded.
21
- * @param {number} reason - The reason for discarding the events. The EventsDiscardedReason
20
+ * @param events - The array of events that have been discarded.
21
+ * @param reason - The reason for discarding the events. The EventsDiscardedReason
22
22
  * constant should be used to check the different values.
23
23
  */
24
24
  eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
25
25
 
26
26
  /**
27
27
  * [Optional] A function called when the events have been requested to be sent to the sever.
28
- * @param {number} sendReason - The reason why the event batch is being sent.
29
- * @param {boolean} isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
28
+ * @param sendReason - The reason why the event batch is being sent.
29
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
30
30
  */
31
31
  eventsSendRequest?: (sendReason: number, isAsync?: boolean) => void;
32
32
 
@@ -12,41 +12,41 @@ export interface INotificationManager {
12
12
 
13
13
  /**
14
14
  * Adds a notification listener.
15
- * @param {INotificationListener} listener - The notification listener to be added.
15
+ * @param listener - The notification listener to be added.
16
16
  */
17
17
  addNotificationListener(listener: INotificationListener): void;
18
18
 
19
19
  /**
20
20
  * Removes all instances of the listener.
21
- * @param {INotificationListener} listener - AWTNotificationListener to remove.
21
+ * @param listener - AWTNotificationListener to remove.
22
22
  */
23
23
  removeNotificationListener(listener: INotificationListener): void;
24
24
 
25
25
  /**
26
26
  * Notification for events sent.
27
- * @param {ITelemetryItem[]} events - The array of events that have been sent.
27
+ * @param events - The array of events that have been sent.
28
28
  */
29
29
  eventsSent(events: ITelemetryItem[]): void;
30
30
 
31
31
  /**
32
32
  * Notification for events being discarded.
33
- * @param {ITelemetryItem[]} events - The array of events that have been discarded by the SDK.
34
- * @param {number} reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
33
+ * @param events - The array of events that have been discarded by the SDK.
34
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
35
35
  * constant should be used to check the different values.
36
36
  */
37
37
  eventsDiscarded(events: ITelemetryItem[], reason: number): void;
38
38
 
39
39
  /**
40
40
  * [Optional] A function called when the events have been requested to be sent to the sever.
41
- * @param {number} sendReason - The reason why the event batch is being sent.
42
- * @param {boolean} isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
41
+ * @param sendReason - The reason why the event batch is being sent.
42
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
43
43
  */
44
44
  eventsSendRequest?(sendReason: number, isAsync: boolean): void;
45
45
 
46
46
  /**
47
47
  * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
48
48
  * the event can be displayed via the debug plugin extension.
49
- * @param perfEvent
49
+ * @param perfEvent - The perf event details
50
50
  */
51
51
  perfEvent?(perfEvent: IPerfEvent): void;
52
52
  }
@@ -13,7 +13,7 @@ export interface IPerfManagerProvider {
13
13
 
14
14
  /**
15
15
  * Set the current performance manager
16
- * @param perfMgr The performance manager
16
+ * @param perfMgr - The performance manager
17
17
  */
18
18
  setPerfMgr(perfMgr: IPerfManager): void;
19
19
  }
@@ -26,7 +26,7 @@ export interface IPerfManager {
26
26
  /**
27
27
  * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
28
28
  * want to monitor this source event.
29
- * @param src The source name of the event
29
+ * @param src - The source name of the event
30
30
  * @param payloadDetails - An optional callback function to fetch the payload details for the event.
31
31
  * @param isAsync - Is the event occurring from a async event
32
32
  */
@@ -34,7 +34,7 @@ export interface IPerfManager {
34
34
 
35
35
  /**
36
36
  * Complete the perfEvent and fire any notifications.
37
- * @param perfEvent Fire the event which will also complete the passed event
37
+ * @param perfEvent - Fire the event which will also complete the passed event
38
38
  */
39
39
  fire(perfEvent: IPerfEvent): void;
40
40
 
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  "use strict";
4
4
 
5
+ import { IConfigDefaults } from "../Config/IConfigDefaults";
5
6
  import { IAppInsightsCore } from "./IAppInsightsCore";
6
7
  import { IConfiguration } from "./IConfiguration";
7
8
  import { IDiagnosticLogger } from "./IDiagnosticLogger";
@@ -11,11 +12,11 @@ import { ITelemetryPluginChain } from "./ITelemetryPluginChain";
11
12
  import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
12
13
  import { ITelemetryUpdateState } from "./ITelemetryUpdateState";
13
14
 
14
- export const enum GetExtCfgMergeType {
15
- None = 0,
16
- MergeDefaultOnly = 1,
17
- MergeDefaultFromRootOrDefault = 2,
18
- }
15
+ // export const enum GetExtCfgMergeType {
16
+ // None = 0,
17
+ // MergeDefaultOnly = 1,
18
+ // MergeDefaultFromRootOrDefault = 2,
19
+ // }
19
20
 
20
21
  export interface IBaseProcessingContext {
21
22
  /**
@@ -36,14 +37,14 @@ export interface IBaseProcessingContext {
36
37
  /**
37
38
  * Gets the named extension config
38
39
  */
39
- getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
40
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
40
41
 
41
42
  /**
42
43
  * Gets the named config from either the named identifier extension or core config if neither exist then the
43
44
  * default value is returned
44
- * @param identifier The named extension identifier
45
- * @param field The config field name
46
- * @param defaultValue The default value to return if no defined config exists
45
+ * @param identifier - The named extension identifier
46
+ * @param field - The config field name
47
+ * @param defaultValue - The default value to return if no defined config exists
47
48
  */
48
49
  getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
49
50
 
@@ -1,8 +1,9 @@
1
1
  import { ITelemetryItem } from "./ITelemetryItem";
2
+ import { ILegacyUnloadHook } from "./IUnloadHook";
2
3
 
3
4
  export declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
4
5
 
5
- export interface ITelemetryInitializerHandler {
6
+ export interface ITelemetryInitializerHandler extends ILegacyUnloadHook {
6
7
  remove(): void;
7
8
  }
8
9
 
@@ -2,7 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
5
- //import { IConfiguration } from "./IConfiguration";
5
+ import { IConfiguration } from "./IConfiguration";
6
6
  import { IPlugin } from "./ITelemetryPlugin";
7
7
 
8
8
  export interface ITelemetryUpdateState {
@@ -13,14 +13,24 @@ export interface ITelemetryUpdateState {
13
13
  reason: TelemetryUpdateReason;
14
14
 
15
15
  /**
16
+ * This is a new active configuration that should be used
17
+ */
18
+ cfg?: IConfiguration,
19
+
20
+ /**
21
+ * The detected changes
22
+ */
23
+ oldCfg?: IConfiguration,
24
+
25
+ /**
16
26
  * If this is a configuration update this was the previous configuration that was used
17
27
  */
18
- //prvCfg?: IConfiguration,
28
+ newConfig?: IConfiguration,
19
29
 
20
30
  /**
21
- * If this is a configuration update is the new configuration that is being used
31
+ * Was the new config requested to be merged with the existing config
22
32
  */
23
- //newCfg?: IConfiguration,
33
+ merge?: boolean,
24
34
 
25
35
  /**
26
36
  * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
@@ -30,5 +40,5 @@ export interface ITelemetryUpdateState {
30
40
  /**
31
41
  * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
32
42
  */
33
- removed?: IPlugin[]
43
+ removed?: IPlugin[]
34
44
  }
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ /**
5
+ * An interface which provides automatic removal during unloading of the component
6
+ */
7
+ export interface IUnloadHook {
8
+ /**
9
+ * Self remove the referenced component
10
+ */
11
+ rm: () => void;
12
+ }
13
+
14
+ /**
15
+ * An alternate interface which provides automatic removal during unloading of the component
16
+ */
17
+ export interface ILegacyUnloadHook {
18
+ /**
19
+ * Legacy Self remove the referenced component
20
+ */
21
+ remove: () => void;
22
+ }
@@ -1,9 +1,9 @@
1
- import { IProcessTelemetryUnloadContext } from "./IProcessTelemetryContext";
2
- import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
3
-
4
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
5
2
  // Licensed under the MIT License.
6
3
 
4
+ import { IProcessTelemetryUnloadContext } from "./IProcessTelemetryContext";
5
+ import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
6
+
7
7
  export interface IUnloadableComponent {
8
8
  /**
9
9
  * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
package/tsconfig.json CHANGED
@@ -13,14 +13,15 @@
13
13
  "alwaysStrict": true,
14
14
  "skipDefaultLibCheck": true,
15
15
  "declaration": true,
16
- "declarationDir": "shared/AppInsightsCore/types",
16
+ "declarationDir": "./types",
17
17
  "outDir": "./dist-esm",
18
- "rootDir": "shared/AppInsightsCore/src",
18
+ "rootDir": "./src",
19
19
  "suppressImplicitAnyIndexErrors": true,
20
20
  "allowSyntheticDefaultImports": true
21
21
  },
22
22
  "include": [
23
23
  "./src/applicationinsights-core-js.ts",
24
+ "./src/Config/**/*.ts",
24
25
  "./src/JavaScriptSDK/**/*.ts",
25
26
  "./src/JavaScriptSDK.Enums/**/*.ts",
26
27
  "./src/JavaScriptSDK.Interfaces/**/*.ts"
@@ -0,0 +1,10 @@
1
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
2
+ import { IConfigDefaultCheck, IConfigDefaults } from "./IConfigDefaults";
3
+ /**
4
+ * Applies the default value on the config property and makes sure that it's dynamic
5
+ * @param theConfig
6
+ * @param name
7
+ * @param defaultValue
8
+ */
9
+ export declare function _applyDefaultValue<T extends IConfiguration, C>(theConfig: C, name: string, defaultValue: C[keyof C] | IConfigDefaultCheck<C, C[keyof C], T>): void;
10
+ export declare function applyDefaults<C>(theConfig: C, defaultValues: IConfigDefaults<C>): C;
@@ -0,0 +1,23 @@
1
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
2
+ import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
3
+ import { IConfigDefaults } from "./IConfigDefaults";
4
+ import { IDynamicConfigHandler } from "./IDynamicConfigHandler";
5
+ import { IWatcherHandler, WatcherFunction } from "./IDynamicWatcher";
6
+ /**
7
+ * Create or return a dynamic version of the passed config, if it is not already dynamic
8
+ * @param config - The config to be converted into a dynamic config
9
+ * @param defaultConfig - The default values to apply on the config if the properties don't already exist
10
+ * @param inPlace - Should the config be converted in-place into a dynamic config or a new instance returned, defaults to true
11
+ * @returns The dynamic config handler for the config (whether new or existing)
12
+ */
13
+ export declare function createDynamicConfig<T extends IConfiguration>(config: T, defaultConfig?: IConfigDefaults<T>, logger?: IDiagnosticLogger, inPlace?: boolean): IDynamicConfigHandler<T>;
14
+ /**
15
+ * Watch and track changes for accesses to the current config, the provided config MUST already be
16
+ * a dynamic config or a child accessed via the dynamic config
17
+ * @param config
18
+ * @param configHandler
19
+ * @param logger - The logger instance to use if there is no existing handler
20
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
21
+ * @throws TypeError if the provided config is not a dynamic config instance
22
+ */
23
+ export declare function onConfigChange<T>(config: T, configHandler: WatcherFunction<T>, logger?: IDiagnosticLogger): IWatcherHandler<T>;
@@ -0,0 +1,3 @@
1
+ import { _IDynamicConfigHandlerState } from "./_IDynamicConfigHandlerState";
2
+ export declare function _setDynamicProperty<T, C, V = any>(state: _IDynamicConfigHandlerState<T>, target: C, name: string, value: V): V;
3
+ export declare function _makeDynamicObject<T>(state: _IDynamicConfigHandlerState<T>, target: any): any;
@@ -0,0 +1,3 @@
1
+ import { _IInternalDynamicConfigHandler } from "./IDynamicConfigHandler";
2
+ import { _IDynamicConfigHandlerState } from "./_IDynamicConfigHandlerState";
3
+ export declare function _createState<T>(cfgHandler: _IInternalDynamicConfigHandler<T>): _IDynamicConfigHandlerState<T>;
@@ -0,0 +1,15 @@
1
+ import { IDynamicConfigHandler } from "./IDynamicConfigHandler";
2
+ export declare const CFG_HANDLER_LINK: symbol;
3
+ export declare function _cfgDeepCopy<T>(source: T): T;
4
+ /**
5
+ * @internal
6
+ * Get the dynamic config handler if the value is already dynamic
7
+ * @param value
8
+ * @returns
9
+ */
10
+ export declare function getDynamicConfigHandler<T>(value: T | IDynamicConfigHandler<T>): IDynamicConfigHandler<T> | null;
11
+ /**
12
+ * Throws an invalid access exception
13
+ * @param message - The message to include in the exception
14
+ */
15
+ export declare function throwInvalidAccess(message: string): never;
@@ -0,0 +1,42 @@
1
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
2
+ /**
3
+ * The type to identify whether the default value should be applied in preference to the provided value.
4
+ */
5
+ export declare type IConfigCheckFn<V> = (value: V) => boolean;
6
+ /**
7
+ * The type which identifies the function use to validate the user supplied value
8
+ */
9
+ export declare type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
10
+ /**
11
+ * The default values with a check function
12
+ */
13
+ export interface IConfigDefaultCheck<T, V, C extends IConfiguration = IConfiguration> {
14
+ /**
15
+ * Callback function to check if the user-supplied value is valid, if not the default will be applied
16
+ */
17
+ isVal?: IConfigCheckFn<V>;
18
+ /**
19
+ * Optional function to allow converting and setting of the default value
20
+ */
21
+ set?: IConfigSetFn<T, V>;
22
+ /**
23
+ * The default value to apply if the user-supplied value is not valid
24
+ */
25
+ v?: V;
26
+ /**
27
+ * The default fallback key if the main key is not present, this is the key value from the config
28
+ */
29
+ fb?: keyof T | keyof C | Array<keyof T | keyof C>;
30
+ /**
31
+ * Use this check to determine the default fallback, default only checked whether the property isDefined,
32
+ * therefore `null`; `""` are considered to be valid values.
33
+ */
34
+ dfVal?: (value: any) => boolean;
35
+ }
36
+ /**
37
+ * The Type definition to define default values to be applied to the config
38
+ * The value may be either the direct value or a ConfigDefaultCheck definition
39
+ */
40
+ export declare type IConfigDefaults<T, C extends IConfiguration = IConfiguration> = {
41
+ [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
42
+ };
@@ -0,0 +1,46 @@
1
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
2
+ import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
3
+ import { IWatcherHandler, WatcherFunction } from "./IDynamicWatcher";
4
+ /**
5
+ * This interface identifies the config which can track changes
6
+ */
7
+ export interface IDynamicConfigHandler<T extends IConfiguration> {
8
+ /**
9
+ * Unique Id for this config handler
10
+ */
11
+ readonly uid: string;
12
+ /**
13
+ * Link back to the configuration object that should be used to get/set values
14
+ */
15
+ cfg: T;
16
+ /**
17
+ * The logger instance to use to loger any issues
18
+ */
19
+ logger: IDiagnosticLogger;
20
+ /**
21
+ * Helper to call any listeners that are waiting to be notified
22
+ */
23
+ notify: () => void;
24
+ /**
25
+ * Watch and track changes for accesses to the current config anb
26
+ */
27
+ watch: (configHandler: WatcherFunction<T>) => IWatcherHandler<T>;
28
+ /**
29
+ * Set the value against the provided config/name with the value, the property
30
+ * will be converted to be dynamic (if not already) as long as the provided config
31
+ * is already a tracked dynamic object.
32
+ * @throws TypeError if the provided config is not a monitored dynamic config
33
+ */
34
+ set: <C, V>(theConfig: C, name: string, value: V) => V;
35
+ }
36
+ /**
37
+ * @internal
38
+ * @ignore
39
+ */
40
+ export interface _IInternalDynamicConfigHandler<T extends IConfiguration> extends IDynamicConfigHandler<T> {
41
+ /**
42
+ * @ignore
43
+ * Internal function to explicitly block watching for any config updates
44
+ */
45
+ _block: (configHandler: WatcherFunction<T>) => void;
46
+ }
@@ -0,0 +1,11 @@
1
+ import { IWatcherHandler } from "./IDynamicWatcher";
2
+ export interface IDynamicPropertyHandler<T> {
3
+ /**
4
+ * Identifies the name of the field that is handled by this handler
5
+ */
6
+ n: string;
7
+ /**
8
+ * The current collection is watcher handlers which should be called if the value changes
9
+ */
10
+ h: IWatcherHandler<T>[];
11
+ }
@@ -0,0 +1,28 @@
1
+ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
2
+ import { IUnloadHook } from "../JavaScriptSDK.Interfaces/IUnloadHook";
3
+ import { IDynamicConfigHandler } from "./IDynamicConfigHandler";
4
+ import { IDynamicPropertyHandler } from "./IDynamicPropertyHandler";
5
+ export interface IWatchDetails<T extends IConfiguration> {
6
+ cfg: T;
7
+ hdlr: IDynamicConfigHandler<T>;
8
+ }
9
+ export declare type WatcherFunction<T extends IConfiguration> = (details: IWatchDetails<T>) => void;
10
+ /**
11
+ * @internal
12
+ */
13
+ export interface _WatcherChangeDetails<T extends IConfiguration> {
14
+ d: _IDynamicDetail<T>;
15
+ }
16
+ /**
17
+ * @internal
18
+ */
19
+ export interface _IDynamicDetail<T extends IConfiguration> extends IDynamicPropertyHandler<T> {
20
+ /**
21
+ * Add the watcher for monitoring changes
22
+ */
23
+ add: (handler: IWatcherHandler<T>) => void;
24
+ }
25
+ export interface IWatcherHandler<T extends IConfiguration> extends IUnloadHook {
26
+ fn: WatcherFunction<T>;
27
+ rm: () => void;
28
+ }
@@ -0,0 +1,35 @@
1
+ import { IDynamicConfigHandler } from "./IDynamicConfigHandler";
2
+ import { IDynamicPropertyHandler } from "./IDynamicPropertyHandler";
3
+ import { IWatcherHandler, WatcherFunction } from "./IDynamicWatcher";
4
+ /**
5
+ * @internal
6
+ * Interface for the global dynamic config handler
7
+ */
8
+ export interface _IDynamicConfigHandlerState<T> {
9
+ prop: symbol;
10
+ ro: symbol;
11
+ /**
12
+ * Link to the handler
13
+ */
14
+ hdlr: IDynamicConfigHandler<T>;
15
+ /**
16
+ * Identifies the current active handler
17
+ */
18
+ act?: IWatcherHandler<T>;
19
+ /**
20
+ * Enable / Disable updates to dynamic readonly properties
21
+ */
22
+ upd?: boolean;
23
+ /**
24
+ * Helper to call any listeners that are waiting to be notified
25
+ */
26
+ notify: () => void;
27
+ /**
28
+ * Add this property handler to the collection to be notified
29
+ */
30
+ add: (handler: IDynamicPropertyHandler<T>) => void;
31
+ /**
32
+ * Use the provided handler to listen for changes
33
+ */
34
+ use: (activeHandler: IWatcherHandler<T>, callback: WatcherFunction<T>) => void;
35
+ }