@microsoft/applicationinsights-core-js 2.8.0-nightly.2202-06 → 2.8.0-nightly.2204-06

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +2440 -1199
  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 +16710 -8876
  7. package/dist/applicationinsights-core-js.api.md +465 -140
  8. package/dist/applicationinsights-core-js.d.ts +856 -217
  9. package/dist/applicationinsights-core-js.js +2440 -1199
  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 +856 -217
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +4 -72
  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 +45 -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 +80 -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/EnumHelperFuncs.js +51 -0
  56. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js.map +1 -0
  57. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +10 -9
  58. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js.map +1 -1
  59. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +90 -96
  60. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  61. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +8 -0
  63. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js.map +1 -0
  64. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +8 -0
  65. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +1 -0
  66. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -2
  67. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js.map +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  70. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +6 -0
  80. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +1 -0
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -2
  84. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js.map +1 -1
  85. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +8 -0
  86. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js.map +1 -0
  87. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +8 -0
  88. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +1 -0
  89. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +6 -0
  90. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +1 -0
  91. package/dist-esm/applicationinsights-core-js.js +13 -7
  92. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  93. package/package.json +2 -2
  94. package/src/JavaScriptSDK/AppInsightsCore.ts +4 -105
  95. package/src/JavaScriptSDK/BaseCore.ts +696 -120
  96. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +205 -31
  97. package/src/JavaScriptSDK/ChannelController.ts +242 -103
  98. package/src/JavaScriptSDK/CookieMgr.ts +7 -5
  99. package/src/JavaScriptSDK/CoreUtils.ts +8 -172
  100. package/src/JavaScriptSDK/DataCacheHelper.ts +106 -0
  101. package/src/JavaScriptSDK/DiagnosticLogger.ts +49 -12
  102. package/src/JavaScriptSDK/EnvUtils.ts +13 -12
  103. package/src/JavaScriptSDK/EventHelpers.ts +550 -0
  104. package/src/JavaScriptSDK/HelperFuncs.ts +114 -97
  105. package/src/JavaScriptSDK/InstrumentHooks.ts +4 -2
  106. package/src/JavaScriptSDK/InternalConstants.ts +26 -0
  107. package/src/JavaScriptSDK/NotificationManager.ts +34 -37
  108. package/src/JavaScriptSDK/PerfManager.ts +4 -7
  109. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +543 -134
  110. package/src/JavaScriptSDK/RandomHelper.ts +35 -3
  111. package/src/JavaScriptSDK/TelemetryHelpers.ts +83 -21
  112. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +111 -0
  113. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +46 -0
  114. package/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts +56 -0
  115. package/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts +48 -8
  116. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +183 -87
  117. package/src/JavaScriptSDK.Enums/SendRequestReason.ts +5 -0
  118. package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +27 -0
  119. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +27 -0
  120. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +82 -2
  121. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +16 -5
  122. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +16 -6
  123. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +94 -14
  124. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +16 -0
  125. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +28 -10
  126. package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +9 -11
  127. package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +10 -0
  128. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +34 -0
  129. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +17 -0
  130. package/types/JavaScriptSDK/AppInsightsCore.d.ts +0 -21
  131. package/types/JavaScriptSDK/BaseCore.d.ts +81 -3
  132. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +53 -10
  133. package/types/JavaScriptSDK/ChannelController.d.ts +16 -17
  134. package/types/JavaScriptSDK/CoreUtils.d.ts +1 -48
  135. package/types/JavaScriptSDK/DataCacheHelper.d.ts +13 -0
  136. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +23 -0
  137. package/types/JavaScriptSDK/EventHelpers.d.ts +154 -0
  138. package/types/JavaScriptSDK/HelperFuncs.d.ts +37 -32
  139. package/types/JavaScriptSDK/InternalConstants.d.ts +20 -0
  140. package/types/JavaScriptSDK/PerfManager.d.ts +1 -1
  141. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +69 -6
  142. package/types/JavaScriptSDK/RandomHelper.d.ts +6 -0
  143. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +23 -3
  144. package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +16 -0
  145. package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +11 -0
  146. package/types/JavaScriptSDK.Enums/EnumHelperFuncs.d.ts +34 -0
  147. package/types/JavaScriptSDK.Enums/EventsDiscardedReason.d.ts +14 -9
  148. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +89 -86
  149. package/types/JavaScriptSDK.Enums/SendRequestReason.d.ts +4 -0
  150. package/types/JavaScriptSDK.Enums/TelemetryUnloadReason.d.ts +21 -0
  151. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +20 -0
  152. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +72 -1
  153. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +16 -5
  154. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +9 -0
  155. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +82 -11
  156. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +13 -0
  157. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +25 -8
  158. package/types/JavaScriptSDK.Interfaces/ITelemetryPluginChain.d.ts +9 -10
  159. package/types/JavaScriptSDK.Interfaces/ITelemetryUnloadState.d.ts +6 -0
  160. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +22 -0
  161. package/types/JavaScriptSDK.Interfaces/IUnloadableComponent.d.ts +13 -0
  162. package/types/applicationinsights-core-js.d.ts +20 -10
  163. package/types/tsdoc-metadata.json +1 -1
  164. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +0 -76
  165. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +0 -1
  166. package/src/JavaScriptSDK/TelemetryPluginChain.ts +0 -120
  167. package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +0 -32
