@safaricom-mxl/web-sdk 0.0.14 → 0.0.16

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 (266) hide show
  1. package/dist/api-logs/api/LogAPI/LogAPI.cjs.map +1 -1
  2. package/dist/api-logs/api/LogAPI/LogAPI.js.map +1 -1
  3. package/dist/api-logs/logAPI.cjs.map +1 -1
  4. package/dist/api-logs/logAPI.js.map +1 -1
  5. package/dist/api-logs/manager/NoOpLogManager/NoOpLogManager.cjs.map +1 -1
  6. package/dist/api-logs/manager/NoOpLogManager/NoOpLogManager.js.map +1 -1
  7. package/dist/api-logs/manager/ProxyLogManager/ProxyLogManager.cjs.map +1 -1
  8. package/dist/api-logs/manager/ProxyLogManager/ProxyLogManager.js.map +1 -1
  9. package/dist/api-page/api/PageAPI/PageAPI.cjs.map +1 -1
  10. package/dist/api-page/api/PageAPI/PageAPI.js.map +1 -1
  11. package/dist/api-page/manager/NoOpPageManager/NoOpPageManager.cjs.map +1 -1
  12. package/dist/api-page/manager/NoOpPageManager/NoOpPageManager.js.map +1 -1
  13. package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.cjs.map +1 -1
  14. package/dist/api-page/manager/ProxyPageManager/ProxyPageManager.js.map +1 -1
  15. package/dist/api-page/pageAPI.cjs.map +1 -1
  16. package/dist/api-page/pageAPI.js.map +1 -1
  17. package/dist/api-sessions/api/SessionAPI/SessionAPI.cjs.map +1 -1
  18. package/dist/api-sessions/api/SessionAPI/SessionAPI.d.cts.map +1 -1
  19. package/dist/api-sessions/api/SessionAPI/SessionAPI.d.ts.map +1 -1
  20. package/dist/api-sessions/api/SessionAPI/SessionAPI.js.map +1 -1
  21. package/dist/api-sessions/manager/NoOpSpanSessionManager/NoOpSpanSessionManager.cjs.map +1 -1
  22. package/dist/api-sessions/manager/NoOpSpanSessionManager/NoOpSpanSessionManager.js.map +1 -1
  23. package/dist/api-sessions/manager/ProxySpanSessionManager/ProxySpanSessionManager.cjs.map +1 -1
  24. package/dist/api-sessions/manager/ProxySpanSessionManager/ProxySpanSessionManager.js.map +1 -1
  25. package/dist/api-sessions/sessionAPI.cjs.map +1 -1
  26. package/dist/api-sessions/sessionAPI.js.map +1 -1
  27. package/dist/api-traces/api/TraceAPI/TraceAPI.cjs.map +1 -1
  28. package/dist/api-traces/api/TraceAPI/TraceAPI.js.map +1 -1
  29. package/dist/api-traces/manager/NoOpTraceManager/NoOpTraceManager.cjs.map +1 -1
  30. package/dist/api-traces/manager/NoOpTraceManager/NoOpTraceManager.js.map +1 -1
  31. package/dist/api-traces/manager/NoOpTraceManager/NonRecordingExtendedSpan.cjs.map +1 -1
  32. package/dist/api-traces/manager/NoOpTraceManager/NonRecordingExtendedSpan.d.cts.map +1 -1
  33. package/dist/api-traces/manager/NoOpTraceManager/NonRecordingExtendedSpan.d.ts.map +1 -1
  34. package/dist/api-traces/manager/NoOpTraceManager/NonRecordingExtendedSpan.js.map +1 -1
  35. package/dist/api-traces/manager/ProxyTraceManager/ProxyTraceManager.cjs.map +1 -1
  36. package/dist/api-traces/manager/ProxyTraceManager/ProxyTraceManager.js.map +1 -1
  37. package/dist/api-traces/traceAPI.cjs.map +1 -1
  38. package/dist/api-traces/traceAPI.js.map +1 -1
  39. package/dist/api-users/api/UserAPI/UserAPI.cjs.map +1 -1
  40. package/dist/api-users/api/UserAPI/UserAPI.js.map +1 -1
  41. package/dist/api-users/manager/NoOpUserManager/NoOpUserManager.cjs.map +1 -1
  42. package/dist/api-users/manager/NoOpUserManager/NoOpUserManager.js.map +1 -1
  43. package/dist/api-users/manager/ProxyUserManager/ProxyUserManager.cjs.map +1 -1
  44. package/dist/api-users/manager/ProxyUserManager/ProxyUserManager.js.map +1 -1
  45. package/dist/api-users/userAPI.cjs.map +1 -1
  46. package/dist/api-users/userAPI.js.map +1 -1
  47. package/dist/common/attributes.cjs.map +1 -1
  48. package/dist/common/attributes.js.map +1 -1
  49. package/dist/constants/attributes.cjs +2 -0
  50. package/dist/constants/attributes.cjs.map +1 -1
  51. package/dist/constants/attributes.d.cts +2 -1
  52. package/dist/constants/attributes.d.cts.map +1 -1
  53. package/dist/constants/attributes.d.ts +2 -1
  54. package/dist/constants/attributes.d.ts.map +1 -1
  55. package/dist/constants/attributes.js +2 -1
  56. package/dist/constants/attributes.js.map +1 -1
  57. package/dist/constants/index.cjs +1 -0
  58. package/dist/constants/index.d.cts +2 -2
  59. package/dist/constants/index.d.ts +2 -2
  60. package/dist/constants/index.js +2 -2
  61. package/dist/exporters/MXLLogExporter/MXLLogExporter.cjs.map +1 -1
  62. package/dist/exporters/MXLLogExporter/MXLLogExporter.js.map +1 -1
  63. package/dist/exporters/MXLLogExporter/OTLPFetchLogExporter.cjs.map +1 -1
  64. package/dist/exporters/MXLLogExporter/OTLPFetchLogExporter.js.map +1 -1
  65. package/dist/exporters/MXLLogExporter/utils.cjs.map +1 -1
  66. package/dist/exporters/MXLLogExporter/utils.js.map +1 -1
  67. package/dist/exporters/MXLTraceExporter/MXLTraceExporter.cjs.map +1 -1
  68. package/dist/exporters/MXLTraceExporter/MXLTraceExporter.js.map +1 -1
  69. package/dist/exporters/MXLTraceExporter/OTLPFetchTraceExporter.cjs.map +1 -1
  70. package/dist/exporters/MXLTraceExporter/OTLPFetchTraceExporter.js.map +1 -1
  71. package/dist/exporters/MXLTraceExporter/utils.cjs.map +1 -1
  72. package/dist/exporters/MXLTraceExporter/utils.js.map +1 -1
  73. package/dist/exporters/otlpBrowserFetchExportDelegate.cjs.map +1 -1
  74. package/dist/exporters/otlpBrowserFetchExportDelegate.d.cts.map +1 -1
  75. package/dist/exporters/otlpBrowserFetchExportDelegate.d.ts.map +1 -1
  76. package/dist/exporters/otlpBrowserFetchExportDelegate.js.map +1 -1
  77. package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.cjs.map +1 -1
  78. package/dist/instrumentations/MXLInstrumentationBase/MXLInstrumentationBase.js.map +1 -1
  79. package/dist/instrumentations/clicks/ClicksInstrumentation/ClicksInstrumentation.cjs.map +1 -1
  80. package/dist/instrumentations/clicks/ClicksInstrumentation/ClicksInstrumentation.js.map +1 -1
  81. package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.cjs.map +1 -1
  82. package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.d.cts.map +1 -1
  83. package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.d.ts.map +1 -1
  84. package/dist/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.js.map +1 -1
  85. package/dist/instrumentations/document-load/DocumentLoadInstrumentation/utils.cjs.map +1 -1
  86. package/dist/instrumentations/document-load/DocumentLoadInstrumentation/utils.js.map +1 -1
  87. package/dist/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.cjs.map +1 -1
  88. package/dist/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.js.map +1 -1
  89. package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.cjs.map +1 -1
  90. package/dist/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.js.map +1 -1
  91. package/dist/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.cjs.map +1 -1
  92. package/dist/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.js.map +1 -1
  93. package/dist/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.cjs +1 -1
  94. package/dist/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.cjs.map +1 -1
  95. package/dist/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.d.cts.map +1 -1
  96. package/dist/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.d.ts.map +1 -1
  97. package/dist/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.js +2 -2
  98. package/dist/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.js.map +1 -1
  99. package/dist/instrumentations/fetch/MXLFetchInstrumentation/MXLFetchInstrumentation.cjs.map +1 -1
  100. package/dist/instrumentations/fetch/MXLFetchInstrumentation/MXLFetchInstrumentation.js.map +1 -1
  101. package/dist/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.cjs.map +1 -1
  102. package/dist/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.js.map +1 -1
  103. package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.cjs.map +1 -1
  104. package/dist/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.js.map +1 -1
  105. package/dist/instrumentations/navigation/NavigationInstrumentation/instance.cjs.map +1 -1
  106. package/dist/instrumentations/navigation/NavigationInstrumentation/instance.js.map +1 -1
  107. package/dist/instrumentations/navigation/NavigationInstrumentation/react/createReactRouterNavigationInstrumentation.cjs.map +1 -1
  108. package/dist/instrumentations/navigation/NavigationInstrumentation/react/createReactRouterNavigationInstrumentation.js.map +1 -1
  109. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.cjs.map +1 -1
  110. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.d.cts.map +1 -1
  111. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.d.ts.map +1 -1
  112. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV5/withMXLRoutingLegacy.js.map +1 -1
  113. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.cjs.map +1 -1
  114. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Data/listenToRouterChanges.js.map +1 -1
  115. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.cjs.map +1 -1
  116. package/dist/instrumentations/navigation/NavigationInstrumentation/react/reactRouterV6Declarative/withMXLRouting.js.map +1 -1
  117. package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.cjs.map +1 -1
  118. package/dist/instrumentations/server-timing/ServerTimingInstrumentation/ServerTimingInstrumentation.js.map +1 -1
  119. package/dist/instrumentations/session/SpanSessionBrowserActivityInstrumentation/SpanSessionBrowserActivityInstrumentation.cjs.map +1 -1
  120. package/dist/instrumentations/session/SpanSessionBrowserActivityInstrumentation/SpanSessionBrowserActivityInstrumentation.js.map +1 -1
  121. package/dist/instrumentations/session/SpanSessionOnLoadInstrumentation/SpanSessionOnLoadInstrumentation.cjs.map +1 -1
  122. package/dist/instrumentations/session/SpanSessionOnLoadInstrumentation/SpanSessionOnLoadInstrumentation.js.map +1 -1
  123. package/dist/instrumentations/session/SpanSessionTimeoutInstrumentation/SpanSessionTimeoutInstrumentation.cjs.map +1 -1
  124. package/dist/instrumentations/session/SpanSessionTimeoutInstrumentation/SpanSessionTimeoutInstrumentation.js.map +1 -1
  125. package/dist/instrumentations/session/SpanSessionVisibilityInstrumentation/SpanSessionVisibilityInstrumentation.cjs.map +1 -1
  126. package/dist/instrumentations/session/SpanSessionVisibilityInstrumentation/SpanSessionVisibilityInstrumentation.js.map +1 -1
  127. package/dist/instrumentations/user-timing/UserTimingInstrumentation/UserTimingInstrumentation.cjs.map +1 -1
  128. package/dist/instrumentations/user-timing/UserTimingInstrumentation/UserTimingInstrumentation.js.map +1 -1
  129. package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.cjs.map +1 -1
  130. package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.cts.map +1 -1
  131. package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.d.ts.map +1 -1
  132. package/dist/instrumentations/web-vitals/WebVitalsInstrumentation/WebVitalsInstrumentation.js.map +1 -1
  133. package/dist/instrumentations/xhr/MXLXHRInstrumentation/MXLXHRInstrumentation.cjs.map +1 -1
  134. package/dist/instrumentations/xhr/MXLXHRInstrumentation/MXLXHRInstrumentation.js.map +1 -1
  135. package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.cjs +1 -1
  136. package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.cjs.map +1 -1
  137. package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.d.cts.map +1 -1
  138. package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.d.ts.map +1 -1
  139. package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.js +1 -1
  140. package/dist/managers/MXLConfigManager/MXLDynamicConfigManager.js.map +1 -1
  141. package/dist/managers/MXLConfigManager/constants.cjs.map +1 -1
  142. package/dist/managers/MXLConfigManager/constants.js.map +1 -1
  143. package/dist/managers/MXLConfigManager/utils.cjs.map +1 -1
  144. package/dist/managers/MXLConfigManager/utils.js.map +1 -1
  145. package/dist/managers/MXLLimitManager/MXLLimitManager.cjs.map +1 -1
  146. package/dist/managers/MXLLimitManager/MXLLimitManager.js.map +1 -1
  147. package/dist/managers/MXLLimitManager/constants.cjs.map +1 -1
  148. package/dist/managers/MXLLimitManager/constants.js.map +1 -1
  149. package/dist/managers/MXLLogManager/MXLLogManager.cjs +3 -1
  150. package/dist/managers/MXLLogManager/MXLLogManager.cjs.map +1 -1
  151. package/dist/managers/MXLLogManager/MXLLogManager.d.cts.map +1 -1
  152. package/dist/managers/MXLLogManager/MXLLogManager.d.ts.map +1 -1
  153. package/dist/managers/MXLLogManager/MXLLogManager.js +4 -2
  154. package/dist/managers/MXLLogManager/MXLLogManager.js.map +1 -1
  155. package/dist/managers/MXLPageManager/MXLPageManager.cjs.map +1 -1
  156. package/dist/managers/MXLPageManager/MXLPageManager.js.map +1 -1
  157. package/dist/managers/MXLSDKFeaturesManager/MXLSDKFeaturesManager.cjs.map +1 -1
  158. package/dist/managers/MXLSDKFeaturesManager/MXLSDKFeaturesManager.js.map +1 -1
  159. package/dist/managers/MXLSpanSessionManager/MXLSpanSessionManager.cjs.map +1 -1
  160. package/dist/managers/MXLSpanSessionManager/MXLSpanSessionManager.d.cts.map +1 -1
  161. package/dist/managers/MXLSpanSessionManager/MXLSpanSessionManager.d.ts.map +1 -1
  162. package/dist/managers/MXLSpanSessionManager/MXLSpanSessionManager.js.map +1 -1
  163. package/dist/managers/MXLTraceManager/MXLExtendedSpan.cjs.map +1 -1
  164. package/dist/managers/MXLTraceManager/MXLExtendedSpan.d.cts.map +1 -1
  165. package/dist/managers/MXLTraceManager/MXLExtendedSpan.d.ts.map +1 -1
  166. package/dist/managers/MXLTraceManager/MXLExtendedSpan.js.map +1 -1
  167. package/dist/managers/MXLTraceManager/MXLTraceManager.cjs.map +1 -1
  168. package/dist/managers/MXLTraceManager/MXLTraceManager.js.map +1 -1
  169. package/dist/managers/MXLUserManager/MXLUserManager.cjs.map +1 -1
  170. package/dist/managers/MXLUserManager/MXLUserManager.js.map +1 -1
  171. package/dist/managers/MXLUserManager/types.cjs.map +1 -1
  172. package/dist/managers/MXLUserManager/types.js.map +1 -1
  173. package/dist/mxl-web-sdk.js +3 -38
  174. package/dist/mxl-web-sdk.js.map +1 -1
  175. package/dist/processors/BrowserLogRecordProcessor/BrowserLogRecordProcessor.cjs.map +1 -1
  176. package/dist/processors/BrowserLogRecordProcessor/BrowserLogRecordProcessor.js.map +1 -1
  177. package/dist/processors/BrowserSpanProcessor/BrowserSpanProcessor.cjs.map +1 -1
  178. package/dist/processors/BrowserSpanProcessor/BrowserSpanProcessor.js.map +1 -1
  179. package/dist/processors/IdentifiableSessionLogRecordProcessor/IdentifiableSessionLogRecordProcessor.cjs.map +1 -1
  180. package/dist/processors/IdentifiableSessionLogRecordProcessor/IdentifiableSessionLogRecordProcessor.js.map +1 -1
  181. package/dist/processors/LogRecordScrubProcessor/LogRecordScrubProcessor.cjs.map +1 -1
  182. package/dist/processors/LogRecordScrubProcessor/LogRecordScrubProcessor.js.map +1 -1
  183. package/dist/processors/MXLLogRecordProcessor/MXLLogRecordProcessor.cjs.map +1 -1
  184. package/dist/processors/MXLLogRecordProcessor/MXLLogRecordProcessor.js.map +1 -1
  185. package/dist/processors/MXLNetworkSpanProcessor/MXLNetworkSpanProcessor.cjs.map +1 -1
  186. package/dist/processors/MXLNetworkSpanProcessor/MXLNetworkSpanProcessor.js.map +1 -1
  187. package/dist/processors/MXLSessionBatchedSpanProcessor/MXLSessionBatchedSpanProcessor.cjs.map +1 -1
  188. package/dist/processors/MXLSessionBatchedSpanProcessor/MXLSessionBatchedSpanProcessor.js.map +1 -1
  189. package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.cjs.map +1 -1
  190. package/dist/processors/PageLogRecordProcessor/PageLogRecordProcessor.js.map +1 -1
  191. package/dist/processors/PageSpanProcessor/PageSpanProcessor.cjs.map +1 -1
  192. package/dist/processors/PageSpanProcessor/PageSpanProcessor.js.map +1 -1
  193. package/dist/processors/SpanScrubProcessor/SpanScrubProcessor.cjs.map +1 -1
  194. package/dist/processors/SpanScrubProcessor/SpanScrubProcessor.js.map +1 -1
  195. package/dist/processors/UserLogRecordProcessor/UserLogRecordProcessor.cjs.map +1 -1
  196. package/dist/processors/UserLogRecordProcessor/UserLogRecordProcessor.js.map +1 -1
  197. package/dist/processors/UserSpanProcessor/UserSpanProcessor.cjs.map +1 -1
  198. package/dist/processors/UserSpanProcessor/UserSpanProcessor.js.map +1 -1
  199. package/dist/propagators/MXLW3CTraceContextPropagator/MXLW3CTraceContextPropagator.cjs.map +1 -1
  200. package/dist/propagators/MXLW3CTraceContextPropagator/MXLW3CTraceContextPropagator.js.map +1 -1
  201. package/dist/resources/appInstanceId.cjs.map +1 -1
  202. package/dist/resources/appInstanceId.js.map +1 -1
  203. package/dist/resources/constants/index.cjs +1 -1
  204. package/dist/resources/constants/index.cjs.map +1 -1
  205. package/dist/resources/constants/index.d.cts +1 -1
  206. package/dist/resources/constants/index.d.ts +1 -1
  207. package/dist/resources/constants/index.js +1 -1
  208. package/dist/resources/constants/index.js.map +1 -1
  209. package/dist/resources/webSdkResource.cjs.map +1 -1
  210. package/dist/resources/webSdkResource.d.cts.map +1 -1
  211. package/dist/resources/webSdkResource.d.ts.map +1 -1
  212. package/dist/resources/webSdkResource.js.map +1 -1
  213. package/dist/sdk/defaultAttributeScrubbers.cjs.map +1 -1
  214. package/dist/sdk/defaultAttributeScrubbers.js.map +1 -1
  215. package/dist/sdk/initSDK.cjs +13 -11
  216. package/dist/sdk/initSDK.cjs.map +1 -1
  217. package/dist/sdk/initSDK.d.cts.map +1 -1
  218. package/dist/sdk/initSDK.d.ts.map +1 -1
  219. package/dist/sdk/initSDK.js +14 -12
  220. package/dist/sdk/initSDK.js.map +1 -1
  221. package/dist/sdk/noopSessionRecording.cjs +10 -0
  222. package/dist/sdk/noopSessionRecording.cjs.map +1 -0
  223. package/dist/sdk/noopSessionRecording.d.cts +7 -0
  224. package/dist/sdk/noopSessionRecording.d.cts.map +1 -0
  225. package/dist/sdk/noopSessionRecording.d.ts +7 -0
  226. package/dist/sdk/noopSessionRecording.d.ts.map +1 -0
  227. package/dist/sdk/noopSessionRecording.js +9 -0
  228. package/dist/sdk/noopSessionRecording.js.map +1 -0
  229. package/dist/sdk/registry.cjs.map +1 -1
  230. package/dist/sdk/registry.js.map +1 -1
  231. package/dist/sdk/setupDefaultInstrumentations.cjs.map +1 -1
  232. package/dist/sdk/setupDefaultInstrumentations.js.map +1 -1
  233. package/dist/sdk/setupSessionRecorder.cjs +64 -22
  234. package/dist/sdk/setupSessionRecorder.cjs.map +1 -1
  235. package/dist/sdk/setupSessionRecorder.d.cts +16 -7
  236. package/dist/sdk/setupSessionRecorder.d.cts.map +1 -1
  237. package/dist/sdk/setupSessionRecorder.d.ts +16 -7
  238. package/dist/sdk/setupSessionRecorder.d.ts.map +1 -1
  239. package/dist/sdk/setupSessionRecorder.js +62 -21
  240. package/dist/sdk/setupSessionRecorder.js.map +1 -1
  241. package/dist/sdk/types.d.cts.map +1 -1
  242. package/dist/sdk/types.d.ts +1 -1
  243. package/dist/sdk/types.d.ts.map +1 -1
  244. package/dist/sdk/utils.cjs.map +1 -1
  245. package/dist/sdk/utils.js.map +1 -1
  246. package/dist/transport/FetchTransport/FetchTransport.cjs.map +1 -1
  247. package/dist/transport/FetchTransport/FetchTransport.js.map +1 -1
  248. package/dist/transport/FetchTransport/createFetchTransport.cjs.map +1 -1
  249. package/dist/transport/FetchTransport/createFetchTransport.js.map +1 -1
  250. package/dist/transport/RetryingTransport/RetryingTransport.cjs.map +1 -1
  251. package/dist/transport/RetryingTransport/RetryingTransport.js.map +1 -1
  252. package/dist/transport/RetryingTransport/createRetryingTransport.cjs.map +1 -1
  253. package/dist/transport/RetryingTransport/createRetryingTransport.js.map +1 -1
  254. package/dist/utils/MXLSpanStorage/MXLSpanStorage.cjs.map +1 -1
  255. package/dist/utils/MXLSpanStorage/MXLSpanStorage.js.map +1 -1
  256. package/dist/utils/PerformanceManager/OTelPerformanceManager.cjs.map +1 -1
  257. package/dist/utils/PerformanceManager/OTelPerformanceManager.js.map +1 -1
  258. package/dist/utils/bulkAddEventListener/bulkAddEventListener.cjs.map +1 -1
  259. package/dist/utils/bulkAddEventListener/bulkAddEventListener.js.map +1 -1
  260. package/dist/utils/bulkRemoveEventListener/bulkRemoveEventListener.cjs.map +1 -1
  261. package/dist/utils/bulkRemoveEventListener/bulkRemoveEventListener.js.map +1 -1
  262. package/dist/utils/getVisibilityState.cjs.map +1 -1
  263. package/dist/utils/getVisibilityState.js.map +1 -1
  264. package/dist/utils/nsfConfigValidation.cjs.map +1 -1
  265. package/dist/utils/nsfConfigValidation.js.map +1 -1
  266. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentLoadInstrumentation.js","names":["ATTR_URL_FULL","ATTR_USER_AGENT_ORIGINAL"],"sources":["../../../../src/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.ts"],"sourcesContent":["/*\n * Adapted from OpenTelemetry document-load instrumentation\n * https://github.com/open-telemetry/opentelemetry-js-contrib/tree/cc7eff47e2e7bad7678241b766753d5bd6dbc85f/packages/instrumentation-document-load\n *\n * Additional PerformanceResourceTiming attributes collected:\n * - entry_type, initiator_type\n * - decoded_body_size, http.response.body.size, http.response.size\n * - delivery_type (Chromium only)\n * - render_blocking_status (Chromium only)\n * - http.response.status_code (no Safari support)\n *\n * Custom diagnostic attributes added to identify resource loading issues:\n * - http.response.cors_opaque - CORS-restricted resource (opaque response)\n * - http.response.cache_revalidated - 304 Not Modified response\n * - http.request.incomplete - Request started but didn't complete (network error, aborted)\n * - http.request.prevented - Request never started (blocked by CSP, browser, extension)\n */\n\nimport type { Span } from '@opentelemetry/api';\nimport { context, propagation, ROOT_CONTEXT, trace } from '@opentelemetry/api';\nimport { TRACE_PARENT_HEADER } from '@opentelemetry/core';\nimport { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport type { PerformanceEntries } from '@opentelemetry/sdk-trace-web';\nimport {\n addSpanNetworkEvent,\n addSpanNetworkEvents,\n hasKey,\n PerformanceTimingNames,\n} from '@opentelemetry/sdk-trace-web';\nimport { ATTR_HTTP_RESPONSE_STATUS_CODE } from '@opentelemetry/semantic-conventions';\nimport {\n ATTR_HTTP_RESPONSE_BODY_SIZE,\n ATTR_HTTP_RESPONSE_SIZE,\n ATTR_URL_FULL,\n ATTR_USER_AGENT_ORIGINAL,\n} from '@opentelemetry/semantic-conventions/incubating';\nimport { MXL_TYPES, KEY_MXL_TYPE } from '../../../constants/index.ts';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport { AttributeNames } from './enums/AttributeNames.ts';\nimport type {\n DocumentLoadCustomAttributeFunction,\n DocumentLoadInstrumentationConfig,\n ResourceFetchCustomAttributeFunction,\n} from './types.ts';\nimport {\n addSpanPerformancePaintEvents,\n getPerformanceNavigationEntries,\n} from './utils.ts';\n\n/**\n * Adds new browser features not yet in TypeScript's DOM lib (as of Oct 2025):\n * - deliveryType: Chromium only (experimental) https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/deliveryType\n * - renderBlockingStatus: Chromium only https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/renderBlockingStatus\n */\ntype MXLPerformanceResourceTiming = PerformanceResourceTiming & {\n deliveryType?: 'cache' | '';\n renderBlockingStatus?: 'blocking' | 'non-blocking';\n};\n\n// PerformanceResourceTiming attribute names\nconst ATTR_HTTP_RESPONSE_DELIVERY_TYPE = 'http.response.delivery_type';\nconst ATTR_HTTP_RESPONSE_DECODED_BODY_SIZE = 'http.response.decoded_body_size';\nconst ATTR_HTTP_REQUEST_INITIATOR_TYPE = 'http.request.initiator_type';\nconst ATTR_HTTP_REQUEST_RENDER_BLOCKING_STATUS =\n 'http.request.render_blocking_status';\n\n// Diagnostic attribute names\nconst ATTR_HTTP_RESPONSE_CORS_OPAQUE = 'http.response.cors_opaque'; // CORS-restricted resource (opaque response)\nconst ATTR_HTTP_RESPONSE_CACHE_REVALIDATED = 'http.response.cache_revalidated'; // 304 Not Modified response\nconst ATTR_HTTP_REQUEST_INCOMPLETE = 'http.request.incomplete'; // Request started but didn't complete\nconst ATTR_HTTP_REQUEST_PREVENTED = 'http.request.prevented'; // Request never started (blocked)\n\nexport class DocumentLoadInstrumentation extends MXLInstrumentationBase<DocumentLoadInstrumentationConfig> {\n private readonly _onDocumentLoaded: () => void;\n private _performanceCollected = false;\n\n public constructor({\n diag,\n perf,\n enabled,\n applyCustomAttributesOnSpan,\n ignorePerformancePaintEvents = false,\n ignoreNetworkEvents = false,\n }: DocumentLoadInstrumentationConfig = {}) {\n super({\n instrumentationName: 'DocumentLoadInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {\n enabled,\n applyCustomAttributesOnSpan,\n ignorePerformancePaintEvents,\n ignoreNetworkEvents,\n },\n });\n\n this._onDocumentLoaded = () => {\n // Timeout needed because performance metrics for loadEnd aren't available until after the load event\n window.setTimeout(() => {\n this._collectPerformance();\n }, 0);\n };\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n protected override init() {\n this._diag.debug('Initializing document load instrumentation');\n return undefined;\n }\n\n /**\n * Adds spans for all resources\n * @param rootSpan\n */\n private _addResourcesSpans(rootSpan: Span): void {\n const resources: MXLPerformanceResourceTiming[] =\n performance.getEntriesByType('resource');\n resources.forEach((resource) => {\n this._initResourceSpan(resource, rootSpan);\n });\n }\n\n /**\n * Collects information about performance and creates appropriate spans\n */\n private _collectPerformance(): void {\n if (this._performanceCollected) {\n return;\n }\n this._performanceCollected = true;\n\n const metaElement = Array.from(document.getElementsByTagName('meta')).find(\n (e) => e.getAttribute('name') === TRACE_PARENT_HEADER,\n );\n const entries = getPerformanceNavigationEntries();\n const traceparent = metaElement?.content || '';\n context.with(propagation.extract(ROOT_CONTEXT, { traceparent }), () => {\n const rootSpan = this._startSpan(\n AttributeNames.DOCUMENT_LOAD,\n PerformanceTimingNames.FETCH_START,\n entries,\n );\n if (!rootSpan) {\n return;\n }\n context.with(trace.setSpan(context.active(), rootSpan), () => {\n const fetchSpan = this._startSpan(\n AttributeNames.DOCUMENT_FETCH,\n PerformanceTimingNames.FETCH_START,\n entries,\n );\n if (fetchSpan) {\n fetchSpan.setAttribute(ATTR_URL_FULL, location.href);\n context.with(trace.setSpan(context.active(), fetchSpan), () => {\n addSpanNetworkEvents(\n fetchSpan,\n entries,\n this.getConfig().ignoreNetworkEvents,\n );\n this._addCustomAttributesOnSpan(\n fetchSpan,\n this.getConfig().applyCustomAttributesOnSpan?.documentFetch,\n );\n this._endSpan(\n fetchSpan,\n PerformanceTimingNames.RESPONSE_END,\n entries,\n );\n });\n }\n });\n\n rootSpan.setAttribute(KEY_MXL_TYPE, MXL_TYPES.DocumentLoad);\n rootSpan.setAttribute(ATTR_URL_FULL, location.href);\n rootSpan.setAttribute(ATTR_USER_AGENT_ORIGINAL, navigator.userAgent);\n\n this._addResourcesSpans(rootSpan);\n\n if (!this.getConfig().ignoreNetworkEvents) {\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.FETCH_START,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.UNLOAD_EVENT_START,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.UNLOAD_EVENT_END,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.DOM_INTERACTIVE,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_START,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_END,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.DOM_COMPLETE,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.LOAD_EVENT_START,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.LOAD_EVENT_END,\n entries,\n );\n }\n\n if (!this.getConfig().ignorePerformancePaintEvents) {\n addSpanPerformancePaintEvents(rootSpan);\n }\n\n this._addCustomAttributesOnSpan(\n rootSpan,\n this.getConfig().applyCustomAttributesOnSpan?.documentLoad,\n );\n this._endSpan(rootSpan, PerformanceTimingNames.LOAD_EVENT_END, entries);\n });\n }\n\n /**\n * Helper function for ending a span\n * @param span\n * @param performanceName name of performance entry for end time\n * @param entries\n */\n private _endSpan(\n span: Span | undefined,\n performanceName: string,\n entries: PerformanceEntries,\n ) {\n // Span can be undefined when entries are missing the required performance timing - no span will be created\n if (span) {\n if (\n hasKey(entries, performanceName) &&\n typeof entries[performanceName] === 'number'\n ) {\n span.end(entries[performanceName]);\n } else {\n span.end();\n }\n }\n }\n\n /**\n * Creates and ends a span with network information about a resource added as timed events\n * @param resource\n * @param parentSpan\n */\n private _initResourceSpan(\n resource: MXLPerformanceResourceTiming,\n parentSpan: Span,\n ) {\n const span = this._startSpan(\n AttributeNames.RESOURCE_FETCH,\n PerformanceTimingNames.FETCH_START,\n resource,\n parentSpan,\n );\n if (!span) {\n return;\n }\n\n span.setAttribute(KEY_MXL_TYPE, MXL_TYPES.ResourceFetch);\n span.setAttribute(ATTR_URL_FULL, resource.name);\n addSpanNetworkEvents(span, resource, this.getConfig().ignoreNetworkEvents);\n\n if (resource.deliveryType) {\n span.setAttribute(\n ATTR_HTTP_RESPONSE_DELIVERY_TYPE,\n resource.deliveryType,\n );\n }\n\n if (resource.initiatorType) {\n span.setAttribute(\n ATTR_HTTP_REQUEST_INITIATOR_TYPE,\n resource.initiatorType,\n );\n }\n\n if (resource.renderBlockingStatus) {\n span.setAttribute(\n ATTR_HTTP_REQUEST_RENDER_BLOCKING_STATUS,\n resource.renderBlockingStatus,\n );\n }\n\n if (resource.responseStatus) {\n span.setAttribute(\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n resource.responseStatus,\n );\n }\n\n // Validate size fields exist and aren't negative\n if (\n typeof resource.encodedBodySize === 'number' &&\n resource.encodedBodySize >= 0\n ) {\n span.setAttribute(ATTR_HTTP_RESPONSE_BODY_SIZE, resource.encodedBodySize);\n }\n\n if (\n typeof resource.transferSize === 'number' &&\n resource.transferSize >= 0\n ) {\n span.setAttribute(ATTR_HTTP_RESPONSE_SIZE, resource.transferSize);\n }\n\n if (\n typeof resource.decodedBodySize === 'number' &&\n resource.decodedBodySize >= 0\n ) {\n span.setAttribute(\n ATTR_HTTP_RESPONSE_DECODED_BODY_SIZE,\n resource.decodedBodySize,\n );\n }\n\n this._addResourceDiagnosticAttributes(span, resource);\n\n this._addCustomAttributesOnResourceSpan(\n span,\n resource,\n this.getConfig().applyCustomAttributesOnSpan?.resourceFetch,\n );\n this._endSpan(span, PerformanceTimingNames.RESPONSE_END, resource);\n }\n\n /**\n * Helper function for starting a span\n * @param spanName name of span\n * @param performanceName name of performance entry for time start\n * @param entries\n * @param parentSpan\n */\n private _startSpan(\n spanName: string,\n performanceName: string,\n entries: PerformanceEntries,\n parentSpan?: Span,\n ): Span | undefined {\n if (\n hasKey(entries, performanceName) &&\n typeof entries[performanceName] === 'number'\n ) {\n const span = this.tracer.startSpan(\n spanName,\n {\n startTime: entries[performanceName],\n },\n parentSpan ? trace.setSpan(context.active(), parentSpan) : undefined,\n );\n return span;\n }\n return undefined;\n }\n\n /**\n * Executes callback {_onDocumentLoaded} when the page is loaded\n */\n private _waitForPageLoad() {\n if (window.document.readyState === 'complete') {\n this._onDocumentLoaded();\n } else {\n window.addEventListener('load', this._onDocumentLoaded);\n }\n }\n\n /**\n * Adds custom attributes to span if configured\n * Used for both documentFetch and documentLoad spans\n */\n private _addCustomAttributesOnSpan(\n span: Span,\n applyCustomAttributesOnSpan:\n | DocumentLoadCustomAttributeFunction\n | undefined,\n ) {\n if (applyCustomAttributesOnSpan) {\n safeExecuteInTheMiddle(\n () => {\n applyCustomAttributesOnSpan(span);\n },\n (error) => {\n if (!error) {\n return;\n }\n\n this._diag.error('addCustomAttributesOnSpan', error);\n },\n true,\n );\n }\n }\n\n /**\n * Adds custom attributes to resource span if configured\n */\n private _addCustomAttributesOnResourceSpan(\n span: Span,\n resource: MXLPerformanceResourceTiming,\n applyCustomAttributesOnSpan:\n | ResourceFetchCustomAttributeFunction\n | undefined,\n ) {\n if (applyCustomAttributesOnSpan) {\n safeExecuteInTheMiddle(\n () => {\n applyCustomAttributesOnSpan(span, resource);\n },\n (error) => {\n if (!error) {\n return;\n }\n\n this._diag.error('addCustomAttributesOnResourceSpan', error);\n },\n true,\n );\n }\n }\n\n private _hasNoSizeData(resource: MXLPerformanceResourceTiming): boolean {\n const transferSize =\n typeof resource.transferSize === 'number' ? resource.transferSize : 0;\n const decodedBodySize =\n typeof resource.decodedBodySize === 'number'\n ? resource.decodedBodySize\n : 0;\n const encodedBodySize =\n typeof resource.encodedBodySize === 'number'\n ? resource.encodedBodySize\n : 0;\n\n return transferSize === 0 && decodedBodySize === 0 && encodedBodySize === 0;\n }\n\n private _hasTimingData(resource: MXLPerformanceResourceTiming): boolean {\n const fetchStart =\n typeof resource.fetchStart === 'number' ? resource.fetchStart : 0;\n const responseEnd =\n typeof resource.responseEnd === 'number' ? resource.responseEnd : 0;\n\n return fetchStart > 0 && responseEnd > 0;\n }\n\n private _isCorsRestricted(\n resource: MXLPerformanceResourceTiming,\n ): boolean {\n return this._hasNoSizeData(resource) && this._hasTimingData(resource);\n }\n\n private _isFetchIncomplete(\n resource: MXLPerformanceResourceTiming,\n ): boolean {\n const fetchStart =\n typeof resource.fetchStart === 'number' ? resource.fetchStart : 0;\n const responseEnd =\n typeof resource.responseEnd === 'number' ? resource.responseEnd : 0;\n\n return this._hasNoSizeData(resource) && fetchStart > 0 && responseEnd === 0;\n }\n\n private _isFetchPrevented(\n resource: MXLPerformanceResourceTiming,\n ): boolean {\n const fetchStart =\n typeof resource.fetchStart === 'number' ? resource.fetchStart : 0;\n\n return this._hasNoSizeData(resource) && fetchStart === 0;\n }\n\n /**\n * Detect cache validation (304 Not Modified responses)\n *\n * 304 responses show transferSize of ~300 bytes (headers only, no body).\n * Use deliveryType to distinguish from cache hits: 'cache' = no network, otherwise = 304.\n *\n * Spec: https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-transfersize\n */\n private _isCacheValidated(\n resource: MXLPerformanceResourceTiming,\n ): boolean {\n const transferSize =\n typeof resource.transferSize === 'number' ? resource.transferSize : 0;\n const deliveryType =\n typeof resource.deliveryType === 'string' ? resource.deliveryType : '';\n\n return transferSize === 300 && deliveryType !== 'cache';\n }\n\n /**\n * Add diagnostic attributes to identify resource loading issues\n *\n * Diagnostic attributes help identify why resources may have incomplete timing data:\n * - CORS restrictions (opaque responses without Timing-Allow-Origin header)\n * - Cache revalidation (304 Not Modified responses)\n * - Request incomplete (started but didn't complete - network error, aborted)\n * - Request prevented (never started - blocked by CSP, browser, extension)\n */\n private _addResourceDiagnosticAttributes(\n span: Span,\n resource: MXLPerformanceResourceTiming,\n ): void {\n if (this._isCorsRestricted(resource)) {\n span.setAttribute(ATTR_HTTP_RESPONSE_CORS_OPAQUE, true);\n } else if (this._isFetchIncomplete(resource)) {\n span.setAttribute(ATTR_HTTP_REQUEST_INCOMPLETE, true);\n } else if (this._isFetchPrevented(resource)) {\n span.setAttribute(ATTR_HTTP_REQUEST_PREVENTED, true);\n }\n\n if (this._isCacheValidated(resource)) {\n span.setAttribute(ATTR_HTTP_RESPONSE_CACHE_REVALIDATED, true);\n }\n }\n\n public enable(): void {\n window.removeEventListener('load', this._onDocumentLoaded);\n this._waitForPageLoad();\n }\n\n public disable(): void {\n window.removeEventListener('load', this._onDocumentLoaded);\n }\n}\n"],"mappings":";;;;;;;;;;;AA4DA,MAAM,mCAAmC;AACzC,MAAM,uCAAuC;AAC7C,MAAM,mCAAmC;AACzC,MAAM,2CACJ;AAGF,MAAM,iCAAiC;AACvC,MAAM,uCAAuC;AAC7C,MAAM,+BAA+B;AACrC,MAAM,8BAA8B;AAEpC,IAAa,8BAAb,cAAiD,uBAA0D;CACzG;CACA,wBAAgC;CAEhC,YAAmB,EACjB,MACA,MACA,SACA,6BACA,+BAA+B,OAC/B,sBAAsB,UACe,EAAE,EAAE;AACzC,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ;IACN;IACA;IACA;IACA;IACD;GACF,CAAC;AAEF,OAAK,0BAA0B;AAE7B,UAAO,iBAAiB;AACtB,SAAK,qBAAqB;MACzB,EAAE;;AAGP,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,OAA0B;AACxB,OAAK,MAAM,MAAM,6CAA6C;;;;;;CAQhE,mBAA2B,UAAsB;AAE7C,cAAY,iBAAiB,WACtB,CAAC,SAAS,aAAa;AAC9B,QAAK,kBAAkB,UAAU,SAAS;IAC1C;;;;;CAMJ,sBAAoC;AAClC,MAAI,KAAK,sBACP;AAEF,OAAK,wBAAwB;EAE7B,MAAM,cAAc,MAAM,KAAK,SAAS,qBAAqB,OAAO,CAAC,CAAC,MACnE,MAAM,EAAE,aAAa,OAAO,KAAK,oBACnC;EACD,MAAM,UAAU,iCAAiC;EACjD,MAAM,cAAc,aAAa,WAAW;AAC5C,UAAQ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kBACE,UACS;EACT,MAAM,eACJ,OAAO,SAAS,iBAAiB,WAAW,SAAS,eAAe;EACtE,MAAM,eACJ,OAAO,SAAS,iBAAiB,WAAW,SAAS,eAAe;AAEtE,SAAO,iBAAiB,OAAO,iBAAiB;;;;;;;;;;;CAYlD,iCACE,MACA,UACM;AACN,MAAI,KAAK,kBAAkB,SAAS,CAClC,MAAK,aAAa,gCAAgC,KAAK;WAC9C,KAAK,mBAAmB,SAAS,CAC1C,MAAK,aAAa,8BAA8B,KAAK;WAC5C,KAAK,kBAAkB,SAAS,CACzC,MAAK,aAAa,6BAA6B,KAAK;AAGtD,MAAI,KAAK,kBAAkB,SAAS,CAClC,MAAK,aAAa,sCAAsC,KAAK;;CAIjE,SAAsB;AACpB,SAAO,oBAAoB,QAAQ,KAAK,kBAAkB;AAC1D,OAAK,kBAAkB;;CAGzB,UAAuB;AACrB,SAAO,oBAAoB,QAAQ,KAAK,kBAAkB"}
1
+ {"version":3,"file":"DocumentLoadInstrumentation.js","names":["ATTR_URL_FULL","ATTR_USER_AGENT_ORIGINAL"],"sources":["../../../../src/instrumentations/document-load/DocumentLoadInstrumentation/DocumentLoadInstrumentation.ts"],"sourcesContent":["/*\n * Adapted from OpenTelemetry document-load instrumentation\n * https://github.com/open-telemetry/opentelemetry-js-contrib/tree/cc7eff47e2e7bad7678241b766753d5bd6dbc85f/packages/instrumentation-document-load\n *\n * Additional PerformanceResourceTiming attributes collected:\n * - entry_type, initiator_type\n * - decoded_body_size, http.response.body.size, http.response.size\n * - delivery_type (Chromium only)\n * - render_blocking_status (Chromium only)\n * - http.response.status_code (no Safari support)\n *\n * Custom diagnostic attributes added to identify resource loading issues:\n * - http.response.cors_opaque - CORS-restricted resource (opaque response)\n * - http.response.cache_revalidated - 304 Not Modified response\n * - http.request.incomplete - Request started but didn't complete (network error, aborted)\n * - http.request.prevented - Request never started (blocked by CSP, browser, extension)\n */\n\nimport type { Span } from '@opentelemetry/api';\nimport { context, propagation, ROOT_CONTEXT, trace } from '@opentelemetry/api';\nimport { TRACE_PARENT_HEADER } from '@opentelemetry/core';\nimport { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport type { PerformanceEntries } from '@opentelemetry/sdk-trace-web';\nimport {\n addSpanNetworkEvent,\n addSpanNetworkEvents,\n hasKey,\n PerformanceTimingNames,\n} from '@opentelemetry/sdk-trace-web';\nimport { ATTR_HTTP_RESPONSE_STATUS_CODE } from '@opentelemetry/semantic-conventions';\nimport {\n ATTR_HTTP_RESPONSE_BODY_SIZE,\n ATTR_HTTP_RESPONSE_SIZE,\n ATTR_URL_FULL,\n ATTR_USER_AGENT_ORIGINAL,\n} from '@opentelemetry/semantic-conventions/incubating';\nimport { KEY_MXL_TYPE, MXL_TYPES } from '../../../constants';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport { AttributeNames } from './enums/AttributeNames';\nimport type {\n DocumentLoadCustomAttributeFunction,\n DocumentLoadInstrumentationConfig,\n ResourceFetchCustomAttributeFunction,\n} from './types';\nimport {\n addSpanPerformancePaintEvents,\n getPerformanceNavigationEntries,\n} from './utils';\n\n/**\n * Adds new browser features not yet in TypeScript's DOM lib (as of Oct 2025):\n * - deliveryType: Chromium only (experimental) https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/deliveryType\n * - renderBlockingStatus: Chromium only https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/renderBlockingStatus\n */\ntype MXLPerformanceResourceTiming = PerformanceResourceTiming & {\n deliveryType?: 'cache' | '';\n renderBlockingStatus?: 'blocking' | 'non-blocking';\n};\n\n// PerformanceResourceTiming attribute names\nconst ATTR_HTTP_RESPONSE_DELIVERY_TYPE = 'http.response.delivery_type';\nconst ATTR_HTTP_RESPONSE_DECODED_BODY_SIZE = 'http.response.decoded_body_size';\nconst ATTR_HTTP_REQUEST_INITIATOR_TYPE = 'http.request.initiator_type';\nconst ATTR_HTTP_REQUEST_RENDER_BLOCKING_STATUS =\n 'http.request.render_blocking_status';\n\n// Diagnostic attribute names\nconst ATTR_HTTP_RESPONSE_CORS_OPAQUE = 'http.response.cors_opaque'; // CORS-restricted resource (opaque response)\nconst ATTR_HTTP_RESPONSE_CACHE_REVALIDATED = 'http.response.cache_revalidated'; // 304 Not Modified response\nconst ATTR_HTTP_REQUEST_INCOMPLETE = 'http.request.incomplete'; // Request started but didn't complete\nconst ATTR_HTTP_REQUEST_PREVENTED = 'http.request.prevented'; // Request never started (blocked)\n\nexport class DocumentLoadInstrumentation extends MXLInstrumentationBase<DocumentLoadInstrumentationConfig> {\n private readonly _onDocumentLoaded: () => void;\n private _performanceCollected = false;\n\n public constructor({\n diag,\n perf,\n enabled,\n applyCustomAttributesOnSpan,\n ignorePerformancePaintEvents = false,\n ignoreNetworkEvents = false,\n }: DocumentLoadInstrumentationConfig = {}) {\n super({\n instrumentationName: 'DocumentLoadInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {\n enabled,\n applyCustomAttributesOnSpan,\n ignorePerformancePaintEvents,\n ignoreNetworkEvents,\n },\n });\n\n this._onDocumentLoaded = () => {\n // Timeout needed because performance metrics for loadEnd aren't available until after the load event\n window.setTimeout(() => {\n this._collectPerformance();\n }, 0);\n };\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n protected override init() {\n this._diag.debug('Initializing document load instrumentation');\n return undefined;\n }\n\n /**\n * Adds spans for all resources\n * @param rootSpan\n */\n private _addResourcesSpans(rootSpan: Span): void {\n const resources: MXLPerformanceResourceTiming[] =\n performance.getEntriesByType('resource');\n resources.forEach((resource) => {\n this._initResourceSpan(resource, rootSpan);\n });\n }\n\n /**\n * Collects information about performance and creates appropriate spans\n */\n private _collectPerformance(): void {\n if (this._performanceCollected) {\n return;\n }\n this._performanceCollected = true;\n\n const metaElement = Array.from(document.getElementsByTagName('meta')).find(\n (e) => e.getAttribute('name') === TRACE_PARENT_HEADER,\n );\n const entries = getPerformanceNavigationEntries();\n const traceparent = metaElement?.content || '';\n context.with(propagation.extract(ROOT_CONTEXT, { traceparent }), () => {\n const rootSpan = this._startSpan(\n AttributeNames.DOCUMENT_LOAD,\n PerformanceTimingNames.FETCH_START,\n entries,\n );\n if (!rootSpan) {\n return;\n }\n context.with(trace.setSpan(context.active(), rootSpan), () => {\n const fetchSpan = this._startSpan(\n AttributeNames.DOCUMENT_FETCH,\n PerformanceTimingNames.FETCH_START,\n entries,\n );\n if (fetchSpan) {\n fetchSpan.setAttribute(ATTR_URL_FULL, location.href);\n context.with(trace.setSpan(context.active(), fetchSpan), () => {\n addSpanNetworkEvents(\n fetchSpan,\n entries,\n this.getConfig().ignoreNetworkEvents,\n );\n this._addCustomAttributesOnSpan(\n fetchSpan,\n this.getConfig().applyCustomAttributesOnSpan?.documentFetch,\n );\n this._endSpan(\n fetchSpan,\n PerformanceTimingNames.RESPONSE_END,\n entries,\n );\n });\n }\n });\n\n rootSpan.setAttribute(KEY_MXL_TYPE, MXL_TYPES.DocumentLoad);\n rootSpan.setAttribute(ATTR_URL_FULL, location.href);\n rootSpan.setAttribute(ATTR_USER_AGENT_ORIGINAL, navigator.userAgent);\n\n this._addResourcesSpans(rootSpan);\n\n if (!this.getConfig().ignoreNetworkEvents) {\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.FETCH_START,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.UNLOAD_EVENT_START,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.UNLOAD_EVENT_END,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.DOM_INTERACTIVE,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_START,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_END,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.DOM_COMPLETE,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.LOAD_EVENT_START,\n entries,\n );\n addSpanNetworkEvent(\n rootSpan,\n PerformanceTimingNames.LOAD_EVENT_END,\n entries,\n );\n }\n\n if (!this.getConfig().ignorePerformancePaintEvents) {\n addSpanPerformancePaintEvents(rootSpan);\n }\n\n this._addCustomAttributesOnSpan(\n rootSpan,\n this.getConfig().applyCustomAttributesOnSpan?.documentLoad,\n );\n this._endSpan(rootSpan, PerformanceTimingNames.LOAD_EVENT_END, entries);\n });\n }\n\n /**\n * Helper function for ending a span\n * @param span\n * @param performanceName name of performance entry for end time\n * @param entries\n */\n private _endSpan(\n span: Span | undefined,\n performanceName: string,\n entries: PerformanceEntries,\n ) {\n // Span can be undefined when entries are missing the required performance timing - no span will be created\n if (span) {\n if (\n hasKey(entries, performanceName) &&\n typeof entries[performanceName] === 'number'\n ) {\n span.end(entries[performanceName]);\n } else {\n span.end();\n }\n }\n }\n\n /**\n * Creates and ends a span with network information about a resource added as timed events\n * @param resource\n * @param parentSpan\n */\n private _initResourceSpan(\n resource: MXLPerformanceResourceTiming,\n parentSpan: Span,\n ) {\n const span = this._startSpan(\n AttributeNames.RESOURCE_FETCH,\n PerformanceTimingNames.FETCH_START,\n resource,\n parentSpan,\n );\n if (!span) {\n return;\n }\n\n span.setAttribute(KEY_MXL_TYPE, MXL_TYPES.ResourceFetch);\n span.setAttribute(ATTR_URL_FULL, resource.name);\n addSpanNetworkEvents(span, resource, this.getConfig().ignoreNetworkEvents);\n\n if (resource.deliveryType) {\n span.setAttribute(\n ATTR_HTTP_RESPONSE_DELIVERY_TYPE,\n resource.deliveryType,\n );\n }\n\n if (resource.initiatorType) {\n span.setAttribute(\n ATTR_HTTP_REQUEST_INITIATOR_TYPE,\n resource.initiatorType,\n );\n }\n\n if (resource.renderBlockingStatus) {\n span.setAttribute(\n ATTR_HTTP_REQUEST_RENDER_BLOCKING_STATUS,\n resource.renderBlockingStatus,\n );\n }\n\n if (resource.responseStatus) {\n span.setAttribute(\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n resource.responseStatus,\n );\n }\n\n // Validate size fields exist and aren't negative\n if (\n typeof resource.encodedBodySize === 'number' &&\n resource.encodedBodySize >= 0\n ) {\n span.setAttribute(ATTR_HTTP_RESPONSE_BODY_SIZE, resource.encodedBodySize);\n }\n\n if (\n typeof resource.transferSize === 'number' &&\n resource.transferSize >= 0\n ) {\n span.setAttribute(ATTR_HTTP_RESPONSE_SIZE, resource.transferSize);\n }\n\n if (\n typeof resource.decodedBodySize === 'number' &&\n resource.decodedBodySize >= 0\n ) {\n span.setAttribute(\n ATTR_HTTP_RESPONSE_DECODED_BODY_SIZE,\n resource.decodedBodySize,\n );\n }\n\n this._addResourceDiagnosticAttributes(span, resource);\n\n this._addCustomAttributesOnResourceSpan(\n span,\n resource,\n this.getConfig().applyCustomAttributesOnSpan?.resourceFetch,\n );\n this._endSpan(span, PerformanceTimingNames.RESPONSE_END, resource);\n }\n\n /**\n * Helper function for starting a span\n * @param spanName name of span\n * @param performanceName name of performance entry for time start\n * @param entries\n * @param parentSpan\n */\n private _startSpan(\n spanName: string,\n performanceName: string,\n entries: PerformanceEntries,\n parentSpan?: Span,\n ): Span | undefined {\n if (\n hasKey(entries, performanceName) &&\n typeof entries[performanceName] === 'number'\n ) {\n const span = this.tracer.startSpan(\n spanName,\n {\n startTime: entries[performanceName],\n },\n parentSpan ? trace.setSpan(context.active(), parentSpan) : undefined,\n );\n return span;\n }\n return undefined;\n }\n\n /**\n * Executes callback {_onDocumentLoaded} when the page is loaded\n */\n private _waitForPageLoad() {\n if (window.document.readyState === 'complete') {\n this._onDocumentLoaded();\n } else {\n window.addEventListener('load', this._onDocumentLoaded);\n }\n }\n\n /**\n * Adds custom attributes to span if configured\n * Used for both documentFetch and documentLoad spans\n */\n private _addCustomAttributesOnSpan(\n span: Span,\n applyCustomAttributesOnSpan:\n | DocumentLoadCustomAttributeFunction\n | undefined,\n ) {\n if (applyCustomAttributesOnSpan) {\n safeExecuteInTheMiddle(\n () => {\n applyCustomAttributesOnSpan(span);\n },\n (error) => {\n if (!error) {\n return;\n }\n\n this._diag.error('addCustomAttributesOnSpan', error);\n },\n true,\n );\n }\n }\n\n /**\n * Adds custom attributes to resource span if configured\n */\n private _addCustomAttributesOnResourceSpan(\n span: Span,\n resource: MXLPerformanceResourceTiming,\n applyCustomAttributesOnSpan:\n | ResourceFetchCustomAttributeFunction\n | undefined,\n ) {\n if (applyCustomAttributesOnSpan) {\n safeExecuteInTheMiddle(\n () => {\n applyCustomAttributesOnSpan(span, resource);\n },\n (error) => {\n if (!error) {\n return;\n }\n\n this._diag.error('addCustomAttributesOnResourceSpan', error);\n },\n true,\n );\n }\n }\n\n private _hasNoSizeData(resource: MXLPerformanceResourceTiming): boolean {\n const transferSize =\n typeof resource.transferSize === 'number' ? resource.transferSize : 0;\n const decodedBodySize =\n typeof resource.decodedBodySize === 'number'\n ? resource.decodedBodySize\n : 0;\n const encodedBodySize =\n typeof resource.encodedBodySize === 'number'\n ? resource.encodedBodySize\n : 0;\n\n return transferSize === 0 && decodedBodySize === 0 && encodedBodySize === 0;\n }\n\n private _hasTimingData(resource: MXLPerformanceResourceTiming): boolean {\n const fetchStart =\n typeof resource.fetchStart === 'number' ? resource.fetchStart : 0;\n const responseEnd =\n typeof resource.responseEnd === 'number' ? resource.responseEnd : 0;\n\n return fetchStart > 0 && responseEnd > 0;\n }\n\n private _isCorsRestricted(resource: MXLPerformanceResourceTiming): boolean {\n return this._hasNoSizeData(resource) && this._hasTimingData(resource);\n }\n\n private _isFetchIncomplete(resource: MXLPerformanceResourceTiming): boolean {\n const fetchStart =\n typeof resource.fetchStart === 'number' ? resource.fetchStart : 0;\n const responseEnd =\n typeof resource.responseEnd === 'number' ? resource.responseEnd : 0;\n\n return this._hasNoSizeData(resource) && fetchStart > 0 && responseEnd === 0;\n }\n\n private _isFetchPrevented(resource: MXLPerformanceResourceTiming): boolean {\n const fetchStart =\n typeof resource.fetchStart === 'number' ? resource.fetchStart : 0;\n\n return this._hasNoSizeData(resource) && fetchStart === 0;\n }\n\n /**\n * Detect cache validation (304 Not Modified responses)\n *\n * 304 responses show transferSize of ~300 bytes (headers only, no body).\n * Use deliveryType to distinguish from cache hits: 'cache' = no network, otherwise = 304.\n *\n * Spec: https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-transfersize\n */\n private _isCacheValidated(resource: MXLPerformanceResourceTiming): boolean {\n const transferSize =\n typeof resource.transferSize === 'number' ? resource.transferSize : 0;\n const deliveryType =\n typeof resource.deliveryType === 'string' ? resource.deliveryType : '';\n\n return transferSize === 300 && deliveryType !== 'cache';\n }\n\n /**\n * Add diagnostic attributes to identify resource loading issues\n *\n * Diagnostic attributes help identify why resources may have incomplete timing data:\n * - CORS restrictions (opaque responses without Timing-Allow-Origin header)\n * - Cache revalidation (304 Not Modified responses)\n * - Request incomplete (started but didn't complete - network error, aborted)\n * - Request prevented (never started - blocked by CSP, browser, extension)\n */\n private _addResourceDiagnosticAttributes(\n span: Span,\n resource: MXLPerformanceResourceTiming,\n ): void {\n if (this._isCorsRestricted(resource)) {\n span.setAttribute(ATTR_HTTP_RESPONSE_CORS_OPAQUE, true);\n } else if (this._isFetchIncomplete(resource)) {\n span.setAttribute(ATTR_HTTP_REQUEST_INCOMPLETE, true);\n } else if (this._isFetchPrevented(resource)) {\n span.setAttribute(ATTR_HTTP_REQUEST_PREVENTED, true);\n }\n\n if (this._isCacheValidated(resource)) {\n span.setAttribute(ATTR_HTTP_RESPONSE_CACHE_REVALIDATED, true);\n }\n }\n\n public enable(): void {\n window.removeEventListener('load', this._onDocumentLoaded);\n this._waitForPageLoad();\n }\n\n public disable(): void {\n window.removeEventListener('load', this._onDocumentLoaded);\n }\n}\n"],"mappings":";;;;;;;;;;;AA4DA,MAAM,mCAAmC;AACzC,MAAM,uCAAuC;AAC7C,MAAM,mCAAmC;AACzC,MAAM,2CACJ;AAGF,MAAM,iCAAiC;AACvC,MAAM,uCAAuC;AAC7C,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CAClC,MAAK,aAAa,sCAAsC,KAAK;;CAIjE,SAAsB;AACpB,SAAO,oBAAoB,QAAQ,KAAK,kBAAkB;AAC1D,OAAK,kBAAkB;;CAGzB,UAAuB;AACrB,SAAO,oBAAoB,QAAQ,KAAK,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["PerformanceTimingNames"],"sources":["../../../../src/instrumentations/document-load/DocumentLoadInstrumentation/utils.ts"],"sourcesContent":["/*\n * Adapted from OpenTelemetry document-load instrumentation\n * https://github.com/open-telemetry/opentelemetry-js-contrib/tree/cc7eff47e2e7bad7678241b766753d5bd6dbc85f/packages/instrumentation-document-load\n */\n\nimport type { Span } from '@opentelemetry/api';\nimport type { PerformanceEntries } from '@opentelemetry/sdk-trace-web';\nimport { hasKey, PerformanceTimingNames } from '@opentelemetry/sdk-trace-web';\nimport { EventNames } from './enums/EventNames.ts';\n\nexport const getPerformanceNavigationEntries = (): PerformanceEntries => {\n const entries: PerformanceEntries = {};\n const performanceNavigationTiming =\n window.performance.getEntriesByType('navigation')[0];\n\n const keys = Object.values(PerformanceTimingNames);\n keys.forEach((key: PerformanceTimingNames) => {\n if (hasKey(performanceNavigationTiming, key)) {\n const value = performanceNavigationTiming[key];\n if (typeof value === 'number') {\n entries[key] = value;\n }\n }\n });\n\n return entries;\n};\n\nconst performancePaintNames = {\n 'first-paint': EventNames.FIRST_PAINT,\n 'first-contentful-paint': EventNames.FIRST_CONTENTFUL_PAINT,\n};\n\nexport const addSpanPerformancePaintEvents = (span: Span) => {\n const performancePaintTiming = window.performance.getEntriesByType('paint');\n performancePaintTiming.forEach(({ name, startTime }) => {\n if (hasKey(performancePaintNames, name)) {\n span.addEvent(performancePaintNames[name], startTime);\n }\n });\n};\n"],"mappings":";;;;;AAUA,MAAa,wCAA4D;CACvE,MAAM,UAA8B,EAAE;CACtC,MAAM,8BACJ,OAAO,YAAY,iBAAiB,aAAa,CAAC;AAEvC,QAAO,OAAOA,6BAAAA,uBACvB,CAAC,SAAS,QAAgC;AAC5C,OAAA,GAAA,6BAAA,QAAW,6BAA6B,IAAI,EAAE;GAC5C,MAAM,QAAQ,4BAA4B;AAC1C,OAAI,OAAO,UAAU,SACnB,SAAQ,OAAO;;GAGnB;AAEF,QAAO;;AAGT,MAAM,wBAAwB;CAC5B,eAAA;CACA,0BAAA;CACD;AAED,MAAa,iCAAiC,SAAe;AAC5B,QAAO,YAAY,iBAAiB,QAC7C,CAAC,SAAS,EAAE,MAAM,gBAAgB;AACtD,OAAA,GAAA,6BAAA,QAAW,uBAAuB,KAAK,CACrC,MAAK,SAAS,sBAAsB,OAAO,UAAU;GAEvD"}
1
+ {"version":3,"file":"utils.cjs","names":["PerformanceTimingNames"],"sources":["../../../../src/instrumentations/document-load/DocumentLoadInstrumentation/utils.ts"],"sourcesContent":["/*\n * Adapted from OpenTelemetry document-load instrumentation\n * https://github.com/open-telemetry/opentelemetry-js-contrib/tree/cc7eff47e2e7bad7678241b766753d5bd6dbc85f/packages/instrumentation-document-load\n */\n\nimport type { Span } from '@opentelemetry/api';\nimport type { PerformanceEntries } from '@opentelemetry/sdk-trace-web';\nimport { hasKey, PerformanceTimingNames } from '@opentelemetry/sdk-trace-web';\nimport { EventNames } from './enums/EventNames';\n\nexport const getPerformanceNavigationEntries = (): PerformanceEntries => {\n const entries: PerformanceEntries = {};\n const performanceNavigationTiming =\n window.performance.getEntriesByType('navigation')[0];\n\n const keys = Object.values(PerformanceTimingNames);\n keys.forEach((key: PerformanceTimingNames) => {\n if (hasKey(performanceNavigationTiming, key)) {\n const value = performanceNavigationTiming[key];\n if (typeof value === 'number') {\n entries[key] = value;\n }\n }\n });\n\n return entries;\n};\n\nconst performancePaintNames = {\n 'first-paint': EventNames.FIRST_PAINT,\n 'first-contentful-paint': EventNames.FIRST_CONTENTFUL_PAINT,\n};\n\nexport const addSpanPerformancePaintEvents = (span: Span) => {\n const performancePaintTiming = window.performance.getEntriesByType('paint');\n performancePaintTiming.forEach(({ name, startTime }) => {\n if (hasKey(performancePaintNames, name)) {\n span.addEvent(performancePaintNames[name], startTime);\n }\n });\n};\n"],"mappings":";;;;;AAUA,MAAa,wCAA4D;CACvE,MAAM,UAA8B,EAAE;CACtC,MAAM,8BACJ,OAAO,YAAY,iBAAiB,aAAa,CAAC;AAEvC,QAAO,OAAOA,6BAAAA,uBACvB,CAAC,SAAS,QAAgC;AAC5C,OAAA,GAAA,6BAAA,QAAW,6BAA6B,IAAI,EAAE;GAC5C,MAAM,QAAQ,4BAA4B;AAC1C,OAAI,OAAO,UAAU,SACnB,SAAQ,OAAO;;GAGnB;AAEF,QAAO;;AAGT,MAAM,wBAAwB;CAC5B,eAAA;CACA,0BAAA;CACD;AAED,MAAa,iCAAiC,SAAe;AAC5B,QAAO,YAAY,iBAAiB,QAC7C,CAAC,SAAS,EAAE,MAAM,gBAAgB;AACtD,OAAA,GAAA,6BAAA,QAAW,uBAAuB,KAAK,CACrC,MAAK,SAAS,sBAAsB,OAAO,UAAU;GAEvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../../../src/instrumentations/document-load/DocumentLoadInstrumentation/utils.ts"],"sourcesContent":["/*\n * Adapted from OpenTelemetry document-load instrumentation\n * https://github.com/open-telemetry/opentelemetry-js-contrib/tree/cc7eff47e2e7bad7678241b766753d5bd6dbc85f/packages/instrumentation-document-load\n */\n\nimport type { Span } from '@opentelemetry/api';\nimport type { PerformanceEntries } from '@opentelemetry/sdk-trace-web';\nimport { hasKey, PerformanceTimingNames } from '@opentelemetry/sdk-trace-web';\nimport { EventNames } from './enums/EventNames.ts';\n\nexport const getPerformanceNavigationEntries = (): PerformanceEntries => {\n const entries: PerformanceEntries = {};\n const performanceNavigationTiming =\n window.performance.getEntriesByType('navigation')[0];\n\n const keys = Object.values(PerformanceTimingNames);\n keys.forEach((key: PerformanceTimingNames) => {\n if (hasKey(performanceNavigationTiming, key)) {\n const value = performanceNavigationTiming[key];\n if (typeof value === 'number') {\n entries[key] = value;\n }\n }\n });\n\n return entries;\n};\n\nconst performancePaintNames = {\n 'first-paint': EventNames.FIRST_PAINT,\n 'first-contentful-paint': EventNames.FIRST_CONTENTFUL_PAINT,\n};\n\nexport const addSpanPerformancePaintEvents = (span: Span) => {\n const performancePaintTiming = window.performance.getEntriesByType('paint');\n performancePaintTiming.forEach(({ name, startTime }) => {\n if (hasKey(performancePaintNames, name)) {\n span.addEvent(performancePaintNames[name], startTime);\n }\n });\n};\n"],"mappings":";;;AAUA,MAAa,wCAA4D;CACvE,MAAM,UAA8B,EAAE;CACtC,MAAM,8BACJ,OAAO,YAAY,iBAAiB,aAAa,CAAC;AAEvC,QAAO,OAAO,uBACvB,CAAC,SAAS,QAAgC;AAC5C,MAAI,OAAO,6BAA6B,IAAI,EAAE;GAC5C,MAAM,QAAQ,4BAA4B;AAC1C,OAAI,OAAO,UAAU,SACnB,SAAQ,OAAO;;GAGnB;AAEF,QAAO;;AAGT,MAAM,wBAAwB;CAC5B,eAAA;CACA,0BAAA;CACD;AAED,MAAa,iCAAiC,SAAe;AAC5B,QAAO,YAAY,iBAAiB,QAC7C,CAAC,SAAS,EAAE,MAAM,gBAAgB;AACtD,MAAI,OAAO,uBAAuB,KAAK,CACrC,MAAK,SAAS,sBAAsB,OAAO,UAAU;GAEvD"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../../src/instrumentations/document-load/DocumentLoadInstrumentation/utils.ts"],"sourcesContent":["/*\n * Adapted from OpenTelemetry document-load instrumentation\n * https://github.com/open-telemetry/opentelemetry-js-contrib/tree/cc7eff47e2e7bad7678241b766753d5bd6dbc85f/packages/instrumentation-document-load\n */\n\nimport type { Span } from '@opentelemetry/api';\nimport type { PerformanceEntries } from '@opentelemetry/sdk-trace-web';\nimport { hasKey, PerformanceTimingNames } from '@opentelemetry/sdk-trace-web';\nimport { EventNames } from './enums/EventNames';\n\nexport const getPerformanceNavigationEntries = (): PerformanceEntries => {\n const entries: PerformanceEntries = {};\n const performanceNavigationTiming =\n window.performance.getEntriesByType('navigation')[0];\n\n const keys = Object.values(PerformanceTimingNames);\n keys.forEach((key: PerformanceTimingNames) => {\n if (hasKey(performanceNavigationTiming, key)) {\n const value = performanceNavigationTiming[key];\n if (typeof value === 'number') {\n entries[key] = value;\n }\n }\n });\n\n return entries;\n};\n\nconst performancePaintNames = {\n 'first-paint': EventNames.FIRST_PAINT,\n 'first-contentful-paint': EventNames.FIRST_CONTENTFUL_PAINT,\n};\n\nexport const addSpanPerformancePaintEvents = (span: Span) => {\n const performancePaintTiming = window.performance.getEntriesByType('paint');\n performancePaintTiming.forEach(({ name, startTime }) => {\n if (hasKey(performancePaintNames, name)) {\n span.addEvent(performancePaintNames[name], startTime);\n }\n });\n};\n"],"mappings":";;;AAUA,MAAa,wCAA4D;CACvE,MAAM,UAA8B,EAAE;CACtC,MAAM,8BACJ,OAAO,YAAY,iBAAiB,aAAa,CAAC;AAEvC,QAAO,OAAO,uBACvB,CAAC,SAAS,QAAgC;AAC5C,MAAI,OAAO,6BAA6B,IAAI,EAAE;GAC5C,MAAM,QAAQ,4BAA4B;AAC1C,OAAI,OAAO,UAAU,SACnB,SAAQ,OAAO;;GAGnB;AAEF,QAAO;;AAGT,MAAM,wBAAwB;CAC5B,eAAA;CACA,0BAAA;CACD;AAED,MAAa,iCAAiC,SAAe;AAC5B,QAAO,YAAY,iBAAiB,QAC7C,CAAC,SAAS,EAAE,MAAM,gBAAgB;AACtD,MAAI,OAAO,uBAAuB,KAAK,CACrC,MAAK,SAAS,sBAAsB,OAAO,UAAU;GAEvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"ElementTimingInstrumentation.cjs","names":["MXLInstrumentationBase","isEntryTypeSupported","createPerformanceObserver","KEY_MXL_TYPE","KEY_MXL_ELEMENT_TIMING_IDENTIFIER","KEY_MXL_ELEMENT_TIMING_ELEMENT","KEY_MXL_ELEMENT_TIMING_RENDER_TIME","KEY_MXL_ELEMENT_TIMING_LOAD_TIME","KEY_MXL_ELEMENT_TIMING_START_TIME","KEY_MXL_ELEMENT_TIMING_URL","KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH","KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT"],"sources":["../../../../src/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.ts"],"sourcesContent":["import { MXL_TYPES, KEY_MXL_TYPE } from '../../../constants/index.ts';\nimport {\n createPerformanceObserver,\n isEntryTypeSupported,\n} from '../../../utils/index.ts';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport {\n KEY_MXL_ELEMENT_TIMING_ELEMENT,\n KEY_MXL_ELEMENT_TIMING_IDENTIFIER,\n KEY_MXL_ELEMENT_TIMING_LOAD_TIME,\n KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT,\n KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH,\n KEY_MXL_ELEMENT_TIMING_RENDER_TIME,\n KEY_MXL_ELEMENT_TIMING_START_TIME,\n KEY_MXL_ELEMENT_TIMING_URL,\n} from './constants.ts';\nimport type {\n ElementTimingInstrumentationArgs,\n PerformanceElementTiming,\n} from './types.ts';\n\nexport class ElementTimingInstrumentation extends MXLInstrumentationBase {\n private _observer: PerformanceObserver | null = null;\n private _isEnabled = false;\n\n public constructor({\n diag,\n perf,\n limitManager,\n }: ElementTimingInstrumentationArgs = {}) {\n super({\n instrumentationName: 'ElementTimingInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n limitManager,\n config: {},\n });\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public enable(): void {\n if (this._isEnabled) {\n return;\n }\n\n if (!isEntryTypeSupported('element')) {\n this._diag.debug('element not supported, skipping');\n return;\n }\n\n this._isEnabled = true;\n\n if (this._observer) {\n this._observer.disconnect();\n }\n\n this._observer = createPerformanceObserver<PerformanceElementTiming>(\n 'element',\n (entry) => this._processEntry(entry),\n { diag: this._diag },\n );\n\n if (!this._observer) {\n this._isEnabled = false;\n this._diag.error('failed to enable');\n return;\n }\n }\n\n public disable(): void {\n this._isEnabled = false;\n\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n }\n\n private _processEntry(entry: PerformanceElementTiming): void {\n if (!this._isEnabled) {\n return;\n }\n\n if (this.limitManager?.limitElementTimingEntry()) {\n return;\n }\n\n const span = this.tracer.startSpan(entry.identifier, {\n // Span start anchors to navigation start so the span duration equals \"time from navigation\n // until the element was rendered\" — useful for analyzing page-load render timing.\n startTime: this.perf.epochMillisFromOriginOffset(0),\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.ElementTiming,\n [KEY_MXL_ELEMENT_TIMING_IDENTIFIER]: entry.identifier,\n [KEY_MXL_ELEMENT_TIMING_ELEMENT]: entry.element?.tagName?.toLowerCase(),\n [KEY_MXL_ELEMENT_TIMING_RENDER_TIME]: entry.renderTime,\n [KEY_MXL_ELEMENT_TIMING_LOAD_TIME]: entry.loadTime,\n [KEY_MXL_ELEMENT_TIMING_START_TIME]: entry.startTime,\n [KEY_MXL_ELEMENT_TIMING_URL]: entry.url,\n [KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH]: entry.naturalWidth,\n [KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT]: entry.naturalHeight,\n },\n });\n if (entry.loadTime > 0) {\n span.addEvent(\n 'load',\n this.perf.epochMillisFromOriginOffset(entry.loadTime),\n );\n }\n // entry.startTime = renderTime if non-zero, else loadTime\n span.end(this.perf.epochMillisFromOriginOffset(entry.startTime));\n }\n}\n"],"mappings":";;;;;;AAqBA,IAAa,+BAAb,cAAkDA,uEAAAA,uBAAuB;CACvE,YAAgD;CAChD,aAAqB;CAErB,YAAmB,EACjB,MACA,MACA,iBACoC,EAAE,EAAE;AACxC,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,SAAsB;AACpB,MAAI,KAAK,WACP;AAGF,MAAI,CAACC,sDAAAA,qBAAqB,UAAU,EAAE;AACpC,QAAK,MAAM,MAAM,kCAAkC;AACnD;;AAGF,OAAK,aAAa;AAElB,MAAI,KAAK,UACP,MAAK,UAAU,YAAY;AAG7B,OAAK,YAAYC,sDAAAA,0BACf,YACC,UAAU,KAAK,cAAc,MAAM,EACpC,EAAE,MAAM,KAAK,OAAO,CACrB;AAED,MAAI,CAAC,KAAK,WAAW;AACnB,QAAK,aAAa;AAClB,QAAK,MAAM,MAAM,mBAAmB;AACpC;;;CAIJ,UAAuB;AACrB,OAAK,aAAa;AAElB,MAAI,KAAK,WAAW;AAClB,QAAK,UAAU,YAAY;AAC3B,QAAK,YAAY;;;CAIrB,cAAsB,OAAuC;AAC3D,MAAI,CAAC,KAAK,WACR;AAGF,MAAI,KAAK,cAAc,yBAAyB,CAC9C;EAGF,MAAM,OAAO,KAAK,OAAO,UAAU,MAAM,YAAY;GAGnD,WAAW,KAAK,KAAK,4BAA4B,EAAE;GACnD,YAAY;KACTC,6BAAAA,eAAAA;KACAC,+EAAAA,oCAAoC,MAAM;KAC1CC,+EAAAA,iCAAiC,MAAM,SAAS,SAAS,aAAa;KACtEC,+EAAAA,qCAAqC,MAAM;KAC3CC,+EAAAA,mCAAmC,MAAM;KACzCC,+EAAAA,oCAAoC,MAAM;KAC1CC,+EAAAA,6BAA6B,MAAM;KACnCC,+EAAAA,uCAAuC,MAAM;KAC7CC,+EAAAA,wCAAwC,MAAM;IAChD;GACF,CAAC;AACF,MAAI,MAAM,WAAW,EACnB,MAAK,SACH,QACA,KAAK,KAAK,4BAA4B,MAAM,SAAS,CACtD;AAGH,OAAK,IAAI,KAAK,KAAK,4BAA4B,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"ElementTimingInstrumentation.cjs","names":["MXLInstrumentationBase","isEntryTypeSupported","createPerformanceObserver","KEY_MXL_TYPE","KEY_MXL_ELEMENT_TIMING_IDENTIFIER","KEY_MXL_ELEMENT_TIMING_ELEMENT","KEY_MXL_ELEMENT_TIMING_RENDER_TIME","KEY_MXL_ELEMENT_TIMING_LOAD_TIME","KEY_MXL_ELEMENT_TIMING_START_TIME","KEY_MXL_ELEMENT_TIMING_URL","KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH","KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT"],"sources":["../../../../src/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.ts"],"sourcesContent":["import { KEY_MXL_TYPE, MXL_TYPES } from '../../../constants';\nimport {\n createPerformanceObserver,\n isEntryTypeSupported,\n} from '../../../utils';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport {\n KEY_MXL_ELEMENT_TIMING_ELEMENT,\n KEY_MXL_ELEMENT_TIMING_IDENTIFIER,\n KEY_MXL_ELEMENT_TIMING_LOAD_TIME,\n KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT,\n KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH,\n KEY_MXL_ELEMENT_TIMING_RENDER_TIME,\n KEY_MXL_ELEMENT_TIMING_START_TIME,\n KEY_MXL_ELEMENT_TIMING_URL,\n} from './constants';\nimport type {\n ElementTimingInstrumentationArgs,\n PerformanceElementTiming,\n} from './types';\n\nexport class ElementTimingInstrumentation extends MXLInstrumentationBase {\n private _observer: PerformanceObserver | null = null;\n private _isEnabled = false;\n\n public constructor({\n diag,\n perf,\n limitManager,\n }: ElementTimingInstrumentationArgs = {}) {\n super({\n instrumentationName: 'ElementTimingInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n limitManager,\n config: {},\n });\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public enable(): void {\n if (this._isEnabled) {\n return;\n }\n\n if (!isEntryTypeSupported('element')) {\n this._diag.debug('element not supported, skipping');\n return;\n }\n\n this._isEnabled = true;\n\n if (this._observer) {\n this._observer.disconnect();\n }\n\n this._observer = createPerformanceObserver<PerformanceElementTiming>(\n 'element',\n (entry) => this._processEntry(entry),\n { diag: this._diag },\n );\n\n if (!this._observer) {\n this._isEnabled = false;\n this._diag.error('failed to enable');\n return;\n }\n }\n\n public disable(): void {\n this._isEnabled = false;\n\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n }\n\n private _processEntry(entry: PerformanceElementTiming): void {\n if (!this._isEnabled) {\n return;\n }\n\n if (this.limitManager?.limitElementTimingEntry()) {\n return;\n }\n\n const span = this.tracer.startSpan(entry.identifier, {\n // Span start anchors to navigation start so the span duration equals \"time from navigation\n // until the element was rendered\" — useful for analyzing page-load render timing.\n startTime: this.perf.epochMillisFromOriginOffset(0),\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.ElementTiming,\n [KEY_MXL_ELEMENT_TIMING_IDENTIFIER]: entry.identifier,\n [KEY_MXL_ELEMENT_TIMING_ELEMENT]: entry.element?.tagName?.toLowerCase(),\n [KEY_MXL_ELEMENT_TIMING_RENDER_TIME]: entry.renderTime,\n [KEY_MXL_ELEMENT_TIMING_LOAD_TIME]: entry.loadTime,\n [KEY_MXL_ELEMENT_TIMING_START_TIME]: entry.startTime,\n [KEY_MXL_ELEMENT_TIMING_URL]: entry.url,\n [KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH]: entry.naturalWidth,\n [KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT]: entry.naturalHeight,\n },\n });\n if (entry.loadTime > 0) {\n span.addEvent(\n 'load',\n this.perf.epochMillisFromOriginOffset(entry.loadTime),\n );\n }\n // entry.startTime = renderTime if non-zero, else loadTime\n span.end(this.perf.epochMillisFromOriginOffset(entry.startTime));\n }\n}\n"],"mappings":";;;;;;AAqBA,IAAa,+BAAb,cAAkDA,uEAAAA,uBAAuB;CACvE,YAAgD;CAChD,aAAqB;CAErB,YAAmB,EACjB,MACA,MACA,iBACoC,EAAE,EAAE;AACxC,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,SAAsB;AACpB,MAAI,KAAK,WACP;AAGF,MAAI,CAACC,sDAAAA,qBAAqB,UAAU,EAAE;AACpC,QAAK,MAAM,MAAM,kCAAkC;AACnD;;AAGF,OAAK,aAAa;AAElB,MAAI,KAAK,UACP,MAAK,UAAU,YAAY;AAG7B,OAAK,YAAYC,sDAAAA,0BACf,YACC,UAAU,KAAK,cAAc,MAAM,EACpC,EAAE,MAAM,KAAK,OAAO,CACrB;AAED,MAAI,CAAC,KAAK,WAAW;AACnB,QAAK,aAAa;AAClB,QAAK,MAAM,MAAM,mBAAmB;AACpC;;;CAIJ,UAAuB;AACrB,OAAK,aAAa;AAElB,MAAI,KAAK,WAAW;AAClB,QAAK,UAAU,YAAY;AAC3B,QAAK,YAAY;;;CAIrB,cAAsB,OAAuC;AAC3D,MAAI,CAAC,KAAK,WACR;AAGF,MAAI,KAAK,cAAc,yBAAyB,CAC9C;EAGF,MAAM,OAAO,KAAK,OAAO,UAAU,MAAM,YAAY;GAGnD,WAAW,KAAK,KAAK,4BAA4B,EAAE;GACnD,YAAY;KACTC,6BAAAA,eAAAA;KACAC,+EAAAA,oCAAoC,MAAM;KAC1CC,+EAAAA,iCAAiC,MAAM,SAAS,SAAS,aAAa;KACtEC,+EAAAA,qCAAqC,MAAM;KAC3CC,+EAAAA,mCAAmC,MAAM;KACzCC,+EAAAA,oCAAoC,MAAM;KAC1CC,+EAAAA,6BAA6B,MAAM;KACnCC,+EAAAA,uCAAuC,MAAM;KAC7CC,+EAAAA,wCAAwC,MAAM;IAChD;GACF,CAAC;AACF,MAAI,MAAM,WAAW,EACnB,MAAK,SACH,QACA,KAAK,KAAK,4BAA4B,MAAM,SAAS,CACtD;AAGH,OAAK,IAAI,KAAK,KAAK,4BAA4B,MAAM,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ElementTimingInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.ts"],"sourcesContent":["import { MXL_TYPES, KEY_MXL_TYPE } from '../../../constants/index.ts';\nimport {\n createPerformanceObserver,\n isEntryTypeSupported,\n} from '../../../utils/index.ts';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport {\n KEY_MXL_ELEMENT_TIMING_ELEMENT,\n KEY_MXL_ELEMENT_TIMING_IDENTIFIER,\n KEY_MXL_ELEMENT_TIMING_LOAD_TIME,\n KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT,\n KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH,\n KEY_MXL_ELEMENT_TIMING_RENDER_TIME,\n KEY_MXL_ELEMENT_TIMING_START_TIME,\n KEY_MXL_ELEMENT_TIMING_URL,\n} from './constants.ts';\nimport type {\n ElementTimingInstrumentationArgs,\n PerformanceElementTiming,\n} from './types.ts';\n\nexport class ElementTimingInstrumentation extends MXLInstrumentationBase {\n private _observer: PerformanceObserver | null = null;\n private _isEnabled = false;\n\n public constructor({\n diag,\n perf,\n limitManager,\n }: ElementTimingInstrumentationArgs = {}) {\n super({\n instrumentationName: 'ElementTimingInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n limitManager,\n config: {},\n });\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public enable(): void {\n if (this._isEnabled) {\n return;\n }\n\n if (!isEntryTypeSupported('element')) {\n this._diag.debug('element not supported, skipping');\n return;\n }\n\n this._isEnabled = true;\n\n if (this._observer) {\n this._observer.disconnect();\n }\n\n this._observer = createPerformanceObserver<PerformanceElementTiming>(\n 'element',\n (entry) => this._processEntry(entry),\n { diag: this._diag },\n );\n\n if (!this._observer) {\n this._isEnabled = false;\n this._diag.error('failed to enable');\n return;\n }\n }\n\n public disable(): void {\n this._isEnabled = false;\n\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n }\n\n private _processEntry(entry: PerformanceElementTiming): void {\n if (!this._isEnabled) {\n return;\n }\n\n if (this.limitManager?.limitElementTimingEntry()) {\n return;\n }\n\n const span = this.tracer.startSpan(entry.identifier, {\n // Span start anchors to navigation start so the span duration equals \"time from navigation\n // until the element was rendered\" — useful for analyzing page-load render timing.\n startTime: this.perf.epochMillisFromOriginOffset(0),\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.ElementTiming,\n [KEY_MXL_ELEMENT_TIMING_IDENTIFIER]: entry.identifier,\n [KEY_MXL_ELEMENT_TIMING_ELEMENT]: entry.element?.tagName?.toLowerCase(),\n [KEY_MXL_ELEMENT_TIMING_RENDER_TIME]: entry.renderTime,\n [KEY_MXL_ELEMENT_TIMING_LOAD_TIME]: entry.loadTime,\n [KEY_MXL_ELEMENT_TIMING_START_TIME]: entry.startTime,\n [KEY_MXL_ELEMENT_TIMING_URL]: entry.url,\n [KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH]: entry.naturalWidth,\n [KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT]: entry.naturalHeight,\n },\n });\n if (entry.loadTime > 0) {\n span.addEvent(\n 'load',\n this.perf.epochMillisFromOriginOffset(entry.loadTime),\n );\n }\n // entry.startTime = renderTime if non-zero, else loadTime\n span.end(this.perf.epochMillisFromOriginOffset(entry.startTime));\n }\n}\n"],"mappings":";;;;;AAqBA,IAAa,+BAAb,cAAkD,uBAAuB;CACvE,YAAgD;CAChD,aAAqB;CAErB,YAAmB,EACjB,MACA,MACA,iBACoC,EAAE,EAAE;AACxC,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,SAAsB;AACpB,MAAI,KAAK,WACP;AAGF,MAAI,CAAC,qBAAqB,UAAU,EAAE;AACpC,QAAK,MAAM,MAAM,kCAAkC;AACnD;;AAGF,OAAK,aAAa;AAElB,MAAI,KAAK,UACP,MAAK,UAAU,YAAY;AAG7B,OAAK,YAAY,0BACf,YACC,UAAU,KAAK,cAAc,MAAM,EACpC,EAAE,MAAM,KAAK,OAAO,CACrB;AAED,MAAI,CAAC,KAAK,WAAW;AACnB,QAAK,aAAa;AAClB,QAAK,MAAM,MAAM,mBAAmB;AACpC;;;CAIJ,UAAuB;AACrB,OAAK,aAAa;AAElB,MAAI,KAAK,WAAW;AAClB,QAAK,UAAU,YAAY;AAC3B,QAAK,YAAY;;;CAIrB,cAAsB,OAAuC;AAC3D,MAAI,CAAC,KAAK,WACR;AAGF,MAAI,KAAK,cAAc,yBAAyB,CAC9C;EAGF,MAAM,OAAO,KAAK,OAAO,UAAU,MAAM,YAAY;GAGnD,WAAW,KAAK,KAAK,4BAA4B,EAAE;GACnD,YAAY;KACT,eAAA;KACA,oCAAoC,MAAM;KAC1C,iCAAiC,MAAM,SAAS,SAAS,aAAa;KACtE,qCAAqC,MAAM;KAC3C,mCAAmC,MAAM;KACzC,oCAAoC,MAAM;KAC1C,6BAA6B,MAAM;KACnC,uCAAuC,MAAM;KAC7C,wCAAwC,MAAM;IAChD;GACF,CAAC;AACF,MAAI,MAAM,WAAW,EACnB,MAAK,SACH,QACA,KAAK,KAAK,4BAA4B,MAAM,SAAS,CACtD;AAGH,OAAK,IAAI,KAAK,KAAK,4BAA4B,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"ElementTimingInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/element-timing/ElementTimingInstrumentation/ElementTimingInstrumentation.ts"],"sourcesContent":["import { KEY_MXL_TYPE, MXL_TYPES } from '../../../constants';\nimport {\n createPerformanceObserver,\n isEntryTypeSupported,\n} from '../../../utils';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport {\n KEY_MXL_ELEMENT_TIMING_ELEMENT,\n KEY_MXL_ELEMENT_TIMING_IDENTIFIER,\n KEY_MXL_ELEMENT_TIMING_LOAD_TIME,\n KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT,\n KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH,\n KEY_MXL_ELEMENT_TIMING_RENDER_TIME,\n KEY_MXL_ELEMENT_TIMING_START_TIME,\n KEY_MXL_ELEMENT_TIMING_URL,\n} from './constants';\nimport type {\n ElementTimingInstrumentationArgs,\n PerformanceElementTiming,\n} from './types';\n\nexport class ElementTimingInstrumentation extends MXLInstrumentationBase {\n private _observer: PerformanceObserver | null = null;\n private _isEnabled = false;\n\n public constructor({\n diag,\n perf,\n limitManager,\n }: ElementTimingInstrumentationArgs = {}) {\n super({\n instrumentationName: 'ElementTimingInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n limitManager,\n config: {},\n });\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public enable(): void {\n if (this._isEnabled) {\n return;\n }\n\n if (!isEntryTypeSupported('element')) {\n this._diag.debug('element not supported, skipping');\n return;\n }\n\n this._isEnabled = true;\n\n if (this._observer) {\n this._observer.disconnect();\n }\n\n this._observer = createPerformanceObserver<PerformanceElementTiming>(\n 'element',\n (entry) => this._processEntry(entry),\n { diag: this._diag },\n );\n\n if (!this._observer) {\n this._isEnabled = false;\n this._diag.error('failed to enable');\n return;\n }\n }\n\n public disable(): void {\n this._isEnabled = false;\n\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n }\n\n private _processEntry(entry: PerformanceElementTiming): void {\n if (!this._isEnabled) {\n return;\n }\n\n if (this.limitManager?.limitElementTimingEntry()) {\n return;\n }\n\n const span = this.tracer.startSpan(entry.identifier, {\n // Span start anchors to navigation start so the span duration equals \"time from navigation\n // until the element was rendered\" — useful for analyzing page-load render timing.\n startTime: this.perf.epochMillisFromOriginOffset(0),\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.ElementTiming,\n [KEY_MXL_ELEMENT_TIMING_IDENTIFIER]: entry.identifier,\n [KEY_MXL_ELEMENT_TIMING_ELEMENT]: entry.element?.tagName?.toLowerCase(),\n [KEY_MXL_ELEMENT_TIMING_RENDER_TIME]: entry.renderTime,\n [KEY_MXL_ELEMENT_TIMING_LOAD_TIME]: entry.loadTime,\n [KEY_MXL_ELEMENT_TIMING_START_TIME]: entry.startTime,\n [KEY_MXL_ELEMENT_TIMING_URL]: entry.url,\n [KEY_MXL_ELEMENT_TIMING_NATURAL_WIDTH]: entry.naturalWidth,\n [KEY_MXL_ELEMENT_TIMING_NATURAL_HEIGHT]: entry.naturalHeight,\n },\n });\n if (entry.loadTime > 0) {\n span.addEvent(\n 'load',\n this.perf.epochMillisFromOriginOffset(entry.loadTime),\n );\n }\n // entry.startTime = renderTime if non-zero, else loadTime\n span.end(this.perf.epochMillisFromOriginOffset(entry.startTime));\n }\n}\n"],"mappings":";;;;;AAqBA,IAAa,+BAAb,cAAkD,uBAAuB;CACvE,YAAgD;CAChD,aAAqB;CAErB,YAAmB,EACjB,MACA,MACA,iBACoC,EAAE,EAAE;AACxC,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,SAAsB;AACpB,MAAI,KAAK,WACP;AAGF,MAAI,CAAC,qBAAqB,UAAU,EAAE;AACpC,QAAK,MAAM,MAAM,kCAAkC;AACnD;;AAGF,OAAK,aAAa;AAElB,MAAI,KAAK,UACP,MAAK,UAAU,YAAY;AAG7B,OAAK,YAAY,0BACf,YACC,UAAU,KAAK,cAAc,MAAM,EACpC,EAAE,MAAM,KAAK,OAAO,CACrB;AAED,MAAI,CAAC,KAAK,WAAW;AACnB,QAAK,aAAa;AAClB,QAAK,MAAM,MAAM,mBAAmB;AACpC;;;CAIJ,UAAuB;AACrB,OAAK,aAAa;AAElB,MAAI,KAAK,WAAW;AAClB,QAAK,UAAU,YAAY;AAC3B,QAAK,YAAY;;;CAIrB,cAAsB,OAAuC;AAC3D,MAAI,CAAC,KAAK,WACR;AAGF,MAAI,KAAK,cAAc,yBAAyB,CAC9C;EAGF,MAAM,OAAO,KAAK,OAAO,UAAU,MAAM,YAAY;GAGnD,WAAW,KAAK,KAAK,4BAA4B,EAAE;GACnD,YAAY;KACT,eAAA;KACA,oCAAoC,MAAM;KAC1C,iCAAiC,MAAM,SAAS,SAAS,aAAa;KACtE,qCAAqC,MAAM;KAC3C,mCAAmC,MAAM;KACzC,oCAAoC,MAAM;KAC1C,6BAA6B,MAAM;KACnC,uCAAuC,MAAM;KAC7C,wCAAwC,MAAM;IAChD;GACF,CAAC;AACF,MAAI,MAAM,WAAW,EACnB,MAAK,SACH,QACA,KAAK,KAAK,4BAA4B,MAAM,SAAS,CACtD;AAGH,OAAK,IAAI,KAAK,KAAK,4BAA4B,MAAM,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"EmptyRootInstrumentation.cjs","names":["MXLInstrumentationBase"],"sources":["../../../../src/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.ts"],"sourcesContent":["import { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport type { EmptyRootInstrumentationArgs } from './types.ts';\n\n/*\n EmptyRootInstrumentation observes changes to what is considered the root node of the application and emits a span\n event on the session span if it ever finds it empty.\n */\nexport class EmptyRootInstrumentation extends MXLInstrumentationBase {\n private readonly _observer: MutationObserver;\n private readonly _emptyCheckDelayMs: number;\n private readonly _rootNode: Node | null;\n\n public constructor({\n diag,\n perf,\n rootNode,\n emptyCheckDelayMs = 500,\n }: EmptyRootInstrumentationArgs) {\n super({\n instrumentationName: 'EmptyRootInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n\n this._rootNode = rootNode;\n this._emptyCheckDelayMs = emptyCheckDelayMs;\n\n this._observer = new MutationObserver(\n (mutationList: MutationRecord[], _observer: MutationObserver) => {\n this._observerCallback(mutationList);\n },\n );\n\n if (this._config.enabled && this._rootNode) {\n this.enable();\n } else if (!this._rootNode) {\n this._diag.warn(\n \"supplied root node was null, this instrumentation won't be enabled\",\n );\n }\n }\n\n public disable(): void {\n this._observer.disconnect();\n }\n\n public enable(): void {\n if (this._rootNode) {\n this._observer.observe(this._rootNode, { childList: true });\n }\n }\n\n protected _observerCallback(mutationList: MutationRecord[]): void {\n let removedNodesFromRoot = false;\n let addedNodesToRoot = false;\n\n for (const mutation of mutationList) {\n if (mutation.target === this._rootNode) {\n if (mutation.removedNodes.length > 0) {\n removedNodesFromRoot = true;\n }\n\n if (mutation.addedNodes.length > 0) {\n addedNodesToRoot = true;\n }\n }\n }\n\n if (removedNodesFromRoot && !addedNodesToRoot) {\n this._diag.debug(\n 'root node had child nodes removed without new ones being added, ' +\n `checking if it's empty in ${this._emptyCheckDelayMs}ms`,\n );\n\n window.setTimeout(() => {\n this._checkForEmptyRootNode();\n }, this._emptyCheckDelayMs);\n }\n }\n\n protected _checkForEmptyRootNode(): void {\n if (this._rootNode?.childNodes.length === 0) {\n this._diag.debug('root node was found to be empty');\n\n const currentSessionSpan = this.sessionManager.getSessionSpan();\n if (currentSessionSpan) {\n currentSessionSpan.addEvent('empty-root-node', {\n 'mxl.type': 'ux.empty_root_node',\n });\n } else {\n this._diag.debug('no active session found to emit event on');\n }\n }\n }\n}\n"],"mappings":";;;AAOA,IAAa,2BAAb,cAA8CA,uEAAAA,uBAAuB;CACnE;CACA;CACA;CAEA,YAAmB,EACjB,MACA,MACA,UACA,oBAAoB,OACW;AAC/B,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,OAAK,YAAY;AACjB,OAAK,qBAAqB;AAE1B,OAAK,YAAY,IAAI,kBAClB,cAAgC,cAAgC;AAC/D,QAAK,kBAAkB,aAAa;IAEvC;AAED,MAAI,KAAK,QAAQ,WAAW,KAAK,UAC/B,MAAK,QAAQ;WACJ,CAAC,KAAK,UACf,MAAK,MAAM,KACT,qEACD;;CAIL,UAAuB;AACrB,OAAK,UAAU,YAAY;;CAG7B,SAAsB;AACpB,MAAI,KAAK,UACP,MAAK,UAAU,QAAQ,KAAK,WAAW,EAAE,WAAW,MAAM,CAAC;;CAI/D,kBAA4B,cAAsC;EAChE,IAAI,uBAAuB;EAC3B,IAAI,mBAAmB;AAEvB,OAAK,MAAM,YAAY,aACrB,KAAI,SAAS,WAAW,KAAK,WAAW;AACtC,OAAI,SAAS,aAAa,SAAS,EACjC,wBAAuB;AAGzB,OAAI,SAAS,WAAW,SAAS,EAC/B,oBAAmB;;AAKzB,MAAI,wBAAwB,CAAC,kBAAkB;AAC7C,QAAK,MAAM,MACT,6FAC+B,KAAK,mBAAmB,IACxD;AAED,UAAO,iBAAiB;AACtB,SAAK,wBAAwB;MAC5B,KAAK,mBAAmB;;;CAI/B,yBAAyC;AACvC,MAAI,KAAK,WAAW,WAAW,WAAW,GAAG;AAC3C,QAAK,MAAM,MAAM,kCAAkC;GAEnD,MAAM,qBAAqB,KAAK,eAAe,gBAAgB;AAC/D,OAAI,mBACF,oBAAmB,SAAS,mBAAmB,EAC7C,YAAY,sBACb,CAAC;OAEF,MAAK,MAAM,MAAM,2CAA2C"}
1
+ {"version":3,"file":"EmptyRootInstrumentation.cjs","names":["MXLInstrumentationBase"],"sources":["../../../../src/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.ts"],"sourcesContent":["import { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport type { EmptyRootInstrumentationArgs } from './types';\n\n/*\n EmptyRootInstrumentation observes changes to what is considered the root node of the application and emits a span\n event on the session span if it ever finds it empty.\n */\nexport class EmptyRootInstrumentation extends MXLInstrumentationBase {\n private readonly _observer: MutationObserver;\n private readonly _emptyCheckDelayMs: number;\n private readonly _rootNode: Node | null;\n\n public constructor({\n diag,\n perf,\n rootNode,\n emptyCheckDelayMs = 500,\n }: EmptyRootInstrumentationArgs) {\n super({\n instrumentationName: 'EmptyRootInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n\n this._rootNode = rootNode;\n this._emptyCheckDelayMs = emptyCheckDelayMs;\n\n this._observer = new MutationObserver(\n (mutationList: MutationRecord[], _observer: MutationObserver) => {\n this._observerCallback(mutationList);\n },\n );\n\n if (this._config.enabled && this._rootNode) {\n this.enable();\n } else if (!this._rootNode) {\n this._diag.warn(\n \"supplied root node was null, this instrumentation won't be enabled\",\n );\n }\n }\n\n public disable(): void {\n this._observer.disconnect();\n }\n\n public enable(): void {\n if (this._rootNode) {\n this._observer.observe(this._rootNode, { childList: true });\n }\n }\n\n protected _observerCallback(mutationList: MutationRecord[]): void {\n let removedNodesFromRoot = false;\n let addedNodesToRoot = false;\n\n for (const mutation of mutationList) {\n if (mutation.target === this._rootNode) {\n if (mutation.removedNodes.length > 0) {\n removedNodesFromRoot = true;\n }\n\n if (mutation.addedNodes.length > 0) {\n addedNodesToRoot = true;\n }\n }\n }\n\n if (removedNodesFromRoot && !addedNodesToRoot) {\n this._diag.debug(\n 'root node had child nodes removed without new ones being added, ' +\n `checking if it's empty in ${this._emptyCheckDelayMs}ms`,\n );\n\n window.setTimeout(() => {\n this._checkForEmptyRootNode();\n }, this._emptyCheckDelayMs);\n }\n }\n\n protected _checkForEmptyRootNode(): void {\n if (this._rootNode?.childNodes.length === 0) {\n this._diag.debug('root node was found to be empty');\n\n const currentSessionSpan = this.sessionManager.getSessionSpan();\n if (currentSessionSpan) {\n currentSessionSpan.addEvent('empty-root-node', {\n 'mxl.type': 'ux.empty_root_node',\n });\n } else {\n this._diag.debug('no active session found to emit event on');\n }\n }\n }\n}\n"],"mappings":";;;AAOA,IAAa,2BAAb,cAA8CA,uEAAAA,uBAAuB;CACnE;CACA;CACA;CAEA,YAAmB,EACjB,MACA,MACA,UACA,oBAAoB,OACW;AAC/B,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,OAAK,YAAY;AACjB,OAAK,qBAAqB;AAE1B,OAAK,YAAY,IAAI,kBAClB,cAAgC,cAAgC;AAC/D,QAAK,kBAAkB,aAAa;IAEvC;AAED,MAAI,KAAK,QAAQ,WAAW,KAAK,UAC/B,MAAK,QAAQ;WACJ,CAAC,KAAK,UACf,MAAK,MAAM,KACT,qEACD;;CAIL,UAAuB;AACrB,OAAK,UAAU,YAAY;;CAG7B,SAAsB;AACpB,MAAI,KAAK,UACP,MAAK,UAAU,QAAQ,KAAK,WAAW,EAAE,WAAW,MAAM,CAAC;;CAI/D,kBAA4B,cAAsC;EAChE,IAAI,uBAAuB;EAC3B,IAAI,mBAAmB;AAEvB,OAAK,MAAM,YAAY,aACrB,KAAI,SAAS,WAAW,KAAK,WAAW;AACtC,OAAI,SAAS,aAAa,SAAS,EACjC,wBAAuB;AAGzB,OAAI,SAAS,WAAW,SAAS,EAC/B,oBAAmB;;AAKzB,MAAI,wBAAwB,CAAC,kBAAkB;AAC7C,QAAK,MAAM,MACT,6FAC+B,KAAK,mBAAmB,IACxD;AAED,UAAO,iBAAiB;AACtB,SAAK,wBAAwB;MAC5B,KAAK,mBAAmB;;;CAI/B,yBAAyC;AACvC,MAAI,KAAK,WAAW,WAAW,WAAW,GAAG;AAC3C,QAAK,MAAM,MAAM,kCAAkC;GAEnD,MAAM,qBAAqB,KAAK,eAAe,gBAAgB;AAC/D,OAAI,mBACF,oBAAmB,SAAS,mBAAmB,EAC7C,YAAY,sBACb,CAAC;OAEF,MAAK,MAAM,MAAM,2CAA2C"}
@@ -1 +1 @@
1
- {"version":3,"file":"EmptyRootInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.ts"],"sourcesContent":["import { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport type { EmptyRootInstrumentationArgs } from './types.ts';\n\n/*\n EmptyRootInstrumentation observes changes to what is considered the root node of the application and emits a span\n event on the session span if it ever finds it empty.\n */\nexport class EmptyRootInstrumentation extends MXLInstrumentationBase {\n private readonly _observer: MutationObserver;\n private readonly _emptyCheckDelayMs: number;\n private readonly _rootNode: Node | null;\n\n public constructor({\n diag,\n perf,\n rootNode,\n emptyCheckDelayMs = 500,\n }: EmptyRootInstrumentationArgs) {\n super({\n instrumentationName: 'EmptyRootInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n\n this._rootNode = rootNode;\n this._emptyCheckDelayMs = emptyCheckDelayMs;\n\n this._observer = new MutationObserver(\n (mutationList: MutationRecord[], _observer: MutationObserver) => {\n this._observerCallback(mutationList);\n },\n );\n\n if (this._config.enabled && this._rootNode) {\n this.enable();\n } else if (!this._rootNode) {\n this._diag.warn(\n \"supplied root node was null, this instrumentation won't be enabled\",\n );\n }\n }\n\n public disable(): void {\n this._observer.disconnect();\n }\n\n public enable(): void {\n if (this._rootNode) {\n this._observer.observe(this._rootNode, { childList: true });\n }\n }\n\n protected _observerCallback(mutationList: MutationRecord[]): void {\n let removedNodesFromRoot = false;\n let addedNodesToRoot = false;\n\n for (const mutation of mutationList) {\n if (mutation.target === this._rootNode) {\n if (mutation.removedNodes.length > 0) {\n removedNodesFromRoot = true;\n }\n\n if (mutation.addedNodes.length > 0) {\n addedNodesToRoot = true;\n }\n }\n }\n\n if (removedNodesFromRoot && !addedNodesToRoot) {\n this._diag.debug(\n 'root node had child nodes removed without new ones being added, ' +\n `checking if it's empty in ${this._emptyCheckDelayMs}ms`,\n );\n\n window.setTimeout(() => {\n this._checkForEmptyRootNode();\n }, this._emptyCheckDelayMs);\n }\n }\n\n protected _checkForEmptyRootNode(): void {\n if (this._rootNode?.childNodes.length === 0) {\n this._diag.debug('root node was found to be empty');\n\n const currentSessionSpan = this.sessionManager.getSessionSpan();\n if (currentSessionSpan) {\n currentSessionSpan.addEvent('empty-root-node', {\n 'mxl.type': 'ux.empty_root_node',\n });\n } else {\n this._diag.debug('no active session found to emit event on');\n }\n }\n }\n}\n"],"mappings":";;AAOA,IAAa,2BAAb,cAA8C,uBAAuB;CACnE;CACA;CACA;CAEA,YAAmB,EACjB,MACA,MACA,UACA,oBAAoB,OACW;AAC/B,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,OAAK,YAAY;AACjB,OAAK,qBAAqB;AAE1B,OAAK,YAAY,IAAI,kBAClB,cAAgC,cAAgC;AAC/D,QAAK,kBAAkB,aAAa;IAEvC;AAED,MAAI,KAAK,QAAQ,WAAW,KAAK,UAC/B,MAAK,QAAQ;WACJ,CAAC,KAAK,UACf,MAAK,MAAM,KACT,qEACD;;CAIL,UAAuB;AACrB,OAAK,UAAU,YAAY;;CAG7B,SAAsB;AACpB,MAAI,KAAK,UACP,MAAK,UAAU,QAAQ,KAAK,WAAW,EAAE,WAAW,MAAM,CAAC;;CAI/D,kBAA4B,cAAsC;EAChE,IAAI,uBAAuB;EAC3B,IAAI,mBAAmB;AAEvB,OAAK,MAAM,YAAY,aACrB,KAAI,SAAS,WAAW,KAAK,WAAW;AACtC,OAAI,SAAS,aAAa,SAAS,EACjC,wBAAuB;AAGzB,OAAI,SAAS,WAAW,SAAS,EAC/B,oBAAmB;;AAKzB,MAAI,wBAAwB,CAAC,kBAAkB;AAC7C,QAAK,MAAM,MACT,6FAC+B,KAAK,mBAAmB,IACxD;AAED,UAAO,iBAAiB;AACtB,SAAK,wBAAwB;MAC5B,KAAK,mBAAmB;;;CAI/B,yBAAyC;AACvC,MAAI,KAAK,WAAW,WAAW,WAAW,GAAG;AAC3C,QAAK,MAAM,MAAM,kCAAkC;GAEnD,MAAM,qBAAqB,KAAK,eAAe,gBAAgB;AAC/D,OAAI,mBACF,oBAAmB,SAAS,mBAAmB,EAC7C,YAAY,sBACb,CAAC;OAEF,MAAK,MAAM,MAAM,2CAA2C"}
1
+ {"version":3,"file":"EmptyRootInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/empty-root/EmptyRootInstrumentation/EmptyRootInstrumentation.ts"],"sourcesContent":["import { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport type { EmptyRootInstrumentationArgs } from './types';\n\n/*\n EmptyRootInstrumentation observes changes to what is considered the root node of the application and emits a span\n event on the session span if it ever finds it empty.\n */\nexport class EmptyRootInstrumentation extends MXLInstrumentationBase {\n private readonly _observer: MutationObserver;\n private readonly _emptyCheckDelayMs: number;\n private readonly _rootNode: Node | null;\n\n public constructor({\n diag,\n perf,\n rootNode,\n emptyCheckDelayMs = 500,\n }: EmptyRootInstrumentationArgs) {\n super({\n instrumentationName: 'EmptyRootInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n\n this._rootNode = rootNode;\n this._emptyCheckDelayMs = emptyCheckDelayMs;\n\n this._observer = new MutationObserver(\n (mutationList: MutationRecord[], _observer: MutationObserver) => {\n this._observerCallback(mutationList);\n },\n );\n\n if (this._config.enabled && this._rootNode) {\n this.enable();\n } else if (!this._rootNode) {\n this._diag.warn(\n \"supplied root node was null, this instrumentation won't be enabled\",\n );\n }\n }\n\n public disable(): void {\n this._observer.disconnect();\n }\n\n public enable(): void {\n if (this._rootNode) {\n this._observer.observe(this._rootNode, { childList: true });\n }\n }\n\n protected _observerCallback(mutationList: MutationRecord[]): void {\n let removedNodesFromRoot = false;\n let addedNodesToRoot = false;\n\n for (const mutation of mutationList) {\n if (mutation.target === this._rootNode) {\n if (mutation.removedNodes.length > 0) {\n removedNodesFromRoot = true;\n }\n\n if (mutation.addedNodes.length > 0) {\n addedNodesToRoot = true;\n }\n }\n }\n\n if (removedNodesFromRoot && !addedNodesToRoot) {\n this._diag.debug(\n 'root node had child nodes removed without new ones being added, ' +\n `checking if it's empty in ${this._emptyCheckDelayMs}ms`,\n );\n\n window.setTimeout(() => {\n this._checkForEmptyRootNode();\n }, this._emptyCheckDelayMs);\n }\n }\n\n protected _checkForEmptyRootNode(): void {\n if (this._rootNode?.childNodes.length === 0) {\n this._diag.debug('root node was found to be empty');\n\n const currentSessionSpan = this.sessionManager.getSessionSpan();\n if (currentSessionSpan) {\n currentSessionSpan.addEvent('empty-root-node', {\n 'mxl.type': 'ux.empty_root_node',\n });\n } else {\n this._diag.debug('no active session found to emit event on');\n }\n }\n }\n}\n"],"mappings":";;AAOA,IAAa,2BAAb,cAA8C,uBAAuB;CACnE;CACA;CACA;CAEA,YAAmB,EACjB,MACA,MACA,UACA,oBAAoB,OACW;AAC/B,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,OAAK,YAAY;AACjB,OAAK,qBAAqB;AAE1B,OAAK,YAAY,IAAI,kBAClB,cAAgC,cAAgC;AAC/D,QAAK,kBAAkB,aAAa;IAEvC;AAED,MAAI,KAAK,QAAQ,WAAW,KAAK,UAC/B,MAAK,QAAQ;WACJ,CAAC,KAAK,UACf,MAAK,MAAM,KACT,qEACD;;CAIL,UAAuB;AACrB,OAAK,UAAU,YAAY;;CAG7B,SAAsB;AACpB,MAAI,KAAK,UACP,MAAK,UAAU,QAAQ,KAAK,WAAW,EAAE,WAAW,MAAM,CAAC;;CAI/D,kBAA4B,cAAsC;EAChE,IAAI,uBAAuB;EAC3B,IAAI,mBAAmB;AAEvB,OAAK,MAAM,YAAY,aACrB,KAAI,SAAS,WAAW,KAAK,WAAW;AACtC,OAAI,SAAS,aAAa,SAAS,EACjC,wBAAuB;AAGzB,OAAI,SAAS,WAAW,SAAS,EAC/B,oBAAmB;;AAKzB,MAAI,wBAAwB,CAAC,kBAAkB;AAC7C,QAAK,MAAM,MACT,6FAC+B,KAAK,mBAAmB,IACxD;AAED,UAAO,iBAAiB;AACtB,SAAK,wBAAwB;MAC5B,KAAK,mBAAmB;;;CAI/B,yBAAyC;AACvC,MAAI,KAAK,WAAW,WAAW,WAAW,GAAG;AAC3C,QAAK,MAAM,MAAM,kCAAkC;GAEnD,MAAM,qBAAqB,KAAK,eAAe,gBAAgB;AAC/D,OAAI,mBACF,oBAAmB,SAAS,mBAAmB,EAC7C,YAAY,sBACb,CAAC;OAEF,MAAK,MAAM,MAAM,2CAA2C"}
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalExceptionInstrumentation.cjs","names":["MXLInstrumentationBase"],"sources":["../../../../src/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.ts"],"sourcesContent":["import { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport type { GlobalExceptionInstrumentationArgs } from './types.ts';\n\nexport class GlobalExceptionInstrumentation extends MXLInstrumentationBase {\n private readonly _onErrorHandler: (event: ErrorEvent) => void;\n private readonly _onUnhandledRejectionHandler: (\n event: PromiseRejectionEvent,\n ) => void;\n\n public constructor({ diag, perf }: GlobalExceptionInstrumentationArgs = {}) {\n super({\n instrumentationName: 'GlobalExceptionInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n this._onErrorHandler = (event: ErrorEvent) => {\n this.logManager.logException(event.error || event.message, {\n handled: false,\n timestamp: this.perf.epochMillisFromOriginOffset(event.timeStamp),\n handler: 'global_exception',\n });\n };\n this._onUnhandledRejectionHandler = (event: PromiseRejectionEvent) => {\n this.logManager.logException(event.reason, {\n handled: false,\n timestamp: this.perf.epochMillisFromOriginOffset(event.timeStamp),\n handler: 'promise_rejection',\n });\n };\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public disable(): void {\n window.removeEventListener('error', this._onErrorHandler);\n window.removeEventListener(\n 'unhandledrejection',\n this._onUnhandledRejectionHandler,\n );\n }\n\n public enable(): void {\n window.addEventListener('error', this._onErrorHandler);\n window.addEventListener(\n 'unhandledrejection',\n this._onUnhandledRejectionHandler,\n );\n }\n}\n"],"mappings":";;;AAGA,IAAa,iCAAb,cAAoDA,uEAAAA,uBAAuB;CACzE;CACA;CAIA,YAAmB,EAAE,MAAM,SAA6C,EAAE,EAAE;AAC1E,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AACF,OAAK,mBAAmB,UAAsB;AAC5C,QAAK,WAAW,aAAa,MAAM,SAAS,MAAM,SAAS;IACzD,SAAS;IACT,WAAW,KAAK,KAAK,4BAA4B,MAAM,UAAU;IACjE,SAAS;IACV,CAAC;;AAEJ,OAAK,gCAAgC,UAAiC;AACpE,QAAK,WAAW,aAAa,MAAM,QAAQ;IACzC,SAAS;IACT,WAAW,KAAK,KAAK,4BAA4B,MAAM,UAAU;IACjE,SAAS;IACV,CAAC;;AAGJ,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,UAAuB;AACrB,SAAO,oBAAoB,SAAS,KAAK,gBAAgB;AACzD,SAAO,oBACL,sBACA,KAAK,6BACN;;CAGH,SAAsB;AACpB,SAAO,iBAAiB,SAAS,KAAK,gBAAgB;AACtD,SAAO,iBACL,sBACA,KAAK,6BACN"}
1
+ {"version":3,"file":"GlobalExceptionInstrumentation.cjs","names":["MXLInstrumentationBase"],"sources":["../../../../src/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.ts"],"sourcesContent":["import { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport type { GlobalExceptionInstrumentationArgs } from './types';\n\nexport class GlobalExceptionInstrumentation extends MXLInstrumentationBase {\n private readonly _onErrorHandler: (event: ErrorEvent) => void;\n private readonly _onUnhandledRejectionHandler: (\n event: PromiseRejectionEvent,\n ) => void;\n\n public constructor({ diag, perf }: GlobalExceptionInstrumentationArgs = {}) {\n super({\n instrumentationName: 'GlobalExceptionInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n this._onErrorHandler = (event: ErrorEvent) => {\n this.logManager.logException(event.error || event.message, {\n handled: false,\n timestamp: this.perf.epochMillisFromOriginOffset(event.timeStamp),\n handler: 'global_exception',\n });\n };\n this._onUnhandledRejectionHandler = (event: PromiseRejectionEvent) => {\n this.logManager.logException(event.reason, {\n handled: false,\n timestamp: this.perf.epochMillisFromOriginOffset(event.timeStamp),\n handler: 'promise_rejection',\n });\n };\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public disable(): void {\n window.removeEventListener('error', this._onErrorHandler);\n window.removeEventListener(\n 'unhandledrejection',\n this._onUnhandledRejectionHandler,\n );\n }\n\n public enable(): void {\n window.addEventListener('error', this._onErrorHandler);\n window.addEventListener(\n 'unhandledrejection',\n this._onUnhandledRejectionHandler,\n );\n }\n}\n"],"mappings":";;;AAGA,IAAa,iCAAb,cAAoDA,uEAAAA,uBAAuB;CACzE;CACA;CAIA,YAAmB,EAAE,MAAM,SAA6C,EAAE,EAAE;AAC1E,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AACF,OAAK,mBAAmB,UAAsB;AAC5C,QAAK,WAAW,aAAa,MAAM,SAAS,MAAM,SAAS;IACzD,SAAS;IACT,WAAW,KAAK,KAAK,4BAA4B,MAAM,UAAU;IACjE,SAAS;IACV,CAAC;;AAEJ,OAAK,gCAAgC,UAAiC;AACpE,QAAK,WAAW,aAAa,MAAM,QAAQ;IACzC,SAAS;IACT,WAAW,KAAK,KAAK,4BAA4B,MAAM,UAAU;IACjE,SAAS;IACV,CAAC;;AAGJ,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,UAAuB;AACrB,SAAO,oBAAoB,SAAS,KAAK,gBAAgB;AACzD,SAAO,oBACL,sBACA,KAAK,6BACN;;CAGH,SAAsB;AACpB,SAAO,iBAAiB,SAAS,KAAK,gBAAgB;AACtD,SAAO,iBACL,sBACA,KAAK,6BACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalExceptionInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.ts"],"sourcesContent":["import { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport type { GlobalExceptionInstrumentationArgs } from './types.ts';\n\nexport class GlobalExceptionInstrumentation extends MXLInstrumentationBase {\n private readonly _onErrorHandler: (event: ErrorEvent) => void;\n private readonly _onUnhandledRejectionHandler: (\n event: PromiseRejectionEvent,\n ) => void;\n\n public constructor({ diag, perf }: GlobalExceptionInstrumentationArgs = {}) {\n super({\n instrumentationName: 'GlobalExceptionInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n this._onErrorHandler = (event: ErrorEvent) => {\n this.logManager.logException(event.error || event.message, {\n handled: false,\n timestamp: this.perf.epochMillisFromOriginOffset(event.timeStamp),\n handler: 'global_exception',\n });\n };\n this._onUnhandledRejectionHandler = (event: PromiseRejectionEvent) => {\n this.logManager.logException(event.reason, {\n handled: false,\n timestamp: this.perf.epochMillisFromOriginOffset(event.timeStamp),\n handler: 'promise_rejection',\n });\n };\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public disable(): void {\n window.removeEventListener('error', this._onErrorHandler);\n window.removeEventListener(\n 'unhandledrejection',\n this._onUnhandledRejectionHandler,\n );\n }\n\n public enable(): void {\n window.addEventListener('error', this._onErrorHandler);\n window.addEventListener(\n 'unhandledrejection',\n this._onUnhandledRejectionHandler,\n );\n }\n}\n"],"mappings":";;AAGA,IAAa,iCAAb,cAAoD,uBAAuB;CACzE;CACA;CAIA,YAAmB,EAAE,MAAM,SAA6C,EAAE,EAAE;AAC1E,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AACF,OAAK,mBAAmB,UAAsB;AAC5C,QAAK,WAAW,aAAa,MAAM,SAAS,MAAM,SAAS;IACzD,SAAS;IACT,WAAW,KAAK,KAAK,4BAA4B,MAAM,UAAU;IACjE,SAAS;IACV,CAAC;;AAEJ,OAAK,gCAAgC,UAAiC;AACpE,QAAK,WAAW,aAAa,MAAM,QAAQ;IACzC,SAAS;IACT,WAAW,KAAK,KAAK,4BAA4B,MAAM,UAAU;IACjE,SAAS;IACV,CAAC;;AAGJ,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,UAAuB;AACrB,SAAO,oBAAoB,SAAS,KAAK,gBAAgB;AACzD,SAAO,oBACL,sBACA,KAAK,6BACN;;CAGH,SAAsB;AACpB,SAAO,iBAAiB,SAAS,KAAK,gBAAgB;AACtD,SAAO,iBACL,sBACA,KAAK,6BACN"}
1
+ {"version":3,"file":"GlobalExceptionInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/exceptions/GlobalExceptionInstrumentation/GlobalExceptionInstrumentation.ts"],"sourcesContent":["import { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport type { GlobalExceptionInstrumentationArgs } from './types';\n\nexport class GlobalExceptionInstrumentation extends MXLInstrumentationBase {\n private readonly _onErrorHandler: (event: ErrorEvent) => void;\n private readonly _onUnhandledRejectionHandler: (\n event: PromiseRejectionEvent,\n ) => void;\n\n public constructor({ diag, perf }: GlobalExceptionInstrumentationArgs = {}) {\n super({\n instrumentationName: 'GlobalExceptionInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n this._onErrorHandler = (event: ErrorEvent) => {\n this.logManager.logException(event.error || event.message, {\n handled: false,\n timestamp: this.perf.epochMillisFromOriginOffset(event.timeStamp),\n handler: 'global_exception',\n });\n };\n this._onUnhandledRejectionHandler = (event: PromiseRejectionEvent) => {\n this.logManager.logException(event.reason, {\n handled: false,\n timestamp: this.perf.epochMillisFromOriginOffset(event.timeStamp),\n handler: 'promise_rejection',\n });\n };\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public disable(): void {\n window.removeEventListener('error', this._onErrorHandler);\n window.removeEventListener(\n 'unhandledrejection',\n this._onUnhandledRejectionHandler,\n );\n }\n\n public enable(): void {\n window.addEventListener('error', this._onErrorHandler);\n window.addEventListener(\n 'unhandledrejection',\n this._onUnhandledRejectionHandler,\n );\n }\n}\n"],"mappings":";;AAGA,IAAa,iCAAb,cAAoD,uBAAuB;CACzE;CACA;CAIA,YAAmB,EAAE,MAAM,SAA6C,EAAE,EAAE;AAC1E,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AACF,OAAK,mBAAmB,UAAsB;AAC5C,QAAK,WAAW,aAAa,MAAM,SAAS,MAAM,SAAS;IACzD,SAAS;IACT,WAAW,KAAK,KAAK,4BAA4B,MAAM,UAAU;IACjE,SAAS;IACV,CAAC;;AAEJ,OAAK,gCAAgC,UAAiC;AACpE,QAAK,WAAW,aAAa,MAAM,QAAQ;IACzC,SAAS;IACT,WAAW,KAAK,KAAK,4BAA4B,MAAM,UAAU;IACjE,SAAS;IACV,CAAC;;AAGJ,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,UAAuB;AACrB,SAAO,oBAAoB,SAAS,KAAK,gBAAgB;AACzD,SAAO,oBACL,sBACA,KAAK,6BACN;;CAGH,SAAsB;AACpB,SAAO,iBAAiB,SAAS,KAAK,gBAAgB;AACtD,SAAO,iBACL,sBACA,KAAK,6BACN"}
@@ -19,7 +19,7 @@ var MXLErrorBoundary = class extends react.Component {
19
19
  this._logManager.logException(error, {
20
20
  handled: false,
21
21
  attributes: {
22
- "react.component_stack": errorInfo.componentStack ?? void 0,
22
+ [require_constants_attributes.KEY_REACT_COMPONENT_STACK]: errorInfo.componentStack ?? void 0,
23
23
  [require_constants_attributes.KEY_MXL_INSTRUMENTATION]: "react_error_boundary"
24
24
  }
25
25
  });
@@ -1 +1 @@
1
- {"version":3,"file":"MXLErrorBoundary.cjs","names":["React","log","KEY_MXL_INSTRUMENTATION"],"sources":["../../../../../src/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.ts"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport * as React from 'react';\nimport type { LogManager } from '../../../../api-logs/index.ts';\nimport { log } from '../../../../api-logs/index.ts';\nimport {\n KEY_MXL_INSTRUMENTATION,\n MXL_ERROR_INSTRUMENTATIONS,\n} from '../../../../constants/index.ts';\n\ntype MXLErrorBoundaryProps = {\n fallback: () => React.ReactNode;\n};\n\ntype MXLErrorBoundaryState = {\n hasError: boolean;\n};\n\nexport class MXLErrorBoundary<\n P extends PropsWithChildren<MXLErrorBoundaryProps>,\n> extends React.Component<P, MXLErrorBoundaryState> {\n private readonly _logManager: LogManager;\n\n public constructor(props: P) {\n super(props);\n\n this._logManager = log.getLogManager();\n this.state = {\n hasError: false,\n };\n }\n\n public static getDerivedStateFromError() {\n return { hasError: true };\n }\n\n public override componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this._logManager.logException(error, {\n handled: false,\n attributes: {\n 'react.component_stack': errorInfo.componentStack ?? undefined,\n [KEY_MXL_INSTRUMENTATION]:\n MXL_ERROR_INSTRUMENTATIONS.ReactErrorBoundary,\n },\n });\n }\n\n public override render() {\n if (this.state.hasError) {\n return this.props.fallback();\n }\n\n return this.props.children;\n }\n}\n"],"mappings":";;;;;;;AAiBA,IAAa,mBAAb,cAEUA,MAAM,UAAoC;CAClD;CAEA,YAAmB,OAAU;AAC3B,QAAM,MAAM;AAEZ,OAAK,cAAcC,wBAAAA,IAAI,eAAe;AACtC,OAAK,QAAQ,EACX,UAAU,OACX;;CAGH,OAAc,2BAA2B;AACvC,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkC,OAAc,WAA4B;AAC1E,OAAK,YAAY,aAAa,OAAO;GACnC,SAAS;GACT,YAAY;IACV,yBAAyB,UAAU,kBAAkB,KAAA;KACpDC,6BAAAA,0BAAAA;IAEF;GACF,CAAC;;CAGJ,SAAyB;AACvB,MAAI,KAAK,MAAM,SACb,QAAO,KAAK,MAAM,UAAU;AAG9B,SAAO,KAAK,MAAM"}
1
+ {"version":3,"file":"MXLErrorBoundary.cjs","names":["React","log","KEY_REACT_COMPONENT_STACK","KEY_MXL_INSTRUMENTATION"],"sources":["../../../../../src/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.ts"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport * as React from 'react';\nimport type { LogManager } from '../../../../api-logs';\nimport { log } from '../../../../api-logs';\nimport {\n KEY_MXL_INSTRUMENTATION,\n KEY_REACT_COMPONENT_STACK,\n MXL_ERROR_INSTRUMENTATIONS,\n} from '../../../../constants';\n\ntype MXLErrorBoundaryProps = {\n fallback: () => React.ReactNode;\n};\n\ntype MXLErrorBoundaryState = {\n hasError: boolean;\n};\n\nexport class MXLErrorBoundary<\n P extends PropsWithChildren<MXLErrorBoundaryProps>,\n> extends React.Component<P, MXLErrorBoundaryState> {\n private readonly _logManager: LogManager;\n\n public constructor(props: P) {\n super(props);\n\n this._logManager = log.getLogManager();\n this.state = {\n hasError: false,\n };\n }\n\n public static getDerivedStateFromError() {\n return { hasError: true };\n }\n\n public override componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this._logManager.logException(error, {\n handled: false,\n attributes: {\n [KEY_REACT_COMPONENT_STACK]: errorInfo.componentStack ?? undefined,\n [KEY_MXL_INSTRUMENTATION]:\n MXL_ERROR_INSTRUMENTATIONS.ReactErrorBoundary,\n },\n });\n }\n\n public override render() {\n if (this.state.hasError) {\n return this.props.fallback();\n }\n\n return this.props.children;\n }\n}\n"],"mappings":";;;;;;;AAkBA,IAAa,mBAAb,cAEUA,MAAM,UAAoC;CAClD;CAEA,YAAmB,OAAU;AAC3B,QAAM,MAAM;AAEZ,OAAK,cAAcC,wBAAAA,IAAI,eAAe;AACtC,OAAK,QAAQ,EACX,UAAU,OACX;;CAGH,OAAc,2BAA2B;AACvC,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkC,OAAc,WAA4B;AAC1E,OAAK,YAAY,aAAa,OAAO;GACnC,SAAS;GACT,YAAY;KACTC,6BAAAA,4BAA4B,UAAU,kBAAkB,KAAA;KACxDC,6BAAAA,0BAAAA;IAEF;GACF,CAAC;;CAGJ,SAAyB;AACvB,MAAI,KAAK,MAAM,SACb,QAAO,KAAK,MAAM,UAAU;AAG9B,SAAO,KAAK,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"MXLErrorBoundary.d.cts","names":[],"sources":["../../../../../src/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.ts"],"mappings":";;;;KASK,qBAAA;EACH,QAAA,QAAgB,OAAA,CAAM,SAAA;AAAA;AAAA,KAGnB,qBAAA;EACH,QAAA;AAAA;AAAA,cAGW,gBAAA,WACD,iBAAA,CAAkB,qBAAA,WACpB,OAAA,CAAM,SAAA,CAAU,CAAA,EAAG,qBAAA;EAAA,iBACV,WAAA;cAEE,KAAA,EAAO,CAAA;EAAA,OASZ,wBAAA,CAAA;;;EAIE,iBAAA,CAAkB,KAAA,EAAO,KAAA,EAAO,SAAA,EAAW,OAAA,CAAM,SAAA;EAWjD,MAAA,CAAA,wCAAM,OAAA,CAAA,YAAA,mBAAA,OAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,OAAA,CAAA,SAAA,IAAA,OAAA,sCAAA,OAAA,CAAA,WAAA,GAAA,OAAA,CAAA,YAAA,mBAAA,OAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,OAAA,CAAA,SAAA,wBAAA,CAAA;AAAA"}
1
+ {"version":3,"file":"MXLErrorBoundary.d.cts","names":[],"sources":["../../../../../src/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.ts"],"mappings":";;;;KAUK,qBAAA;EACH,QAAA,QAAgB,OAAA,CAAM,SAAA;AAAA;AAAA,KAGnB,qBAAA;EACH,QAAA;AAAA;AAAA,cAGW,gBAAA,WACD,iBAAA,CAAkB,qBAAA,WACpB,OAAA,CAAM,SAAA,CAAU,CAAA,EAAG,qBAAA;EAAA,iBACV,WAAA;cAEE,KAAA,EAAO,CAAA;EAAA,OASZ,wBAAA,CAAA;;;EAIE,iBAAA,CAAkB,KAAA,EAAO,KAAA,EAAO,SAAA,EAAW,OAAA,CAAM,SAAA;EAWjD,MAAA,CAAA,wCAAM,OAAA,CAAA,YAAA,mBAAA,OAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,OAAA,CAAA,SAAA,IAAA,OAAA,sCAAA,OAAA,CAAA,WAAA,GAAA,OAAA,CAAA,YAAA,mBAAA,OAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,OAAA,CAAA,SAAA,wBAAA,CAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"MXLErrorBoundary.d.ts","names":[],"sources":["../../../../../src/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.ts"],"mappings":";;;;KASK,qBAAA;EACH,QAAA,QAAgB,OAAA,CAAM,SAAA;AAAA;AAAA,KAGnB,qBAAA;EACH,QAAA;AAAA;AAAA,cAGW,gBAAA,WACD,iBAAA,CAAkB,qBAAA,WACpB,OAAA,CAAM,SAAA,CAAU,CAAA,EAAG,qBAAA;EAAA,iBACV,WAAA;cAEE,KAAA,EAAO,CAAA;EAAA,OASZ,wBAAA,CAAA;;;EAIE,iBAAA,CAAkB,KAAA,EAAO,KAAA,EAAO,SAAA,EAAW,OAAA,CAAM,SAAA;EAWjD,MAAA,CAAA,wCAAM,OAAA,CAAA,YAAA,mBAAA,OAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,OAAA,CAAA,SAAA,IAAA,OAAA,sCAAA,OAAA,CAAA,WAAA,GAAA,OAAA,CAAA,YAAA,mBAAA,OAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,OAAA,CAAA,SAAA,wBAAA,CAAA;AAAA"}
1
+ {"version":3,"file":"MXLErrorBoundary.d.ts","names":[],"sources":["../../../../../src/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.ts"],"mappings":";;;;KAUK,qBAAA;EACH,QAAA,QAAgB,OAAA,CAAM,SAAA;AAAA;AAAA,KAGnB,qBAAA;EACH,QAAA;AAAA;AAAA,cAGW,gBAAA,WACD,iBAAA,CAAkB,qBAAA,WACpB,OAAA,CAAM,SAAA,CAAU,CAAA,EAAG,qBAAA;EAAA,iBACV,WAAA;cAEE,KAAA,EAAO,CAAA;EAAA,OASZ,wBAAA,CAAA;;;EAIE,iBAAA,CAAkB,KAAA,EAAO,KAAA,EAAO,SAAA,EAAW,OAAA,CAAM,SAAA;EAWjD,MAAA,CAAA,wCAAM,OAAA,CAAA,YAAA,mBAAA,OAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,OAAA,CAAA,SAAA,IAAA,OAAA,sCAAA,OAAA,CAAA,WAAA,GAAA,OAAA,CAAA,YAAA,mBAAA,OAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,OAAA,CAAA,SAAA,wBAAA,CAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- import { KEY_MXL_INSTRUMENTATION } from "../../../../constants/attributes.js";
1
+ import { KEY_MXL_INSTRUMENTATION, KEY_REACT_COMPONENT_STACK } from "../../../../constants/attributes.js";
2
2
  import { log } from "../../../../api-logs/logAPI.js";
3
3
  import * as React$1 from "react";
4
4
  //#region src/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.ts
@@ -16,7 +16,7 @@ var MXLErrorBoundary = class extends React$1.Component {
16
16
  this._logManager.logException(error, {
17
17
  handled: false,
18
18
  attributes: {
19
- "react.component_stack": errorInfo.componentStack ?? void 0,
19
+ [KEY_REACT_COMPONENT_STACK]: errorInfo.componentStack ?? void 0,
20
20
  [KEY_MXL_INSTRUMENTATION]: "react_error_boundary"
21
21
  }
22
22
  });
@@ -1 +1 @@
1
- {"version":3,"file":"MXLErrorBoundary.js","names":["React"],"sources":["../../../../../src/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.ts"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport * as React from 'react';\nimport type { LogManager } from '../../../../api-logs/index.ts';\nimport { log } from '../../../../api-logs/index.ts';\nimport {\n KEY_MXL_INSTRUMENTATION,\n MXL_ERROR_INSTRUMENTATIONS,\n} from '../../../../constants/index.ts';\n\ntype MXLErrorBoundaryProps = {\n fallback: () => React.ReactNode;\n};\n\ntype MXLErrorBoundaryState = {\n hasError: boolean;\n};\n\nexport class MXLErrorBoundary<\n P extends PropsWithChildren<MXLErrorBoundaryProps>,\n> extends React.Component<P, MXLErrorBoundaryState> {\n private readonly _logManager: LogManager;\n\n public constructor(props: P) {\n super(props);\n\n this._logManager = log.getLogManager();\n this.state = {\n hasError: false,\n };\n }\n\n public static getDerivedStateFromError() {\n return { hasError: true };\n }\n\n public override componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this._logManager.logException(error, {\n handled: false,\n attributes: {\n 'react.component_stack': errorInfo.componentStack ?? undefined,\n [KEY_MXL_INSTRUMENTATION]:\n MXL_ERROR_INSTRUMENTATIONS.ReactErrorBoundary,\n },\n });\n }\n\n public override render() {\n if (this.state.hasError) {\n return this.props.fallback();\n }\n\n return this.props.children;\n }\n}\n"],"mappings":";;;;AAiBA,IAAa,mBAAb,cAEUA,QAAM,UAAoC;CAClD;CAEA,YAAmB,OAAU;AAC3B,QAAM,MAAM;AAEZ,OAAK,cAAc,IAAI,eAAe;AACtC,OAAK,QAAQ,EACX,UAAU,OACX;;CAGH,OAAc,2BAA2B;AACvC,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkC,OAAc,WAA4B;AAC1E,OAAK,YAAY,aAAa,OAAO;GACnC,SAAS;GACT,YAAY;IACV,yBAAyB,UAAU,kBAAkB,KAAA;KACpD,0BAAA;IAEF;GACF,CAAC;;CAGJ,SAAyB;AACvB,MAAI,KAAK,MAAM,SACb,QAAO,KAAK,MAAM,UAAU;AAG9B,SAAO,KAAK,MAAM"}
1
+ {"version":3,"file":"MXLErrorBoundary.js","names":["React"],"sources":["../../../../../src/instrumentations/exceptions/react/MXLErrorBoundary/MXLErrorBoundary.ts"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport * as React from 'react';\nimport type { LogManager } from '../../../../api-logs';\nimport { log } from '../../../../api-logs';\nimport {\n KEY_MXL_INSTRUMENTATION,\n KEY_REACT_COMPONENT_STACK,\n MXL_ERROR_INSTRUMENTATIONS,\n} from '../../../../constants';\n\ntype MXLErrorBoundaryProps = {\n fallback: () => React.ReactNode;\n};\n\ntype MXLErrorBoundaryState = {\n hasError: boolean;\n};\n\nexport class MXLErrorBoundary<\n P extends PropsWithChildren<MXLErrorBoundaryProps>,\n> extends React.Component<P, MXLErrorBoundaryState> {\n private readonly _logManager: LogManager;\n\n public constructor(props: P) {\n super(props);\n\n this._logManager = log.getLogManager();\n this.state = {\n hasError: false,\n };\n }\n\n public static getDerivedStateFromError() {\n return { hasError: true };\n }\n\n public override componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this._logManager.logException(error, {\n handled: false,\n attributes: {\n [KEY_REACT_COMPONENT_STACK]: errorInfo.componentStack ?? undefined,\n [KEY_MXL_INSTRUMENTATION]:\n MXL_ERROR_INSTRUMENTATIONS.ReactErrorBoundary,\n },\n });\n }\n\n public override render() {\n if (this.state.hasError) {\n return this.props.fallback();\n }\n\n return this.props.children;\n }\n}\n"],"mappings":";;;;AAkBA,IAAa,mBAAb,cAEUA,QAAM,UAAoC;CAClD;CAEA,YAAmB,OAAU;AAC3B,QAAM,MAAM;AAEZ,OAAK,cAAc,IAAI,eAAe;AACtC,OAAK,QAAQ,EACX,UAAU,OACX;;CAGH,OAAc,2BAA2B;AACvC,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkC,OAAc,WAA4B;AAC1E,OAAK,YAAY,aAAa,OAAO;GACnC,SAAS;GACT,YAAY;KACT,4BAA4B,UAAU,kBAAkB,KAAA;KACxD,0BAAA;IAEF;GACF,CAAC;;CAGJ,SAAyB;AACvB,MAAI,KAAK,MAAM,SACb,QAAO,KAAK,MAAM,UAAU;AAG9B,SAAO,KAAK,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"MXLFetchInstrumentation.cjs","names":["FetchInstrumentation"],"sources":["../../../../src/instrumentations/fetch/MXLFetchInstrumentation/MXLFetchInstrumentation.ts"],"sourcesContent":["import { isWrapped } from '@opentelemetry/instrumentation';\n\nimport { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';\nimport type { MXLFetchInstrumentationArgs } from './types.ts';\n\nexport class MXLFetchInstrumentation extends FetchInstrumentation {\n private readonly _omitIfAlreadyPatched?: boolean;\n\n public constructor({\n omitIfAlreadyPatched,\n ...rest\n }: MXLFetchInstrumentationArgs = {}) {\n // Base constructor automatically calls this.enable() if enabled is true, but we need to run our overridden constructor\n // first so force enabled false here and call it ourselves later\n super({ ...rest, enabled: false });\n\n this._omitIfAlreadyPatched = omitIfAlreadyPatched;\n\n if (rest.enabled) {\n this.enable();\n }\n }\n\n public override enable(): void {\n // The base implementation always removes and then re-patches, this means the last instrumentation to run \"wins\":\n // https://github.com/open-telemetry/opentelemetry-js/blob/2d7eecbb19aec17bf2d8b9a4e4b2d84dc92c2d88/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L604\n // Exposing an option in this class to allow leaving the existing patch in place and letting a previous instrumentation\n // control the global\n if (this._omitIfAlreadyPatched && isWrapped(fetch)) {\n this._diag.debug(\n 'fetch is already passed and `omitIfAlreadyPatched` is true, skipping enabling this instrumentation',\n );\n return;\n }\n\n super.enable();\n }\n}\n"],"mappings":";;;;;AAKA,IAAa,0BAAb,cAA6CA,qCAAAA,qBAAqB;CAChE;CAEA,YAAmB,EACjB,sBACA,GAAG,SAC4B,EAAE,EAAE;AAGnC,QAAM;GAAE,GAAG;GAAM,SAAS;GAAO,CAAC;AAElC,OAAK,wBAAwB;AAE7B,MAAI,KAAK,QACP,MAAK,QAAQ;;CAIjB,SAA+B;AAK7B,MAAI,KAAK,0BAAA,GAAA,+BAAA,WAAmC,MAAM,EAAE;AAClD,QAAK,MAAM,MACT,qGACD;AACD;;AAGF,QAAM,QAAQ"}
1
+ {"version":3,"file":"MXLFetchInstrumentation.cjs","names":["FetchInstrumentation"],"sources":["../../../../src/instrumentations/fetch/MXLFetchInstrumentation/MXLFetchInstrumentation.ts"],"sourcesContent":["import { isWrapped } from '@opentelemetry/instrumentation';\n\nimport { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';\nimport type { MXLFetchInstrumentationArgs } from './types';\n\nexport class MXLFetchInstrumentation extends FetchInstrumentation {\n private readonly _omitIfAlreadyPatched?: boolean;\n\n public constructor({\n omitIfAlreadyPatched,\n ...rest\n }: MXLFetchInstrumentationArgs = {}) {\n // Base constructor automatically calls this.enable() if enabled is true, but we need to run our overridden constructor\n // first so force enabled false here and call it ourselves later\n super({ ...rest, enabled: false });\n\n this._omitIfAlreadyPatched = omitIfAlreadyPatched;\n\n if (rest.enabled) {\n this.enable();\n }\n }\n\n public override enable(): void {\n // The base implementation always removes and then re-patches, this means the last instrumentation to run \"wins\":\n // https://github.com/open-telemetry/opentelemetry-js/blob/2d7eecbb19aec17bf2d8b9a4e4b2d84dc92c2d88/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L604\n // Exposing an option in this class to allow leaving the existing patch in place and letting a previous instrumentation\n // control the global\n if (this._omitIfAlreadyPatched && isWrapped(fetch)) {\n this._diag.debug(\n 'fetch is already passed and `omitIfAlreadyPatched` is true, skipping enabling this instrumentation',\n );\n return;\n }\n\n super.enable();\n }\n}\n"],"mappings":";;;;;AAKA,IAAa,0BAAb,cAA6CA,qCAAAA,qBAAqB;CAChE;CAEA,YAAmB,EACjB,sBACA,GAAG,SAC4B,EAAE,EAAE;AAGnC,QAAM;GAAE,GAAG;GAAM,SAAS;GAAO,CAAC;AAElC,OAAK,wBAAwB;AAE7B,MAAI,KAAK,QACP,MAAK,QAAQ;;CAIjB,SAA+B;AAK7B,MAAI,KAAK,0BAAA,GAAA,+BAAA,WAAmC,MAAM,EAAE;AAClD,QAAK,MAAM,MACT,qGACD;AACD;;AAGF,QAAM,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"MXLFetchInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/fetch/MXLFetchInstrumentation/MXLFetchInstrumentation.ts"],"sourcesContent":["import { isWrapped } from '@opentelemetry/instrumentation';\n\nimport { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';\nimport type { MXLFetchInstrumentationArgs } from './types.ts';\n\nexport class MXLFetchInstrumentation extends FetchInstrumentation {\n private readonly _omitIfAlreadyPatched?: boolean;\n\n public constructor({\n omitIfAlreadyPatched,\n ...rest\n }: MXLFetchInstrumentationArgs = {}) {\n // Base constructor automatically calls this.enable() if enabled is true, but we need to run our overridden constructor\n // first so force enabled false here and call it ourselves later\n super({ ...rest, enabled: false });\n\n this._omitIfAlreadyPatched = omitIfAlreadyPatched;\n\n if (rest.enabled) {\n this.enable();\n }\n }\n\n public override enable(): void {\n // The base implementation always removes and then re-patches, this means the last instrumentation to run \"wins\":\n // https://github.com/open-telemetry/opentelemetry-js/blob/2d7eecbb19aec17bf2d8b9a4e4b2d84dc92c2d88/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L604\n // Exposing an option in this class to allow leaving the existing patch in place and letting a previous instrumentation\n // control the global\n if (this._omitIfAlreadyPatched && isWrapped(fetch)) {\n this._diag.debug(\n 'fetch is already passed and `omitIfAlreadyPatched` is true, skipping enabling this instrumentation',\n );\n return;\n }\n\n super.enable();\n }\n}\n"],"mappings":";;;AAKA,IAAa,0BAAb,cAA6C,qBAAqB;CAChE;CAEA,YAAmB,EACjB,sBACA,GAAG,SAC4B,EAAE,EAAE;AAGnC,QAAM;GAAE,GAAG;GAAM,SAAS;GAAO,CAAC;AAElC,OAAK,wBAAwB;AAE7B,MAAI,KAAK,QACP,MAAK,QAAQ;;CAIjB,SAA+B;AAK7B,MAAI,KAAK,yBAAyB,UAAU,MAAM,EAAE;AAClD,QAAK,MAAM,MACT,qGACD;AACD;;AAGF,QAAM,QAAQ"}
1
+ {"version":3,"file":"MXLFetchInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/fetch/MXLFetchInstrumentation/MXLFetchInstrumentation.ts"],"sourcesContent":["import { isWrapped } from '@opentelemetry/instrumentation';\n\nimport { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';\nimport type { MXLFetchInstrumentationArgs } from './types';\n\nexport class MXLFetchInstrumentation extends FetchInstrumentation {\n private readonly _omitIfAlreadyPatched?: boolean;\n\n public constructor({\n omitIfAlreadyPatched,\n ...rest\n }: MXLFetchInstrumentationArgs = {}) {\n // Base constructor automatically calls this.enable() if enabled is true, but we need to run our overridden constructor\n // first so force enabled false here and call it ourselves later\n super({ ...rest, enabled: false });\n\n this._omitIfAlreadyPatched = omitIfAlreadyPatched;\n\n if (rest.enabled) {\n this.enable();\n }\n }\n\n public override enable(): void {\n // The base implementation always removes and then re-patches, this means the last instrumentation to run \"wins\":\n // https://github.com/open-telemetry/opentelemetry-js/blob/2d7eecbb19aec17bf2d8b9a4e4b2d84dc92c2d88/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L604\n // Exposing an option in this class to allow leaving the existing patch in place and letting a previous instrumentation\n // control the global\n if (this._omitIfAlreadyPatched && isWrapped(fetch)) {\n this._diag.debug(\n 'fetch is already passed and `omitIfAlreadyPatched` is true, skipping enabling this instrumentation',\n );\n return;\n }\n\n super.enable();\n }\n}\n"],"mappings":";;;AAKA,IAAa,0BAAb,cAA6C,qBAAqB;CAChE;CAEA,YAAmB,EACjB,sBACA,GAAG,SAC4B,EAAE,EAAE;AAGnC,QAAM;GAAE,GAAG;GAAM,SAAS;GAAO,CAAC;AAElC,OAAK,wBAAwB;AAE7B,MAAI,KAAK,QACP,MAAK,QAAQ;;CAIjB,SAA+B;AAK7B,MAAI,KAAK,yBAAyB,UAAU,MAAM,EAAE;AAClD,QAAK,MAAM,MACT,qGACD;AACD;;AAGF,QAAM,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"LoafInstrumentation.cjs","names":["MXLInstrumentationBase","isEntryTypeSupported","createPerformanceObserver","MAX_SCRIPT_URL_LENGTH","KEY_MXL_TYPE","generateWebVitalID","ATTR_TBD_LOAF_TOTAL_DURATION","ATTR_TBD_LOAF_WORK_DURATION","ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION","ATTR_TBD_LOAF_COUNT","ATTR_TBD_LOAF_LONGEST_DURATION","ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST","LOAF_EVENT_NAME","SeverityNumber","LOAF_SCRIPTS_EVENT_NAME"],"sources":["../../../../src/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.ts"],"sourcesContent":["/* eslint-disable baseline-js/use-baseline */\nimport { SeverityNumber } from '@opentelemetry/api-logs';\nimport type { Metric } from 'web-vitals';\nimport type { SpanSessionManager } from '../../../api-sessions/index.ts';\nimport { MXL_TYPES, KEY_MXL_TYPE } from '../../../constants/index.ts';\nimport { generateWebVitalID } from '../../../utils/generateWebVitalID.ts';\nimport {\n createPerformanceObserver,\n isEntryTypeSupported,\n} from '../../../utils/index.ts';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport {\n ATTR_TBD_LOAF_COUNT,\n ATTR_TBD_LOAF_LONGEST_DURATION,\n ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST,\n ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION,\n ATTR_TBD_LOAF_TOTAL_DURATION,\n ATTR_TBD_LOAF_WORK_DURATION,\n BLOCKING_DURATION_GOOD_THRESHOLD,\n BLOCKING_DURATION_POOR_THRESHOLD,\n LOAF_EVENT_NAME,\n LOAF_SCRIPTS_EVENT_NAME,\n MAX_SCRIPT_ENTRIES,\n MAX_SCRIPT_URL_LENGTH,\n} from './constants.ts';\nimport type { LoafInstrumentationArgs } from './types.ts';\n\ntype ScriptSummaryValue = {\n totalDuration: number;\n styleAndLayoutDuration: number;\n count: number;\n};\n\ntype ScriptSummaries = Map<string, ScriptSummaryValue>;\n\nexport class LoafInstrumentation extends MXLInstrumentationBase {\n private _observer: PerformanceObserver | null = null;\n private _isFirstEntry = true;\n private _removeSessionEndListener: (() => void) | null = null;\n private _isEnabled = false;\n\n private _totalDuration = 0;\n private _workDuration = 0;\n private _styleLayoutDuration = 0;\n private _count = 0;\n private _longestDuration = 0;\n private _longestDurationExcludingFirst = 0;\n private _totalBlockingDuration = 0;\n private _scriptSummaries: ScriptSummaries = new Map();\n\n public constructor({ diag, perf }: LoafInstrumentationArgs = {}) {\n super({\n instrumentationName: 'LoafInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public enable(): void {\n if (this._isEnabled) {\n return;\n }\n\n if (!isEntryTypeSupported('long-animation-frame')) {\n this._diag.debug('long-animation-frame not supported, skipping');\n return;\n }\n\n this._isEnabled = true;\n\n if (this._observer) {\n this._observer.disconnect();\n }\n\n this._observer =\n createPerformanceObserver<PerformanceLongAnimationFrameTiming>(\n 'long-animation-frame',\n (entry) => this._processEntry(entry),\n { diag: this._diag },\n );\n\n if (!this._observer) {\n this._isEnabled = false;\n this._diag.error('failed to enable');\n return;\n }\n\n this._registerSessionEndListener();\n }\n\n private _registerSessionEndListener(): void {\n if (!this._isEnabled) {\n return;\n }\n\n if (this._removeSessionEndListener) {\n this._removeSessionEndListener();\n }\n\n this._removeSessionEndListener =\n this.sessionManager.addSessionEndedListener(() => {\n try {\n this._flushReport();\n } catch (e) {\n this._diag.error('error flushing report', e);\n }\n });\n }\n\n public override setSessionManager(sessionManager: SpanSessionManager): void {\n super.setSessionManager(sessionManager);\n this._registerSessionEndListener();\n }\n\n public disable(): void {\n this._isEnabled = false;\n this._resetAccumulators();\n\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n\n if (this._removeSessionEndListener) {\n this._removeSessionEndListener();\n this._removeSessionEndListener = null;\n }\n }\n\n private _processEntry(entry: PerformanceLongAnimationFrameTiming): void {\n if (!this._isEnabled) {\n return;\n }\n\n this._count++;\n this._totalDuration += entry.duration;\n this._workDuration += entry.renderStart\n ? entry.renderStart - entry.startTime\n : entry.duration;\n\n if (entry.styleAndLayoutStart) {\n this._styleLayoutDuration += Math.max(\n 0,\n entry.startTime + entry.duration - entry.styleAndLayoutStart,\n );\n }\n\n this._longestDuration = Math.max(this._longestDuration, entry.duration);\n\n if (this._isFirstEntry && this._count === 1) {\n this._isFirstEntry = false;\n } else {\n this._longestDurationExcludingFirst = Math.max(\n this._longestDurationExcludingFirst,\n entry.duration,\n );\n if (entry.firstUIEventTimestamp === 0) {\n this._totalBlockingDuration += entry.blockingDuration;\n }\n }\n\n try {\n for (const script of entry.scripts) {\n // sourceURL is an empty string for inline scripts\n let url = script.sourceURL || '(inline)';\n if (url.length > MAX_SCRIPT_URL_LENGTH) {\n url = `${url.substring(0, MAX_SCRIPT_URL_LENGTH)}...`;\n }\n\n const existing = this._scriptSummaries.get(url);\n if (existing) {\n existing.totalDuration += script.duration;\n existing.styleAndLayoutDuration +=\n script.forcedStyleAndLayoutDuration;\n existing.count++;\n } else {\n this._scriptSummaries.set(url, {\n totalDuration: script.duration,\n styleAndLayoutDuration: script.forcedStyleAndLayoutDuration,\n count: 1,\n });\n }\n }\n } catch (e) {\n this._diag.error('error processing scripts for entry', e);\n }\n }\n\n private _flushReport(): void {\n if (this._count === 0) {\n return;\n }\n\n // use web-vitals Metric type for rating\n let rating: Metric['rating'];\n if (this._totalBlockingDuration <= BLOCKING_DURATION_GOOD_THRESHOLD) {\n rating = 'good';\n } else if (\n this._totalBlockingDuration <= BLOCKING_DURATION_POOR_THRESHOLD\n ) {\n rating = 'needs-improvement';\n } else {\n rating = 'poor';\n }\n\n const attrs: Record<string, string | number> = {\n [KEY_MXL_TYPE]: MXL_TYPES.WebVital,\n ['mxl.web_vital.id']: generateWebVitalID(),\n ['mxl.web_vital.name']: 'TBD',\n ['mxl.web_vital.value']: Math.round(this._totalBlockingDuration),\n ['mxl.web_vital.rating']: rating,\n [ATTR_TBD_LOAF_TOTAL_DURATION]: Math.round(this._totalDuration),\n [ATTR_TBD_LOAF_WORK_DURATION]: Math.round(this._workDuration),\n [ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION]: Math.round(\n this._styleLayoutDuration,\n ),\n [ATTR_TBD_LOAF_COUNT]: this._count,\n [ATTR_TBD_LOAF_LONGEST_DURATION]: Math.round(this._longestDuration),\n [ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST]: Math.round(\n this._longestDurationExcludingFirst,\n ),\n };\n\n try {\n this.logger.emit({\n eventName: LOAF_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n attributes: attrs,\n });\n } catch (e) {\n this._diag.error('error emitting loaf report', e);\n }\n\n try {\n if (this._scriptSummaries.size > 0) {\n const scripts = [...this._scriptSummaries]\n .sort((a, b) => b[1].totalDuration - a[1].totalDuration)\n .slice(0, MAX_SCRIPT_ENTRIES)\n .map(([url, script]) => [\n url,\n {\n total_duration: Math.round(script.totalDuration),\n style_and_layout_duration: Math.round(\n script.styleAndLayoutDuration,\n ),\n count: script.count,\n },\n ]);\n\n this.logger.emit({\n eventName: LOAF_SCRIPTS_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n body: JSON.stringify(Object.fromEntries(scripts)),\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.LoafScripts,\n },\n });\n }\n } catch (e) {\n this._diag.error('error emitting loaf script summary', e);\n }\n\n this._resetAccumulators();\n }\n\n private _resetAccumulators(): void {\n this._totalDuration = 0;\n this._workDuration = 0;\n this._styleLayoutDuration = 0;\n this._count = 0;\n this._longestDuration = 0;\n this._longestDurationExcludingFirst = 0;\n this._totalBlockingDuration = 0;\n this._scriptSummaries = new Map();\n }\n}\n"],"mappings":";;;;;;;;;AAmCA,IAAa,sBAAb,cAAyCA,uEAAAA,uBAAuB;CAC9D,YAAgD;CAChD,gBAAwB;CACxB,4BAAyD;CACzD,aAAqB;CAErB,iBAAyB;CACzB,gBAAwB;CACxB,uBAA+B;CAC/B,SAAiB;CACjB,mBAA2B;CAC3B,iCAAyC;CACzC,yBAAiC;CACjC,mCAA4C,IAAI,KAAK;CAErD,YAAmB,EAAE,MAAM,SAAkC,EAAE,EAAE;AAC/D,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIj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ACV,QAAK,MAAM,MAAM,8BAA8B,EAAE;;AAGnD,MAAI;AACF,OAAI,KAAK,iBAAiB,OAAO,GAAG;IAClC,MAAM,UAAU,CAAC,GAAG,KAAK,iBAAiB,CACvC,MAAM,GAAG,MAAM,EAAE,GAAG,gBAAgB,EAAE,GAAG,cAAc,CACvD,MAAM,GAAA,IAAsB,CAC5B,KAAK,CAAC,KAAK,YAAY,CACtB,KACA;KACE,gBAAgB,KAAK,MAAM,OAAO,cAAc;KAChD,2BAA2B,KAAK,MAC9B,OAAO,uBACR;KACD,OAAO,OAAO;KACf,CACF,CAAC;AAEJ,SAAK,OAAO,KAAK;KACf,WAAWC,4DAAAA;KACX,gBAAgBD,wBAAAA,eAAe;KAC/B,MAAM,KAAK,UAAU,OAAO,YAAY,QAAQ,CAAC;KACjD,YAAY,GACTT,6BAAAA,eAAAA,mBACF;KACF,CAAC;;WAEG,GAAG;AACV,QAAK,MAAM,MAAM,sCAAsC,EAAE;;AAG3D,OAAK,oBAAoB;;CAG3B,qBAAmC;AACjC,OAAK,iBAAiB;AACtB,OAAK,gBAAgB;AACrB,OAAK,uBAAuB;AAC5B,OAAK,SAAS;AACd,OAAK,mBAAmB;AACxB,OAAK,iCAAiC;AACtC,OAAK,yBAAyB;AAC9B,OAAK,mCAAmB,IAAI,KAAK"}
1
+ {"version":3,"file":"LoafInstrumentation.cjs","names":["MXLInstrumentationBase","isEntryTypeSupported","createPerformanceObserver","MAX_SCRIPT_URL_LENGTH","KEY_MXL_TYPE","generateWebVitalID","ATTR_TBD_LOAF_TOTAL_DURATION","ATTR_TBD_LOAF_WORK_DURATION","ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION","ATTR_TBD_LOAF_COUNT","ATTR_TBD_LOAF_LONGEST_DURATION","ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST","LOAF_EVENT_NAME","SeverityNumber","LOAF_SCRIPTS_EVENT_NAME"],"sources":["../../../../src/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.ts"],"sourcesContent":["/* eslint-disable baseline-js/use-baseline */\nimport { SeverityNumber } from '@opentelemetry/api-logs';\nimport type { Metric } from 'web-vitals';\nimport type { SpanSessionManager } from '../../../api-sessions';\nimport { KEY_MXL_TYPE, MXL_TYPES } from '../../../constants';\nimport {\n createPerformanceObserver,\n isEntryTypeSupported,\n} from '../../../utils';\nimport { generateWebVitalID } from '../../../utils/generateWebVitalID';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport {\n ATTR_TBD_LOAF_COUNT,\n ATTR_TBD_LOAF_LONGEST_DURATION,\n ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST,\n ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION,\n ATTR_TBD_LOAF_TOTAL_DURATION,\n ATTR_TBD_LOAF_WORK_DURATION,\n BLOCKING_DURATION_GOOD_THRESHOLD,\n BLOCKING_DURATION_POOR_THRESHOLD,\n LOAF_EVENT_NAME,\n LOAF_SCRIPTS_EVENT_NAME,\n MAX_SCRIPT_ENTRIES,\n MAX_SCRIPT_URL_LENGTH,\n} from './constants';\nimport type { LoafInstrumentationArgs } from './types';\n\ntype ScriptSummaryValue = {\n totalDuration: number;\n styleAndLayoutDuration: number;\n count: number;\n};\n\ntype ScriptSummaries = Map<string, ScriptSummaryValue>;\n\nexport class LoafInstrumentation extends MXLInstrumentationBase {\n private _observer: PerformanceObserver | null = null;\n private _isFirstEntry = true;\n private _removeSessionEndListener: (() => void) | null = null;\n private _isEnabled = false;\n\n private _totalDuration = 0;\n private _workDuration = 0;\n private _styleLayoutDuration = 0;\n private _count = 0;\n private _longestDuration = 0;\n private _longestDurationExcludingFirst = 0;\n private _totalBlockingDuration = 0;\n private _scriptSummaries: ScriptSummaries = new Map();\n\n public constructor({ diag, perf }: LoafInstrumentationArgs = {}) {\n super({\n instrumentationName: 'LoafInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public enable(): void {\n if (this._isEnabled) {\n return;\n }\n\n if (!isEntryTypeSupported('long-animation-frame')) {\n this._diag.debug('long-animation-frame not supported, skipping');\n return;\n }\n\n this._isEnabled = true;\n\n if (this._observer) {\n this._observer.disconnect();\n }\n\n this._observer =\n createPerformanceObserver<PerformanceLongAnimationFrameTiming>(\n 'long-animation-frame',\n (entry) => this._processEntry(entry),\n { diag: this._diag },\n );\n\n if (!this._observer) {\n this._isEnabled = false;\n this._diag.error('failed to enable');\n return;\n }\n\n this._registerSessionEndListener();\n }\n\n private _registerSessionEndListener(): void {\n if (!this._isEnabled) {\n return;\n }\n\n if (this._removeSessionEndListener) {\n this._removeSessionEndListener();\n }\n\n this._removeSessionEndListener =\n this.sessionManager.addSessionEndedListener(() => {\n try {\n this._flushReport();\n } catch (e) {\n this._diag.error('error flushing report', e);\n }\n });\n }\n\n public override setSessionManager(sessionManager: SpanSessionManager): void {\n super.setSessionManager(sessionManager);\n this._registerSessionEndListener();\n }\n\n public disable(): void {\n this._isEnabled = false;\n this._resetAccumulators();\n\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n\n if (this._removeSessionEndListener) {\n this._removeSessionEndListener();\n this._removeSessionEndListener = null;\n }\n }\n\n private _processEntry(entry: PerformanceLongAnimationFrameTiming): void {\n if (!this._isEnabled) {\n return;\n }\n\n this._count++;\n this._totalDuration += entry.duration;\n this._workDuration += entry.renderStart\n ? entry.renderStart - entry.startTime\n : entry.duration;\n\n if (entry.styleAndLayoutStart) {\n this._styleLayoutDuration += Math.max(\n 0,\n entry.startTime + entry.duration - entry.styleAndLayoutStart,\n );\n }\n\n this._longestDuration = Math.max(this._longestDuration, entry.duration);\n\n if (this._isFirstEntry && this._count === 1) {\n this._isFirstEntry = false;\n } else {\n this._longestDurationExcludingFirst = Math.max(\n this._longestDurationExcludingFirst,\n entry.duration,\n );\n if (entry.firstUIEventTimestamp === 0) {\n this._totalBlockingDuration += entry.blockingDuration;\n }\n }\n\n try {\n for (const script of entry.scripts) {\n // sourceURL is an empty string for inline scripts\n let url = script.sourceURL || '(inline)';\n if (url.length > MAX_SCRIPT_URL_LENGTH) {\n url = `${url.substring(0, MAX_SCRIPT_URL_LENGTH)}...`;\n }\n\n const existing = this._scriptSummaries.get(url);\n if (existing) {\n existing.totalDuration += script.duration;\n existing.styleAndLayoutDuration +=\n script.forcedStyleAndLayoutDuration;\n existing.count++;\n } else {\n this._scriptSummaries.set(url, {\n totalDuration: script.duration,\n styleAndLayoutDuration: script.forcedStyleAndLayoutDuration,\n count: 1,\n });\n }\n }\n } catch (e) {\n this._diag.error('error processing scripts for entry', e);\n }\n }\n\n private _flushReport(): void {\n if (this._count === 0) {\n return;\n }\n\n // use web-vitals Metric type for rating\n let rating: Metric['rating'];\n if (this._totalBlockingDuration <= BLOCKING_DURATION_GOOD_THRESHOLD) {\n rating = 'good';\n } else if (\n this._totalBlockingDuration <= BLOCKING_DURATION_POOR_THRESHOLD\n ) {\n rating = 'needs-improvement';\n } else {\n rating = 'poor';\n }\n\n const attrs: Record<string, string | number> = {\n [KEY_MXL_TYPE]: MXL_TYPES.WebVital,\n ['mxl.web_vital.id']: generateWebVitalID(),\n ['mxl.web_vital.name']: 'TBD',\n ['mxl.web_vital.value']: Math.round(this._totalBlockingDuration),\n ['mxl.web_vital.rating']: rating,\n [ATTR_TBD_LOAF_TOTAL_DURATION]: Math.round(this._totalDuration),\n [ATTR_TBD_LOAF_WORK_DURATION]: Math.round(this._workDuration),\n [ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION]: Math.round(\n this._styleLayoutDuration,\n ),\n [ATTR_TBD_LOAF_COUNT]: this._count,\n [ATTR_TBD_LOAF_LONGEST_DURATION]: Math.round(this._longestDuration),\n [ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST]: Math.round(\n this._longestDurationExcludingFirst,\n ),\n };\n\n try {\n this.logger.emit({\n eventName: LOAF_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n attributes: attrs,\n });\n } catch (e) {\n this._diag.error('error emitting loaf report', e);\n }\n\n try {\n if (this._scriptSummaries.size > 0) {\n const scripts = [...this._scriptSummaries]\n .sort((a, b) => b[1].totalDuration - a[1].totalDuration)\n .slice(0, MAX_SCRIPT_ENTRIES)\n .map(([url, script]) => [\n url,\n {\n total_duration: Math.round(script.totalDuration),\n style_and_layout_duration: Math.round(\n script.styleAndLayoutDuration,\n ),\n count: script.count,\n },\n ]);\n\n this.logger.emit({\n eventName: LOAF_SCRIPTS_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n body: JSON.stringify(Object.fromEntries(scripts)),\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.LoafScripts,\n },\n });\n }\n } catch (e) {\n this._diag.error('error emitting loaf script summary', e);\n }\n\n this._resetAccumulators();\n }\n\n private _resetAccumulators(): void {\n this._totalDuration = 0;\n this._workDuration = 0;\n this._styleLayoutDuration = 0;\n this._count = 0;\n this._longestDuration = 0;\n this._longestDurationExcludingFirst = 0;\n this._totalBlockingDuration = 0;\n this._scriptSummaries = new Map();\n }\n}\n"],"mappings":";;;;;;;;;AAmCA,IAAa,sBAAb,cAAyCA,uEAAAA,uBAAuB;CAC9D,YAAgD;CAChD,gBAAwB;CACxB,4BAAyD;CACzD,aAAqB;CAErB,iBAAyB;CACzB,gBAAwB;CACxB,uBAA+B;CAC/B,SAAiB;CACjB,mBAA2B;CAC3B,iCAAyC;CACzC,yBAAiC;CACjC,mCAA4C,IAAI,KAAK;CAErD,YAAmB,EAAE,MAAM,SAAkC,EAAE,EAAE;AAC/D,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,SAAsB;AACpB,MAAI,KAAK,WACP;AAGF,MAAI,CAACC,sDAAAA,qBAAqB,uBAAuB,EAAE;AACjD,QAAK,MAAM,MAAM,+CAA+C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AAG,KAAK,iBAAiB,CACvC,MAAM,GAAG,MAAM,EAAE,GAAG,gBAAgB,EAAE,GAAG,cAAc,CACvD,MAAM,GAAA,IAAsB,CAC5B,KAAK,CAAC,KAAK,YAAY,CACtB,KACA;KACE,gBAAgB,KAAK,MAAM,OAAO,cAAc;KAChD,2BAA2B,KAAK,MAC9B,OAAO,uBACR;KACD,OAAO,OAAO;KACf,CACF,CAAC;AAEJ,SAAK,OAAO,KAAK;KACf,WAAWC,4DAAAA;KACX,gBAAgBD,wBAAAA,eAAe;KAC/B,MAAM,KAAK,UAAU,OAAO,YAAY,QAAQ,CAAC;KACjD,YAAY,GACTT,6BAAAA,eAAAA,mBACF;KACF,CAAC;;WAEG,GAAG;AACV,QAAK,MAAM,MAAM,sCAAsC,EAAE;;AAG3D,OAAK,oBAAoB;;CAG3B,qBAAmC;AACjC,OAAK,iBAAiB;AACtB,OAAK,gBAAgB;AACrB,OAAK,uBAAuB;AAC5B,OAAK,SAAS;AACd,OAAK,mBAAmB;AACxB,OAAK,iCAAiC;AACtC,OAAK,yBAAyB;AAC9B,OAAK,mCAAmB,IAAI,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"LoafInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.ts"],"sourcesContent":["/* eslint-disable baseline-js/use-baseline */\nimport { SeverityNumber } from '@opentelemetry/api-logs';\nimport type { Metric } from 'web-vitals';\nimport type { SpanSessionManager } from '../../../api-sessions/index.ts';\nimport { MXL_TYPES, KEY_MXL_TYPE } from '../../../constants/index.ts';\nimport { generateWebVitalID } from '../../../utils/generateWebVitalID.ts';\nimport {\n createPerformanceObserver,\n isEntryTypeSupported,\n} from '../../../utils/index.ts';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport {\n ATTR_TBD_LOAF_COUNT,\n ATTR_TBD_LOAF_LONGEST_DURATION,\n ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST,\n ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION,\n ATTR_TBD_LOAF_TOTAL_DURATION,\n ATTR_TBD_LOAF_WORK_DURATION,\n BLOCKING_DURATION_GOOD_THRESHOLD,\n BLOCKING_DURATION_POOR_THRESHOLD,\n LOAF_EVENT_NAME,\n LOAF_SCRIPTS_EVENT_NAME,\n MAX_SCRIPT_ENTRIES,\n MAX_SCRIPT_URL_LENGTH,\n} from './constants.ts';\nimport type { LoafInstrumentationArgs } from './types.ts';\n\ntype ScriptSummaryValue = {\n totalDuration: number;\n styleAndLayoutDuration: number;\n count: number;\n};\n\ntype ScriptSummaries = Map<string, ScriptSummaryValue>;\n\nexport class LoafInstrumentation extends MXLInstrumentationBase {\n private _observer: PerformanceObserver | null = null;\n private _isFirstEntry = true;\n private _removeSessionEndListener: (() => void) | null = null;\n private _isEnabled = false;\n\n private _totalDuration = 0;\n private _workDuration = 0;\n private _styleLayoutDuration = 0;\n private _count = 0;\n private _longestDuration = 0;\n private _longestDurationExcludingFirst = 0;\n private _totalBlockingDuration = 0;\n private _scriptSummaries: ScriptSummaries = new Map();\n\n public constructor({ diag, perf }: LoafInstrumentationArgs = {}) {\n super({\n instrumentationName: 'LoafInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public enable(): void {\n if (this._isEnabled) {\n return;\n }\n\n if (!isEntryTypeSupported('long-animation-frame')) {\n this._diag.debug('long-animation-frame not supported, skipping');\n return;\n }\n\n this._isEnabled = true;\n\n if (this._observer) {\n this._observer.disconnect();\n }\n\n this._observer =\n createPerformanceObserver<PerformanceLongAnimationFrameTiming>(\n 'long-animation-frame',\n (entry) => this._processEntry(entry),\n { diag: this._diag },\n );\n\n if (!this._observer) {\n this._isEnabled = false;\n this._diag.error('failed to enable');\n return;\n }\n\n this._registerSessionEndListener();\n }\n\n private _registerSessionEndListener(): void {\n if (!this._isEnabled) {\n return;\n }\n\n if (this._removeSessionEndListener) {\n this._removeSessionEndListener();\n }\n\n this._removeSessionEndListener =\n this.sessionManager.addSessionEndedListener(() => {\n try {\n this._flushReport();\n } catch (e) {\n this._diag.error('error flushing report', e);\n }\n });\n }\n\n public override setSessionManager(sessionManager: SpanSessionManager): void {\n super.setSessionManager(sessionManager);\n this._registerSessionEndListener();\n }\n\n public disable(): void {\n this._isEnabled = false;\n this._resetAccumulators();\n\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n\n if (this._removeSessionEndListener) {\n this._removeSessionEndListener();\n this._removeSessionEndListener = null;\n }\n }\n\n private _processEntry(entry: PerformanceLongAnimationFrameTiming): void {\n if (!this._isEnabled) {\n return;\n }\n\n this._count++;\n this._totalDuration += entry.duration;\n this._workDuration += entry.renderStart\n ? entry.renderStart - entry.startTime\n : entry.duration;\n\n if (entry.styleAndLayoutStart) {\n this._styleLayoutDuration += Math.max(\n 0,\n entry.startTime + entry.duration - entry.styleAndLayoutStart,\n );\n }\n\n this._longestDuration = Math.max(this._longestDuration, entry.duration);\n\n if (this._isFirstEntry && this._count === 1) {\n this._isFirstEntry = false;\n } else {\n this._longestDurationExcludingFirst = Math.max(\n this._longestDurationExcludingFirst,\n entry.duration,\n );\n if (entry.firstUIEventTimestamp === 0) {\n this._totalBlockingDuration += entry.blockingDuration;\n }\n }\n\n try {\n for (const script of entry.scripts) {\n // sourceURL is an empty string for inline scripts\n let url = script.sourceURL || '(inline)';\n if (url.length > MAX_SCRIPT_URL_LENGTH) {\n url = `${url.substring(0, MAX_SCRIPT_URL_LENGTH)}...`;\n }\n\n const existing = this._scriptSummaries.get(url);\n if (existing) {\n existing.totalDuration += script.duration;\n existing.styleAndLayoutDuration +=\n script.forcedStyleAndLayoutDuration;\n existing.count++;\n } else {\n this._scriptSummaries.set(url, {\n totalDuration: script.duration,\n styleAndLayoutDuration: script.forcedStyleAndLayoutDuration,\n count: 1,\n });\n }\n }\n } catch (e) {\n this._diag.error('error processing scripts for entry', e);\n }\n }\n\n private _flushReport(): void {\n if (this._count === 0) {\n return;\n }\n\n // use web-vitals Metric type for rating\n let rating: Metric['rating'];\n if (this._totalBlockingDuration <= BLOCKING_DURATION_GOOD_THRESHOLD) {\n rating = 'good';\n } else if (\n this._totalBlockingDuration <= BLOCKING_DURATION_POOR_THRESHOLD\n ) {\n rating = 'needs-improvement';\n } else {\n rating = 'poor';\n }\n\n const attrs: Record<string, string | number> = {\n [KEY_MXL_TYPE]: MXL_TYPES.WebVital,\n ['mxl.web_vital.id']: generateWebVitalID(),\n ['mxl.web_vital.name']: 'TBD',\n ['mxl.web_vital.value']: Math.round(this._totalBlockingDuration),\n ['mxl.web_vital.rating']: rating,\n [ATTR_TBD_LOAF_TOTAL_DURATION]: Math.round(this._totalDuration),\n [ATTR_TBD_LOAF_WORK_DURATION]: Math.round(this._workDuration),\n [ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION]: Math.round(\n this._styleLayoutDuration,\n ),\n [ATTR_TBD_LOAF_COUNT]: this._count,\n [ATTR_TBD_LOAF_LONGEST_DURATION]: Math.round(this._longestDuration),\n [ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST]: Math.round(\n this._longestDurationExcludingFirst,\n ),\n };\n\n try {\n this.logger.emit({\n eventName: LOAF_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n attributes: attrs,\n });\n } catch (e) {\n this._diag.error('error emitting loaf report', e);\n }\n\n try {\n if (this._scriptSummaries.size > 0) {\n const scripts = [...this._scriptSummaries]\n .sort((a, b) => b[1].totalDuration - a[1].totalDuration)\n .slice(0, MAX_SCRIPT_ENTRIES)\n .map(([url, script]) => [\n url,\n {\n total_duration: Math.round(script.totalDuration),\n style_and_layout_duration: Math.round(\n script.styleAndLayoutDuration,\n ),\n count: script.count,\n },\n ]);\n\n this.logger.emit({\n eventName: LOAF_SCRIPTS_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n body: JSON.stringify(Object.fromEntries(scripts)),\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.LoafScripts,\n },\n });\n }\n } catch (e) {\n this._diag.error('error emitting loaf script summary', e);\n }\n\n this._resetAccumulators();\n }\n\n private _resetAccumulators(): void {\n this._totalDuration = 0;\n this._workDuration = 0;\n this._styleLayoutDuration = 0;\n this._count = 0;\n this._longestDuration = 0;\n this._longestDurationExcludingFirst = 0;\n this._totalBlockingDuration = 0;\n this._scriptSummaries = new Map();\n }\n}\n"],"mappings":";;;;;;;AAmCA,IAAa,sBAAb,cAAyC,uBAAuB;CAC9D,YAAgD;CAChD,gBAAwB;CACxB,4BAAyD;CACzD,aAAqB;CAErB,iBAAyB;CACzB,gBAAwB;CACxB,uBAA+B;CAC/B,SAAiB;CACjB,mBAA2B;CAC3B,iCAAyC;CACzC,yBAAiC;CACjC,mCAA4C,IAAI,KAAK;CAErD,YAAmB,EAAE,MAAM,SAAkC,EAAE,EAAE;AAC/D,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,SAAsB;AACpB,MAAI,KAAK,WACP;AAGF,MAAI,CAAC,qBAAqB,uBAAuB,EAAE;AACjD,QAAK,MAAM,MAAM,+CAA+C;AAChE;;AAGF,OAAK,aAAa;AAElB,MAAI,KAAK,UACP,MAAK,UAAU,YAAY;AAG7B,OAAK,YACH,0BACE,yBACC,UAAU,KAAK,cAAc,MAAM,EACpC,EAAE,MAAM,KAAK,OAAO,CACrB;AAEH,MAAI,CAAC,KAAK,WAAW;AACnB,QAAK,aAAa;AAClB,QAAK,MAAM,MAAM,mBAAmB;AACpC;;AAGF,OAAK,6BAA6B;;CAGpC,8BAA4C;AAC1C,MAAI,CAAC,KAAK,WACR;AAGF,MAAI,KAAK,0BACP,MAAK,2BAA2B;AAGlC,OAAK,4BACH,KAAK,eAAe,8BAA8B;AAChD,OAAI;AACF,SAAK,cAAc;YACZ,GA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K,uBAAuB;AAC5B,OAAK,SAAS;AACd,OAAK,mBAAmB;AACxB,OAAK,iCAAiC;AACtC,OAAK,yBAAyB;AAC9B,OAAK,mCAAmB,IAAI,KAAK"}
1
+ {"version":3,"file":"LoafInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/loaf/LoafInstrumentation/LoafInstrumentation.ts"],"sourcesContent":["/* eslint-disable baseline-js/use-baseline */\nimport { SeverityNumber } from '@opentelemetry/api-logs';\nimport type { Metric } from 'web-vitals';\nimport type { SpanSessionManager } from '../../../api-sessions';\nimport { KEY_MXL_TYPE, MXL_TYPES } from '../../../constants';\nimport {\n createPerformanceObserver,\n isEntryTypeSupported,\n} from '../../../utils';\nimport { generateWebVitalID } from '../../../utils/generateWebVitalID';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport {\n ATTR_TBD_LOAF_COUNT,\n ATTR_TBD_LOAF_LONGEST_DURATION,\n ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST,\n ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION,\n ATTR_TBD_LOAF_TOTAL_DURATION,\n ATTR_TBD_LOAF_WORK_DURATION,\n BLOCKING_DURATION_GOOD_THRESHOLD,\n BLOCKING_DURATION_POOR_THRESHOLD,\n LOAF_EVENT_NAME,\n LOAF_SCRIPTS_EVENT_NAME,\n MAX_SCRIPT_ENTRIES,\n MAX_SCRIPT_URL_LENGTH,\n} from './constants';\nimport type { LoafInstrumentationArgs } from './types';\n\ntype ScriptSummaryValue = {\n totalDuration: number;\n styleAndLayoutDuration: number;\n count: number;\n};\n\ntype ScriptSummaries = Map<string, ScriptSummaryValue>;\n\nexport class LoafInstrumentation extends MXLInstrumentationBase {\n private _observer: PerformanceObserver | null = null;\n private _isFirstEntry = true;\n private _removeSessionEndListener: (() => void) | null = null;\n private _isEnabled = false;\n\n private _totalDuration = 0;\n private _workDuration = 0;\n private _styleLayoutDuration = 0;\n private _count = 0;\n private _longestDuration = 0;\n private _longestDurationExcludingFirst = 0;\n private _totalBlockingDuration = 0;\n private _scriptSummaries: ScriptSummaries = new Map();\n\n public constructor({ diag, perf }: LoafInstrumentationArgs = {}) {\n super({\n instrumentationName: 'LoafInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n perf,\n config: {},\n });\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public enable(): void {\n if (this._isEnabled) {\n return;\n }\n\n if (!isEntryTypeSupported('long-animation-frame')) {\n this._diag.debug('long-animation-frame not supported, skipping');\n return;\n }\n\n this._isEnabled = true;\n\n if (this._observer) {\n this._observer.disconnect();\n }\n\n this._observer =\n createPerformanceObserver<PerformanceLongAnimationFrameTiming>(\n 'long-animation-frame',\n (entry) => this._processEntry(entry),\n { diag: this._diag },\n );\n\n if (!this._observer) {\n this._isEnabled = false;\n this._diag.error('failed to enable');\n return;\n }\n\n this._registerSessionEndListener();\n }\n\n private _registerSessionEndListener(): void {\n if (!this._isEnabled) {\n return;\n }\n\n if (this._removeSessionEndListener) {\n this._removeSessionEndListener();\n }\n\n this._removeSessionEndListener =\n this.sessionManager.addSessionEndedListener(() => {\n try {\n this._flushReport();\n } catch (e) {\n this._diag.error('error flushing report', e);\n }\n });\n }\n\n public override setSessionManager(sessionManager: SpanSessionManager): void {\n super.setSessionManager(sessionManager);\n this._registerSessionEndListener();\n }\n\n public disable(): void {\n this._isEnabled = false;\n this._resetAccumulators();\n\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n\n if (this._removeSessionEndListener) {\n this._removeSessionEndListener();\n this._removeSessionEndListener = null;\n }\n }\n\n private _processEntry(entry: PerformanceLongAnimationFrameTiming): void {\n if (!this._isEnabled) {\n return;\n }\n\n this._count++;\n this._totalDuration += entry.duration;\n this._workDuration += entry.renderStart\n ? entry.renderStart - entry.startTime\n : entry.duration;\n\n if (entry.styleAndLayoutStart) {\n this._styleLayoutDuration += Math.max(\n 0,\n entry.startTime + entry.duration - entry.styleAndLayoutStart,\n );\n }\n\n this._longestDuration = Math.max(this._longestDuration, entry.duration);\n\n if (this._isFirstEntry && this._count === 1) {\n this._isFirstEntry = false;\n } else {\n this._longestDurationExcludingFirst = Math.max(\n this._longestDurationExcludingFirst,\n entry.duration,\n );\n if (entry.firstUIEventTimestamp === 0) {\n this._totalBlockingDuration += entry.blockingDuration;\n }\n }\n\n try {\n for (const script of entry.scripts) {\n // sourceURL is an empty string for inline scripts\n let url = script.sourceURL || '(inline)';\n if (url.length > MAX_SCRIPT_URL_LENGTH) {\n url = `${url.substring(0, MAX_SCRIPT_URL_LENGTH)}...`;\n }\n\n const existing = this._scriptSummaries.get(url);\n if (existing) {\n existing.totalDuration += script.duration;\n existing.styleAndLayoutDuration +=\n script.forcedStyleAndLayoutDuration;\n existing.count++;\n } else {\n this._scriptSummaries.set(url, {\n totalDuration: script.duration,\n styleAndLayoutDuration: script.forcedStyleAndLayoutDuration,\n count: 1,\n });\n }\n }\n } catch (e) {\n this._diag.error('error processing scripts for entry', e);\n }\n }\n\n private _flushReport(): void {\n if (this._count === 0) {\n return;\n }\n\n // use web-vitals Metric type for rating\n let rating: Metric['rating'];\n if (this._totalBlockingDuration <= BLOCKING_DURATION_GOOD_THRESHOLD) {\n rating = 'good';\n } else if (\n this._totalBlockingDuration <= BLOCKING_DURATION_POOR_THRESHOLD\n ) {\n rating = 'needs-improvement';\n } else {\n rating = 'poor';\n }\n\n const attrs: Record<string, string | number> = {\n [KEY_MXL_TYPE]: MXL_TYPES.WebVital,\n ['mxl.web_vital.id']: generateWebVitalID(),\n ['mxl.web_vital.name']: 'TBD',\n ['mxl.web_vital.value']: Math.round(this._totalBlockingDuration),\n ['mxl.web_vital.rating']: rating,\n [ATTR_TBD_LOAF_TOTAL_DURATION]: Math.round(this._totalDuration),\n [ATTR_TBD_LOAF_WORK_DURATION]: Math.round(this._workDuration),\n [ATTR_TBD_LOAF_STYLE_AND_LAYOUT_DURATION]: Math.round(\n this._styleLayoutDuration,\n ),\n [ATTR_TBD_LOAF_COUNT]: this._count,\n [ATTR_TBD_LOAF_LONGEST_DURATION]: Math.round(this._longestDuration),\n [ATTR_TBD_LOAF_LONGEST_DURATION_EXCLUDING_FIRST]: Math.round(\n this._longestDurationExcludingFirst,\n ),\n };\n\n try {\n this.logger.emit({\n eventName: LOAF_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n attributes: attrs,\n });\n } catch (e) {\n this._diag.error('error emitting loaf report', e);\n }\n\n try {\n if (this._scriptSummaries.size > 0) {\n const scripts = [...this._scriptSummaries]\n .sort((a, b) => b[1].totalDuration - a[1].totalDuration)\n .slice(0, MAX_SCRIPT_ENTRIES)\n .map(([url, script]) => [\n url,\n {\n total_duration: Math.round(script.totalDuration),\n style_and_layout_duration: Math.round(\n script.styleAndLayoutDuration,\n ),\n count: script.count,\n },\n ]);\n\n this.logger.emit({\n eventName: LOAF_SCRIPTS_EVENT_NAME,\n severityNumber: SeverityNumber.INFO,\n body: JSON.stringify(Object.fromEntries(scripts)),\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.LoafScripts,\n },\n });\n }\n } catch (e) {\n this._diag.error('error emitting loaf script summary', e);\n }\n\n this._resetAccumulators();\n }\n\n private _resetAccumulators(): void {\n this._totalDuration = 0;\n this._workDuration = 0;\n this._styleLayoutDuration = 0;\n this._count = 0;\n this._longestDuration = 0;\n this._longestDurationExcludingFirst = 0;\n this._totalBlockingDuration = 0;\n this._scriptSummaries = new Map();\n }\n}\n"],"mappings":";;;;;;;AAmCA,IAAa,sBAAb,cAAyC,uBAAuB;CAC9D,YAAgD;CAChD,gBAAwB;CACxB,4BAAyD;CACzD,aAAqB;CAErB,iBAAyB;CACzB,gBAAwB;CACxB,uBAA+B;CAC/B,SAAiB;CACjB,mBAA2B;CAC3B,iCAAyC;CACzC,yBAAiC;CACjC,mCAA4C,IAAI,KAAK;CAErD,YAAmB,EAAE,MAAM,SAAkC,EAAE,EAAE;AAC/D,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA;GAC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;AACF,OAAI,KAAK,iBAAiB,OAAO,GAAG;IAClC,MAAM,UAAU,CAAC,GAAG,KAAK,iBAAiB,CACvC,MAAM,GAAG,MAAM,EAAE,GAAG,gBAAgB,EAAE,GAAG,cAAc,CACvD,MAAM,GAAA,IAAsB,CAC5B,KAAK,CAAC,KAAK,YAAY,CACtB,KACA;KACE,gBAAgB,KAAK,MAAM,OAAO,cAAc;KAChD,2BAA2B,KAAK,MAC9B,OAAO,uBACR;KACD,OAAO,OAAO;KACf,CACF,CAAC;AAEJ,SAAK,OAAO,KAAK;KACf,WAAW;KACX,gBAAgB,eAAe;KAC/B,MAAM,KAAK,UAAU,OAAO,YAAY,QAAQ,CAAC;KACjD,YAAY,GACT,eAAA,mBACF;KACF,CAAC;;WAEG,GAAG;AACV,QAAK,MAAM,MAAM,sCAAsC,EAAE;;AAG3D,OAAK,oBAAoB;;CAG3B,qBAAmC;AACjC,OAAK,iBAAiB;AACtB,OAAK,gBAAgB;AACrB,OAAK,uBAAuB;AAC5B,OAAK,SAAS;AACd,OAAK,mBAAmB;AACxB,OAAK,iCAAiC;AACtC,OAAK,yBAAyB;AAC9B,OAAK,mCAAmB,IAAI,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationInstrumentation.cjs","names":["MXLInstrumentationBase","page","KEY_MXL_TYPE","KEY_MXL_PAGE_PATH","KEY_MXL_PAGE_ID","KEY_MXL_INSTRUMENTATION"],"sources":["../../../../src/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { Route } from '../../../api-page/index.ts';\nimport { page } from '../../../api-page/index.ts';\nimport {\n MXL_NAVIGATION_INSTRUMENTATIONS,\n MXL_TYPES,\n KEY_MXL_INSTRUMENTATION,\n KEY_MXL_PAGE_ID,\n KEY_MXL_PAGE_PATH,\n KEY_MXL_TYPE,\n} from '../../../constants/index.ts';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport type { NavigationInstrumentationArgs } from './types.ts';\n\n// Regular expression to match path options in the format \"(option)\"\n// Used to clean up paths that are like \"/order/:orderState(pending|shipped|delivered)/type:(sale|normal)\" to \"/order/:orderState/:type\"\n// Could be simplified but done this way to prevent: https://javascript.info/regexp-catastrophic-backtracking\nconst PATH_OPTIONS_RE = /\\([^()]+\\)/g;\n\nexport class NavigationInstrumentation extends MXLInstrumentationBase {\n private readonly _shouldCleanupPathOptionsFromRouteName: boolean = true;\n private _currentRouteSpan: Span | null = null;\n private _instrumentationType: MXL_NAVIGATION_INSTRUMENTATIONS =\n MXL_NAVIGATION_INSTRUMENTATIONS.Manual;\n private _removeSessionStartedFn: (() => void) | null = null;\n private _removeSessionEndedFn: (() => void) | null = null;\n\n public constructor({\n diag,\n shouldCleanupPathOptionsFromRouteName = true,\n }: NavigationInstrumentationArgs) {\n super({\n instrumentationName: 'NavigationInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n config: {},\n });\n\n this._shouldCleanupPathOptionsFromRouteName =\n shouldCleanupPathOptionsFromRouteName;\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public setInstrumentationType = (\n instrumentationType: MXL_NAVIGATION_INSTRUMENTATIONS,\n ) => {\n this._instrumentationType = instrumentationType;\n };\n\n public setCurrentRoute = (route: Route) => {\n if (!this._config.enabled) {\n return;\n }\n\n const currentRoute = page.getCurrentRoute();\n\n if (route.url !== currentRoute?.url) {\n page.setCurrentRoute(route);\n\n this._endRouteSpan(currentRoute);\n this._startRouteSpan(route);\n }\n };\n\n private readonly _setupSessionListeners = () => {\n if (!this._removeSessionStartedFn) {\n this._removeSessionStartedFn =\n this.sessionManager.addSessionStartedListener(() => {\n const currentRoute = page.getCurrentRoute();\n\n if (currentRoute && !this._currentRouteSpan) {\n this._diag.debug('Session started, starting route span.');\n\n this._startRouteSpan(currentRoute);\n }\n });\n }\n\n if (!this._removeSessionEndedFn) {\n this._removeSessionEndedFn = this.sessionManager.addSessionEndedListener(\n () => {\n if (this._currentRouteSpan) {\n this._diag.debug('Session ended, ending route span.');\n\n this._endRouteSpan(page.getCurrentRoute());\n }\n },\n );\n }\n };\n\n private readonly _cleanUpSessionListeners = () => {\n if (this._removeSessionStartedFn) {\n this._removeSessionStartedFn();\n this._removeSessionStartedFn = null;\n }\n\n if (this._removeSessionEndedFn) {\n this._removeSessionEndedFn();\n this._removeSessionEndedFn = null;\n }\n };\n\n private readonly _startRouteSpan = (route: Route): Span => {\n this._diag.debug(`Starting route span for url: ${route.url}`);\n this._setupSessionListeners();\n\n const pathName = this._shouldCleanupPathOptionsFromRouteName\n ? route.path.replace(PATH_OPTIONS_RE, '')\n : route.path;\n this._currentRouteSpan = this.tracer.startSpan(pathName, {\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.Surface,\n [KEY_MXL_PAGE_PATH]: pathName,\n [KEY_MXL_PAGE_ID]: page.getCurrentPageId() || undefined,\n },\n });\n\n this._currentRouteSpan.setAttribute(\n KEY_MXL_INSTRUMENTATION,\n this._instrumentationType,\n );\n\n return this._currentRouteSpan;\n };\n\n private readonly _endRouteSpan = (currentRoute: Route | null) => {\n if (this._currentRouteSpan) {\n if (currentRoute) {\n this._diag.debug(`Ending route span for url: ${currentRoute.url}`);\n }\n\n this._currentRouteSpan.end();\n this._currentRouteSpan = null;\n }\n };\n\n public enable = () => {\n this.setConfig({\n enabled: true,\n });\n this._diag.debug(\n 'NavigationInstrumentation enabled, listening for navigation events.',\n );\n };\n\n public disable = () => {\n this._cleanUpSessionListeners();\n this.setConfig({\n enabled: false,\n });\n this._diag.debug(\n 'NavigationInstrumentation disabled, stopped listening for navigation events.',\n );\n };\n}\n"],"mappings":";;;;;AAiBA,MAAM,kBAAkB;AAExB,IAAa,4BAAb,cAA+CA,uEAAAA,uBAAuB;CACpE,yCAAmE;CACnE,oBAAyC;CACzC,uBAAQ;CAER,0BAAuD;CACvD,wBAAqD;CAErD,YAAmB,EACjB,MACA,wCAAwC,QACR;AAChC,QAAM;GACJ,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BC,6BAAAA,kBAAkBH,yBAAAA,KAAK,kBAAkB,IAAI,KAAA;GAC/C,EACF,CAAC;AAEF,OAAK,kBAAkB,aACrBI,6BAAAA,yBACA,KAAK,qBACN;AAED,SAAO,KAAK;;CAGd,iBAAkC,iBAA+B;AAC/D,MAAI,KAAK,mBAAmB;AAC1B,OAAI,aACF,MAAK,MAAM,MAAM,8BAA8B,aAAa,MAAM;AAGpE,QAAK,kBAAkB,KAAK;AAC5B,QAAK,oBAAoB;;;CAI7B,eAAsB;AACpB,OAAK,UAAU,EACb,SAAS,MACV,CAAC;AACF,OAAK,MAAM,MACT,sEACD;;CAGH,gBAAuB;AACrB,OAAK,0BAA0B;AAC/B,OAAK,UAAU,EACb,SAAS,OACV,CAAC;AACF,OAAK,MAAM,MACT,+EACD"}
1
+ {"version":3,"file":"NavigationInstrumentation.cjs","names":["MXLInstrumentationBase","page","KEY_MXL_TYPE","KEY_MXL_PAGE_PATH","KEY_MXL_PAGE_ID","KEY_MXL_INSTRUMENTATION"],"sources":["../../../../src/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { Route } from '../../../api-page';\nimport { page } from '../../../api-page';\nimport {\n KEY_MXL_INSTRUMENTATION,\n KEY_MXL_PAGE_ID,\n KEY_MXL_PAGE_PATH,\n KEY_MXL_TYPE,\n MXL_NAVIGATION_INSTRUMENTATIONS,\n MXL_TYPES,\n} from '../../../constants';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport type { NavigationInstrumentationArgs } from './types';\n\n// Regular expression to match path options in the format \"(option)\"\n// Used to clean up paths that are like \"/order/:orderState(pending|shipped|delivered)/type:(sale|normal)\" to \"/order/:orderState/:type\"\n// Could be simplified but done this way to prevent: https://javascript.info/regexp-catastrophic-backtracking\nconst PATH_OPTIONS_RE = /\\([^()]+\\)/g;\n\nexport class NavigationInstrumentation extends MXLInstrumentationBase {\n private readonly _shouldCleanupPathOptionsFromRouteName: boolean = true;\n private _currentRouteSpan: Span | null = null;\n private _instrumentationType: MXL_NAVIGATION_INSTRUMENTATIONS =\n MXL_NAVIGATION_INSTRUMENTATIONS.Manual;\n private _removeSessionStartedFn: (() => void) | null = null;\n private _removeSessionEndedFn: (() => void) | null = null;\n\n public constructor({\n diag,\n shouldCleanupPathOptionsFromRouteName = true,\n }: NavigationInstrumentationArgs) {\n super({\n instrumentationName: 'NavigationInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n config: {},\n });\n\n this._shouldCleanupPathOptionsFromRouteName =\n shouldCleanupPathOptionsFromRouteName;\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public setInstrumentationType = (\n instrumentationType: MXL_NAVIGATION_INSTRUMENTATIONS,\n ) => {\n this._instrumentationType = instrumentationType;\n };\n\n public setCurrentRoute = (route: Route) => {\n if (!this._config.enabled) {\n return;\n }\n\n const currentRoute = page.getCurrentRoute();\n\n if (route.url !== currentRoute?.url) {\n page.setCurrentRoute(route);\n\n this._endRouteSpan(currentRoute);\n this._startRouteSpan(route);\n }\n };\n\n private readonly _setupSessionListeners = () => {\n if (!this._removeSessionStartedFn) {\n this._removeSessionStartedFn =\n this.sessionManager.addSessionStartedListener(() => {\n const currentRoute = page.getCurrentRoute();\n\n if (currentRoute && !this._currentRouteSpan) {\n this._diag.debug('Session started, starting route span.');\n\n this._startRouteSpan(currentRoute);\n }\n });\n }\n\n if (!this._removeSessionEndedFn) {\n this._removeSessionEndedFn = this.sessionManager.addSessionEndedListener(\n () => {\n if (this._currentRouteSpan) {\n this._diag.debug('Session ended, ending route span.');\n\n this._endRouteSpan(page.getCurrentRoute());\n }\n },\n );\n }\n };\n\n private readonly _cleanUpSessionListeners = () => {\n if (this._removeSessionStartedFn) {\n this._removeSessionStartedFn();\n this._removeSessionStartedFn = null;\n }\n\n if (this._removeSessionEndedFn) {\n this._removeSessionEndedFn();\n this._removeSessionEndedFn = null;\n }\n };\n\n private readonly _startRouteSpan = (route: Route): Span => {\n this._diag.debug(`Starting route span for url: ${route.url}`);\n this._setupSessionListeners();\n\n const pathName = this._shouldCleanupPathOptionsFromRouteName\n ? route.path.replace(PATH_OPTIONS_RE, '')\n : route.path;\n this._currentRouteSpan = this.tracer.startSpan(pathName, {\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.Surface,\n [KEY_MXL_PAGE_PATH]: pathName,\n [KEY_MXL_PAGE_ID]: page.getCurrentPageId() || undefined,\n },\n });\n\n this._currentRouteSpan.setAttribute(\n KEY_MXL_INSTRUMENTATION,\n this._instrumentationType,\n );\n\n return this._currentRouteSpan;\n };\n\n private readonly _endRouteSpan = (currentRoute: Route | null) => {\n if (this._currentRouteSpan) {\n if (currentRoute) {\n this._diag.debug(`Ending route span for url: ${currentRoute.url}`);\n }\n\n this._currentRouteSpan.end();\n this._currentRouteSpan = null;\n }\n };\n\n public enable = () => {\n this.setConfig({\n enabled: true,\n });\n this._diag.debug(\n 'NavigationInstrumentation enabled, listening for navigation events.',\n );\n };\n\n public disable = () => {\n this._cleanUpSessionListeners();\n this.setConfig({\n enabled: false,\n });\n this._diag.debug(\n 'NavigationInstrumentation disabled, stopped listening for navigation events.',\n );\n };\n}\n"],"mappings":";;;;;AAiBA,MAAM,kBAAkB;AAExB,IAAa,4BAAb,cAA+CA,uEAAAA,uBAAuB;CACpE,yCAAmE;CACnE,oBAAyC;CACzC,uBAAQ;CAER,0BAAuD;CACvD,wBAAqD;CAErD,YAAmB,EACjB,MACA,wCAAwC,QACR;AAChC,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,OAAK,yCACH;AAEF,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,0BACE,wBACG;AACH,OAAK,uBAAuB;;CAG9B,mBAA0B,UAAiB;AACzC,MAAI,CAAC,KAAK,QAAQ,QAChB;EAGF,MAAM,eAAeC,yBAAAA,KAAK,iBAAiB;AAE3C,MAAI,MAAM,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AAC5B,QAAK,oBAAoB;;;CAI7B,eAAsB;AACpB,OAAK,UAAU,EACb,SAAS,MACV,CAAC;AACF,OAAK,MAAM,MACT,sEACD;;CAGH,gBAAuB;AACrB,OAAK,0BAA0B;AAC/B,OAAK,UAAU,EACb,SAAS,OACV,CAAC;AACF,OAAK,MAAM,MACT,+EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { Route } from '../../../api-page/index.ts';\nimport { page } from '../../../api-page/index.ts';\nimport {\n MXL_NAVIGATION_INSTRUMENTATIONS,\n MXL_TYPES,\n KEY_MXL_INSTRUMENTATION,\n KEY_MXL_PAGE_ID,\n KEY_MXL_PAGE_PATH,\n KEY_MXL_TYPE,\n} from '../../../constants/index.ts';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase/index.ts';\nimport type { NavigationInstrumentationArgs } from './types.ts';\n\n// Regular expression to match path options in the format \"(option)\"\n// Used to clean up paths that are like \"/order/:orderState(pending|shipped|delivered)/type:(sale|normal)\" to \"/order/:orderState/:type\"\n// Could be simplified but done this way to prevent: https://javascript.info/regexp-catastrophic-backtracking\nconst PATH_OPTIONS_RE = /\\([^()]+\\)/g;\n\nexport class NavigationInstrumentation extends MXLInstrumentationBase {\n private readonly _shouldCleanupPathOptionsFromRouteName: boolean = true;\n private _currentRouteSpan: Span | null = null;\n private _instrumentationType: MXL_NAVIGATION_INSTRUMENTATIONS =\n MXL_NAVIGATION_INSTRUMENTATIONS.Manual;\n private _removeSessionStartedFn: (() => void) | null = null;\n private _removeSessionEndedFn: (() => void) | null = null;\n\n public constructor({\n diag,\n shouldCleanupPathOptionsFromRouteName = true,\n }: NavigationInstrumentationArgs) {\n super({\n instrumentationName: 'NavigationInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n config: {},\n });\n\n this._shouldCleanupPathOptionsFromRouteName =\n shouldCleanupPathOptionsFromRouteName;\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public setInstrumentationType = (\n instrumentationType: MXL_NAVIGATION_INSTRUMENTATIONS,\n ) => {\n this._instrumentationType = instrumentationType;\n };\n\n public setCurrentRoute = (route: Route) => {\n if (!this._config.enabled) {\n return;\n }\n\n const currentRoute = page.getCurrentRoute();\n\n if (route.url !== currentRoute?.url) {\n page.setCurrentRoute(route);\n\n this._endRouteSpan(currentRoute);\n this._startRouteSpan(route);\n }\n };\n\n private readonly _setupSessionListeners = () => {\n if (!this._removeSessionStartedFn) {\n this._removeSessionStartedFn =\n this.sessionManager.addSessionStartedListener(() => {\n const currentRoute = page.getCurrentRoute();\n\n if (currentRoute && !this._currentRouteSpan) {\n this._diag.debug('Session started, starting route span.');\n\n this._startRouteSpan(currentRoute);\n }\n });\n }\n\n if (!this._removeSessionEndedFn) {\n this._removeSessionEndedFn = this.sessionManager.addSessionEndedListener(\n () => {\n if (this._currentRouteSpan) {\n this._diag.debug('Session ended, ending route span.');\n\n this._endRouteSpan(page.getCurrentRoute());\n }\n },\n );\n }\n };\n\n private readonly _cleanUpSessionListeners = () => {\n if (this._removeSessionStartedFn) {\n this._removeSessionStartedFn();\n this._removeSessionStartedFn = null;\n }\n\n if (this._removeSessionEndedFn) {\n this._removeSessionEndedFn();\n this._removeSessionEndedFn = null;\n }\n };\n\n private readonly _startRouteSpan = (route: Route): Span => {\n this._diag.debug(`Starting route span for url: ${route.url}`);\n this._setupSessionListeners();\n\n const pathName = this._shouldCleanupPathOptionsFromRouteName\n ? route.path.replace(PATH_OPTIONS_RE, '')\n : route.path;\n this._currentRouteSpan = this.tracer.startSpan(pathName, {\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.Surface,\n [KEY_MXL_PAGE_PATH]: pathName,\n [KEY_MXL_PAGE_ID]: page.getCurrentPageId() || undefined,\n },\n });\n\n this._currentRouteSpan.setAttribute(\n KEY_MXL_INSTRUMENTATION,\n this._instrumentationType,\n );\n\n return this._currentRouteSpan;\n };\n\n private readonly _endRouteSpan = (currentRoute: Route | null) => {\n if (this._currentRouteSpan) {\n if (currentRoute) {\n this._diag.debug(`Ending route span for url: ${currentRoute.url}`);\n }\n\n this._currentRouteSpan.end();\n this._currentRouteSpan = null;\n }\n };\n\n public enable = () => {\n this.setConfig({\n enabled: true,\n });\n this._diag.debug(\n 'NavigationInstrumentation enabled, listening for navigation events.',\n );\n };\n\n public disable = () => {\n this._cleanUpSessionListeners();\n this.setConfig({\n enabled: false,\n });\n this._diag.debug(\n 'NavigationInstrumentation disabled, stopped listening for navigation events.',\n );\n };\n}\n"],"mappings":";;;;AAiBA,MAAM,kBAAkB;AAExB,IAAa,4BAAb,cAA+C,uBAAuB;CACpE,yCAAmE;CACnE,oBAAyC;CACzC,uBAAQ;CAER,0BAAuD;CACvD,wBAAqD;CAErD,YAAmB,EACjB,MACA,wCAAwC,QACR;AAChC,QAAM;GACJ,qBAAqB;GACrB,wBAAwB;GACxB;GACA,QAAQ,EAAE;GACX,CAAC;AAEF,OAAK,yCACH;AAEF,MAAI,KAAK,QAAQ,QACf,MAAK,QAAQ;;CAIjB,0BACE,wBACG;AACH,OAAK,uBAAuB;;CAG9B,mBAA0B,UAAiB;AACzC,MAAI,CAAC,KAAK,QAAQ,QAChB;EAGF,MAAM,eAAe,KAAK,iBAAiB;AAE3C,MAAI,MAAM,QAAQ,cAAc,KAAK;AACnC,QAAK,gBAAgB,MAAM;AAE3B,QAAK,cAAc,aAAa;AAChC,QAAK,gBAAgB,MAAM;;;CAI/B,+BAAgD;AAC9C,MAAI,CAAC,KAAK,wBACR,MAAK,0BACH,KAAK,eAAe,gCAAgC;GAClD,MAAM,eAAe,KAAK,iBAAiB;AAE3C,OAAI,gBAAgB,CAAC,KAAK,mBAAmB;AAC3C,SAAK,MAAM,MAAM,wCAAwC;AAEzD,SAAK,gBAAgB,aAAa;;IAEpC;AAGN,MAAI,CAAC,KAAK,sBACR,MAAK,wBAAwB,KAAK,eAAe,8BACzC;AACJ,OAAI,KAAK,mBAAmB;AAC1B,SAAK,MAAM,MAAM,oCAAoC;AAErD,SAAK,cAAc,KAAK,iBAAiB,CAAC;;IAG/C;;CAIL,iCAAkD;AAChD,MAAI,KAAK,yBAAyB;AAChC,QAAK,yBAAyB;AAC9B,QAAK,0BAA0B;;AAGjC,MAAI,KAAK,uBAAuB;AAC9B,QAAK,uBAAuB;AAC5B,QAAK,wBAAwB;;;CAIjC,mBAAoC,UAAuB;AACzD,OAAK,MAAM,MAAM,gCAAgC,MAAM,MAAM;AAC7D,OAAK,wBAAwB;EAE7B,MAAM,WAAW,KAAK,yCAClB,MAAM,KAAK,QAAQ,iBAAiB,GAAG,GACvC,MAAM;AACV,OAAK,oBAAoB,KAAK,OAAO,UAAU,UAAU,EACvD,YAAY;IACT,eAAA;IACA,oBAAoB;IACpB,kBAAkB,KAAK,kBAAkB,IAAI,KAAA;GAC/C,EACF,CAAC;AAEF,OAAK,kBAAkB,aACrB,yBACA,KAAK,qBACN;AAED,SAAO,KAAK;;CAGd,iBAAkC,iBAA+B;AAC/D,MAAI,KAAK,mBAAmB;AAC1B,OAAI,aACF,MAAK,MAAM,MAAM,8BAA8B,aAAa,MAAM;AAGpE,QAAK,kBAAkB,KAAK;AAC5B,QAAK,oBAAoB;;;CAI7B,eAAsB;AACpB,OAAK,UAAU,EACb,SAAS,MACV,CAAC;AACF,OAAK,MAAM,MACT,sEACD;;CAGH,gBAAuB;AACrB,OAAK,0BAA0B;AAC/B,OAAK,UAAU,EACb,SAAS,OACV,CAAC;AACF,OAAK,MAAM,MACT,+EACD"}
1
+ {"version":3,"file":"NavigationInstrumentation.js","names":[],"sources":["../../../../src/instrumentations/navigation/NavigationInstrumentation/NavigationInstrumentation.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { Route } from '../../../api-page';\nimport { page } from '../../../api-page';\nimport {\n KEY_MXL_INSTRUMENTATION,\n KEY_MXL_PAGE_ID,\n KEY_MXL_PAGE_PATH,\n KEY_MXL_TYPE,\n MXL_NAVIGATION_INSTRUMENTATIONS,\n MXL_TYPES,\n} from '../../../constants';\nimport { MXLInstrumentationBase } from '../../MXLInstrumentationBase';\nimport type { NavigationInstrumentationArgs } from './types';\n\n// Regular expression to match path options in the format \"(option)\"\n// Used to clean up paths that are like \"/order/:orderState(pending|shipped|delivered)/type:(sale|normal)\" to \"/order/:orderState/:type\"\n// Could be simplified but done this way to prevent: https://javascript.info/regexp-catastrophic-backtracking\nconst PATH_OPTIONS_RE = /\\([^()]+\\)/g;\n\nexport class NavigationInstrumentation extends MXLInstrumentationBase {\n private readonly _shouldCleanupPathOptionsFromRouteName: boolean = true;\n private _currentRouteSpan: Span | null = null;\n private _instrumentationType: MXL_NAVIGATION_INSTRUMENTATIONS =\n MXL_NAVIGATION_INSTRUMENTATIONS.Manual;\n private _removeSessionStartedFn: (() => void) | null = null;\n private _removeSessionEndedFn: (() => void) | null = null;\n\n public constructor({\n diag,\n shouldCleanupPathOptionsFromRouteName = true,\n }: NavigationInstrumentationArgs) {\n super({\n instrumentationName: 'NavigationInstrumentation',\n instrumentationVersion: '1.0.0',\n diag,\n config: {},\n });\n\n this._shouldCleanupPathOptionsFromRouteName =\n shouldCleanupPathOptionsFromRouteName;\n\n if (this._config.enabled) {\n this.enable();\n }\n }\n\n public setInstrumentationType = (\n instrumentationType: MXL_NAVIGATION_INSTRUMENTATIONS,\n ) => {\n this._instrumentationType = instrumentationType;\n };\n\n public setCurrentRoute = (route: Route) => {\n if (!this._config.enabled) {\n return;\n }\n\n const currentRoute = page.getCurrentRoute();\n\n if (route.url !== currentRoute?.url) {\n page.setCurrentRoute(route);\n\n this._endRouteSpan(currentRoute);\n this._startRouteSpan(route);\n }\n };\n\n private readonly _setupSessionListeners = () => {\n if (!this._removeSessionStartedFn) {\n this._removeSessionStartedFn =\n this.sessionManager.addSessionStartedListener(() => {\n const currentRoute = page.getCurrentRoute();\n\n if (currentRoute && !this._currentRouteSpan) {\n this._diag.debug('Session started, starting route span.');\n\n this._startRouteSpan(currentRoute);\n }\n });\n }\n\n if (!this._removeSessionEndedFn) {\n this._removeSessionEndedFn = this.sessionManager.addSessionEndedListener(\n () => {\n if (this._currentRouteSpan) {\n this._diag.debug('Session ended, ending route span.');\n\n this._endRouteSpan(page.getCurrentRoute());\n }\n },\n );\n }\n };\n\n private readonly _cleanUpSessionListeners = () => {\n if (this._removeSessionStartedFn) {\n this._removeSessionStartedFn();\n this._removeSessionStartedFn = null;\n }\n\n if (this._removeSessionEndedFn) {\n this._removeSessionEndedFn();\n this._removeSessionEndedFn = null;\n }\n };\n\n private readonly _startRouteSpan = (route: Route): Span => {\n this._diag.debug(`Starting route span for url: ${route.url}`);\n this._setupSessionListeners();\n\n const pathName = this._shouldCleanupPathOptionsFromRouteName\n ? route.path.replace(PATH_OPTIONS_RE, '')\n : route.path;\n this._currentRouteSpan = this.tracer.startSpan(pathName, {\n attributes: {\n [KEY_MXL_TYPE]: MXL_TYPES.Surface,\n [KEY_MXL_PAGE_PATH]: pathName,\n [KEY_MXL_PAGE_ID]: page.getCurrentPageId() || undefined,\n },\n });\n\n this._currentRouteSpan.setAttribute(\n KEY_MXL_INSTRUMENTATION,\n this._instrumentationType,\n );\n\n return this._currentRouteSpan;\n };\n\n private readonly _endRouteSpan = (currentRoute: Route | null) => {\n if (this._currentRouteSpan) {\n if (currentRoute) {\n this._diag.debug(`Ending route span for url: ${currentRoute.url}`);\n }\n\n this._currentRouteSpan.end();\n this._currentRouteSpan = null;\n }\n };\n\n public enable = () => {\n this.setConfig({\n enabled: true,\n });\n this._diag.debug(\n 'NavigationInstrumentation enabled, listening for navigation events.',\n );\n };\n\n public disable = () => {\n this._cleanUpSessionListeners();\n this.setConfig({\n enabled: false,\n });\n this._diag.debug(\n 'NavigationInstrumentation disabled, stopped listening for navigation events.',\n );\n };\n}\n"],"mappings":";;;;AAiBA,MAAM,kBAAkB;AAExB,IAAa,4BAAb,cAA+C,uBAAuB;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AAoB,KAAK,OAAO,UAAU,UAAU,EACvD,YAAY;IACT,eAAA;IACA,oBAAoB;IACpB,kBAAkB,KAAK,kBAAkB,IAAI,KAAA;GAC/C,EACF,CAAC;AAEF,OAAK,kBAAkB,aACrB,yBACA,KAAK,qBACN;AAED,SAAO,KAAK;;CAGd,iBAAkC,iBAA+B;AAC/D,MAAI,KAAK,mBAAmB;AAC1B,OAAI,aACF,MAAK,MAAM,MAAM,8BAA8B,aAAa,MAAM;AAGpE,QAAK,kBAAkB,KAAK;AAC5B,QAAK,oBAAoB;;;CAI7B,eAAsB;AACpB,OAAK,UAAU,EACb,SAAS,MACV,CAAC;AACF,OAAK,MAAM,MACT,sEACD;;CAGH,gBAAuB;AACrB,OAAK,0BAA0B;AAC/B,OAAK,UAAU,EACb,SAAS,OACV,CAAC;AACF,OAAK,MAAM,MACT,+EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"instance.cjs","names":["NavigationInstrumentation"],"sources":["../../../../src/instrumentations/navigation/NavigationInstrumentation/instance.ts"],"sourcesContent":["import { NavigationInstrumentation } from './NavigationInstrumentation.ts';\nimport type { NavigationInstrumentationArgs } from './types.ts';\n\nlet navigationInstrumentation: NavigationInstrumentation | undefined;\n\nexport const getNavigationInstrumentation = (\n config: NavigationInstrumentationArgs = {},\n): NavigationInstrumentation => {\n if (!navigationInstrumentation) {\n navigationInstrumentation = new NavigationInstrumentation(config);\n }\n\n return navigationInstrumentation;\n};\n"],"mappings":";;;AAGA,IAAI;AAEJ,MAAa,gCACX,SAAwC,EAAE,KACZ;AAC9B,KAAI,CAAC,0BACH,6BAA4B,IAAIA,wFAAAA,0BAA0B,OAAO;AAGnE,QAAO"}
1
+ {"version":3,"file":"instance.cjs","names":["NavigationInstrumentation"],"sources":["../../../../src/instrumentations/navigation/NavigationInstrumentation/instance.ts"],"sourcesContent":["import { NavigationInstrumentation } from './NavigationInstrumentation';\nimport type { NavigationInstrumentationArgs } from './types';\n\nlet navigationInstrumentation: NavigationInstrumentation | undefined;\n\nexport const getNavigationInstrumentation = (\n config: NavigationInstrumentationArgs = {},\n): NavigationInstrumentation => {\n if (!navigationInstrumentation) {\n navigationInstrumentation = new NavigationInstrumentation(config);\n }\n\n return navigationInstrumentation;\n};\n"],"mappings":";;;AAGA,IAAI;AAEJ,MAAa,gCACX,SAAwC,EAAE,KACZ;AAC9B,KAAI,CAAC,0BACH,6BAA4B,IAAIA,wFAAAA,0BAA0B,OAAO;AAGnE,QAAO"}