@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
@@ -1,6 +1,9 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
- export enum LoggingSeverity {
3
+
4
+ import { createEnumStyle } from "../JavaScriptSDK.Enums/EnumHelperFuncs";
5
+
6
+ export const enum eLoggingSeverity {
4
7
  /**
5
8
  * Error will be sent as internal telemetry
6
9
  */
@@ -9,97 +12,190 @@ export enum LoggingSeverity {
9
12
  /**
10
13
  * Error will NOT be sent as internal telemetry, and will only be shown in browser console
11
14
  */
12
- WARNING = 2,
15
+ WARNING = 2
16
+ }
17
+
18
+ export const LoggingSeverity = createEnumStyle<typeof eLoggingSeverity>({
19
+ CRITICAL: eLoggingSeverity.CRITICAL,
20
+ WARNING: eLoggingSeverity.WARNING
21
+ });
22
+ export type LoggingSeverity = number | eLoggingSeverity;
23
+
24
+ export const enum _eInternalMessageId {
25
+ BrowserDoesNotSupportLocalStorage = 0,
26
+ BrowserCannotReadLocalStorage = 1,
27
+ BrowserCannotReadSessionStorage = 2,
28
+ BrowserCannotWriteLocalStorage = 3,
29
+ BrowserCannotWriteSessionStorage = 4,
30
+ BrowserFailedRemovalFromLocalStorage = 5,
31
+ BrowserFailedRemovalFromSessionStorage = 6,
32
+ CannotSendEmptyTelemetry = 7,
33
+ ClientPerformanceMathError = 8,
34
+ ErrorParsingAISessionCookie = 9,
35
+ ErrorPVCalc = 10,
36
+ ExceptionWhileLoggingError = 11,
37
+ FailedAddingTelemetryToBuffer = 12,
38
+ FailedMonitorAjaxAbort = 13,
39
+ FailedMonitorAjaxDur = 14,
40
+ FailedMonitorAjaxOpen = 15,
41
+ FailedMonitorAjaxRSC = 16,
42
+ FailedMonitorAjaxSend = 17,
43
+ FailedMonitorAjaxGetCorrelationHeader = 18,
44
+ FailedToAddHandlerForOnBeforeUnload = 19,
45
+ FailedToSendQueuedTelemetry = 20,
46
+ FailedToReportDataLoss = 21,
47
+ FlushFailed = 22,
48
+ MessageLimitPerPVExceeded = 23,
49
+ MissingRequiredFieldSpecification = 24,
50
+ NavigationTimingNotSupported = 25,
51
+ OnError = 26,
52
+ SessionRenewalDateIsZero = 27,
53
+ SenderNotInitialized = 28,
54
+ StartTrackEventFailed = 29,
55
+ StopTrackEventFailed = 30,
56
+ StartTrackFailed = 31,
57
+ StopTrackFailed = 32,
58
+ TelemetrySampledAndNotSent = 33,
59
+ TrackEventFailed = 34,
60
+ TrackExceptionFailed = 35,
61
+ TrackMetricFailed = 36,
62
+ TrackPVFailed = 37,
63
+ TrackPVFailedCalc = 38,
64
+ TrackTraceFailed = 39,
65
+ TransmissionFailed = 40,
66
+ FailedToSetStorageBuffer = 41,
67
+ FailedToRestoreStorageBuffer = 42,
68
+ InvalidBackendResponse = 43,
69
+ FailedToFixDepricatedValues = 44,
70
+ InvalidDurationValue = 45,
71
+ TelemetryEnvelopeInvalid = 46,
72
+ CreateEnvelopeError = 47,
73
+
74
+ // User actionable
75
+ CannotSerializeObject = 48,
76
+ CannotSerializeObjectNonSerializable = 49,
77
+ CircularReferenceDetected = 50,
78
+ ClearAuthContextFailed = 51,
79
+ ExceptionTruncated = 52,
80
+ IllegalCharsInName = 53,
81
+ ItemNotInArray = 54,
82
+ MaxAjaxPerPVExceeded = 55,
83
+ MessageTruncated = 56,
84
+ NameTooLong = 57,
85
+ SampleRateOutOfRange = 58,
86
+ SetAuthContextFailed = 59,
87
+ SetAuthContextFailedAccountName = 60,
88
+ StringValueTooLong = 61,
89
+ StartCalledMoreThanOnce = 62,
90
+ StopCalledWithoutStart = 63,
91
+ TelemetryInitializerFailed = 64,
92
+ TrackArgumentsNotSpecified = 65,
93
+ UrlTooLong = 66,
94
+ SessionStorageBufferFull = 67,
95
+ CannotAccessCookie = 68,
96
+ IdTooLong = 69,
97
+ InvalidEvent = 70,
98
+ FailedMonitorAjaxSetRequestHeader = 71,
99
+ SendBrowserInfoOnUserInit = 72,
100
+ PluginException = 73,
101
+ NotificationException = 74,
102
+ SnippetScriptLoadFailure = 99,
103
+ InvalidInstrumentationKey = 100,
104
+ CannotParseAiBlobValue = 101,
105
+ InvalidContentBlob = 102,
106
+ TrackPageActionEventFailed = 103,
107
+ FailedAddingCustomDefinedRequestContext = 104,
108
+ InMemoryStorageBufferFull = 105
13
109
  }
14
110
 
15
111
  /**
16
112
  * Internal message ID. Please create a new one for every conceptually different message. Please keep alphabetically ordered
17
113
  */
18
- export const _InternalMessageId = {
114
+ export const _InternalMessageId = createEnumStyle<typeof _eInternalMessageId>({
19
115
  // Non user actionable
20
- BrowserDoesNotSupportLocalStorage: 0,
21
- BrowserCannotReadLocalStorage: 1,
22
- BrowserCannotReadSessionStorage: 2,
23
- BrowserCannotWriteLocalStorage: 3,
24
- BrowserCannotWriteSessionStorage: 4,
25
- BrowserFailedRemovalFromLocalStorage: 5,
26
- BrowserFailedRemovalFromSessionStorage: 6,
27
- CannotSendEmptyTelemetry: 7,
28
- ClientPerformanceMathError: 8,
29
- ErrorParsingAISessionCookie: 9,
30
- ErrorPVCalc: 10,
31
- ExceptionWhileLoggingError: 11,
32
- FailedAddingTelemetryToBuffer: 12,
33
- FailedMonitorAjaxAbort: 13,
34
- FailedMonitorAjaxDur: 14,
35
- FailedMonitorAjaxOpen: 15,
36
- FailedMonitorAjaxRSC: 16,
37
- FailedMonitorAjaxSend: 17,
38
- FailedMonitorAjaxGetCorrelationHeader: 18,
39
- FailedToAddHandlerForOnBeforeUnload: 19,
40
- FailedToSendQueuedTelemetry: 20,
41
- FailedToReportDataLoss: 21,
42
- FlushFailed: 22,
43
- MessageLimitPerPVExceeded: 23,
44
- MissingRequiredFieldSpecification: 24,
45
- NavigationTimingNotSupported: 25,
46
- OnError: 26,
47
- SessionRenewalDateIsZero: 27,
48
- SenderNotInitialized: 28,
49
- StartTrackEventFailed: 29,
50
- StopTrackEventFailed: 30,
51
- StartTrackFailed: 31,
52
- StopTrackFailed: 32,
53
- TelemetrySampledAndNotSent: 33,
54
- TrackEventFailed: 34,
55
- TrackExceptionFailed: 35,
56
- TrackMetricFailed: 36,
57
- TrackPVFailed: 37,
58
- TrackPVFailedCalc: 38,
59
- TrackTraceFailed: 39,
60
- TransmissionFailed: 40,
61
- FailedToSetStorageBuffer: 41,
62
- FailedToRestoreStorageBuffer: 42,
63
- InvalidBackendResponse: 43,
64
- FailedToFixDepricatedValues: 44,
65
- InvalidDurationValue: 45,
66
- TelemetryEnvelopeInvalid: 46,
67
- CreateEnvelopeError: 47,
116
+ BrowserDoesNotSupportLocalStorage: _eInternalMessageId.BrowserDoesNotSupportLocalStorage,
117
+ BrowserCannotReadLocalStorage: _eInternalMessageId.BrowserCannotReadLocalStorage,
118
+ BrowserCannotReadSessionStorage: _eInternalMessageId.BrowserCannotReadSessionStorage,
119
+ BrowserCannotWriteLocalStorage: _eInternalMessageId.BrowserCannotWriteLocalStorage,
120
+ BrowserCannotWriteSessionStorage: _eInternalMessageId.BrowserCannotWriteSessionStorage,
121
+ BrowserFailedRemovalFromLocalStorage: _eInternalMessageId.BrowserFailedRemovalFromLocalStorage,
122
+ BrowserFailedRemovalFromSessionStorage: _eInternalMessageId.BrowserFailedRemovalFromSessionStorage,
123
+ CannotSendEmptyTelemetry: _eInternalMessageId.CannotSendEmptyTelemetry,
124
+ ClientPerformanceMathError: _eInternalMessageId.ClientPerformanceMathError,
125
+ ErrorParsingAISessionCookie: _eInternalMessageId.ErrorParsingAISessionCookie,
126
+ ErrorPVCalc: _eInternalMessageId.ErrorPVCalc,
127
+ ExceptionWhileLoggingError: _eInternalMessageId.ExceptionWhileLoggingError,
128
+ FailedAddingTelemetryToBuffer: _eInternalMessageId.FailedAddingTelemetryToBuffer,
129
+ FailedMonitorAjaxAbort: _eInternalMessageId.FailedMonitorAjaxAbort,
130
+ FailedMonitorAjaxDur: _eInternalMessageId.FailedMonitorAjaxDur,
131
+ FailedMonitorAjaxOpen: _eInternalMessageId.FailedMonitorAjaxOpen,
132
+ FailedMonitorAjaxRSC: _eInternalMessageId.FailedMonitorAjaxRSC,
133
+ FailedMonitorAjaxSend: _eInternalMessageId.FailedMonitorAjaxSend,
134
+ FailedMonitorAjaxGetCorrelationHeader: _eInternalMessageId.FailedMonitorAjaxGetCorrelationHeader,
135
+ FailedToAddHandlerForOnBeforeUnload: _eInternalMessageId.FailedToAddHandlerForOnBeforeUnload,
136
+ FailedToSendQueuedTelemetry: _eInternalMessageId.FailedToSendQueuedTelemetry,
137
+ FailedToReportDataLoss: _eInternalMessageId.FailedToReportDataLoss,
138
+ FlushFailed: _eInternalMessageId.FlushFailed,
139
+ MessageLimitPerPVExceeded: _eInternalMessageId.MessageLimitPerPVExceeded,
140
+ MissingRequiredFieldSpecification: _eInternalMessageId.MissingRequiredFieldSpecification,
141
+ NavigationTimingNotSupported: _eInternalMessageId.NavigationTimingNotSupported,
142
+ OnError: _eInternalMessageId.OnError,
143
+ SessionRenewalDateIsZero: _eInternalMessageId.SessionRenewalDateIsZero,
144
+ SenderNotInitialized: _eInternalMessageId.SenderNotInitialized,
145
+ StartTrackEventFailed: _eInternalMessageId.StartTrackEventFailed,
146
+ StopTrackEventFailed: _eInternalMessageId.StopTrackEventFailed,
147
+ StartTrackFailed: _eInternalMessageId.StartTrackFailed,
148
+ StopTrackFailed: _eInternalMessageId.StopTrackFailed,
149
+ TelemetrySampledAndNotSent: _eInternalMessageId.TelemetrySampledAndNotSent,
150
+ TrackEventFailed: _eInternalMessageId.TrackEventFailed,
151
+ TrackExceptionFailed: _eInternalMessageId.TrackExceptionFailed,
152
+ TrackMetricFailed: _eInternalMessageId.TrackMetricFailed,
153
+ TrackPVFailed: _eInternalMessageId.TrackPVFailed,
154
+ TrackPVFailedCalc: _eInternalMessageId.TrackPVFailedCalc,
155
+ TrackTraceFailed: _eInternalMessageId.TrackTraceFailed,
156
+ TransmissionFailed: _eInternalMessageId.TransmissionFailed,
157
+ FailedToSetStorageBuffer: _eInternalMessageId.FailedToSetStorageBuffer,
158
+ FailedToRestoreStorageBuffer: _eInternalMessageId.FailedToRestoreStorageBuffer,
159
+ InvalidBackendResponse: _eInternalMessageId.InvalidBackendResponse,
160
+ FailedToFixDepricatedValues: _eInternalMessageId.FailedToFixDepricatedValues,
161
+ InvalidDurationValue: _eInternalMessageId.InvalidDurationValue,
162
+ TelemetryEnvelopeInvalid: _eInternalMessageId.TelemetryEnvelopeInvalid,
163
+ CreateEnvelopeError: _eInternalMessageId.CreateEnvelopeError,
68
164
 
69
165
  // User actionable
70
- CannotSerializeObject: 48,
71
- CannotSerializeObjectNonSerializable: 49,
72
- CircularReferenceDetected: 50,
73
- ClearAuthContextFailed: 51,
74
- ExceptionTruncated: 52,
75
- IllegalCharsInName: 53,
76
- ItemNotInArray: 54,
77
- MaxAjaxPerPVExceeded: 55,
78
- MessageTruncated: 56,
79
- NameTooLong: 57,
80
- SampleRateOutOfRange: 58,
81
- SetAuthContextFailed: 59,
82
- SetAuthContextFailedAccountName: 60,
83
- StringValueTooLong: 61,
84
- StartCalledMoreThanOnce: 62,
85
- StopCalledWithoutStart: 63,
86
- TelemetryInitializerFailed: 64,
87
- TrackArgumentsNotSpecified: 65,
88
- UrlTooLong: 66,
89
- SessionStorageBufferFull: 67,
90
- CannotAccessCookie: 68,
91
- IdTooLong: 69,
92
- InvalidEvent: 70,
93
- FailedMonitorAjaxSetRequestHeader: 71,
94
- SendBrowserInfoOnUserInit: 72,
95
- PluginException: 73,
96
- NotificationException: 74,
97
- SnippetScriptLoadFailure: 99,
98
- InvalidInstrumentationKey:100,
99
- CannotParseAiBlobValue: 101,
100
- InvalidContentBlob: 102,
101
- TrackPageActionEventFailed: 103,
102
- FailedAddingCustomDefinedRequestContext: 104,
103
- InMemoryStorageBufferFull: 105
104
- };
105
- export type _InternalMessageId = number | typeof _InternalMessageId;
166
+ CannotSerializeObject: _eInternalMessageId.CannotSerializeObject,
167
+ CannotSerializeObjectNonSerializable: _eInternalMessageId.CannotSerializeObjectNonSerializable,
168
+ CircularReferenceDetected: _eInternalMessageId.CircularReferenceDetected,
169
+ ClearAuthContextFailed: _eInternalMessageId.ClearAuthContextFailed,
170
+ ExceptionTruncated: _eInternalMessageId.ExceptionTruncated,
171
+ IllegalCharsInName: _eInternalMessageId.IllegalCharsInName,
172
+ ItemNotInArray: _eInternalMessageId.ItemNotInArray,
173
+ MaxAjaxPerPVExceeded: _eInternalMessageId.MaxAjaxPerPVExceeded,
174
+ MessageTruncated: _eInternalMessageId.MessageTruncated,
175
+ NameTooLong: _eInternalMessageId.NameTooLong,
176
+ SampleRateOutOfRange: _eInternalMessageId.SampleRateOutOfRange,
177
+ SetAuthContextFailed: _eInternalMessageId.SetAuthContextFailed,
178
+ SetAuthContextFailedAccountName: _eInternalMessageId.SetAuthContextFailedAccountName,
179
+ StringValueTooLong: _eInternalMessageId.StringValueTooLong,
180
+ StartCalledMoreThanOnce: _eInternalMessageId.StartCalledMoreThanOnce,
181
+ StopCalledWithoutStart: _eInternalMessageId.StopCalledWithoutStart,
182
+ TelemetryInitializerFailed: _eInternalMessageId.TelemetryInitializerFailed,
183
+ TrackArgumentsNotSpecified: _eInternalMessageId.TrackArgumentsNotSpecified,
184
+ UrlTooLong: _eInternalMessageId.UrlTooLong,
185
+ SessionStorageBufferFull: _eInternalMessageId.SessionStorageBufferFull,
186
+ CannotAccessCookie: _eInternalMessageId.CannotAccessCookie,
187
+ IdTooLong: _eInternalMessageId.IdTooLong,
188
+ InvalidEvent: _eInternalMessageId.InvalidEvent,
189
+ FailedMonitorAjaxSetRequestHeader: _eInternalMessageId.FailedMonitorAjaxSetRequestHeader,
190
+ SendBrowserInfoOnUserInit: _eInternalMessageId.SendBrowserInfoOnUserInit,
191
+ PluginException: _eInternalMessageId.PluginException,
192
+ NotificationException: _eInternalMessageId.NotificationException,
193
+ SnippetScriptLoadFailure: _eInternalMessageId.SnippetScriptLoadFailure,
194
+ InvalidInstrumentationKey: _eInternalMessageId.InvalidInstrumentationKey,
195
+ CannotParseAiBlobValue: _eInternalMessageId.CannotParseAiBlobValue,
196
+ InvalidContentBlob: _eInternalMessageId.InvalidContentBlob,
197
+ TrackPageActionEventFailed: _eInternalMessageId.TrackPageActionEventFailed,
198
+ FailedAddingCustomDefinedRequestContext: _eInternalMessageId.FailedAddingCustomDefinedRequestContext,
199
+ InMemoryStorageBufferFull: _eInternalMessageId.InMemoryStorageBufferFull
200
+ });
201
+ export type _InternalMessageId = number | _eInternalMessageId;
@@ -38,6 +38,11 @@ export const enum SendRequestReason {
38
38
  * The event(s) being sent as a retry
39
39
  */
40
40
  Retry = 5,
41
+
42
+ /**
43
+ * The SDK is unloading
44
+ */
45
+ SdkUnload = 6,
41
46
 
42
47
  /**
43
48
  * Maximum batch size would be exceeded
@@ -0,0 +1,27 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ /**
5
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
6
+ */
7
+ export const enum TelemetryUnloadReason {
8
+ /**
9
+ * Teardown has been called without any context.
10
+ */
11
+ ManualTeardown = 0,
12
+
13
+ /**
14
+ * Just this plugin is being removed
15
+ */
16
+ PluginUnload = 1,
17
+
18
+ /**
19
+ * This instance of the plugin is being removed and replaced
20
+ */
21
+ PluginReplace = 2,
22
+
23
+ /**
24
+ * The entire SDK is being unloaded
25
+ */
26
+ SdkUnload = 50
27
+ }
@@ -0,0 +1,27 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ /**
5
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
6
+ */
7
+ export const enum TelemetryUpdateReason {
8
+ /**
9
+ * Unknown.
10
+ */
11
+ Unknown = 0,
12
+
13
+ /**
14
+ * The configuration has ben updated or changed
15
+ */
16
+ //ConfigurationChanged = 0x01,
17
+
18
+ /**
19
+ * One or more plugins have been added
20
+ */
21
+ PluginAdded = 0x10,
22
+
23
+ /**
24
+ * One or more plugins have been removed
25
+ */
26
+ PluginRemoved = 0x20,
27
+ }
@@ -2,7 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  import { ITelemetryItem } from "./ITelemetryItem";
4
4
  import { IChannelControls } from "./IChannelControls";
5
- import { IPlugin } from "./ITelemetryPlugin";
5
+ import { IPlugin, ITelemetryPlugin } from "./ITelemetryPlugin";
6
6
  import { IConfiguration } from "./IConfiguration";
7
7
  import { INotificationManager } from "./INotificationManager";
8
8
  import { INotificationListener } from "./INotificationListener";
@@ -10,8 +10,31 @@ import { IDiagnosticLogger } from "./IDiagnosticLogger";
10
10
  import { IProcessTelemetryContext } from "./IProcessTelemetryContext";
11
11
  import { IPerfManagerProvider } from "./IPerfManager";
12
12
  import { ICookieMgr } from "./ICookieMgr";
13
+ import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "./ITelemetryInitializers";
14
+ import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
15
+ import { UnloadHandler } from "../JavaScriptSDK/UnloadHandlerContainer";
16
+ import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
13
17
 
14
- "use strict";
18
+ export interface ILoadedPlugin<T extends IPlugin> {
19
+ plugin: T;
20
+
21
+ /**
22
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
23
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
24
+ * @returns boolean = true if the plugin is in a state where it is operational.
25
+ */
26
+ isEnabled: () => boolean;
27
+
28
+ /**
29
+ * You can optionally enable / disable a plugin from processing events.
30
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
31
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
32
+ * (unless it's also been re-initialized)
33
+ */
34
+ setEnabled: (isEnabled: boolean) => void;
35
+
36
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
37
+ }
15
38
 
16
39
  export interface IAppInsightsCore extends IPerfManagerProvider {
17
40
 
@@ -72,6 +95,13 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
72
95
  */
73
96
  removeNotificationListener?(listener: INotificationListener): void;
74
97
 
98
+ /**
99
+ * Add a telemetry processor to decorate or drop telemetry events.
100
+ * @param telemetryInitializer - The Telemetry Initializer function
101
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
102
+ */
103
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
104
+
75
105
  pollInternalLogs?(eventName?: string): number;
76
106
 
77
107
  stopPollingInternalLogs?(): void;
@@ -80,4 +110,54 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
80
110
  * Return a new instance of the IProcessTelemetryContext for processing events
81
111
  */
82
112
  getProcessTelContext() : IProcessTelemetryContext;
113
+
114
+ /**
115
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
116
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
117
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
118
+ * approach is to create a new instance and initialize that instance.
119
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
120
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
121
+ * @param isAsync - Can the unload be performed asynchronously (default)
122
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
123
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
124
+ */
125
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
126
+
127
+ /**
128
+ * Find and return the (first) plugin with the specified identifier if present
129
+ * @param pluginIdentifier
130
+ */
131
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
132
+
133
+ /**
134
+ * Add a new plugin to the installation
135
+ * @param plugin - The new plugin to add
136
+ * @param replaceExisting - should any existing plugin be replaced, default is false
137
+ * @param doAsync - Should the add be performed asynchronously
138
+ * @param addCb - [Optional] callback to call after the plugin has been added
139
+ */
140
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
141
+
142
+ /**
143
+ * Returns the unique event namespace that should be used when registering events
144
+ */
145
+ evtNamespace(): string;
146
+
147
+ /**
148
+ * Add a handler that will be called when the SDK is being unloaded
149
+ * @param handler - the handler
150
+ */
151
+ addUnloadCb(handler: UnloadHandler): void;
152
+
153
+ /**
154
+ * Flush and send any batched / cached data immediately
155
+ * @param async - send data asynchronously when true (defaults to true)
156
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
157
+ * If the caller doesn't return true the caller should assume that it may never be called.
158
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
159
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
160
+ * @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
161
+ */
162
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
83
163
  }
@@ -1,6 +1,9 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
+ import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
4
+ import { IProcessTelemetryUnloadContext } from "./IProcessTelemetryContext";
3
5
  import { ITelemetryPlugin } from "./ITelemetryPlugin";
6
+ import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
4
7
 
5
8
  "use strict";
6
9
 
@@ -20,16 +23,24 @@ export interface IChannelControls extends ITelemetryPlugin {
20
23
  resume(): void;
21
24
 
22
25
  /**
23
- * Tear down transmission pipeline
26
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
27
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
28
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
29
+ * @param unloadCtx - This is the context that should be used during unloading.
30
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
31
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
24
32
  */
25
- teardown(): void;
33
+ teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
26
34
 
27
35
  /**
28
36
  * Flush to send data immediately; channel should default to sending data asynchronously
29
- * @param async: send data asynchronously when true
30
- * @param callBack: if specified, notify caller when send is complete
37
+ * @param async - send data asynchronously when true
38
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
39
+ * If the caller doesn't return true the caller should assume that it may never be called.
40
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
41
+ * @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
31
42
  */
32
- flush(async: boolean, callBack?: () => void): void;
43
+ flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
33
44
  }
34
45
 
35
46
  export const MinChannelPriorty: number = 100;
@@ -12,6 +12,11 @@ export type InstrumentorHooksCallback = (funcArgs:IInstrumentCallDetails, ...org
12
12
  * You must always supply the error callback
13
13
  */
14
14
  export interface IInstrumentHooksCallbacks {
15
+ /**
16
+ * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
17
+ * identify the source of the instrumented hooks
18
+ */
19
+ ns?: string | string[];
15
20
 
16
21
  /**
17
22
  * The hook callback to call before the original function is called
@@ -40,20 +45,20 @@ export interface IInstrumentHooksCallbacks {
40
45
  */
41
46
  export interface IInstrumentHook {
42
47
  /** Unique Id for this callback on the hooked method */
43
- id:number;
48
+ id: number;
44
49
 
45
50
  /** Holds the callbacks */
46
- cbks:IInstrumentHooksCallbacks;
51
+ cbks: IInstrumentHooksCallbacks;
47
52
 
48
53
  /** Remove this hook from the function */
49
54
  rm: () => void;
50
55
  }
51
56
 
52
57
  export interface IInstrumentHooks {
53
- i:number; // Used to create unique ids
54
- n:string; // Function name
55
- f:any; // Original Function
56
- h:IInstrumentHook[]; // The hook
58
+ i: number; // Used to create unique ids
59
+ n: string; // Function name
60
+ f: any; // Original Function
61
+ h: IInstrumentHook[]; // The hook
57
62
  }
58
63
 
59
64
  export interface IInstrumentCallDetails {
@@ -85,4 +90,9 @@ export interface IInstrumentCallDetails {
85
90
  * The error (exception) which occurred while executing the original method
86
91
  */
87
92
  err?: Error;
93
+
94
+ /**
95
+ * The Event object from (window.event) at the start of the original call
96
+ */
97
+ evt?: Event;
88
98
  }