@@ -0,0 +1,34 @@
1
+ export declare type EnumValue<E = any> = {
2
+ readonly [key in keyof E]: E[key];
3
+ };
4
+ export declare type EnumMap<E = any, I = E> = {
5
+ readonly [key in keyof E extends string ? keyof E : never]: key extends string ? key : keyof E;
6
+ } & I;
7
+ /**
8
+ * Create an enum style object which has both the key => value and value => key mappings
9
+ * @param values - The values to populate on the new object
10
+ * @returns
11
+ */
12
+ export declare function createEnumStyle<E>(values: {
13
+ [key in keyof E]: E[keyof E];
14
+ }): EnumValue<E>;
15
+ /**
16
+ * Create a 2 index map that maps an enum's key as both the key and value, X["key"] => "key" and X[0] => "keyof 0".
17
+ * @param values - The values to populate on the new object
18
+ * @returns
19
+ */
20
+ export declare function createEnumMap<E, I = keyof E>(values: {
21
+ [key in keyof E]: E[keyof E];
22
+ }): EnumMap<E, I>;
23
+ /**
24
+ * Create a 2 index map that maps an enum's key and value to the defined map value, X["key"] => mapValue and X[0] => mapValue.
25
+ * Generic values
26
+ * - E = the const enum type (typeof eRequestHeaders);
27
+ * - V = Identifies the valid values for the keys, this should include both the enum numeric and string key of the type. The
28
+ * resulting "Value" of each entry identifies the valid values withing the assignments.
29
+ * @param values - The values to populate on the new object
30
+ * @returns
31
+ */
32
+ export declare function createValueMap<E, V = E>(values: {
33
+ [key in keyof E]: [eValue: E[keyof E], mapValue: V[keyof V]];
34
+ }): V;
@@ -1,29 +1,34 @@
1
1
  /**
2
- * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
2
+ * The eEventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
3
3
  */
4
- export declare const EventsDiscardedReason: {
4
+ export declare const enum eEventsDiscardedReason {
5
5
  /**
6
6
  * Unknown.
7
7
  */
8
- Unknown: number;
8
+ Unknown = 0,
9
9
  /**
10
10
  * Status set to non-retryable.
11
11
  */
12
- NonRetryableStatus: number;
12
+ NonRetryableStatus = 1,
13
13
  /**
14
14
  * The event is invalid.
15
15
  */
16
- InvalidEvent: number;
16
+ InvalidEvent = 2,
17
17
  /**
18
18
  * The size of the event is too large.
19
19
  */
20
- SizeLimitExceeded: number;
20
+ SizeLimitExceeded = 3,
21
21
  /**
22
22
  * The server is not accepting events from this instrumentation key.
23
23
  */
24
- KillSwitch: number;
24
+ KillSwitch = 4,
25
25
  /**
26
26
  * The event queue is full.
27
27
  */
28
- QueueFull: number;
29
- };
28
+ QueueFull = 5
29
+ }
30
+ /**
31
+ * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
32
+ */
33
+ export declare const EventsDiscardedReason: import("../JavaScriptSDK.Enums/EnumHelperFuncs").EnumValue<typeof eEventsDiscardedReason>;
34
+ export declare type EventsDiscardedReason = number | eEventsDiscardedReason;
@@ -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,91 +8,94 @@ export declare enum LoggingSeverity {
8
8
  */
9
9
  WARNING = 2
10
10
  }
11
+ export declare const LoggingSeverity: import("../JavaScriptSDK.Enums/EnumHelperFuncs").EnumValue<typeof eLoggingSeverity>;
12
+ export declare type LoggingSeverity = number | eLoggingSeverity;
13
+ export declare const enum _eInternalMessageId {
14
+ BrowserDoesNotSupportLocalStorage = 0,
15
+ BrowserCannotReadLocalStorage = 1,
16
+ BrowserCannotReadSessionStorage = 2,
17
+ BrowserCannotWriteLocalStorage = 3,
18
+ BrowserCannotWriteSessionStorage = 4,
19
+ BrowserFailedRemovalFromLocalStorage = 5,
20
+ BrowserFailedRemovalFromSessionStorage = 6,
21
+ CannotSendEmptyTelemetry = 7,
22
+ ClientPerformanceMathError = 8,
23
+ ErrorParsingAISessionCookie = 9,
24
+ ErrorPVCalc = 10,
25
+ ExceptionWhileLoggingError = 11,
26
+ FailedAddingTelemetryToBuffer = 12,
27
+ FailedMonitorAjaxAbort = 13,
28
+ FailedMonitorAjaxDur = 14,
29
+ FailedMonitorAjaxOpen = 15,
30
+ FailedMonitorAjaxRSC = 16,
31
+ FailedMonitorAjaxSend = 17,
32
+ FailedMonitorAjaxGetCorrelationHeader = 18,
33
+ FailedToAddHandlerForOnBeforeUnload = 19,
34
+ FailedToSendQueuedTelemetry = 20,
35
+ FailedToReportDataLoss = 21,
36
+ FlushFailed = 22,
37
+ MessageLimitPerPVExceeded = 23,
38
+ MissingRequiredFieldSpecification = 24,
39
+ NavigationTimingNotSupported = 25,
40
+ OnError = 26,
41
+ SessionRenewalDateIsZero = 27,
42
+ SenderNotInitialized = 28,
43
+ StartTrackEventFailed = 29,
44
+ StopTrackEventFailed = 30,
45
+ StartTrackFailed = 31,
46
+ StopTrackFailed = 32,
47
+ TelemetrySampledAndNotSent = 33,
48
+ TrackEventFailed = 34,
49
+ TrackExceptionFailed = 35,
50
+ TrackMetricFailed = 36,
51
+ TrackPVFailed = 37,
52
+ TrackPVFailedCalc = 38,
53
+ TrackTraceFailed = 39,
54
+ TransmissionFailed = 40,
55
+ FailedToSetStorageBuffer = 41,
56
+ FailedToRestoreStorageBuffer = 42,
57
+ InvalidBackendResponse = 43,
58
+ FailedToFixDepricatedValues = 44,
59
+ InvalidDurationValue = 45,
60
+ TelemetryEnvelopeInvalid = 46,
61
+ CreateEnvelopeError = 47,
62
+ CannotSerializeObject = 48,
63
+ CannotSerializeObjectNonSerializable = 49,
64
+ CircularReferenceDetected = 50,
65
+ ClearAuthContextFailed = 51,
66
+ ExceptionTruncated = 52,
67
+ IllegalCharsInName = 53,
68
+ ItemNotInArray = 54,
69
+ MaxAjaxPerPVExceeded = 55,
70
+ MessageTruncated = 56,
71
+ NameTooLong = 57,
72
+ SampleRateOutOfRange = 58,
73
+ SetAuthContextFailed = 59,
74
+ SetAuthContextFailedAccountName = 60,
75
+ StringValueTooLong = 61,
76
+ StartCalledMoreThanOnce = 62,
77
+ StopCalledWithoutStart = 63,
78
+ TelemetryInitializerFailed = 64,
79
+ TrackArgumentsNotSpecified = 65,
80
+ UrlTooLong = 66,
81
+ SessionStorageBufferFull = 67,
82
+ CannotAccessCookie = 68,
83
+ IdTooLong = 69,
84
+ InvalidEvent = 70,
85
+ FailedMonitorAjaxSetRequestHeader = 71,
86
+ SendBrowserInfoOnUserInit = 72,
87
+ PluginException = 73,
88
+ NotificationException = 74,
89
+ SnippetScriptLoadFailure = 99,
90
+ InvalidInstrumentationKey = 100,
91
+ CannotParseAiBlobValue = 101,
92
+ InvalidContentBlob = 102,
93
+ TrackPageActionEventFailed = 103,
94
+ FailedAddingCustomDefinedRequestContext = 104,
95
+ InMemoryStorageBufferFull = 105
96
+ }
11
97
  /**
12
98
  * Internal message ID. Please create a new one for every conceptually different message. Please keep alphabetically ordered
13
99
  */
14
- export declare const _InternalMessageId: {
15
- BrowserDoesNotSupportLocalStorage: number;
16
- BrowserCannotReadLocalStorage: number;
17
- BrowserCannotReadSessionStorage: number;
18
- BrowserCannotWriteLocalStorage: number;
19
- BrowserCannotWriteSessionStorage: number;
20
- BrowserFailedRemovalFromLocalStorage: number;
21
- BrowserFailedRemovalFromSessionStorage: number;
22
- CannotSendEmptyTelemetry: number;
23
- ClientPerformanceMathError: number;
24
- ErrorParsingAISessionCookie: number;
25
- ErrorPVCalc: number;
26
- ExceptionWhileLoggingError: number;
27
- FailedAddingTelemetryToBuffer: number;
28
- FailedMonitorAjaxAbort: number;
29
- FailedMonitorAjaxDur: number;
30
- FailedMonitorAjaxOpen: number;
31
- FailedMonitorAjaxRSC: number;
32
- FailedMonitorAjaxSend: number;
33
- FailedMonitorAjaxGetCorrelationHeader: number;
34
- FailedToAddHandlerForOnBeforeUnload: number;
35
- FailedToSendQueuedTelemetry: number;
36
- FailedToReportDataLoss: number;
37
- FlushFailed: number;
38
- MessageLimitPerPVExceeded: number;
39
- MissingRequiredFieldSpecification: number;
40
- NavigationTimingNotSupported: number;
41
- OnError: number;
42
- SessionRenewalDateIsZero: number;
43
- SenderNotInitialized: number;
44
- StartTrackEventFailed: number;
45
- StopTrackEventFailed: number;
46
- StartTrackFailed: number;
47
- StopTrackFailed: number;
48
- TelemetrySampledAndNotSent: number;
49
- TrackEventFailed: number;
50
- TrackExceptionFailed: number;
51
- TrackMetricFailed: number;
52
- TrackPVFailed: number;
53
- TrackPVFailedCalc: number;
54
- TrackTraceFailed: number;
55
- TransmissionFailed: number;
56
- FailedToSetStorageBuffer: number;
57
- FailedToRestoreStorageBuffer: number;
58
- InvalidBackendResponse: number;
59
- FailedToFixDepricatedValues: number;
60
- InvalidDurationValue: number;
61
- TelemetryEnvelopeInvalid: number;
62
- CreateEnvelopeError: number;
63
- CannotSerializeObject: number;
64
- CannotSerializeObjectNonSerializable: number;
65
- CircularReferenceDetected: number;
66
- ClearAuthContextFailed: number;
67
- ExceptionTruncated: number;
68
- IllegalCharsInName: number;
69
- ItemNotInArray: number;
70
- MaxAjaxPerPVExceeded: number;
71
- MessageTruncated: number;
72
- NameTooLong: number;
73
- SampleRateOutOfRange: number;
74
- SetAuthContextFailed: number;
75
- SetAuthContextFailedAccountName: number;
76
- StringValueTooLong: number;
77
- StartCalledMoreThanOnce: number;
78
- StopCalledWithoutStart: number;
79
- TelemetryInitializerFailed: number;
80
- TrackArgumentsNotSpecified: number;
81
- UrlTooLong: number;
82
- SessionStorageBufferFull: number;
83
- CannotAccessCookie: number;
84
- IdTooLong: number;
85
- InvalidEvent: number;
86
- FailedMonitorAjaxSetRequestHeader: number;
87
- SendBrowserInfoOnUserInit: number;
88
- PluginException: number;
89
- NotificationException: number;
90
- SnippetScriptLoadFailure: number;
91
- InvalidInstrumentationKey: number;
92
- CannotParseAiBlobValue: number;
93
- InvalidContentBlob: number;
94
- TrackPageActionEventFailed: number;
95
- FailedAddingCustomDefinedRequestContext: number;
96
- InMemoryStorageBufferFull: number;
97
- };
98
- export declare type _InternalMessageId = number | typeof _InternalMessageId;
100
+ export declare const _InternalMessageId: import("../JavaScriptSDK.Enums/EnumHelperFuncs").EnumValue<typeof _eInternalMessageId>;
101
+ 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
  }
@@ -1,14 +1,17 @@
1
1
  import { IAppInsightsCore } from "./IAppInsightsCore";
2
- import { IDiagnosticLogger } from "./IDiagnosticLogger";
3
2
  import { IConfiguration } from "./IConfiguration";
3
+ import { IDiagnosticLogger } from "./IDiagnosticLogger";
4
4
  import { ITelemetryItem } from "./ITelemetryItem";
5
- import { IPlugin } from "./ITelemetryPlugin";
5
+ import { IPlugin, ITelemetryPlugin } from "./ITelemetryPlugin";
6
6
  import { ITelemetryPluginChain } from "./ITelemetryPluginChain";
7
- /**
8
- * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
9
- * between multiple AppInsights instances
10
- */
11
- export interface IProcessTelemetryContext {
7
+ import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
8
+ import { ITelemetryUpdateState } from "./ITelemetryUpdateState";
9
+ export declare const enum GetExtCfgMergeType {
10
+ None = 0,
11
+ MergeDefaultOnly = 1,
12
+ MergeDefaultFromRootOrDefault = 2
13
+ }
14
+ export interface IBaseProcessingContext {
12
15
  /**
13
16
  * The current core instance for the request
14
17
  */
@@ -24,7 +27,7 @@ export interface IProcessTelemetryContext {
24
27
  /**
25
28
  * Gets the named extension config
26
29
  */
27
- getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
30
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
28
31
  /**
29
32
  * Gets the named config from either the named identifier extension or core config if neither exist then the
30
33
  * default value is returned
@@ -32,7 +35,7 @@ export interface IProcessTelemetryContext {
32
35
  * @param field The config field name
33
36
  * @param defaultValue The default value to return if no defined config exists
34
37
  */
35
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
38
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
36
39
  /**
37
40
  * Helper to allow plugins to check and possibly shortcut executing code only
38
41
  * required if there is a nextPlugin
@@ -46,13 +49,41 @@ export interface IProcessTelemetryContext {
46
49
  * Helper to set the next plugin proxy
47
50
  */
48
51
  setNext: (nextCtx: ITelemetryPluginChain) => void;
52
+ /**
53
+ * Synchronously iterate over the context chain running the callback for each plugin, once
54
+ * every plugin has been executed via the callback, any associated onComplete will be called.
55
+ * @param callback - The function call for each plugin in the context chain
56
+ */
57
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
58
+ /**
59
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
60
+ * @param onComplete - The onComplete to call
61
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
62
+ * @param args - Any additional arguments to pass to the onComplete function
63
+ */
64
+ onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
65
+ /**
66
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
67
+ * @param plugins - The execution order to process the plugins, if null or not supplied
68
+ * then the current execution order will be copied.
69
+ * @param startAt - The plugin to start processing from, if missing from the execution
70
+ * order then the next plugin will be NOT set.
71
+ */
72
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
73
+ }
74
+ /**
75
+ * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
76
+ * between multiple AppInsights instances
77
+ */
78
+ export interface IProcessTelemetryContext extends IBaseProcessingContext {
49
79
  /**
50
80
  * Call back for telemetry processing before it it is sent
51
81
  * @param env - This is the current event being reported
82
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
52
83
  */
53
- processNext: (env: ITelemetryItem) => void;
84
+ processNext: (env: ITelemetryItem) => boolean | void;
54
85
  /**
55
- * Create a new context using the core and config from the current instance
86
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
56
87
  * @param plugins - The execution order to process the plugins, if null or not supplied
57
88
  * then the current execution order will be copied.
58
89
  * @param startAt - The plugin to start processing from, if missing from the execution
@@ -60,3 +91,43 @@ export interface IProcessTelemetryContext {
60
91
  */
61
92
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
62
93
  }
94
+ /**
95
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
96
+ * or the SDK is being unloaded.
97
+ */
98
+ export interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
99
+ /**
100
+ * This Plugin has finished unloading, so unload the next one
101
+ * @param uploadState - The state of the unload process
102
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
103
+ */
104
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
105
+ /**
106
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
107
+ * @param plugins - The execution order to process the plugins, if null or not supplied
108
+ * then the current execution order will be copied.
109
+ * @param startAt - The plugin to start processing from, if missing from the execution
110
+ * order then the next plugin will be NOT set.
111
+ */
112
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
113
+ }
114
+ /**
115
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
116
+ * for when plugins are added, removed or the configuration was changed.
117
+ */
118
+ export interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
119
+ /**
120
+ * This Plugin has finished unloading, so unload the next one
121
+ * @param updateState - The update State
122
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
123
+ */
124
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
125
+ /**
126
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
127
+ * @param plugins - The execution order to process the plugins, if null or not supplied
128
+ * then the current execution order will be copied.
129
+ * @param startAt - The plugin to start processing from, if missing from the execution
130
+ * order then the next plugin will be NOT set.
131
+ */
132
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
133
+ }
@@ -0,0 +1,13 @@
1
+ import { ITelemetryItem } from "./ITelemetryItem";
2
+ export declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
3
+ export interface ITelemetryInitializerHandler {
4
+ remove(): void;
5
+ }
6
+ export interface ITelemetryInitializerContainer {
7
+ /**
8
+ * Add a telemetry processor to decorate or drop telemetry events.
9
+ * @param telemetryInitializer - The Telemetry Initializer function
10
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
11
+ */
12
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
13
+ }