@sentry/browser 11.0.0-alpha.1 → 11.0.0-beta.0

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 (463) hide show
  1. package/build/npm/cjs/dev/client.js +5 -5
  2. package/build/npm/cjs/dev/client.js.map +1 -1
  3. package/build/npm/cjs/dev/diagnose-sdk.js +3 -3
  4. package/build/npm/cjs/dev/diagnose-sdk.js.map +1 -1
  5. package/build/npm/cjs/dev/eventbuilder.js +25 -25
  6. package/build/npm/cjs/dev/eventbuilder.js.map +1 -1
  7. package/build/npm/cjs/dev/helpers.js +13 -12
  8. package/build/npm/cjs/dev/helpers.js.map +1 -1
  9. package/build/npm/cjs/dev/index.js +87 -84
  10. package/build/npm/cjs/dev/index.js.map +1 -1
  11. package/build/npm/cjs/dev/integrations/bfcacheMetrics.js +115 -0
  12. package/build/npm/cjs/dev/integrations/bfcacheMetrics.js.map +1 -0
  13. package/build/npm/cjs/dev/integrations/breadcrumbs.js +28 -28
  14. package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -1
  15. package/build/npm/cjs/dev/integrations/browserapierrors.js +16 -16
  16. package/build/npm/cjs/dev/integrations/browserapierrors.js.map +1 -1
  17. package/build/npm/cjs/dev/integrations/browsersession.js +9 -9
  18. package/build/npm/cjs/dev/integrations/browsersession.js.map +1 -1
  19. package/build/npm/cjs/dev/integrations/contextlines.js +5 -5
  20. package/build/npm/cjs/dev/integrations/contextlines.js.map +1 -1
  21. package/build/npm/cjs/dev/integrations/culturecontext.js +3 -3
  22. package/build/npm/cjs/dev/integrations/culturecontext.js.map +1 -1
  23. package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js +2 -2
  24. package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
  25. package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js +5 -5
  26. package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  27. package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js +7 -7
  28. package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
  29. package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js +5 -5
  30. package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
  31. package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js +7 -7
  32. package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
  33. package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js +11 -5
  34. package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js.map +1 -1
  35. package/build/npm/cjs/dev/integrations/globalhandlers.js +17 -16
  36. package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -1
  37. package/build/npm/cjs/dev/integrations/graphqlClient.js +28 -15
  38. package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -1
  39. package/build/npm/cjs/dev/integrations/httpclient.js +20 -23
  40. package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -1
  41. package/build/npm/cjs/dev/integrations/httpcontext.js +6 -7
  42. package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -1
  43. package/build/npm/cjs/dev/integrations/linkederrors.js +3 -3
  44. package/build/npm/cjs/dev/integrations/linkederrors.js.map +1 -1
  45. package/build/npm/cjs/dev/integrations/reportingobserver.js +10 -7
  46. package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -1
  47. package/build/npm/cjs/dev/integrations/spotlight.js +8 -7
  48. package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -1
  49. package/build/npm/cjs/dev/integrations/view-hierarchy.js +4 -3
  50. package/build/npm/cjs/dev/integrations/view-hierarchy.js.map +1 -1
  51. package/build/npm/cjs/dev/integrations/webVitals.js +3 -3
  52. package/build/npm/cjs/dev/integrations/webVitals.js.map +1 -1
  53. package/build/npm/cjs/dev/integrations/webWorker.js +18 -18
  54. package/build/npm/cjs/dev/integrations/webWorker.js.map +1 -1
  55. package/build/npm/cjs/dev/profiling/UIProfiler.js +33 -33
  56. package/build/npm/cjs/dev/profiling/UIProfiler.js.map +1 -1
  57. package/build/npm/cjs/dev/profiling/index.js +7 -7
  58. package/build/npm/cjs/dev/profiling/index.js.map +1 -1
  59. package/build/npm/cjs/dev/profiling/integration.js +8 -8
  60. package/build/npm/cjs/dev/profiling/integration.js.map +1 -1
  61. package/build/npm/cjs/dev/profiling/utils.js +16 -16
  62. package/build/npm/cjs/dev/profiling/utils.js.map +1 -1
  63. package/build/npm/cjs/dev/report-dialog.js +7 -7
  64. package/build/npm/cjs/dev/report-dialog.js.map +1 -1
  65. package/build/npm/cjs/dev/sdk.js +9 -13
  66. package/build/npm/cjs/dev/sdk.js.map +1 -1
  67. package/build/npm/cjs/dev/stack-parsers.js +10 -10
  68. package/build/npm/cjs/dev/stack-parsers.js.map +1 -1
  69. package/build/npm/cjs/dev/tracing/backgroundtab.js +7 -7
  70. package/build/npm/cjs/dev/tracing/backgroundtab.js.map +1 -1
  71. package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +66 -118
  72. package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
  73. package/build/npm/cjs/dev/tracing/linkedTraces.js +10 -12
  74. package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -1
  75. package/build/npm/cjs/dev/tracing/reportPageLoaded.js +2 -2
  76. package/build/npm/cjs/dev/tracing/reportPageLoaded.js.map +1 -1
  77. package/build/npm/cjs/dev/tracing/request.js +40 -32
  78. package/build/npm/cjs/dev/tracing/request.js.map +1 -1
  79. package/build/npm/cjs/dev/tracing/setActiveSpan.js +5 -5
  80. package/build/npm/cjs/dev/tracing/setActiveSpan.js.map +1 -1
  81. package/build/npm/cjs/dev/transports/fetch.js +3 -3
  82. package/build/npm/cjs/dev/transports/fetch.js.map +1 -1
  83. package/build/npm/cjs/dev/transports/offline.js +5 -5
  84. package/build/npm/cjs/dev/transports/offline.js.map +1 -1
  85. package/build/npm/cjs/dev/userfeedback.js +3 -3
  86. package/build/npm/cjs/dev/userfeedback.js.map +1 -1
  87. package/build/npm/cjs/dev/utils/detectBrowserExtension.js +4 -3
  88. package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -1
  89. package/build/npm/cjs/dev/utils/lazyLoadIntegration.js +4 -3
  90. package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -1
  91. package/build/npm/cjs/prod/client.js +5 -5
  92. package/build/npm/cjs/prod/client.js.map +1 -1
  93. package/build/npm/cjs/prod/diagnose-sdk.js +3 -3
  94. package/build/npm/cjs/prod/diagnose-sdk.js.map +1 -1
  95. package/build/npm/cjs/prod/eventbuilder.js +25 -25
  96. package/build/npm/cjs/prod/eventbuilder.js.map +1 -1
  97. package/build/npm/cjs/prod/helpers.js +13 -12
  98. package/build/npm/cjs/prod/helpers.js.map +1 -1
  99. package/build/npm/cjs/prod/index.js +87 -84
  100. package/build/npm/cjs/prod/index.js.map +1 -1
  101. package/build/npm/cjs/prod/integrations/bfcacheMetrics.js +115 -0
  102. package/build/npm/cjs/prod/integrations/bfcacheMetrics.js.map +1 -0
  103. package/build/npm/cjs/prod/integrations/breadcrumbs.js +28 -28
  104. package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -1
  105. package/build/npm/cjs/prod/integrations/browserapierrors.js +16 -16
  106. package/build/npm/cjs/prod/integrations/browserapierrors.js.map +1 -1
  107. package/build/npm/cjs/prod/integrations/browsersession.js +9 -9
  108. package/build/npm/cjs/prod/integrations/browsersession.js.map +1 -1
  109. package/build/npm/cjs/prod/integrations/contextlines.js +5 -5
  110. package/build/npm/cjs/prod/integrations/contextlines.js.map +1 -1
  111. package/build/npm/cjs/prod/integrations/culturecontext.js +3 -3
  112. package/build/npm/cjs/prod/integrations/culturecontext.js.map +1 -1
  113. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js +2 -2
  114. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
  115. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js +5 -5
  116. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  117. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js +7 -7
  118. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
  119. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js +5 -5
  120. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
  121. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js +7 -7
  122. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
  123. package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js +11 -5
  124. package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js.map +1 -1
  125. package/build/npm/cjs/prod/integrations/globalhandlers.js +17 -16
  126. package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -1
  127. package/build/npm/cjs/prod/integrations/graphqlClient.js +28 -15
  128. package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -1
  129. package/build/npm/cjs/prod/integrations/httpclient.js +20 -23
  130. package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -1
  131. package/build/npm/cjs/prod/integrations/httpcontext.js +6 -7
  132. package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -1
  133. package/build/npm/cjs/prod/integrations/linkederrors.js +3 -3
  134. package/build/npm/cjs/prod/integrations/linkederrors.js.map +1 -1
  135. package/build/npm/cjs/prod/integrations/reportingobserver.js +10 -7
  136. package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -1
  137. package/build/npm/cjs/prod/integrations/spotlight.js +8 -7
  138. package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -1
  139. package/build/npm/cjs/prod/integrations/view-hierarchy.js +4 -3
  140. package/build/npm/cjs/prod/integrations/view-hierarchy.js.map +1 -1
  141. package/build/npm/cjs/prod/integrations/webVitals.js +3 -3
  142. package/build/npm/cjs/prod/integrations/webVitals.js.map +1 -1
  143. package/build/npm/cjs/prod/integrations/webWorker.js +18 -18
  144. package/build/npm/cjs/prod/integrations/webWorker.js.map +1 -1
  145. package/build/npm/cjs/prod/profiling/UIProfiler.js +33 -33
  146. package/build/npm/cjs/prod/profiling/UIProfiler.js.map +1 -1
  147. package/build/npm/cjs/prod/profiling/index.js +7 -7
  148. package/build/npm/cjs/prod/profiling/index.js.map +1 -1
  149. package/build/npm/cjs/prod/profiling/integration.js +8 -8
  150. package/build/npm/cjs/prod/profiling/integration.js.map +1 -1
  151. package/build/npm/cjs/prod/profiling/utils.js +16 -16
  152. package/build/npm/cjs/prod/profiling/utils.js.map +1 -1
  153. package/build/npm/cjs/prod/report-dialog.js +7 -7
  154. package/build/npm/cjs/prod/report-dialog.js.map +1 -1
  155. package/build/npm/cjs/prod/sdk.js +9 -13
  156. package/build/npm/cjs/prod/sdk.js.map +1 -1
  157. package/build/npm/cjs/prod/stack-parsers.js +10 -10
  158. package/build/npm/cjs/prod/stack-parsers.js.map +1 -1
  159. package/build/npm/cjs/prod/tracing/backgroundtab.js +7 -7
  160. package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -1
  161. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +66 -118
  162. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
  163. package/build/npm/cjs/prod/tracing/linkedTraces.js +10 -12
  164. package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -1
  165. package/build/npm/cjs/prod/tracing/reportPageLoaded.js +2 -2
  166. package/build/npm/cjs/prod/tracing/reportPageLoaded.js.map +1 -1
  167. package/build/npm/cjs/prod/tracing/request.js +40 -32
  168. package/build/npm/cjs/prod/tracing/request.js.map +1 -1
  169. package/build/npm/cjs/prod/tracing/setActiveSpan.js +5 -5
  170. package/build/npm/cjs/prod/tracing/setActiveSpan.js.map +1 -1
  171. package/build/npm/cjs/prod/transports/fetch.js +3 -3
  172. package/build/npm/cjs/prod/transports/fetch.js.map +1 -1
  173. package/build/npm/cjs/prod/transports/offline.js +5 -5
  174. package/build/npm/cjs/prod/transports/offline.js.map +1 -1
  175. package/build/npm/cjs/prod/userfeedback.js +3 -3
  176. package/build/npm/cjs/prod/userfeedback.js.map +1 -1
  177. package/build/npm/cjs/prod/utils/detectBrowserExtension.js +4 -3
  178. package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -1
  179. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +4 -3
  180. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -1
  181. package/build/npm/esm/dev/client.js +1 -1
  182. package/build/npm/esm/dev/client.js.map +1 -1
  183. package/build/npm/esm/dev/diagnose-sdk.js +1 -1
  184. package/build/npm/esm/dev/diagnose-sdk.js.map +1 -1
  185. package/build/npm/esm/dev/eventbuilder.js +1 -1
  186. package/build/npm/esm/dev/eventbuilder.js.map +1 -1
  187. package/build/npm/esm/dev/helpers.js +2 -1
  188. package/build/npm/esm/dev/helpers.js.map +1 -1
  189. package/build/npm/esm/dev/index.js +5 -4
  190. package/build/npm/esm/dev/index.js.map +1 -1
  191. package/build/npm/esm/dev/integrations/bfcacheMetrics.js +111 -0
  192. package/build/npm/esm/dev/integrations/bfcacheMetrics.js.map +1 -0
  193. package/build/npm/esm/dev/integrations/breadcrumbs.js +2 -2
  194. package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -1
  195. package/build/npm/esm/dev/integrations/browserapierrors.js +1 -1
  196. package/build/npm/esm/dev/integrations/browserapierrors.js.map +1 -1
  197. package/build/npm/esm/dev/integrations/browsersession.js +1 -1
  198. package/build/npm/esm/dev/integrations/browsersession.js.map +1 -1
  199. package/build/npm/esm/dev/integrations/contextlines.js +1 -1
  200. package/build/npm/esm/dev/integrations/contextlines.js.map +1 -1
  201. package/build/npm/esm/dev/integrations/culturecontext.js +1 -1
  202. package/build/npm/esm/dev/integrations/culturecontext.js.map +1 -1
  203. package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js +1 -1
  204. package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
  205. package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js +1 -1
  206. package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  207. package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js +1 -1
  208. package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
  209. package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js +1 -1
  210. package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
  211. package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js +1 -1
  212. package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
  213. package/build/npm/esm/dev/integrations/fetchStreamPerformance.js +12 -6
  214. package/build/npm/esm/dev/integrations/fetchStreamPerformance.js.map +1 -1
  215. package/build/npm/esm/dev/integrations/globalhandlers.js +2 -1
  216. package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -1
  217. package/build/npm/esm/dev/integrations/graphqlClient.js +21 -8
  218. package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -1
  219. package/build/npm/esm/dev/integrations/httpclient.js +1 -4
  220. package/build/npm/esm/dev/integrations/httpclient.js.map +1 -1
  221. package/build/npm/esm/dev/integrations/httpcontext.js +1 -2
  222. package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -1
  223. package/build/npm/esm/dev/integrations/linkederrors.js +1 -1
  224. package/build/npm/esm/dev/integrations/linkederrors.js.map +1 -1
  225. package/build/npm/esm/dev/integrations/reportingobserver.js +4 -1
  226. package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -1
  227. package/build/npm/esm/dev/integrations/spotlight.js +3 -2
  228. package/build/npm/esm/dev/integrations/spotlight.js.map +1 -1
  229. package/build/npm/esm/dev/integrations/view-hierarchy.js +2 -1
  230. package/build/npm/esm/dev/integrations/view-hierarchy.js.map +1 -1
  231. package/build/npm/esm/dev/integrations/webVitals.js +1 -1
  232. package/build/npm/esm/dev/integrations/webVitals.js.map +1 -1
  233. package/build/npm/esm/dev/integrations/webWorker.js +1 -1
  234. package/build/npm/esm/dev/integrations/webWorker.js.map +1 -1
  235. package/build/npm/esm/dev/package.json +1 -1
  236. package/build/npm/esm/dev/profiling/UIProfiler.js +1 -1
  237. package/build/npm/esm/dev/profiling/UIProfiler.js.map +1 -1
  238. package/build/npm/esm/dev/profiling/index.js +1 -1
  239. package/build/npm/esm/dev/profiling/index.js.map +1 -1
  240. package/build/npm/esm/dev/profiling/integration.js +1 -1
  241. package/build/npm/esm/dev/profiling/integration.js.map +1 -1
  242. package/build/npm/esm/dev/profiling/utils.js +1 -1
  243. package/build/npm/esm/dev/profiling/utils.js.map +1 -1
  244. package/build/npm/esm/dev/report-dialog.js +1 -1
  245. package/build/npm/esm/dev/report-dialog.js.map +1 -1
  246. package/build/npm/esm/dev/sdk.js +1 -5
  247. package/build/npm/esm/dev/sdk.js.map +1 -1
  248. package/build/npm/esm/dev/stack-parsers.js +1 -1
  249. package/build/npm/esm/dev/stack-parsers.js.map +1 -1
  250. package/build/npm/esm/dev/tracing/backgroundtab.js +1 -1
  251. package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -1
  252. package/build/npm/esm/dev/tracing/browserTracingIntegration.js +34 -85
  253. package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
  254. package/build/npm/esm/dev/tracing/linkedTraces.js +1 -3
  255. package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -1
  256. package/build/npm/esm/dev/tracing/reportPageLoaded.js +1 -1
  257. package/build/npm/esm/dev/tracing/reportPageLoaded.js.map +1 -1
  258. package/build/npm/esm/dev/tracing/request.js +21 -13
  259. package/build/npm/esm/dev/tracing/request.js.map +1 -1
  260. package/build/npm/esm/dev/tracing/setActiveSpan.js +1 -1
  261. package/build/npm/esm/dev/tracing/setActiveSpan.js.map +1 -1
  262. package/build/npm/esm/dev/transports/fetch.js +1 -1
  263. package/build/npm/esm/dev/transports/fetch.js.map +1 -1
  264. package/build/npm/esm/dev/transports/offline.js +1 -1
  265. package/build/npm/esm/dev/transports/offline.js.map +1 -1
  266. package/build/npm/esm/dev/userfeedback.js +1 -1
  267. package/build/npm/esm/dev/userfeedback.js.map +1 -1
  268. package/build/npm/esm/dev/utils/detectBrowserExtension.js +2 -1
  269. package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -1
  270. package/build/npm/esm/dev/utils/lazyLoadIntegration.js +2 -1
  271. package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -1
  272. package/build/npm/esm/prod/client.js +1 -1
  273. package/build/npm/esm/prod/client.js.map +1 -1
  274. package/build/npm/esm/prod/diagnose-sdk.js +1 -1
  275. package/build/npm/esm/prod/diagnose-sdk.js.map +1 -1
  276. package/build/npm/esm/prod/eventbuilder.js +1 -1
  277. package/build/npm/esm/prod/eventbuilder.js.map +1 -1
  278. package/build/npm/esm/prod/helpers.js +2 -1
  279. package/build/npm/esm/prod/helpers.js.map +1 -1
  280. package/build/npm/esm/prod/index.js +5 -4
  281. package/build/npm/esm/prod/index.js.map +1 -1
  282. package/build/npm/esm/prod/integrations/bfcacheMetrics.js +111 -0
  283. package/build/npm/esm/prod/integrations/bfcacheMetrics.js.map +1 -0
  284. package/build/npm/esm/prod/integrations/breadcrumbs.js +2 -2
  285. package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -1
  286. package/build/npm/esm/prod/integrations/browserapierrors.js +1 -1
  287. package/build/npm/esm/prod/integrations/browserapierrors.js.map +1 -1
  288. package/build/npm/esm/prod/integrations/browsersession.js +1 -1
  289. package/build/npm/esm/prod/integrations/browsersession.js.map +1 -1
  290. package/build/npm/esm/prod/integrations/contextlines.js +1 -1
  291. package/build/npm/esm/prod/integrations/contextlines.js.map +1 -1
  292. package/build/npm/esm/prod/integrations/culturecontext.js +1 -1
  293. package/build/npm/esm/prod/integrations/culturecontext.js.map +1 -1
  294. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js +1 -1
  295. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
  296. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js +1 -1
  297. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  298. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js +1 -1
  299. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
  300. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js +1 -1
  301. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
  302. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js +1 -1
  303. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
  304. package/build/npm/esm/prod/integrations/fetchStreamPerformance.js +12 -6
  305. package/build/npm/esm/prod/integrations/fetchStreamPerformance.js.map +1 -1
  306. package/build/npm/esm/prod/integrations/globalhandlers.js +2 -1
  307. package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -1
  308. package/build/npm/esm/prod/integrations/graphqlClient.js +21 -8
  309. package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -1
  310. package/build/npm/esm/prod/integrations/httpclient.js +1 -4
  311. package/build/npm/esm/prod/integrations/httpclient.js.map +1 -1
  312. package/build/npm/esm/prod/integrations/httpcontext.js +1 -2
  313. package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -1
  314. package/build/npm/esm/prod/integrations/linkederrors.js +1 -1
  315. package/build/npm/esm/prod/integrations/linkederrors.js.map +1 -1
  316. package/build/npm/esm/prod/integrations/reportingobserver.js +4 -1
  317. package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -1
  318. package/build/npm/esm/prod/integrations/spotlight.js +3 -2
  319. package/build/npm/esm/prod/integrations/spotlight.js.map +1 -1
  320. package/build/npm/esm/prod/integrations/view-hierarchy.js +2 -1
  321. package/build/npm/esm/prod/integrations/view-hierarchy.js.map +1 -1
  322. package/build/npm/esm/prod/integrations/webVitals.js +1 -1
  323. package/build/npm/esm/prod/integrations/webVitals.js.map +1 -1
  324. package/build/npm/esm/prod/integrations/webWorker.js +1 -1
  325. package/build/npm/esm/prod/integrations/webWorker.js.map +1 -1
  326. package/build/npm/esm/prod/package.json +1 -1
  327. package/build/npm/esm/prod/profiling/UIProfiler.js +1 -1
  328. package/build/npm/esm/prod/profiling/UIProfiler.js.map +1 -1
  329. package/build/npm/esm/prod/profiling/index.js +1 -1
  330. package/build/npm/esm/prod/profiling/index.js.map +1 -1
  331. package/build/npm/esm/prod/profiling/integration.js +1 -1
  332. package/build/npm/esm/prod/profiling/integration.js.map +1 -1
  333. package/build/npm/esm/prod/profiling/utils.js +1 -1
  334. package/build/npm/esm/prod/profiling/utils.js.map +1 -1
  335. package/build/npm/esm/prod/report-dialog.js +1 -1
  336. package/build/npm/esm/prod/report-dialog.js.map +1 -1
  337. package/build/npm/esm/prod/sdk.js +1 -5
  338. package/build/npm/esm/prod/sdk.js.map +1 -1
  339. package/build/npm/esm/prod/stack-parsers.js +1 -1
  340. package/build/npm/esm/prod/stack-parsers.js.map +1 -1
  341. package/build/npm/esm/prod/tracing/backgroundtab.js +1 -1
  342. package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -1
  343. package/build/npm/esm/prod/tracing/browserTracingIntegration.js +34 -85
  344. package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
  345. package/build/npm/esm/prod/tracing/linkedTraces.js +1 -3
  346. package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -1
  347. package/build/npm/esm/prod/tracing/reportPageLoaded.js +1 -1
  348. package/build/npm/esm/prod/tracing/reportPageLoaded.js.map +1 -1
  349. package/build/npm/esm/prod/tracing/request.js +21 -13
  350. package/build/npm/esm/prod/tracing/request.js.map +1 -1
  351. package/build/npm/esm/prod/tracing/setActiveSpan.js +1 -1
  352. package/build/npm/esm/prod/tracing/setActiveSpan.js.map +1 -1
  353. package/build/npm/esm/prod/transports/fetch.js +1 -1
  354. package/build/npm/esm/prod/transports/fetch.js.map +1 -1
  355. package/build/npm/esm/prod/transports/offline.js +1 -1
  356. package/build/npm/esm/prod/transports/offline.js.map +1 -1
  357. package/build/npm/esm/prod/userfeedback.js +1 -1
  358. package/build/npm/esm/prod/userfeedback.js.map +1 -1
  359. package/build/npm/esm/prod/utils/detectBrowserExtension.js +2 -1
  360. package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -1
  361. package/build/npm/esm/prod/utils/lazyLoadIntegration.js +2 -1
  362. package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -1
  363. package/build/npm/types/client.d.ts +24 -2
  364. package/build/npm/types/client.d.ts.map +1 -1
  365. package/build/npm/types/eventbuilder.d.ts +1 -1
  366. package/build/npm/types/eventbuilder.d.ts.map +1 -1
  367. package/build/npm/types/exports.d.ts +3 -3
  368. package/build/npm/types/exports.d.ts.map +1 -1
  369. package/build/npm/types/helpers.d.ts +2 -2
  370. package/build/npm/types/helpers.d.ts.map +1 -1
  371. package/build/npm/types/index.bundle.logs.metrics.d.ts +1 -1
  372. package/build/npm/types/index.bundle.logs.metrics.d.ts.map +1 -1
  373. package/build/npm/types/index.bundle.replay.logs.metrics.d.ts +1 -1
  374. package/build/npm/types/index.bundle.replay.logs.metrics.d.ts.map +1 -1
  375. package/build/npm/types/index.bundle.tracing.d.ts +4 -3
  376. package/build/npm/types/index.bundle.tracing.d.ts.map +1 -1
  377. package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts +5 -4
  378. package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts.map +1 -1
  379. package/build/npm/types/index.bundle.tracing.replay.d.ts +4 -3
  380. package/build/npm/types/index.bundle.tracing.replay.d.ts.map +1 -1
  381. package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts +4 -3
  382. package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts.map +1 -1
  383. package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +4 -3
  384. package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts.map +1 -1
  385. package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts +5 -4
  386. package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts.map +1 -1
  387. package/build/npm/types/index.d.ts +7 -5
  388. package/build/npm/types/index.d.ts.map +1 -1
  389. package/build/npm/types/integrations/bfcacheMetrics.d.ts +42 -0
  390. package/build/npm/types/integrations/bfcacheMetrics.d.ts.map +1 -0
  391. package/build/npm/types/integrations/breadcrumbs.d.ts.map +1 -1
  392. package/build/npm/types/integrations/contextlines.d.ts +1 -1
  393. package/build/npm/types/integrations/contextlines.d.ts.map +1 -1
  394. package/build/npm/types/integrations/fetchStreamPerformance.d.ts.map +1 -1
  395. package/build/npm/types/integrations/globalhandlers.d.ts +1 -1
  396. package/build/npm/types/integrations/globalhandlers.d.ts.map +1 -1
  397. package/build/npm/types/integrations/graphqlClient.d.ts.map +1 -1
  398. package/build/npm/types/integrations/interactions.d.ts +2 -0
  399. package/build/npm/types/integrations/interactions.d.ts.map +1 -0
  400. package/build/npm/types/integrations/reportingobserver.d.ts.map +1 -1
  401. package/build/npm/types/integrations/spotlight.d.ts.map +1 -1
  402. package/build/npm/types/integrations/view-hierarchy.d.ts +1 -1
  403. package/build/npm/types/integrations/view-hierarchy.d.ts.map +1 -1
  404. package/build/npm/types/integrations/webWorker.d.ts +1 -1
  405. package/build/npm/types/integrations/webWorker.d.ts.map +1 -1
  406. package/build/npm/types/integrations-bundle/index.captureconsole.d.ts +1 -1
  407. package/build/npm/types/integrations-bundle/index.captureconsole.d.ts.map +1 -1
  408. package/build/npm/types/integrations-bundle/index.dedupe.d.ts +1 -1
  409. package/build/npm/types/integrations-bundle/index.dedupe.d.ts.map +1 -1
  410. package/build/npm/types/integrations-bundle/index.extraerrordata.d.ts +1 -1
  411. package/build/npm/types/integrations-bundle/index.extraerrordata.d.ts.map +1 -1
  412. package/build/npm/types/integrations-bundle/index.feedback.d.ts +1 -1
  413. package/build/npm/types/integrations-bundle/index.feedback.d.ts.map +1 -1
  414. package/build/npm/types/integrations-bundle/index.modulemetadata.d.ts +1 -1
  415. package/build/npm/types/integrations-bundle/index.modulemetadata.d.ts.map +1 -1
  416. package/build/npm/types/integrations-bundle/index.rewriteframes.d.ts +1 -1
  417. package/build/npm/types/integrations-bundle/index.rewriteframes.d.ts.map +1 -1
  418. package/build/npm/types/pluggable-exports-bundle/index.multiplexedtransport.d.ts +1 -1
  419. package/build/npm/types/pluggable-exports-bundle/index.multiplexedtransport.d.ts.map +1 -1
  420. package/build/npm/types/profiling/UIProfiler.d.ts +1 -1
  421. package/build/npm/types/profiling/UIProfiler.d.ts.map +1 -1
  422. package/build/npm/types/profiling/index.d.ts +1 -1
  423. package/build/npm/types/profiling/index.d.ts.map +1 -1
  424. package/build/npm/types/profiling/utils.d.ts +1 -1
  425. package/build/npm/types/profiling/utils.d.ts.map +1 -1
  426. package/build/npm/types/report-dialog.d.ts +1 -1
  427. package/build/npm/types/report-dialog.d.ts.map +1 -1
  428. package/build/npm/types/sdk.d.ts +1 -1
  429. package/build/npm/types/sdk.d.ts.map +1 -1
  430. package/build/npm/types/stack-parsers.d.ts +1 -1
  431. package/build/npm/types/stack-parsers.d.ts.map +1 -1
  432. package/build/npm/types/tracing/browserTracingIntegration.d.ts +1 -10
  433. package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
  434. package/build/npm/types/tracing/linkedTraces.d.ts +2 -2
  435. package/build/npm/types/tracing/linkedTraces.d.ts.map +1 -1
  436. package/build/npm/types/tracing/reportPageLoaded.d.ts +1 -1
  437. package/build/npm/types/tracing/reportPageLoaded.d.ts.map +1 -1
  438. package/build/npm/types/tracing/request.d.ts +2 -1
  439. package/build/npm/types/tracing/request.d.ts.map +1 -1
  440. package/build/npm/types/tracing/setActiveSpan.d.ts +1 -1
  441. package/build/npm/types/tracing/setActiveSpan.d.ts.map +1 -1
  442. package/build/npm/types/transports/fetch.d.ts +1 -1
  443. package/build/npm/types/transports/fetch.d.ts.map +1 -1
  444. package/build/npm/types/transports/offline.d.ts +1 -1
  445. package/build/npm/types/transports/offline.d.ts.map +1 -1
  446. package/build/npm/types/transports/types.d.ts +1 -1
  447. package/build/npm/types/transports/types.d.ts.map +1 -1
  448. package/build/npm/types/userfeedback.d.ts +1 -1
  449. package/build/npm/types/userfeedback.d.ts.map +1 -1
  450. package/build/npm/types/utils/detectBrowserExtension.d.ts.map +1 -1
  451. package/build/npm/types/utils/lazyLoadIntegration.d.ts +2 -2
  452. package/build/npm/types/utils/lazyLoadIntegration.d.ts.map +1 -1
  453. package/package.json +10 -9
  454. package/build/npm/cjs/dev/integrations/spanstreaming.js +0 -34
  455. package/build/npm/cjs/dev/integrations/spanstreaming.js.map +0 -1
  456. package/build/npm/cjs/prod/integrations/spanstreaming.js +0 -34
  457. package/build/npm/cjs/prod/integrations/spanstreaming.js.map +0 -1
  458. package/build/npm/esm/dev/integrations/spanstreaming.js +0 -31
  459. package/build/npm/esm/dev/integrations/spanstreaming.js.map +0 -1
  460. package/build/npm/esm/prod/integrations/spanstreaming.js +0 -31
  461. package/build/npm/esm/prod/integrations/spanstreaming.js.map +0 -1
  462. package/build/npm/types/integrations/spanstreaming.d.ts +0 -5
  463. package/build/npm/types/integrations/spanstreaming.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"eventbuilder.js","sources":["../../../../src/eventbuilder.ts"],"sourcesContent":["import type {\n Event,\n EventHint,\n Exception,\n ParameterizedString,\n SeverityLevel,\n StackFrame,\n StackParser,\n} from '@sentry/core/browser';\nimport {\n _INTERNAL_enhanceErrorWithSentryInfo,\n addExceptionMechanism,\n addExceptionTypeValue,\n extractExceptionKeysForMessage,\n getClient,\n isDOMError,\n isDOMException,\n isError,\n isErrorEvent,\n isEvent,\n isParameterizedString,\n isPlainObject,\n normalizeToSize,\n resolvedSyncPromise,\n} from '@sentry/core/browser';\n\ntype Prototype = { constructor: (...args: unknown[]) => unknown };\n\n/**\n * This function creates an exception from a JavaScript Error\n */\nexport function exceptionFromError(stackParser: StackParser, ex: Error): Exception {\n // Get the frames first since Opera can lose the stack if we touch anything else first\n const frames = parseStackFrames(stackParser, ex);\n\n const exception: Exception = {\n type: extractType(ex),\n value: extractMessage(ex),\n };\n\n if (frames.length) {\n exception.stacktrace = { frames };\n }\n\n if (exception.type === undefined && exception.value === '') {\n exception.value = 'Unrecoverable error caught';\n }\n\n return exception;\n}\n\nfunction eventFromPlainObject(\n stackParser: StackParser,\n exception: Record<string, unknown>,\n syntheticException?: Error,\n isUnhandledRejection?: boolean,\n): Event {\n const client = getClient();\n const normalizeDepth = client?.getOptions().normalizeDepth;\n\n // If we can, we extract an exception from the object properties\n const errorFromProp = getErrorPropertyFromObject(exception);\n\n const extra = {\n __serialized__: normalizeToSize(exception, normalizeDepth),\n };\n\n if (errorFromProp) {\n return {\n exception: {\n values: [exceptionFromError(stackParser, errorFromProp)],\n },\n extra,\n };\n }\n\n const exceptionValue: Exception = {\n type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',\n value: getNonErrorObjectExceptionValue(exception, { isUnhandledRejection }),\n };\n\n const event = {\n exception: {\n values: [exceptionValue],\n },\n extra,\n } satisfies Event;\n\n if (syntheticException) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n // event.exception.values[0] has been set above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n event.exception.values[0]!.stacktrace = { frames };\n }\n }\n\n return event;\n}\n\nfunction eventFromError(stackParser: StackParser, ex: Error): Event {\n return {\n exception: {\n values: [exceptionFromError(stackParser, ex)],\n },\n };\n}\n\n/** Parses stack frames from an error */\nfunction parseStackFrames(\n stackParser: StackParser,\n ex: Error & { framesToPop?: number; stacktrace?: string },\n): StackFrame[] {\n // Access and store the stacktrace property before doing ANYTHING\n // else to it because Opera is not very good at providing it\n // reliably in other circumstances.\n const stacktrace = ex.stacktrace || ex.stack || '';\n\n const skipLines = getSkipFirstStackStringLines(ex);\n const framesToPop = getPopFirstTopFrames(ex);\n\n try {\n return stackParser(stacktrace, skipLines, framesToPop);\n } catch {\n // no-empty\n }\n\n return [];\n}\n\n// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108\nconst reactMinifiedRegexp = /Minified React error #\\d+;/i;\n\n/**\n * Certain known React errors contain links that would be falsely\n * parsed as frames. This function check for these errors and\n * returns number of the stack string lines to skip.\n */\nfunction getSkipFirstStackStringLines(ex: Error): number {\n if (ex && reactMinifiedRegexp.test(ex.message)) {\n return 1;\n }\n\n return 0;\n}\n\n/**\n * If error has `framesToPop` property, it means that the\n * creator tells us the first x frames will be useless\n * and should be discarded. Typically error from wrapper function\n * which don't point to the actual location in the developer's code.\n *\n * Example: https://github.com/zertosh/invariant/blob/master/invariant.js#L46\n */\nfunction getPopFirstTopFrames(ex: Error & { framesToPop?: unknown }): number {\n if (typeof ex.framesToPop === 'number') {\n return ex.framesToPop;\n }\n\n return 0;\n}\n\n// https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Exception\nfunction isWebAssemblyException(exception: unknown): exception is WebAssembly.Exception {\n // Check for support\n // oxlint-disable-next-line typescript/prefer-optional-chain\n if (typeof WebAssembly !== 'undefined' && typeof WebAssembly.Exception !== 'undefined') {\n return exception instanceof WebAssembly.Exception;\n } else {\n return false;\n }\n}\n\n/**\n * Extracts from errors what we use as the exception `type` in error events.\n *\n * Usually, this is the `name` property on Error objects but WASM errors need to be treated differently.\n */\nexport function extractType(ex: Error & { message: { error?: Error } }): string | undefined {\n const name = ex?.name;\n\n // The name for WebAssembly.Exception Errors needs to be extracted differently.\n // Context: https://github.com/getsentry/sentry-javascript/issues/13787\n if (!name && isWebAssemblyException(ex)) {\n // Emscripten sets array[type, message] to the \"message\" property on the WebAssembly.Exception object\n const hasTypeInMessage = ex.message && Array.isArray(ex.message) && ex.message.length == 2;\n return hasTypeInMessage ? ex.message[0] : 'WebAssembly.Exception';\n }\n\n return name;\n}\n\n/**\n * There are cases where stacktrace.message is an Event object\n * https://github.com/getsentry/sentry-javascript/issues/1949\n * In this specific case we try to extract stacktrace.message.error.message\n */\nexport function extractMessage(ex: Error & { message: { error?: Error } }): string {\n const message = ex?.message;\n\n if (isWebAssemblyException(ex)) {\n // For Node 18, Emscripten sets array[type, message] to the \"message\" property on the WebAssembly.Exception object\n if (Array.isArray(ex.message) && ex.message.length == 2) {\n return ex.message[1];\n }\n return 'wasm exception';\n }\n\n if (!message) {\n return 'No error message';\n }\n\n if (message.error && typeof message.error.message === 'string') {\n return _INTERNAL_enhanceErrorWithSentryInfo(message.error);\n }\n\n return _INTERNAL_enhanceErrorWithSentryInfo(ex);\n}\n\n/**\n * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.\n * @hidden\n */\nexport function eventFromException(\n stackParser: StackParser,\n exception: unknown,\n hint?: EventHint,\n attachStacktrace?: boolean,\n): PromiseLike<Event> {\n const syntheticException = hint?.syntheticException || undefined;\n const event = eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace);\n addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }\n event.level = 'error';\n if (hint?.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * Builds and Event from a Message\n * @hidden\n */\nexport function eventFromMessage(\n stackParser: StackParser,\n message: ParameterizedString,\n level: SeverityLevel = 'info',\n hint?: EventHint,\n attachStacktrace?: boolean,\n): PromiseLike<Event> {\n const syntheticException = hint?.syntheticException || undefined;\n const event = eventFromString(stackParser, message, syntheticException, attachStacktrace);\n event.level = level;\n if (hint?.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * @hidden\n */\nexport function eventFromUnknownInput(\n stackParser: StackParser,\n exception: unknown,\n syntheticException?: Error,\n attachStacktrace?: boolean,\n isUnhandledRejection?: boolean,\n): Event {\n let event: Event;\n\n if (isErrorEvent(exception) && (exception as ErrorEvent).error) {\n // If it is an ErrorEvent with `error` property, extract it to get actual Error\n const errorEvent = exception as ErrorEvent;\n return eventFromError(stackParser, errorEvent.error as Error);\n }\n\n // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name\n // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be\n // `Error`s, but that's not the case in IE11, so in that case we treat it the same as we do a `DOMError`.\n //\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMError\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMException\n // https://webidl.spec.whatwg.org/#es-DOMException-specialness\n if (isDOMError(exception) || isDOMException(exception)) {\n const domException = exception as DOMException;\n\n if ('stack' in (exception as Error)) {\n event = eventFromError(stackParser, exception as Error);\n\n const firstException = event.exception?.values?.[0];\n if (attachStacktrace && syntheticException && firstException && !firstException.stacktrace) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n firstException.stacktrace = { frames };\n addExceptionMechanism(event, { synthetic: true });\n }\n }\n } else {\n const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');\n const message = domException.message ? `${name}: ${domException.message}` : name;\n event = eventFromString(stackParser, message, syntheticException, attachStacktrace);\n addExceptionTypeValue(event, message);\n }\n if ('code' in domException) {\n // eslint-disable-next-line typescript/no-deprecated\n event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` };\n }\n\n return event;\n }\n if (isError(exception)) {\n // we have a real Error object, do nothing\n return eventFromError(stackParser, exception);\n }\n if (isPlainObject(exception) || isEvent(exception)) {\n // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize\n // it manually. This will allow us to group events based on top-level keys which is much better than creating a new\n // group on any key/value change.\n const objectException = exception;\n event = eventFromPlainObject(stackParser, objectException, syntheticException, isUnhandledRejection);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n return event;\n }\n\n // If none of previous checks were valid, then it means that it's not:\n // - an instance of DOMError\n // - an instance of DOMException\n // - an instance of Event\n // - an instance of Error\n // - a valid ErrorEvent (one with an error property)\n // - a plain Object\n //\n // So bail out and capture it as a simple message:\n const stringifiedException = String(exception);\n event = eventFromString(stackParser, stringifiedException, syntheticException, attachStacktrace);\n addExceptionTypeValue(event, stringifiedException, undefined);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n\n return event;\n}\n\nfunction eventFromString(\n stackParser: StackParser,\n message: ParameterizedString,\n syntheticException?: Error,\n attachStacktrace?: boolean,\n): Event {\n const event: Event = {};\n\n if (attachStacktrace && syntheticException) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n event.exception = {\n values: [{ value: message, stacktrace: { frames } }],\n };\n }\n addExceptionMechanism(event, { synthetic: true });\n }\n\n if (isParameterizedString(message)) {\n const { __sentry_template_string__, __sentry_template_values__ } = message;\n\n event.logentry = {\n message: __sentry_template_string__,\n params: __sentry_template_values__,\n };\n return event;\n }\n\n event.message = message;\n return event;\n}\n\nfunction getNonErrorObjectExceptionValue(\n exception: Record<string, unknown>,\n { isUnhandledRejection }: { isUnhandledRejection?: boolean },\n): string {\n const keys = extractExceptionKeysForMessage(exception);\n const captureType = isUnhandledRejection ? 'promise rejection' : 'exception';\n\n // Some ErrorEvent instances do not have an `error` property, which is why they are not handled before\n // We still want to try to get a decent message for these cases\n if (isErrorEvent(exception)) {\n return `Event \\`ErrorEvent\\` captured as ${captureType} with message \\`${exception.message}\\``;\n }\n\n if (isEvent(exception)) {\n const className = getObjectClassName(exception);\n return `Event \\`${className}\\` (type=${exception.type}) captured as ${captureType}`;\n }\n\n return `Object captured as ${captureType} with keys: ${keys}`;\n}\n\nfunction getObjectClassName(obj: unknown): string | undefined | void {\n try {\n const prototype: Prototype | null = Object.getPrototypeOf(obj);\n return prototype ? prototype.constructor.name : undefined;\n } catch {\n // ignore errors here\n }\n}\n\n/** If a plain object has a property that is an `Error`, return this error. */\nfunction getErrorPropertyFromObject(obj: Record<string, unknown>): Error | undefined {\n return Object.values(obj).find(isError);\n}\n"],"names":[],"mappings":";;AA+BO,SAAS,kBAAA,CAAmB,aAA0B,EAAA,EAAsB;AAEjF,EAAA,MAAM,MAAA,GAAS,gBAAA,CAAiB,WAAA,EAAa,EAAE,CAAA;AAE/C,EAAA,MAAM,SAAA,GAAuB;AAAA,IAC3B,IAAA,EAAM,YAAY,EAAE,CAAA;AAAA,IACpB,KAAA,EAAO,eAAe,EAAE;AAAA,GAC1B;AAEA,EAAA,IAAI,OAAO,MAAA,EAAQ;AACjB,IAAA,SAAA,CAAU,UAAA,GAAa,EAAE,MAAA,EAAO;AAAA,EAClC;AAEA,EAAA,IAAI,SAAA,CAAU,IAAA,KAAS,MAAA,IAAa,SAAA,CAAU,UAAU,EAAA,EAAI;AAC1D,IAAA,SAAA,CAAU,KAAA,GAAQ,4BAAA;AAAA,EACpB;AAEA,EAAA,OAAO,SAAA;AACT;AAEA,SAAS,oBAAA,CACP,WAAA,EACA,SAAA,EACA,kBAAA,EACA,oBAAA,EACO;AACP,EAAA,MAAM,SAAS,SAAA,EAAU;AACzB,EAAA,MAAM,cAAA,GAAiB,MAAA,EAAQ,UAAA,EAAW,CAAE,cAAA;AAG5C,EAAA,MAAM,aAAA,GAAgB,2BAA2B,SAAS,CAAA;AAE1D,EAAA,MAAM,KAAA,GAAQ;AAAA,IACZ,cAAA,EAAgB,eAAA,CAAgB,SAAA,EAAW,cAAc;AAAA,GAC3D;AAEA,EAAA,IAAI,aAAA,EAAe;AACjB,IAAA,OAAO;AAAA,MACL,SAAA,EAAW;AAAA,QACT,MAAA,EAAQ,CAAC,kBAAA,CAAmB,WAAA,EAAa,aAAa,CAAC;AAAA,OACzD;AAAA,MACA;AAAA,KACF;AAAA,EACF;AAEA,EAAA,MAAM,cAAA,GAA4B;AAAA,IAChC,IAAA,EAAM,QAAQ,SAAS,CAAA,GAAI,UAAU,WAAA,CAAY,IAAA,GAA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A,CAAe,GAAG,CAAA;AAC7D,IAAA,OAAO,SAAA,GAAY,SAAA,CAAU,WAAA,CAAY,IAAA,GAAO,KAAA,CAAA;AAAA,EAClD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAGA,SAAS,2BAA2B,GAAA,EAAiD;AACnF,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,GAAG,CAAA,CAAE,KAAK,OAAO,CAAA;AACxC;;;;"}
1
+ {"version":3,"file":"eventbuilder.js","sources":["../../../../src/eventbuilder.ts"],"sourcesContent":["import type {\n Event,\n EventHint,\n Exception,\n ParameterizedString,\n SeverityLevel,\n StackFrame,\n StackParser,\n} from '@sentry/core';\nimport {\n _INTERNAL_enhanceErrorWithSentryInfo,\n addExceptionMechanism,\n addExceptionTypeValue,\n extractExceptionKeysForMessage,\n getClient,\n isDOMError,\n isDOMException,\n isError,\n isErrorEvent,\n isEvent,\n isParameterizedString,\n isPlainObject,\n normalizeToSize,\n resolvedSyncPromise,\n} from '@sentry/core';\n\ntype Prototype = { constructor: (...args: unknown[]) => unknown };\n\n/**\n * This function creates an exception from a JavaScript Error\n */\nexport function exceptionFromError(stackParser: StackParser, ex: Error): Exception {\n // Get the frames first since Opera can lose the stack if we touch anything else first\n const frames = parseStackFrames(stackParser, ex);\n\n const exception: Exception = {\n type: extractType(ex),\n value: extractMessage(ex),\n };\n\n if (frames.length) {\n exception.stacktrace = { frames };\n }\n\n if (exception.type === undefined && exception.value === '') {\n exception.value = 'Unrecoverable error caught';\n }\n\n return exception;\n}\n\nfunction eventFromPlainObject(\n stackParser: StackParser,\n exception: Record<string, unknown>,\n syntheticException?: Error,\n isUnhandledRejection?: boolean,\n): Event {\n const client = getClient();\n const normalizeDepth = client?.getOptions().normalizeDepth;\n\n // If we can, we extract an exception from the object properties\n const errorFromProp = getErrorPropertyFromObject(exception);\n\n const extra = {\n __serialized__: normalizeToSize(exception, normalizeDepth),\n };\n\n if (errorFromProp) {\n return {\n exception: {\n values: [exceptionFromError(stackParser, errorFromProp)],\n },\n extra,\n };\n }\n\n const exceptionValue: Exception = {\n type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',\n value: getNonErrorObjectExceptionValue(exception, { isUnhandledRejection }),\n };\n\n const event = {\n exception: {\n values: [exceptionValue],\n },\n extra,\n } satisfies Event;\n\n if (syntheticException) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n // event.exception.values[0] has been set above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n event.exception.values[0]!.stacktrace = { frames };\n }\n }\n\n return event;\n}\n\nfunction eventFromError(stackParser: StackParser, ex: Error): Event {\n return {\n exception: {\n values: [exceptionFromError(stackParser, ex)],\n },\n };\n}\n\n/** Parses stack frames from an error */\nfunction parseStackFrames(\n stackParser: StackParser,\n ex: Error & { framesToPop?: number; stacktrace?: string },\n): StackFrame[] {\n // Access and store the stacktrace property before doing ANYTHING\n // else to it because Opera is not very good at providing it\n // reliably in other circumstances.\n const stacktrace = ex.stacktrace || ex.stack || '';\n\n const skipLines = getSkipFirstStackStringLines(ex);\n const framesToPop = getPopFirstTopFrames(ex);\n\n try {\n return stackParser(stacktrace, skipLines, framesToPop);\n } catch {\n // no-empty\n }\n\n return [];\n}\n\n// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108\nconst reactMinifiedRegexp = /Minified React error #\\d+;/i;\n\n/**\n * Certain known React errors contain links that would be falsely\n * parsed as frames. This function check for these errors and\n * returns number of the stack string lines to skip.\n */\nfunction getSkipFirstStackStringLines(ex: Error): number {\n if (ex && reactMinifiedRegexp.test(ex.message)) {\n return 1;\n }\n\n return 0;\n}\n\n/**\n * If error has `framesToPop` property, it means that the\n * creator tells us the first x frames will be useless\n * and should be discarded. Typically error from wrapper function\n * which don't point to the actual location in the developer's code.\n *\n * Example: https://github.com/zertosh/invariant/blob/master/invariant.js#L46\n */\nfunction getPopFirstTopFrames(ex: Error & { framesToPop?: unknown }): number {\n if (typeof ex.framesToPop === 'number') {\n return ex.framesToPop;\n }\n\n return 0;\n}\n\n// https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Exception\nfunction isWebAssemblyException(exception: unknown): exception is WebAssembly.Exception {\n // Check for support\n // oxlint-disable-next-line typescript/prefer-optional-chain\n if (typeof WebAssembly !== 'undefined' && typeof WebAssembly.Exception !== 'undefined') {\n return exception instanceof WebAssembly.Exception;\n } else {\n return false;\n }\n}\n\n/**\n * Extracts from errors what we use as the exception `type` in error events.\n *\n * Usually, this is the `name` property on Error objects but WASM errors need to be treated differently.\n */\nexport function extractType(ex: Error & { message: { error?: Error } }): string | undefined {\n const name = ex?.name;\n\n // The name for WebAssembly.Exception Errors needs to be extracted differently.\n // Context: https://github.com/getsentry/sentry-javascript/issues/13787\n if (!name && isWebAssemblyException(ex)) {\n // Emscripten sets array[type, message] to the \"message\" property on the WebAssembly.Exception object\n const hasTypeInMessage = ex.message && Array.isArray(ex.message) && ex.message.length == 2;\n return hasTypeInMessage ? ex.message[0] : 'WebAssembly.Exception';\n }\n\n return name;\n}\n\n/**\n * There are cases where stacktrace.message is an Event object\n * https://github.com/getsentry/sentry-javascript/issues/1949\n * In this specific case we try to extract stacktrace.message.error.message\n */\nexport function extractMessage(ex: Error & { message: { error?: Error } }): string {\n const message = ex?.message;\n\n if (isWebAssemblyException(ex)) {\n // For Node 18, Emscripten sets array[type, message] to the \"message\" property on the WebAssembly.Exception object\n if (Array.isArray(ex.message) && ex.message.length == 2) {\n return ex.message[1];\n }\n return 'wasm exception';\n }\n\n if (!message) {\n return 'No error message';\n }\n\n if (message.error && typeof message.error.message === 'string') {\n return _INTERNAL_enhanceErrorWithSentryInfo(message.error);\n }\n\n return _INTERNAL_enhanceErrorWithSentryInfo(ex);\n}\n\n/**\n * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.\n * @hidden\n */\nexport function eventFromException(\n stackParser: StackParser,\n exception: unknown,\n hint?: EventHint,\n attachStacktrace?: boolean,\n): PromiseLike<Event> {\n const syntheticException = hint?.syntheticException || undefined;\n const event = eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace);\n addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }\n event.level = 'error';\n if (hint?.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * Builds and Event from a Message\n * @hidden\n */\nexport function eventFromMessage(\n stackParser: StackParser,\n message: ParameterizedString,\n level: SeverityLevel = 'info',\n hint?: EventHint,\n attachStacktrace?: boolean,\n): PromiseLike<Event> {\n const syntheticException = hint?.syntheticException || undefined;\n const event = eventFromString(stackParser, message, syntheticException, attachStacktrace);\n event.level = level;\n if (hint?.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * @hidden\n */\nexport function eventFromUnknownInput(\n stackParser: StackParser,\n exception: unknown,\n syntheticException?: Error,\n attachStacktrace?: boolean,\n isUnhandledRejection?: boolean,\n): Event {\n let event: Event;\n\n if (isErrorEvent(exception) && (exception as ErrorEvent).error) {\n // If it is an ErrorEvent with `error` property, extract it to get actual Error\n const errorEvent = exception as ErrorEvent;\n return eventFromError(stackParser, errorEvent.error as Error);\n }\n\n // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name\n // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be\n // `Error`s, but that's not the case in IE11, so in that case we treat it the same as we do a `DOMError`.\n //\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMError\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMException\n // https://webidl.spec.whatwg.org/#es-DOMException-specialness\n if (isDOMError(exception) || isDOMException(exception)) {\n const domException = exception as DOMException;\n\n if ('stack' in (exception as Error)) {\n event = eventFromError(stackParser, exception as Error);\n\n const firstException = event.exception?.values?.[0];\n if (attachStacktrace && syntheticException && firstException && !firstException.stacktrace) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n firstException.stacktrace = { frames };\n addExceptionMechanism(event, { synthetic: true });\n }\n }\n } else {\n const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');\n const message = domException.message ? `${name}: ${domException.message}` : name;\n event = eventFromString(stackParser, message, syntheticException, attachStacktrace);\n addExceptionTypeValue(event, message);\n }\n if ('code' in domException) {\n // eslint-disable-next-line typescript/no-deprecated\n event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` };\n }\n\n return event;\n }\n if (isError(exception)) {\n // we have a real Error object, do nothing\n return eventFromError(stackParser, exception);\n }\n if (isPlainObject(exception) || isEvent(exception)) {\n // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize\n // it manually. This will allow us to group events based on top-level keys which is much better than creating a new\n // group on any key/value change.\n const objectException = exception;\n event = eventFromPlainObject(stackParser, objectException, syntheticException, isUnhandledRejection);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n return event;\n }\n\n // If none of previous checks were valid, then it means that it's not:\n // - an instance of DOMError\n // - an instance of DOMException\n // - an instance of Event\n // - an instance of Error\n // - a valid ErrorEvent (one with an error property)\n // - a plain Object\n //\n // So bail out and capture it as a simple message:\n const stringifiedException = String(exception);\n event = eventFromString(stackParser, stringifiedException, syntheticException, attachStacktrace);\n addExceptionTypeValue(event, stringifiedException, undefined);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n\n return event;\n}\n\nfunction eventFromString(\n stackParser: StackParser,\n message: ParameterizedString,\n syntheticException?: Error,\n attachStacktrace?: boolean,\n): Event {\n const event: Event = {};\n\n if (attachStacktrace && syntheticException) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n event.exception = {\n values: [{ value: message, stacktrace: { frames } }],\n };\n }\n addExceptionMechanism(event, { synthetic: true });\n }\n\n if (isParameterizedString(message)) {\n const { __sentry_template_string__, __sentry_template_values__ } = message;\n\n event.logentry = {\n message: __sentry_template_string__,\n params: __sentry_template_values__,\n };\n return event;\n }\n\n event.message = message;\n return event;\n}\n\nfunction getNonErrorObjectExceptionValue(\n exception: Record<string, unknown>,\n { isUnhandledRejection }: { isUnhandledRejection?: boolean },\n): string {\n const keys = extractExceptionKeysForMessage(exception);\n const captureType = isUnhandledRejection ? 'promise rejection' : 'exception';\n\n // Some ErrorEvent instances do not have an `error` property, which is why they are not handled before\n // We still want to try to get a decent message for these cases\n if (isErrorEvent(exception)) {\n return `Event \\`ErrorEvent\\` captured as ${captureType} with message \\`${exception.message}\\``;\n }\n\n if (isEvent(exception)) {\n const className = getObjectClassName(exception);\n return `Event \\`${className}\\` (type=${exception.type}) captured as ${captureType}`;\n }\n\n return `Object captured as ${captureType} with keys: ${keys}`;\n}\n\nfunction getObjectClassName(obj: unknown): string | undefined | void {\n try {\n const prototype: Prototype | null = Object.getPrototypeOf(obj);\n return prototype ? prototype.constructor.name : undefined;\n } catch {\n // ignore errors here\n }\n}\n\n/** If a plain object has a property that is an `Error`, return this error. */\nfunction getErrorPropertyFromObject(obj: Record<string, unknown>): Error | undefined {\n return Object.values(obj).find(isError);\n}\n"],"names":[],"mappings":";;AA+BO,SAAS,kBAAA,CAAmB,aAA0B,EAAA,EAAsB;AAEjF,EAAA,MAAM,MAAA,GAAS,gBAAA,CAAiB,WAAA,EAAa,EAAE,CAAA;AAE/C,EAAA,MAAM,SAAA,GAAuB;AAAA,IAC3B,IAAA,EAAM,YAAY,EAAE,CAAA;AAAA,IACpB,KAAA,EAAO,eAAe,EAAE;AAAA,GAC1B;AAEA,EAAA,IAAI,OAAO,MAAA,EAAQ;AACjB,IAAA,SAAA,CAAU,UAAA,GAAa,EAAE,MAAA,EAAO;AAAA,EAClC;AAEA,EAAA,IAAI,SAAA,CAAU,IAAA,KAAS,MAAA,IAAa,SAAA,CAAU,UAAU,EAAA,EAAI;AAC1D,IAAA,SAAA,CAAU,KAAA,GAAQ,4BAAA;AAAA,EACpB;AAEA,EAAA,OAAO,SAAA;A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AS,CAAA;AACrD,EAAA,MAAM,WAAA,GAAc,uBAAuB,mBAAA,GAAsB,WAAA;AAIjE,EAAA,IAAI,YAAA,CAAa,SAAS,CAAA,EAAG;AAC3B,IAAA,OAAO,CAAA,iCAAA,EAAoC,WAAW,CAAA,gBAAA,EAAmB,SAAA,CAAU,OAAO,CAAA,EAAA,CAAA;AAAA,EAC5F;AAEA,EAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG;AACtB,IAAA,MAAM,SAAA,GAAY,mBAAmB,SAAS,CAAA;AAC9C,IAAA,OAAO,WAAW,SAAS,CAAA,SAAA,EAAY,SAAA,CAAU,IAAI,iBAAiB,WAAW,CAAA,CAAA;AAAA,EACnF;AAEA,EAAA,OAAO,CAAA,mBAAA,EAAsB,WAAW,CAAA,YAAA,EAAe,IAAI,CAAA,CAAA;AAC7D;AAEA,SAAS,mBAAmB,GAAA,EAAyC;AACnE,EAAA,IAAI;AACF,IAAA,MAAM,SAAA,GAA8B,MAAA,CAAO,cAAA,CAAe,GAAG,CAAA;AAC7D,IAAA,OAAO,SAAA,GAAY,SAAA,CAAU,WAAA,CAAY,IAAA,GAAO,KAAA,CAAA;AAAA,EAClD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAGA,SAAS,2BAA2B,GAAA,EAAiD;AACnF,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,GAAG,CAAA,CAAE,KAAK,OAAO,CAAA;AACxC;;;;"}
@@ -1,4 +1,5 @@
1
- import { GLOBAL_OBJ, getOriginalFunction, markFunctionWrapped, addNonEnumerableProperty, withScope, addExceptionTypeValue, addExceptionMechanism, captureException, getLocationHref } from '@sentry/core/browser';
1
+ import { GLOBAL_OBJ, getOriginalFunction, markFunctionWrapped, addNonEnumerableProperty, withScope, addExceptionTypeValue, addExceptionMechanism, captureException } from '@sentry/core';
2
+ import { getLocationHref } from '@sentry/browser-utils';
2
3
 
3
4
  const WINDOW = GLOBAL_OBJ;
4
5
  let ignoreOnError = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../../src/helpers.ts"],"sourcesContent":["import type { Mechanism, WrappedFunction } from '@sentry/core/browser';\nimport {\n addExceptionMechanism,\n addExceptionTypeValue,\n addNonEnumerableProperty,\n captureException,\n getLocationHref,\n getOriginalFunction,\n GLOBAL_OBJ,\n markFunctionWrapped,\n withScope,\n} from '@sentry/core/browser';\n\nexport const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nlet ignoreOnError: number = 0;\n\n/**\n * @hidden\n */\nexport function shouldIgnoreOnError(): boolean {\n return ignoreOnError > 0;\n}\n\n/**\n * @hidden\n */\nexport function ignoreNextOnError(): void {\n // onerror should trigger before setTimeout\n ignoreOnError++;\n setTimeout(() => {\n ignoreOnError--;\n });\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\ntype WrappableFunction = Function;\n\nexport function wrap<T extends WrappableFunction>(\n fn: T,\n options?: {\n mechanism?: Mechanism;\n },\n): WrappedFunction<T>;\nexport function wrap<NonFunction>(\n fn: NonFunction,\n options?: {\n mechanism?: Mechanism;\n },\n): NonFunction;\n/**\n * Instruments the given function and sends an event to Sentry every time the\n * function throws an exception.\n *\n * @param fn A function to wrap. It is generally safe to pass an unbound function, because the returned wrapper always\n * has a correct `this` context.\n * @returns The wrapped function.\n * @hidden\n */\nexport function wrap<T extends WrappableFunction, NonFunction>(\n fn: T | NonFunction,\n options: {\n mechanism?: Mechanism;\n } = {},\n): NonFunction | WrappedFunction<T> {\n // for future readers what this does is wrap a function and then create\n // a bi-directional wrapping between them.\n //\n // example: wrapped = wrap(original);\n // original.__sentry_wrapped__ -> wrapped\n // wrapped.__sentry_original__ -> original\n\n function isFunction(fn: T | NonFunction): fn is T {\n return typeof fn === 'function';\n }\n\n if (!isFunction(fn)) {\n return fn;\n }\n\n try {\n // If we're dealing with a function that was previously wrapped, return the original wrapper.\n // Check via hasOwnProperty so a `__sentry_wrapped__` inherited from a wrapped `Function.prototype`\n // is not mistaken for a real wrapper.\n const hasOwnWrapper = Object.prototype.hasOwnProperty.call(fn, '__sentry_wrapped__');\n if (hasOwnWrapper) {\n const wrapper = (fn as WrappedFunction<T>).__sentry_wrapped__;\n if (typeof wrapper === 'function') {\n return wrapper;\n } else {\n // If we find that the `__sentry_wrapped__` function is not a function at the time of accessing it, it means\n // that something messed with it. In that case we want to return the originally passed function.\n return fn;\n }\n }\n\n // We don't wanna wrap it twice\n if (getOriginalFunction(fn)) {\n return fn;\n }\n } catch {\n // Just accessing custom props in some Selenium environments\n // can cause a \"Permission denied\" exception (see raven-js#495).\n // Bail on wrapping and return the function as-is (defers to window.onerror).\n return fn;\n }\n\n // Wrap the function itself\n // It is important that `sentryWrapped` is not an arrow function to preserve the context of `this`\n const sentryWrapped = function (this: unknown, ...args: unknown[]): unknown {\n // Track depth on GLOBAL_OBJ so the thirdPartyErrorFilterIntegration (in @sentry/core) can detect\n // that processEvent is running inside a sentryWrapped call, even with minified/bundled code.\n GLOBAL_OBJ._sentryWrappedDepth = (GLOBAL_OBJ._sentryWrappedDepth || 0) + 1;\n try {\n // Also wrap arguments that are themselves functions\n const wrappedArguments = args.map(arg => wrap(arg, options));\n\n // Attempt to invoke user-land function\n // NOTE: If you are a Sentry user, and you are seeing this stack frame, it\n // means the sentry.javascript SDK caught an error invoking your application code. This\n // is expected behavior and NOT indicative of a bug with sentry.javascript.\n return fn.apply(this, wrappedArguments);\n } catch (ex) {\n ignoreNextOnError();\n\n withScope(scope => {\n scope.addEventProcessor(event => {\n if (options.mechanism) {\n addExceptionTypeValue(event, undefined, undefined);\n addExceptionMechanism(event, options.mechanism);\n }\n\n event.extra = {\n ...event.extra,\n arguments: args,\n };\n\n return event;\n });\n\n // no need to add a mechanism here, we already add it via an event processor above\n captureException(ex);\n });\n\n throw ex;\n } finally {\n GLOBAL_OBJ._sentryWrappedDepth = (GLOBAL_OBJ._sentryWrappedDepth || 0) - 1;\n }\n } as unknown as WrappedFunction<T>;\n\n // Wrap the wrapped function in a proxy, to ensure any other properties of the original function remain available\n try {\n for (const property in fn) {\n if (Object.prototype.hasOwnProperty.call(fn, property)) {\n sentryWrapped[property as keyof T] = fn[property as keyof T];\n }\n }\n } catch {\n // Accessing some objects may throw\n // ref: https://github.com/getsentry/sentry-javascript/issues/1168\n }\n\n // Signal that this function has been wrapped/filled already\n // for both debugging and to prevent it to being wrapped/filled twice\n markFunctionWrapped(sentryWrapped, fn);\n\n addNonEnumerableProperty(fn, '__sentry_wrapped__', sentryWrapped);\n\n // Restore original function name (not all browsers allow that)\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, 'name')!;\n if (descriptor.configurable) {\n Object.defineProperty(sentryWrapped, 'name', {\n get(): string {\n return fn.name;\n },\n });\n }\n } catch {\n // This may throw if e.g. the descriptor does not exist, or a browser does not allow redefining `name`.\n // to save some bytes we simply try-catch this\n }\n\n return sentryWrapped;\n}\n\n/**\n * Get HTTP request data from the current page.\n */\nexport function getHttpRequestData(): { url: string; headers: Record<string, string> } {\n // grab as much info as exists and add it to the event\n const url = getLocationHref();\n const { referrer } = WINDOW.document || {};\n const { userAgent } = WINDOW.navigator || {};\n\n const headers = {\n ...(referrer && { Referer: referrer }),\n ...(userAgent && { 'User-Agent': userAgent }),\n };\n const request = {\n url,\n headers,\n };\n\n return request;\n}\n"],"names":["fn"],"mappings":";;AAaO,MAAM,MAAA,GAAS;AAEtB,IAAI,aAAA,GAAwB,CAAA;AAKrB,SAAS,mBAAA,GAA+B;AAC7C,EAAA,OAAO,aAAA,GAAgB,CAAA;AACzB;AAKO,SAAS,iBAAA,GAA0B;AAExC,EAAA,aAAA,EAAA;AACA,EAAA,UAAA,CAAW,MAAM;AACf,IAAA,aAAA,EAAA;AAAA,EACF,CAAC,CAAA;AACH;AA0BO,SAAS,IAAA,CACd,EAAA,EACA,OAAA,GAEI,EAAC,EAC6B;AAQlC,EAAA,SAAS,WAAWA,GAAAA,EAA8B;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B,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,MAAA,CAAO,YAAY,EAAC;AACzC,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,MAAA,CAAO,aAAa,EAAC;AAE3C,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAI,QAAA,IAAY,EAAE,OAAA,EAAS,QAAA,EAAS;AAAA,IACpC,GAAI,SAAA,IAAa,EAAE,YAAA,EAAc,SAAA;AAAU,GAC7C;AACA,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
1
+ {"version":3,"file":"helpers.js","sources":["../../../../src/helpers.ts"],"sourcesContent":["import type { Mechanism, WrappedFunction } from '@sentry/core';\nimport {\n addExceptionMechanism,\n addExceptionTypeValue,\n addNonEnumerableProperty,\n captureException,\n getOriginalFunction,\n GLOBAL_OBJ,\n markFunctionWrapped,\n withScope,\n} from '@sentry/core';\nimport { getLocationHref } from '@sentry/browser-utils';\n\nexport const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nlet ignoreOnError: number = 0;\n\n/**\n * @hidden\n */\nexport function shouldIgnoreOnError(): boolean {\n return ignoreOnError > 0;\n}\n\n/**\n * @hidden\n */\nexport function ignoreNextOnError(): void {\n // onerror should trigger before setTimeout\n ignoreOnError++;\n setTimeout(() => {\n ignoreOnError--;\n });\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\ntype WrappableFunction = Function;\n\nexport function wrap<T extends WrappableFunction>(\n fn: T,\n options?: {\n mechanism?: Mechanism;\n },\n): WrappedFunction<T>;\nexport function wrap<NonFunction>(\n fn: NonFunction,\n options?: {\n mechanism?: Mechanism;\n },\n): NonFunction;\n/**\n * Instruments the given function and sends an event to Sentry every time the\n * function throws an exception.\n *\n * @param fn A function to wrap. It is generally safe to pass an unbound function, because the returned wrapper always\n * has a correct `this` context.\n * @returns The wrapped function.\n * @hidden\n */\nexport function wrap<T extends WrappableFunction, NonFunction>(\n fn: T | NonFunction,\n options: {\n mechanism?: Mechanism;\n } = {},\n): NonFunction | WrappedFunction<T> {\n // for future readers what this does is wrap a function and then create\n // a bi-directional wrapping between them.\n //\n // example: wrapped = wrap(original);\n // original.__sentry_wrapped__ -> wrapped\n // wrapped.__sentry_original__ -> original\n\n function isFunction(fn: T | NonFunction): fn is T {\n return typeof fn === 'function';\n }\n\n if (!isFunction(fn)) {\n return fn;\n }\n\n try {\n // If we're dealing with a function that was previously wrapped, return the original wrapper.\n // Check via hasOwnProperty so a `__sentry_wrapped__` inherited from a wrapped `Function.prototype`\n // is not mistaken for a real wrapper.\n const hasOwnWrapper = Object.prototype.hasOwnProperty.call(fn, '__sentry_wrapped__');\n if (hasOwnWrapper) {\n const wrapper = (fn as WrappedFunction<T>).__sentry_wrapped__;\n if (typeof wrapper === 'function') {\n return wrapper;\n } else {\n // If we find that the `__sentry_wrapped__` function is not a function at the time of accessing it, it means\n // that something messed with it. In that case we want to return the originally passed function.\n return fn;\n }\n }\n\n // We don't wanna wrap it twice\n if (getOriginalFunction(fn)) {\n return fn;\n }\n } catch {\n // Just accessing custom props in some Selenium environments\n // can cause a \"Permission denied\" exception (see raven-js#495).\n // Bail on wrapping and return the function as-is (defers to window.onerror).\n return fn;\n }\n\n // Wrap the function itself\n // It is important that `sentryWrapped` is not an arrow function to preserve the context of `this`\n const sentryWrapped = function (this: unknown, ...args: unknown[]): unknown {\n // Track depth on GLOBAL_OBJ so the thirdPartyErrorFilterIntegration (in @sentry/core) can detect\n // that processEvent is running inside a sentryWrapped call, even with minified/bundled code.\n GLOBAL_OBJ._sentryWrappedDepth = (GLOBAL_OBJ._sentryWrappedDepth || 0) + 1;\n try {\n // Also wrap arguments that are themselves functions\n const wrappedArguments = args.map(arg => wrap(arg, options));\n\n // Attempt to invoke user-land function\n // NOTE: If you are a Sentry user, and you are seeing this stack frame, it\n // means the sentry.javascript SDK caught an error invoking your application code. This\n // is expected behavior and NOT indicative of a bug with sentry.javascript.\n return fn.apply(this, wrappedArguments);\n } catch (ex) {\n ignoreNextOnError();\n\n withScope(scope => {\n scope.addEventProcessor(event => {\n if (options.mechanism) {\n addExceptionTypeValue(event, undefined, undefined);\n addExceptionMechanism(event, options.mechanism);\n }\n\n event.extra = {\n ...event.extra,\n arguments: args,\n };\n\n return event;\n });\n\n // no need to add a mechanism here, we already add it via an event processor above\n captureException(ex);\n });\n\n throw ex;\n } finally {\n GLOBAL_OBJ._sentryWrappedDepth = (GLOBAL_OBJ._sentryWrappedDepth || 0) - 1;\n }\n } as unknown as WrappedFunction<T>;\n\n // Wrap the wrapped function in a proxy, to ensure any other properties of the original function remain available\n try {\n for (const property in fn) {\n if (Object.prototype.hasOwnProperty.call(fn, property)) {\n sentryWrapped[property as keyof T] = fn[property as keyof T];\n }\n }\n } catch {\n // Accessing some objects may throw\n // ref: https://github.com/getsentry/sentry-javascript/issues/1168\n }\n\n // Signal that this function has been wrapped/filled already\n // for both debugging and to prevent it to being wrapped/filled twice\n markFunctionWrapped(sentryWrapped, fn);\n\n addNonEnumerableProperty(fn, '__sentry_wrapped__', sentryWrapped);\n\n // Restore original function name (not all browsers allow that)\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, 'name')!;\n if (descriptor.configurable) {\n Object.defineProperty(sentryWrapped, 'name', {\n get(): string {\n return fn.name;\n },\n });\n }\n } catch {\n // This may throw if e.g. the descriptor does not exist, or a browser does not allow redefining `name`.\n // to save some bytes we simply try-catch this\n }\n\n return sentryWrapped;\n}\n\n/**\n * Get HTTP request data from the current page.\n */\nexport function getHttpRequestData(): { url: string; headers: Record<string, string> } {\n // grab as much info as exists and add it to the event\n const url = getLocationHref();\n const { referrer } = WINDOW.document || {};\n const { userAgent } = WINDOW.navigator || {};\n\n const headers = {\n ...(referrer && { Referer: referrer }),\n ...(userAgent && { 'User-Agent': userAgent }),\n };\n const request = {\n url,\n headers,\n };\n\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A,GAAa,MAAA,CAAO,wBAAA,CAAyB,aAAA,EAAe,MAAM,CAAA;AACxE,IAAA,IAAI,WAAW,YAAA,EAAc;AAC3B,MAAA,MAAA,CAAO,cAAA,CAAe,eAAe,MAAA,EAAQ;AAAA,QAC3C,GAAA,GAAc;AACZ,UAAA,OAAO,EAAA,CAAG,IAAA;AAAA,QACZ;AAAA,OACD,CAAA;AAAA,IACH;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAGR;AAEA,EAAA,OAAO,aAAA;AACT;AAKO,SAAS,kBAAA,GAAuE;AAErF,EAAA,MAAM,MAAM,eAAA,EAAgB;AAC5B,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,MAAA,CAAO,YAAY,EAAC;AACzC,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,MAAA,CAAO,aAAa,EAAC;AAE3C,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAI,QAAA,IAAY,EAAE,OAAA,EAAS,QAAA,EAAS;AAAA,IACpC,GAAI,SAAA,IAAa,EAAE,YAAA,EAAc,SAAA;AAAU,GAC7C;AACA,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
@@ -1,6 +1,6 @@
1
1
  export { feedbackAsyncIntegration } from './feedbackAsync.js';
2
2
  export { feedbackSyncIntegration as feedbackIntegration, feedbackSyncIntegration } from './feedbackSync.js';
3
- export { MULTIPLEXED_TRANSPORT_EXTRA_KEY, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, bindScopeToEmitter, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleLoggingIntegration, continueTrace, createConsolaReporter, createTransport, dedupeIntegration, endSession, eventFiltersIntegration, extraErrorDataIntegration, featureFlagsIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, instrumentSupabaseClient, isEnabled, isInitialized, lastEventId, logger, makeMultiplexedTransport, metrics, moduleMetadataIntegration, parameterize, registerSpanErrorInstrumentation, rewriteFramesIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, supabaseIntegration, suppressTracing, thirdPartyErrorFilterIntegration, updateSpanName, withActiveSpan, withIsolationScope, withScope, withStaticSpan, withStreamedSpan, zodErrorsIntegration } from '@sentry/core/browser';
3
+ export { MULTIPLEXED_TRANSPORT_EXTRA_KEY, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SENTRY_SEGMENT_NAME_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, bindScopeToEmitter, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleLoggingIntegration, continueTrace, createConsolaReporter, createTransport, dedupeIntegration, endSession, eventFiltersIntegration, extraErrorDataIntegration, featureFlagsIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, instrumentSupabaseClient, isEnabled, isInitialized, lastEventId, logger, makeMultiplexedTransport, metrics, moduleMetadataIntegration, parameterize, registerSpanErrorInstrumentation, rewriteFramesIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, startNewTrace, startSession, supabaseIntegration, suppressTracing, thirdPartyErrorFilterIntegration, updateSpanName, withActiveSpan, withIsolationScope, withScope, withStaticSpan, withStreamedSpan, zodErrorsIntegration } from '@sentry/core';
4
4
  export { WINDOW } from './helpers.js';
5
5
  export { BrowserClient } from './client.js';
6
6
  export { makeFetchTransport } from './transports/fetch.js';
@@ -26,14 +26,15 @@ export { getReplay, replayIntegration } from '@sentry/replay';
26
26
  export { replayCanvasIntegration } from '@sentry/replay-canvas';
27
27
  export { getFeedback, sendFeedback } from '@sentry/feedback';
28
28
  export { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from './tracing/request.js';
29
- export { browserTracingIntegration, isBotUserAgent, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } from './tracing/browserTracingIntegration.js';
30
- export { elementTimingIntegration, getAbsoluteUrl, userTimingIntegration } from '@sentry/browser-utils';
29
+ export { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } from './tracing/browserTracingIntegration.js';
30
+ export { elementTimingIntegration, getAbsoluteUrl, interactionsIntegration, isBotUserAgent, userTimingIntegration } from '@sentry/browser-utils';
31
31
  export { normalizeStringifyValue } from './normalizeStringifyValue.js';
32
32
  export { reportPageLoaded } from './tracing/reportPageLoaded.js';
33
33
  export { setActiveSpanInBrowser } from './tracing/setActiveSpan.js';
34
- export { spanStreamingIntegration } from './integrations/spanstreaming.js';
35
34
  export { fetchStreamPerformanceIntegration } from './integrations/fetchStreamPerformance.js';
36
35
  export { webVitalsIntegration } from './integrations/webVitals.js';
36
+ export { bfcacheMetricsIntegration } from './integrations/bfcacheMetrics.js';
37
+ export { startInactiveSpan, startSpan, startSpanManual } from '@sentry/core/browser';
37
38
  export { makeBrowserOfflineTransport } from './transports/offline.js';
38
39
  export { browserProfilingIntegration } from './profiling/integration.js';
39
40
  export { spotlightBrowserIntegration } from './integrations/spotlight.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,111 @@
1
+ import { SENTRY_ORIGIN, SENTRY_SEGMENT_NAME, BROWSER_BFCACHE_FRAME, BROWSER_BFCACHE_REASON, BROWSER_BFCACHE_NOT_RESTORED_REASON_COUNT, BROWSER_BFCACHE_OUTCOME } from '@sentry/conventions/attributes';
2
+ import { defineIntegration, debug, metrics, getCurrentScope } from '@sentry/core';
3
+ import { DEBUG_BUILD } from '../debug-build.js';
4
+ import { WINDOW } from '../helpers.js';
5
+
6
+ const INTEGRATION_NAME = "BfcacheMetrics";
7
+ const bfcacheMetricsIntegration = defineIntegration(
8
+ (options = {}) => {
9
+ const maxReasons = _resolveMaxReasons(options.maxReasons);
10
+ return {
11
+ name: INTEGRATION_NAME,
12
+ setupOnce() {
13
+ if (!WINDOW.addEventListener || !WINDOW.performance?.getEntriesByType) {
14
+ DEBUG_BUILD && debug.log(`[${INTEGRATION_NAME}] Browser APIs unavailable, skipping instrumentation.`);
15
+ return;
16
+ }
17
+ function onPageShow(event) {
18
+ const routeName = _getSegmentName();
19
+ if (event.persisted) {
20
+ _captureBFCacheNavigation("hit", 0, routeName);
21
+ return;
22
+ }
23
+ const navigationEntry = WINDOW.performance.getEntriesByType("navigation")[0];
24
+ if (navigationEntry?.type !== "back_forward") {
25
+ return;
26
+ }
27
+ const reasons = _collectNotRestoredReasons(navigationEntry.notRestoredReasons, maxReasons);
28
+ _captureBFCacheNavigation("miss", reasons.length, routeName);
29
+ if (typeof navigationEntry.duration === "number" && navigationEntry.duration > 0) {
30
+ metrics.distribution("browser.bfcache.reload.duration", navigationEntry.duration, {
31
+ unit: "millisecond",
32
+ attributes: _withOriginAttr({
33
+ [SENTRY_SEGMENT_NAME]: routeName
34
+ })
35
+ });
36
+ }
37
+ reasons.forEach((r) => _captureBFCacheReason(r, routeName));
38
+ }
39
+ WINDOW.addEventListener("pageshow", onPageShow, true);
40
+ }
41
+ };
42
+ }
43
+ );
44
+ function _captureBFCacheNavigation(outcome, reasonCount, routeName) {
45
+ metrics.count("browser.bfcache.navigation", 1, {
46
+ attributes: _withOriginAttr({
47
+ [BROWSER_BFCACHE_OUTCOME]: outcome,
48
+ // Attribute should be present if reasons are >= 1
49
+ [BROWSER_BFCACHE_NOT_RESTORED_REASON_COUNT]: reasonCount || void 0,
50
+ [SENTRY_SEGMENT_NAME]: routeName
51
+ })
52
+ });
53
+ }
54
+ function _captureBFCacheReason({ reason, frame }, routeName) {
55
+ metrics.count("browser.bfcache.not_restored", 1, {
56
+ attributes: _withOriginAttr({
57
+ [BROWSER_BFCACHE_REASON]: reason,
58
+ [BROWSER_BFCACHE_FRAME]: frame,
59
+ [SENTRY_SEGMENT_NAME]: routeName
60
+ })
61
+ });
62
+ }
63
+ function _getSegmentName() {
64
+ return getCurrentScope().getScopeData().transactionName || WINDOW.location?.pathname;
65
+ }
66
+ function _resolveMaxReasons(maxReasons) {
67
+ if (maxReasons == null) {
68
+ return Infinity;
69
+ }
70
+ if (maxReasons < 1) {
71
+ DEBUG_BUILD && debug.warn(`[${INTEGRATION_NAME}] \`maxReasons\` must be at least 1, got ${maxReasons}. Using 1 instead.`);
72
+ return 1;
73
+ }
74
+ return maxReasons;
75
+ }
76
+ function _collectNotRestoredReasons(notRestoredReasons, maxReasons) {
77
+ const reasons = [];
78
+ if (!notRestoredReasons || maxReasons <= 0) {
79
+ return reasons;
80
+ }
81
+ _collectReasonsFromFrame(notRestoredReasons, "top", reasons, maxReasons);
82
+ return reasons;
83
+ }
84
+ function _collectReasonsFromFrame(frame, frameType, collectedReasons, maxReasons) {
85
+ if (collectedReasons.length >= maxReasons) {
86
+ return;
87
+ }
88
+ frame.reasons?.forEach((reason) => {
89
+ if (collectedReasons.length >= maxReasons) {
90
+ return;
91
+ }
92
+ const reasonValue = typeof reason === "string" ? reason : reason.reason;
93
+ if (!reasonValue) {
94
+ return;
95
+ }
96
+ collectedReasons.push({
97
+ reason: reasonValue,
98
+ frame: frameType
99
+ });
100
+ });
101
+ frame.children?.forEach((child) => {
102
+ _collectReasonsFromFrame(child, "child", collectedReasons, maxReasons);
103
+ });
104
+ }
105
+ function _withOriginAttr(attributes) {
106
+ attributes[SENTRY_ORIGIN] = "auto.browser.bfcache";
107
+ return attributes;
108
+ }
109
+
110
+ export { _collectNotRestoredReasons, _resolveMaxReasons, bfcacheMetricsIntegration };
111
+ //# sourceMappingURL=bfcacheMetrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bfcacheMetrics.js","sources":["../../../../../src/integrations/bfcacheMetrics.ts"],"sourcesContent":["import {\n SENTRY_SEGMENT_NAME,\n BROWSER_BFCACHE_FRAME,\n BROWSER_BFCACHE_NOT_RESTORED_REASON_COUNT,\n BROWSER_BFCACHE_OUTCOME,\n BROWSER_BFCACHE_REASON,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport type { IntegrationFn, SpanAttributes } from '@sentry/core';\nimport { debug, defineIntegration, getCurrentScope, metrics } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\nconst INTEGRATION_NAME = 'BfcacheMetrics';\n\ntype BFCacheOutcome = 'hit' | 'miss';\n\ntype BFCacheFrame = 'top' | 'child';\n\ninterface BFCacheMetricsIntegrationOptions {\n /**\n * Maximum number of not-restored reasons to emit per miss.\n *\n * By default every reason is reported. Set this to cap the number emitted per miss.\n * Values below 1 are clamped to 1.\n */\n maxReasons: number;\n}\n\ninterface NotRestoredReason {\n reason?: string;\n}\n\ninterface NotRestoredReasons {\n children?: NotRestoredReasons[] | null;\n reasons?: (NotRestoredReason | string)[] | null;\n}\n\ninterface NavigationTimingWithNotRestoredReasons extends PerformanceNavigationTiming {\n notRestoredReasons?: NotRestoredReasons | null;\n}\n\ninterface CollectedReason {\n reason: string;\n frame: BFCacheFrame;\n}\n\n/**\n * Captures bfcache hit/miss counters and Chromium notRestoredReasons when available.\n */\nexport const bfcacheMetricsIntegration = defineIntegration(\n (options: Partial<BFCacheMetricsIntegrationOptions> = {}) => {\n const maxReasons = _resolveMaxReasons(options.maxReasons);\n\n return {\n name: INTEGRATION_NAME,\n\n setupOnce() {\n if (!WINDOW.addEventListener || !WINDOW.performance?.getEntriesByType) {\n DEBUG_BUILD && debug.log(`[${INTEGRATION_NAME}] Browser APIs unavailable, skipping instrumentation.`);\n return;\n }\n\n function onPageShow(event: PageTransitionEvent) {\n const routeName = _getSegmentName();\n if (event.persisted) {\n _captureBFCacheNavigation('hit', 0, routeName);\n return;\n }\n\n const navigationEntry = WINDOW.performance.getEntriesByType('navigation')[0] as\n | NavigationTimingWithNotRestoredReasons\n | undefined;\n\n if (navigationEntry?.type !== 'back_forward') {\n return;\n }\n\n const reasons = _collectNotRestoredReasons(navigationEntry.notRestoredReasons, maxReasons);\n _captureBFCacheNavigation('miss', reasons.length, routeName);\n\n // Measures how expensive the fallback reload was when a back/forward navigation missed bfcache.\n if (typeof navigationEntry.duration === 'number' && navigationEntry.duration > 0) {\n metrics.distribution('browser.bfcache.reload.duration', navigationEntry.duration, {\n unit: 'millisecond',\n attributes: _withOriginAttr({\n [SENTRY_SEGMENT_NAME]: routeName,\n }),\n });\n }\n\n reasons.forEach(r => _captureBFCacheReason(r, routeName));\n }\n\n // Listener should stay active because the event can trigger for an initial show before the bfcache entry coming into the second one.\n // This can be platform-dependent so we need to skip as many events till we get to the one containing the entry.\n // So we can't have { once } or a cleanup logic here, which is fine because `setupOnce` registers it a single time regardless of how many clients are created.\n WINDOW.addEventListener('pageshow', onPageShow, true);\n },\n };\n },\n) satisfies IntegrationFn;\n\n/**\n * Captures a bf navigation as a metric and records the outcome and reason count.\n */\nfunction _captureBFCacheNavigation(outcome: BFCacheOutcome, reasonCount: number, routeName?: string): void {\n metrics.count('browser.bfcache.navigation', 1, {\n attributes: _withOriginAttr({\n [BROWSER_BFCACHE_OUTCOME]: outcome,\n // Attribute should be present if reasons are >= 1\n [BROWSER_BFCACHE_NOT_RESTORED_REASON_COUNT]: reasonCount || undefined,\n [SENTRY_SEGMENT_NAME]: routeName,\n }),\n });\n}\n\n/**\n * Maps a collected reason to a metric and captures/sends it.\n */\nfunction _captureBFCacheReason({ reason, frame }: CollectedReason, routeName?: string) {\n metrics.count('browser.bfcache.not_restored', 1, {\n attributes: _withOriginAttr({\n [BROWSER_BFCACHE_REASON]: reason,\n [BROWSER_BFCACHE_FRAME]: frame,\n [SENTRY_SEGMENT_NAME]: routeName,\n }),\n });\n}\n\n/**\n * The segment name for a bfcache navigation, read from the scope rather than any span.\n *\n * A hit restore is silent to tracing (no pageload span), but the frozen scope still holds the last\n * transaction name a downstream SDK (Vue/React/etc.) set before the freeze, so we reuse that. On a miss the\n * page reloads with a fresh scope, so this is the new pageload name. Falls back to the raw pathname when unset.\n */\nfunction _getSegmentName(): string | undefined {\n return getCurrentScope().getScopeData().transactionName || WINDOW.location?.pathname;\n}\n\n/**\n * Resolves the configured `maxReasons` cap. Reports every reason by default and clamps values below 1 to 1,\n * since a cap under 1 would silently drop all reasons.\n *\n * Exported for tests only.\n */\nexport function _resolveMaxReasons(maxReasons: number | undefined): number {\n if (maxReasons == null) {\n return Infinity;\n }\n\n if (maxReasons < 1) {\n DEBUG_BUILD &&\n debug.warn(`[${INTEGRATION_NAME}] \\`maxReasons\\` must be at least 1, got ${maxReasons}. Using 1 instead.`);\n return 1;\n }\n\n return maxReasons;\n}\n\n/**\n * Flattens the (possibly nested) bfcache `notRestoredReasons` tree into a capped list of reasons.\n *\n * Exported for tests only.\n */\nexport function _collectNotRestoredReasons(\n notRestoredReasons: NotRestoredReasons | null | undefined,\n maxReasons: number,\n): CollectedReason[] {\n const reasons: CollectedReason[] = [];\n\n if (!notRestoredReasons || maxReasons <= 0) {\n return reasons;\n }\n\n _collectReasonsFromFrame(notRestoredReasons, 'top', reasons, maxReasons);\n\n return reasons;\n}\n\nfunction _collectReasonsFromFrame(\n frame: NotRestoredReasons,\n frameType: BFCacheFrame,\n collectedReasons: CollectedReason[],\n maxReasons: number,\n): void {\n if (collectedReasons.length >= maxReasons) {\n return;\n }\n\n frame.reasons?.forEach(reason => {\n if (collectedReasons.length >= maxReasons) {\n return;\n }\n\n const reasonValue = typeof reason === 'string' ? reason : reason.reason;\n if (!reasonValue) {\n return;\n }\n\n collectedReasons.push({\n reason: reasonValue,\n frame: frameType,\n });\n });\n\n frame.children?.forEach(child => {\n _collectReasonsFromFrame(child, 'child', collectedReasons, maxReasons);\n });\n}\n\n/**\n * Adds the origin attributes to a set of attributes, it mutates the original attributes.\n */\nfunction _withOriginAttr(attributes: SpanAttributes): SpanAttributes {\n attributes[SENTRY_ORIGIN] = 'auto.browser.bfcache';\n\n return attributes;\n}\n"],"names":[],"mappings":";;;;;AAaA,MAAM,gBAAA,GAAmB,gBAAA;AAqClB,MAAM,yBAAA,GAA4B,iBAAA;AAAA,EACvC,CAAC,OAAA,GAAqD,EAAC,KAAM;AAC3D,IAAA,MAAM,UAAA,GAAa,kBAAA,CAAmB,OAAA,CAAQ,UAAU,CAAA;AAExD,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,gBAAA;AAAA,MAEN,SAAA,GAAY;AACV,QAAA,IAAI,CAAC,MAAA,CAAO,gBAAA,IAAoB,CAAC,MAAA,CAAO,aAAa,gBAAA,EAAkB;AACrE,UAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,CAAA,CAAA,EAAI,gBAAgB,CAAA,qDAAA,CAAuD,CAAA;AACpG,UAAA;AAAA,QACF;AAEA,QAAA,SAAS,WAAW,KAAA,EAA4B;AAC9C,UAAA,MAAM,YAAY,eAAA,EAAgB;AAClC,UAAA,IAAI,MAAM,SAAA,EAAW;AACnB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AAS,QAAQ,CAAA,MAAA,KAAU;AAC/B,IAAA,IAAI,gBAAA,CAAiB,UAAU,UAAA,EAAY;AACzC,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,WAAA,GAAc,OAAO,MAAA,KAAW,QAAA,GAAW,SAAS,MAAA,CAAO,MAAA;AACjE,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA;AAAA,IACF;AAEA,IAAA,gBAAA,CAAiB,IAAA,CAAK;AAAA,MACpB,MAAA,EAAQ,WAAA;AAAA,MACR,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,EACH,CAAC,CAAA;AAED,EAAA,KAAA,CAAM,QAAA,EAAU,QAAQ,CAAA,KAAA,KAAS;AAC/B,IAAA,wBAAA,CAAyB,KAAA,EAAO,OAAA,EAAS,gBAAA,EAAkB,UAAU,CAAA;AAAA,EACvE,CAAC,CAAA;AACH;AAKA,SAAS,gBAAgB,UAAA,EAA4C;AACnE,EAAA,UAAA,CAAW,aAAa,CAAA,GAAI,sBAAA;AAE5B,EAAA,OAAO,UAAA;AACT;;;;"}
@@ -1,5 +1,5 @@
1
- import { defineIntegration, addConsoleInstrumentationHandler, addFetchInstrumentationHandler, getClient, safeJoin, severityLevelFromString, addBreadcrumb, debug, getComponentName, getBreadcrumbLogLevelFromHttpStatusCode, parseUrl, getEventDescription } from '@sentry/core/browser';
2
- import { addClickKeypressInstrumentationHandler, addXhrInstrumentationHandler, addHistoryInstrumentationHandler, htmlTreeAsString, SENTRY_XHR_DATA_KEY } from '@sentry/browser-utils';
1
+ import { defineIntegration, addConsoleInstrumentationHandler, addFetchInstrumentationHandler, getClient, safeJoin, severityLevelFromString, addBreadcrumb, debug, getBreadcrumbLogLevelFromHttpStatusCode, parseUrl, getEventDescription } from '@sentry/core';
2
+ import { addClickKeypressInstrumentationHandler, addXhrInstrumentationHandler, addHistoryInstrumentationHandler, htmlTreeAsString, getComponentName, SENTRY_XHR_DATA_KEY } from '@sentry/browser-utils';
3
3
  import { DEBUG_BUILD } from '../debug-build.js';
4
4
  import { WINDOW } from '../helpers.js';
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumbs.js","sources":["../../../../../src/integrations/breadcrumbs.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport type {\n Breadcrumb,\n Client,\n Event as SentryEvent,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataConsole,\n HandlerDataDom,\n HandlerDataFetch,\n HandlerDataHistory,\n HandlerDataXhr,\n IntegrationFn,\n XhrBreadcrumbData,\n XhrBreadcrumbHint,\n} from '@sentry/core/browser';\nimport {\n addBreadcrumb,\n addConsoleInstrumentationHandler,\n addFetchInstrumentationHandler,\n debug,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getComponentName,\n getEventDescription,\n parseUrl,\n safeJoin,\n severityLevelFromString,\n} from '@sentry/core/browser';\nimport type { FetchHint, XhrHint } from '@sentry/browser-utils';\nimport {\n addClickKeypressInstrumentationHandler,\n addHistoryInstrumentationHandler,\n addXhrInstrumentationHandler,\n htmlTreeAsString,\n SENTRY_XHR_DATA_KEY,\n} from '@sentry/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\ninterface BreadcrumbsOptions {\n console: boolean;\n dom:\n | boolean\n | {\n serializeAttribute?: string | string[];\n maxStringLength?: number;\n };\n fetch: boolean;\n history: boolean;\n sentry: boolean;\n xhr: boolean;\n}\n\n/** maxStringLength gets capped to prevent 100 breadcrumbs exceeding 1MB event payload size */\nconst MAX_ALLOWED_STRING_LENGTH = 1024;\n\nconst INTEGRATION_NAME = 'Breadcrumbs' as const;\n\nconst _breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) => {\n const _options = {\n console: true,\n dom: true,\n fetch: true,\n history: true,\n sentry: true,\n xhr: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n // TODO(v11): Remove this functionality and use `consoleIntegration` from @sentry/core instead.\n if (_options.console) {\n addConsoleInstrumentationHandler(_getConsoleBreadcrumbHandler(client));\n }\n if (_options.dom) {\n addClickKeypressInstrumentationHandler(_getDomBreadcrumbHandler(client, _options.dom));\n }\n if (_options.xhr) {\n addXhrInstrumentationHandler(_getXhrBreadcrumbHandler(client));\n }\n if (_options.fetch) {\n addFetchInstrumentationHandler(_getFetchBreadcrumbHandler(client));\n }\n if (_options.history) {\n addHistoryInstrumentationHandler(_getHistoryBreadcrumbHandler(client));\n }\n if (_options.sentry) {\n client.on('beforeSendEvent', _getSentryBreadcrumbHandler(client));\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const breadcrumbsIntegration = defineIntegration(_breadcrumbsIntegration);\n\n/**\n * Adds a breadcrumb for Sentry events or transactions if this option is enabled.\n */\nfunction _getSentryBreadcrumbHandler(client: Client): (event: SentryEvent) => void {\n return function addSentryBreadcrumb(event: SentryEvent): void {\n if (getClient() !== client) {\n return;\n }\n\n addBreadcrumb(\n {\n category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,\n event_id: event.event_id,\n level: event.level,\n message: getEventDescription(event),\n },\n {\n event,\n },\n );\n };\n}\n\n/**\n * A HOC that creates a function that creates breadcrumbs from DOM API calls.\n * This is a HOC so that we get access to dom options in the closure.\n */\nfunction _getDomBreadcrumbHandler(\n client: Client,\n dom: BreadcrumbsOptions['dom'],\n): (handlerData: HandlerDataDom) => void {\n return function _innerDomBreadcrumb(handlerData: HandlerDataDom): void {\n if (getClient() !== client) {\n return;\n }\n\n let target;\n let componentName;\n let keyAttrs = typeof dom === 'object' ? dom.serializeAttribute : undefined;\n\n let maxStringLength =\n typeof dom === 'object' && typeof dom.maxStringLength === 'number' ? dom.maxStringLength : undefined;\n if (maxStringLength && maxStringLength > MAX_ALLOWED_STRING_LENGTH) {\n DEBUG_BUILD &&\n debug.warn(\n `\\`dom.maxStringLength\\` cannot exceed ${MAX_ALLOWED_STRING_LENGTH}, but a value of ${maxStringLength} was configured. Sentry will use ${MAX_ALLOWED_STRING_LENGTH} instead.`,\n );\n maxStringLength = MAX_ALLOWED_STRING_LENGTH;\n }\n\n if (typeof keyAttrs === 'string') {\n keyAttrs = [keyAttrs];\n }\n\n // Accessing event.target can throw (see getsentry/raven-js#838, #768)\n try {\n const event = handlerData.event as Event | Node;\n const element = _isEvent(event) ? event.target : event;\n\n target = htmlTreeAsString(element, { keyAttrs, maxStringLength });\n componentName = getComponentName(element);\n } catch {\n target = '<unknown>';\n }\n\n if (target.length === 0) {\n return;\n }\n\n const breadcrumb: Breadcrumb = {\n category: `ui.${handlerData.name}`,\n message: target,\n };\n\n if (componentName) {\n breadcrumb.data = { 'ui.component_name': componentName };\n }\n\n addBreadcrumb(breadcrumb, {\n event: handlerData.event,\n name: handlerData.name,\n global: handlerData.global,\n });\n };\n}\n\n/**\n * Creates breadcrumbs from console API calls\n */\nfunction _getConsoleBreadcrumbHandler(client: Client): (handlerData: HandlerDataConsole) => void {\n return function _consoleBreadcrumb(handlerData: HandlerDataConsole): void {\n if (getClient() !== client) {\n return;\n }\n\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: handlerData.args,\n logger: 'console',\n },\n level: severityLevelFromString(handlerData.level),\n message: safeJoin(handlerData.args, ' '),\n };\n\n if (handlerData.level === 'assert') {\n if (handlerData.args[0] === false) {\n breadcrumb.message = `Assertion failed: ${safeJoin(handlerData.args.slice(1), ' ') || 'console.assert'}`;\n breadcrumb.data.arguments = handlerData.args.slice(1);\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: handlerData.args,\n level: handlerData.level,\n });\n };\n}\n\n/**\n * Creates breadcrumbs from XHR API calls\n */\nfunction _getXhrBreadcrumbHandler(client: Client): (handlerData: HandlerDataXhr) => void {\n return function _xhrBreadcrumb(handlerData: HandlerDataXhr): void {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n const sentryXhrData = handlerData.xhr[SENTRY_XHR_DATA_KEY];\n\n // We only capture complete, non-sentry requests\n if (!startTimestamp || !endTimestamp || !sentryXhrData) {\n return;\n }\n\n const { method, url, status_code, body } = sentryXhrData;\n\n const data: XhrBreadcrumbData = {\n method,\n url,\n status_code,\n };\n\n const hint: XhrBreadcrumbHint = {\n xhr: handlerData.xhr,\n input: body,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'xhr',\n data,\n type: 'http',\n level: getBreadcrumbLogLevelFromHttpStatusCode(status_code),\n };\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint as XhrHint);\n\n addBreadcrumb(breadcrumb, hint);\n };\n}\n\n/**\n * Creates breadcrumbs from fetch API calls\n */\nfunction _getFetchBreadcrumbHandler(client: Client): (handlerData: HandlerDataFetch) => void {\n return function _fetchBreadcrumb(handlerData: HandlerDataFetch): void {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n if (handlerData.fetchData.url.match(/sentry_key/) && handlerData.fetchData.method === 'POST') {\n // We will not create breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)\n return;\n }\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'fetch',\n data: handlerData.fetchData,\n level: 'error',\n type: 'http',\n } satisfies Breadcrumb;\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint as FetchHint);\n\n addBreadcrumb(breadcrumb, hint);\n } else {\n const response = handlerData.response as Response | undefined;\n const data: FetchBreadcrumbData = {\n ...handlerData.fetchData,\n status_code: response?.status,\n };\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'fetch',\n data,\n type: 'http',\n level: getBreadcrumbLogLevelFromHttpStatusCode(data.status_code),\n };\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint as FetchHint);\n\n addBreadcrumb(breadcrumb, hint);\n }\n };\n}\n\n/**\n * Creates breadcrumbs from history API calls\n */\nfunction _getHistoryBreadcrumbHandler(client: Client): (handlerData: HandlerDataHistory) => void {\n return function _historyBreadcrumb(handlerData: HandlerDataHistory): void {\n if (getClient() !== client) {\n return;\n }\n\n let from: string | undefined = handlerData.from;\n let to: string | undefined = handlerData.to;\n const parsedLoc = parseUrl(WINDOW.location.href);\n let parsedFrom = from ? parseUrl(from) : undefined;\n const parsedTo = parseUrl(to);\n\n // Initial pushState doesn't provide `from` information\n if (!parsedFrom?.path) {\n parsedFrom = parsedLoc;\n }\n\n // Use only the path component of the URL if the URL matches the current\n // document (almost all the time when using pushState)\n if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) {\n to = parsedTo.relative;\n }\n if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) {\n from = parsedFrom.relative;\n }\n\n addBreadcrumb({\n category: 'navigation',\n data: {\n from,\n to,\n },\n });\n };\n}\n\nfunction _isEvent(event: unknown): event is Event {\n return !!event && !!(event as Record<string, unknown>).target;\n}\n"],"names":[],"mappings":";;;;;AAyDA,MAAM,yBAAA,GAA4B,IAAA;AAElC,MAAM,gBAAA,GAAmB,aAAA;AAEzB,MAAM,uBAAA,IAA2B,CAAC,OAAA,GAAuC,EAAC,KAAM;AAC9E,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,OAAA,EAAS,IAAA;AAAA,IACT,GAAA,EAAK,IAAA;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,OAAA,EAAS,IAAA;AAAA,IACT,MAAA,EAAQ,IAAA;AAAA,IACR,GAAA,EAAK,IAAA;AAAA,IACL,GAAG;AAAA,GACL;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AAEZ,MAAA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,KAAA,CAAkC,MAAA;AACzD;;;;"}
1
+ {"version":3,"file":"breadcrumbs.js","sources":["../../../../../src/integrations/breadcrumbs.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport type {\n Breadcrumb,\n Client,\n Event as SentryEvent,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataConsole,\n HandlerDataFetch,\n IntegrationFn,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addConsoleInstrumentationHandler,\n addFetchInstrumentationHandler,\n debug,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getEventDescription,\n parseUrl,\n safeJoin,\n severityLevelFromString,\n} from '@sentry/core';\nimport type { FetchHint, HandlerDataDom, HandlerDataHistory, HandlerDataXhr } from '@sentry/browser-utils';\nimport {\n addClickKeypressInstrumentationHandler,\n addHistoryInstrumentationHandler,\n addXhrInstrumentationHandler,\n htmlTreeAsString,\n getComponentName,\n SENTRY_XHR_DATA_KEY,\n} from '@sentry/browser-utils';\nimport type { XhrBreadcrumbData, XhrBreadcrumbHint } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\ninterface BreadcrumbsOptions {\n console: boolean;\n dom:\n | boolean\n | {\n serializeAttribute?: string | string[];\n maxStringLength?: number;\n };\n fetch: boolean;\n history: boolean;\n sentry: boolean;\n xhr: boolean;\n}\n\n/** maxStringLength gets capped to prevent 100 breadcrumbs exceeding 1MB event payload size */\nconst MAX_ALLOWED_STRING_LENGTH = 1024;\n\nconst INTEGRATION_NAME = 'Breadcrumbs' as const;\n\nconst _breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) => {\n const _options = {\n console: true,\n dom: true,\n fetch: true,\n history: true,\n sentry: true,\n xhr: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n // TODO(v11): Remove this functionality and use `consoleIntegration` from @sentry/core instead.\n if (_options.console) {\n addConsoleInstrumentationHandler(_getConsoleBreadcrumbHandler(client));\n }\n if (_options.dom) {\n addClickKeypressInstrumentationHandler(_getDomBreadcrumbHandler(client, _options.dom));\n }\n if (_options.xhr) {\n addXhrInstrumentationHandler(_getXhrBreadcrumbHandler(client));\n }\n if (_options.fetch) {\n addFetchInstrumentationHandler(_getFetchBreadcrumbHandler(client));\n }\n if (_options.history) {\n addHistoryInstrumentationHandler(_getHistoryBreadcrumbHandler(client));\n }\n if (_options.sentry) {\n client.on('beforeSendEvent', _getSentryBreadcrumbHandler(client));\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const breadcrumbsIntegration = defineIntegration(_breadcrumbsIntegration);\n\n/**\n * Adds a breadcrumb for Sentry events or transactions if this option is enabled.\n */\nfunction _getSentryBreadcrumbHandler(client: Client): (event: SentryEvent) => void {\n return function addSentryBreadcrumb(event: SentryEvent): void {\n if (getClient() !== client) {\n return;\n }\n\n addBreadcrumb(\n {\n category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,\n event_id: event.event_id,\n level: event.level,\n message: getEventDescription(event),\n },\n {\n event,\n },\n );\n };\n}\n\n/**\n * A HOC that creates a function that creates breadcrumbs from DOM API calls.\n * This is a HOC so that we get access to dom options in the closure.\n */\nfunction _getDomBreadcrumbHandler(\n client: Client,\n dom: BreadcrumbsOptions['dom'],\n): (handlerData: HandlerDataDom) => void {\n return function _innerDomBreadcrumb(handlerData: HandlerDataDom): void {\n if (getClient() !== client) {\n return;\n }\n\n let target;\n let componentName;\n let keyAttrs = typeof dom === 'object' ? dom.serializeAttribute : undefined;\n\n let maxStringLength =\n typeof dom === 'object' && typeof dom.maxStringLength === 'number' ? dom.maxStringLength : undefined;\n if (maxStringLength && maxStringLength > MAX_ALLOWED_STRING_LENGTH) {\n DEBUG_BUILD &&\n debug.warn(\n `\\`dom.maxStringLength\\` cannot exceed ${MAX_ALLOWED_STRING_LENGTH}, but a value of ${maxStringLength} was configured. Sentry will use ${MAX_ALLOWED_STRING_LENGTH} instead.`,\n );\n maxStringLength = MAX_ALLOWED_STRING_LENGTH;\n }\n\n if (typeof keyAttrs === 'string') {\n keyAttrs = [keyAttrs];\n }\n\n // Accessing event.target can throw (see getsentry/raven-js#838, #768)\n try {\n const event = handlerData.event as Event | Node;\n const element = _isEvent(event) ? event.target : event;\n\n target = htmlTreeAsString(element, { keyAttrs, maxStringLength });\n componentName = getComponentName(element);\n } catch {\n target = '<unknown>';\n }\n\n if (target.length === 0) {\n return;\n }\n\n const breadcrumb: Breadcrumb = {\n category: `ui.${handlerData.name}`,\n message: target,\n };\n\n if (componentName) {\n breadcrumb.data = { 'ui.component_name': componentName };\n }\n\n addBreadcrumb(breadcrumb, {\n event: handlerData.event,\n name: handlerData.name,\n global: handlerData.global,\n });\n };\n}\n\n/**\n * Creates breadcrumbs from console API calls\n */\nfunction _getConsoleBreadcrumbHandler(client: Client): (handlerData: HandlerDataConsole) => void {\n return function _consoleBreadcrumb(handlerData: HandlerDataConsole): void {\n if (getClient() !== client) {\n return;\n }\n\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: handlerData.args,\n logger: 'console',\n },\n level: severityLevelFromString(handlerData.level),\n message: safeJoin(handlerData.args, ' '),\n };\n\n if (handlerData.level === 'assert') {\n if (handlerData.args[0] === false) {\n breadcrumb.message = `Assertion failed: ${safeJoin(handlerData.args.slice(1), ' ') || 'console.assert'}`;\n breadcrumb.data.arguments = handlerData.args.slice(1);\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: handlerData.args,\n level: handlerData.level,\n });\n };\n}\n\n/**\n * Creates breadcrumbs from XHR API calls\n */\nfunction _getXhrBreadcrumbHandler(client: Client): (handlerData: HandlerDataXhr) => void {\n return function _xhrBreadcrumb(handlerData: HandlerDataXhr): void {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n const sentryXhrData = handlerData.xhr[SENTRY_XHR_DATA_KEY];\n\n // We only capture complete, non-sentry requests\n if (!startTimestamp || !endTimestamp || !sentryXhrData) {\n return;\n }\n\n const { method, url, status_code, body } = sentryXhrData;\n\n const data: XhrBreadcrumbData = {\n method,\n url,\n status_code,\n };\n\n const hint: XhrBreadcrumbHint = {\n xhr: handlerData.xhr,\n input: body,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'xhr',\n data,\n type: 'http',\n level: getBreadcrumbLogLevelFromHttpStatusCode(status_code),\n };\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint);\n\n addBreadcrumb(breadcrumb, hint);\n };\n}\n\n/**\n * Creates breadcrumbs from fetch API calls\n */\nfunction _getFetchBreadcrumbHandler(client: Client): (handlerData: HandlerDataFetch) => void {\n return function _fetchBreadcrumb(handlerData: HandlerDataFetch): void {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n if (handlerData.fetchData.url.match(/sentry_key/) && handlerData.fetchData.method === 'POST') {\n // We will not create breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)\n return;\n }\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'fetch',\n data: handlerData.fetchData,\n level: 'error',\n type: 'http',\n } satisfies Breadcrumb;\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint as FetchHint);\n\n addBreadcrumb(breadcrumb, hint);\n } else {\n const response = handlerData.response as Response | undefined;\n const data: FetchBreadcrumbData = {\n ...handlerData.fetchData,\n status_code: response?.status,\n };\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n\n const breadcrumb = {\n category: 'fetch',\n data,\n type: 'http',\n level: getBreadcrumbLogLevelFromHttpStatusCode(data.status_code),\n };\n\n client.emit('beforeOutgoingRequestBreadcrumb', breadcrumb, hint as FetchHint);\n\n addBreadcrumb(breadcrumb, hint);\n }\n };\n}\n\n/**\n * Creates breadcrumbs from history API calls\n */\nfunction _getHistoryBreadcrumbHandler(client: Client): (handlerData: HandlerDataHistory) => void {\n return function _historyBreadcrumb(handlerData: HandlerDataHistory): void {\n if (getClient() !== client) {\n return;\n }\n\n let from: string | undefined = handlerData.from;\n let to: string | undefined = handlerData.to;\n const parsedLoc = parseUrl(WINDOW.location.href);\n let parsedFrom = from ? parseUrl(from) : undefined;\n const parsedTo = parseUrl(to);\n\n // Initial pushState doesn't provide `from` information\n if (!parsedFrom?.path) {\n parsedFrom = parsedLoc;\n }\n\n // Use only the path component of the URL if the URL matches the current\n // document (almost all the time when using pushState)\n if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) {\n to = parsedTo.relative;\n }\n if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) {\n from = parsedFrom.relative;\n }\n\n addBreadcrumb({\n category: 'navigation',\n data: {\n from,\n to,\n },\n });\n };\n}\n\nfunction _isEvent(event: unknown): event is Event {\n return !!event && !!(event as Record<string, unknown>).target;\n}\n"],"names":[],"mappings":";;;;;AAqDA,MAAM,yBAAA,GAA4B,IAAA;AAElC,MAAM,gBAAA,GAAmB,aAAA;AAEzB,MAAM,uBAAA,IAA2B,CAAC,OAAA,GAAuC,EAAC,KAAM;AAC9E,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,OAAA,EAAS,IAAA;AAAA,IACT,GAAA,EAAK,IAAA;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,OAAA,EAAS,IAAA;AAAA,IACT,MAAA,EAAQ,IAAA;AAAA,IACR,GAAA,EAAK,IAAA;AAAA,IACL,GAAG;AAAA,GACL;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AAEZ,MAAA,IAAI,SAAS,OAAA,EAAS;AACpB,QAAA,gCAAA,CA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4 @@
1
- import { defineIntegration, fill, getFunctionName, getOriginalFunction } from '@sentry/core/browser';
1
+ import { defineIntegration, fill, getFunctionName, getOriginalFunction } from '@sentry/core';
2
2
  import { WINDOW, wrap } from '../helpers.js';
3
3
 
4
4
  const DEFAULT_EVENT_TARGET = "EventTarget,Window,Node,ApplicationCache,AudioTrackList,BroadcastChannel,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(
@@ -1 +1 @@
1
- {"version":3,"file":"browserapierrors.js","sources":["../../../../../src/integrations/browserapierrors.ts"],"sourcesContent":["import type { IntegrationFn, WrappedFunction } from '@sentry/core/browser';\nimport { defineIntegration, fill, getFunctionName, getOriginalFunction } from '@sentry/core/browser';\nimport { WINDOW, wrap } from '../helpers';\n\n// Using a comma-separated string and split for smaller bundle size vs an array literal\nconst DEFAULT_EVENT_TARGET =\n 'EventTarget,Window,Node,ApplicationCache,AudioTrackList,BroadcastChannel,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload'.split(\n ',',\n );\n\nconst INTEGRATION_NAME = 'BrowserApiErrors' as const;\n\ntype XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange';\n\ninterface BrowserApiErrorsOptions {\n setTimeout: boolean;\n setInterval: boolean;\n requestAnimationFrame: boolean;\n XMLHttpRequest: boolean;\n eventTarget: boolean | string[];\n\n /**\n * If you experience issues with this integration causing double-invocations of event listeners,\n * try setting this option to `true`. It will unregister the original callbacks from the event targets\n * before adding the instrumented callback.\n *\n * @default false\n */\n unregisterOriginalCallbacks: boolean;\n}\n\nconst _browserApiErrorsIntegration = ((options: Partial<BrowserApiErrorsOptions> = {}) => {\n const _options = {\n XMLHttpRequest: true,\n eventTarget: true,\n requestAnimationFrame: true,\n setInterval: true,\n setTimeout: true,\n unregisterOriginalCallbacks: false,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n // TODO: This currently only works for the first client this is setup\n // We may want to adjust this to check for client etc.\n setupOnce() {\n if (_options.setTimeout) {\n fill(WINDOW, 'setTimeout', _wrapTimeFunction);\n }\n\n if (_options.setInterval) {\n fill(WINDOW, 'setInterval', _wrapTimeFunction);\n }\n\n if (_options.requestAnimationFrame) {\n fill(WINDOW, 'requestAnimationFrame', _wrapRAF);\n }\n\n if (_options.XMLHttpRequest && 'XMLHttpRequest' in WINDOW) {\n fill(XMLHttpRequest.prototype, 'send', _wrapXHR);\n }\n\n const eventTargetOption = _options.eventTarget;\n if (eventTargetOption) {\n const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;\n eventTarget.forEach(target => _wrapEventTarget(target, _options));\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Wrap timer functions and event targets to catch errors and provide better meta data.\n */\nexport const browserApiErrorsIntegration = defineIntegration(_browserApiErrorsIntegration);\n\nfunction _wrapTimeFunction(original: () => void): () => number {\n return function (this: unknown, ...args: unknown[]): number {\n const originalCallback = args[0];\n args[0] = wrap(originalCallback, {\n mechanism: {\n handled: false,\n type: `auto.browser.browserapierrors.${getFunctionName(original)}`,\n },\n });\n return original.apply(this, args);\n };\n}\n\nfunction _wrapRAF(original: () => void): (callback: () => void) => unknown {\n return function (this: unknown, callback: () => void): () => void {\n return original.apply(this, [\n wrap(callback, {\n mechanism: {\n data: {\n handler: getFunctionName(original),\n },\n handled: false,\n type: 'auto.browser.browserapierrors.requestAnimationFrame',\n },\n }),\n ]);\n };\n}\n\nfunction _wrapXHR(originalSend: () => void): () => void {\n return function (this: XMLHttpRequest, ...args: unknown[]): void {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const xhr = this;\n const xmlHttpRequestProps: XMLHttpRequestProp[] = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];\n\n xmlHttpRequestProps.forEach(prop => {\n if (prop in xhr && typeof xhr[prop] === 'function') {\n fill(xhr, prop, function (original) {\n const wrapOptions = {\n mechanism: {\n data: {\n handler: getFunctionName(original),\n },\n handled: false,\n type: `auto.browser.browserapierrors.xhr.${prop}`,\n },\n };\n\n // If Instrument integration has been called before BrowserApiErrors, get the name of original function\n const originalFunction = getOriginalFunction(original);\n if (originalFunction) {\n wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);\n }\n\n // Otherwise wrap directly\n return wrap(original, wrapOptions);\n });\n }\n });\n\n return originalSend.apply(this, args);\n };\n}\n\nfunction _wrapEventTarget(target: string, integrationOptions: BrowserApiErrorsOptions): void {\n const globalObject = WINDOW as unknown as Record<string, { prototype?: object }>;\n const proto = globalObject[target]?.prototype;\n\n // eslint-disable-next-line no-prototype-builtins\n if (!proto?.hasOwnProperty?.('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function (original: VoidFunction): (\n ...args: Parameters<typeof WINDOW.addEventListener>\n ) => ReturnType<typeof WINDOW.addEventListener> {\n return function (this: unknown, eventName, fn, options): VoidFunction {\n try {\n if (isEventListenerObject(fn)) {\n // ESlint disable explanation:\n // First, it is generally safe to call `wrap` with an unbound function. Furthermore, using `.bind()` would\n // introduce a bug here, because bind returns a new function that doesn't have our\n // flags(like __sentry_original__) attached. `wrap` checks for those flags to avoid unnecessary wrapping.\n // Without those flags, every call to addEventListener wraps the function again, causing a memory leak.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n fn.handleEvent = wrap(fn.handleEvent, {\n mechanism: {\n data: {\n handler: getFunctionName(fn),\n target,\n },\n handled: false,\n type: 'auto.browser.browserapierrors.handleEvent',\n },\n });\n }\n } catch {\n // can sometimes get 'Permission denied to access property \"handle Event'\n }\n\n if (integrationOptions.unregisterOriginalCallbacks) {\n unregisterOriginalCallback(this, eventName, fn);\n }\n\n return original.apply(this, [\n eventName,\n wrap(fn, {\n mechanism: {\n data: {\n handler: getFunctionName(fn),\n target,\n },\n handled: false,\n type: 'auto.browser.browserapierrors.addEventListener',\n },\n }),\n options,\n ]);\n };\n });\n\n fill(proto, 'removeEventListener', function (originalRemoveEventListener: VoidFunction): (\n this: unknown,\n ...args: Parameters<typeof WINDOW.removeEventListener>\n ) => ReturnType<typeof WINDOW.removeEventListener> {\n return function (this: unknown, eventName, fn, options): VoidFunction {\n /**\n * There are 2 possible scenarios here:\n *\n * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified\n * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function\n * as a pass-through, and call original `removeEventListener` with it.\n *\n * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using\n * our wrapped version of `addEventListener`, which internally calls `wrap` helper.\n * This helper \"wraps\" whole callback inside a try/catch statement, and attached appropriate metadata to it,\n * in order for us to make a distinction between wrapped/non-wrapped functions possible.\n * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.\n *\n * When someone adds a handler prior to initialization, and then do it again, but after,\n * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible\n * to get rid of the initial handler and it'd stick there forever.\n */\n try {\n // Check via hasOwnProperty so a `__sentry_wrapped__` inherited from a wrapped\n // `Function.prototype` doesn't cause removal of the wrong handler.\n if (Object.prototype.hasOwnProperty.call(fn, '__sentry_wrapped__')) {\n const originalEventHandler = (fn as WrappedFunction).__sentry_wrapped__;\n if (originalEventHandler) {\n originalRemoveEventListener.call(this, eventName, originalEventHandler, options);\n }\n }\n } catch {\n // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments\n }\n return originalRemoveEventListener.call(this, eventName, fn, options);\n };\n });\n}\n\nfunction isEventListenerObject(obj: unknown): obj is EventListenerObject {\n return typeof (obj as EventListenerObject).handleEvent === 'function';\n}\n\nfunction unregisterOriginalCallback(target: unknown, eventName: string, fn: EventListenerOrEventListenerObject): void {\n if (\n target &&\n typeof target === 'object' &&\n 'removeEventListener' in target &&\n typeof target.removeEventListener === 'function'\n ) {\n target.removeEventListener(eventName, fn);\n }\n}\n"],"names":[],"mappings":";;;AAKA,MAAM,uBACJ,yaAAA,CAA0a,KAAA;AAAA,EACxa;AACF,CAAA;AAEF,MAAM,gBAAA,GAAmB,kBAAA;AAqBzB,MAAM,4BAAA,IAAgC,CAAC,OAAA,GAA4C,EAAC,KAAM;AACxF,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,cAAA,EAAgB,IAAA;AAAA,IAChB,WAAA,EAAa,IAAA;AAAA,IACb,qBAAA,EAAuB,IAAA;AAAA,IACvB,WAAA,EAAa,IAAA;AAAA,IACb,UAAA,EAAY,IAAA;AAAA,IACZ,2BAAA,EAA6B,KAAA;AAAA,IAC7B,GAAG;AAAA,GACL;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA;AAAA;AAAA,IAGN,SAAA,GAAY;AACV,MAAA,IAAI,SAAS,UAAA,EAAY;AACvB,QAAA,IAAA,CAAK,MAAA,EAAQ,cAAc,iBAAiB,CAAA;AAAA,MAC9C;AAEA,MAAA,IAAI,SAAS,WAAA,EAAa;AACxB,QAAA,IAAA,CAAK,MAAA,EAAQ,eAAe,iBAAiB,CAAA;AAAA,MAC/C;AAEA,MAAA,IAAI,SAAS,qBAAA,EAAuB;AAClC,QAAA,IAAA,CAAK,MAAA,EAAQ,yBAAyB,QAAQ,CAAA;AAAA,MAChD;AAEA,MAAA,IAAI,QAAA,CAAS,cAAA,IAAkB,gBAAA,IAAoB,MAAA,EAAQ;AACzD,QAAA,IAAA,CAAK,cAAA,CAAe,SAAA,EAAW,MAAA,EAAQ,QAAQ,CAAA;AAAA,MACjD;A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YAAA,2BAAA,CAA4B,IAAA,CAAK,IAAA,EAAM,SAAA,EAAW,oBAAA,EAAsB,OAAO,CAAA;AAAA,UACjF;AAAA,QACF;AAAA,MACF,CAAA,CAAA,MAAQ;AAAA,MAER;AACA,MAAA,OAAO,2BAAA,CAA4B,IAAA,CAAK,IAAA,EAAM,SAAA,EAAW,IAAI,OAAO,CAAA;AAAA,IACtE,CAAA;AAAA,EACF,CAAC,CAAA;AACH;AAEA,SAAS,sBAAsB,GAAA,EAA0C;AACvE,EAAA,OAAO,OAAQ,IAA4B,WAAA,KAAgB,UAAA;AAC7D;AAEA,SAAS,0BAAA,CAA2B,MAAA,EAAiB,SAAA,EAAmB,EAAA,EAA8C;AACpH,EAAA,IACE,MAAA,IACA,OAAO,MAAA,KAAW,QAAA,IAClB,yBAAyB,MAAA,IACzB,OAAO,MAAA,CAAO,mBAAA,KAAwB,UAAA,EACtC;AACA,IAAA,MAAA,CAAO,mBAAA,CAAoB,WAAW,EAAE,CAAA;AAAA,EAC1C;AACF;;;;"}
1
+ {"version":3,"file":"browserapierrors.js","sources":["../../../../../src/integrations/browserapierrors.ts"],"sourcesContent":["import type { IntegrationFn, WrappedFunction } from '@sentry/core';\nimport { defineIntegration, fill, getFunctionName, getOriginalFunction } from '@sentry/core';\nimport { WINDOW, wrap } from '../helpers';\n\n// Using a comma-separated string and split for smaller bundle size vs an array literal\nconst DEFAULT_EVENT_TARGET =\n 'EventTarget,Window,Node,ApplicationCache,AudioTrackList,BroadcastChannel,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload'.split(\n ',',\n );\n\nconst INTEGRATION_NAME = 'BrowserApiErrors' as const;\n\ntype XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange';\n\ninterface BrowserApiErrorsOptions {\n setTimeout: boolean;\n setInterval: boolean;\n requestAnimationFrame: boolean;\n XMLHttpRequest: boolean;\n eventTarget: boolean | string[];\n\n /**\n * If you experience issues with this integration causing double-invocations of event listeners,\n * try setting this option to `true`. It will unregister the original callbacks from the event targets\n * before adding the instrumented callback.\n *\n * @default false\n */\n unregisterOriginalCallbacks: boolean;\n}\n\nconst _browserApiErrorsIntegration = ((options: Partial<BrowserApiErrorsOptions> = {}) => {\n const _options = {\n XMLHttpRequest: true,\n eventTarget: true,\n requestAnimationFrame: true,\n setInterval: true,\n setTimeout: true,\n unregisterOriginalCallbacks: false,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n // TODO: This currently only works for the first client this is setup\n // We may want to adjust this to check for client etc.\n setupOnce() {\n if (_options.setTimeout) {\n fill(WINDOW, 'setTimeout', _wrapTimeFunction);\n }\n\n if (_options.setInterval) {\n fill(WINDOW, 'setInterval', _wrapTimeFunction);\n }\n\n if (_options.requestAnimationFrame) {\n fill(WINDOW, 'requestAnimationFrame', _wrapRAF);\n }\n\n if (_options.XMLHttpRequest && 'XMLHttpRequest' in WINDOW) {\n fill(XMLHttpRequest.prototype, 'send', _wrapXHR);\n }\n\n const eventTargetOption = _options.eventTarget;\n if (eventTargetOption) {\n const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;\n eventTarget.forEach(target => _wrapEventTarget(target, _options));\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Wrap timer functions and event targets to catch errors and provide better meta data.\n */\nexport const browserApiErrorsIntegration = defineIntegration(_browserApiErrorsIntegration);\n\nfunction _wrapTimeFunction(original: () => void): () => number {\n return function (this: unknown, ...args: unknown[]): number {\n const originalCallback = args[0];\n args[0] = wrap(originalCallback, {\n mechanism: {\n handled: false,\n type: `auto.browser.browserapierrors.${getFunctionName(original)}`,\n },\n });\n return original.apply(this, args);\n };\n}\n\nfunction _wrapRAF(original: () => void): (callback: () => void) => unknown {\n return function (this: unknown, callback: () => void): () => void {\n return original.apply(this, [\n wrap(callback, {\n mechanism: {\n data: {\n handler: getFunctionName(original),\n },\n handled: false,\n type: 'auto.browser.browserapierrors.requestAnimationFrame',\n },\n }),\n ]);\n };\n}\n\nfunction _wrapXHR(originalSend: () => void): () => void {\n return function (this: XMLHttpRequest, ...args: unknown[]): void {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const xhr = this;\n const xmlHttpRequestProps: XMLHttpRequestProp[] = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];\n\n xmlHttpRequestProps.forEach(prop => {\n if (prop in xhr && typeof xhr[prop] === 'function') {\n fill(xhr, prop, function (original) {\n const wrapOptions = {\n mechanism: {\n data: {\n handler: getFunctionName(original),\n },\n handled: false,\n type: `auto.browser.browserapierrors.xhr.${prop}`,\n },\n };\n\n // If Instrument integration has been called before BrowserApiErrors, get the name of original function\n const originalFunction = getOriginalFunction(original);\n if (originalFunction) {\n wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);\n }\n\n // Otherwise wrap directly\n return wrap(original, wrapOptions);\n });\n }\n });\n\n return originalSend.apply(this, args);\n };\n}\n\nfunction _wrapEventTarget(target: string, integrationOptions: BrowserApiErrorsOptions): void {\n const globalObject = WINDOW as unknown as Record<string, { prototype?: object }>;\n const proto = globalObject[target]?.prototype;\n\n // eslint-disable-next-line no-prototype-builtins\n if (!proto?.hasOwnProperty?.('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function (original: VoidFunction): (\n ...args: Parameters<typeof WINDOW.addEventListener>\n ) => ReturnType<typeof WINDOW.addEventListener> {\n return function (this: unknown, eventName, fn, options): VoidFunction {\n try {\n if (isEventListenerObject(fn)) {\n // ESlint disable explanation:\n // First, it is generally safe to call `wrap` with an unbound function. Furthermore, using `.bind()` would\n // introduce a bug here, because bind returns a new function that doesn't have our\n // flags(like __sentry_original__) attached. `wrap` checks for those flags to avoid unnecessary wrapping.\n // Without those flags, every call to addEventListener wraps the function again, causing a memory leak.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n fn.handleEvent = wrap(fn.handleEvent, {\n mechanism: {\n data: {\n handler: getFunctionName(fn),\n target,\n },\n handled: false,\n type: 'auto.browser.browserapierrors.handleEvent',\n },\n });\n }\n } catch {\n // can sometimes get 'Permission denied to access property \"handle Event'\n }\n\n if (integrationOptions.unregisterOriginalCallbacks) {\n unregisterOriginalCallback(this, eventName, fn);\n }\n\n return original.apply(this, [\n eventName,\n wrap(fn, {\n mechanism: {\n data: {\n handler: getFunctionName(fn),\n target,\n },\n handled: false,\n type: 'auto.browser.browserapierrors.addEventListener',\n },\n }),\n options,\n ]);\n };\n });\n\n fill(proto, 'removeEventListener', function (originalRemoveEventListener: VoidFunction): (\n this: unknown,\n ...args: Parameters<typeof WINDOW.removeEventListener>\n ) => ReturnType<typeof WINDOW.removeEventListener> {\n return function (this: unknown, eventName, fn, options): VoidFunction {\n /**\n * There are 2 possible scenarios here:\n *\n * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified\n * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function\n * as a pass-through, and call original `removeEventListener` with it.\n *\n * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using\n * our wrapped version of `addEventListener`, which internally calls `wrap` helper.\n * This helper \"wraps\" whole callback inside a try/catch statement, and attached appropriate metadata to it,\n * in order for us to make a distinction between wrapped/non-wrapped functions possible.\n * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.\n *\n * When someone adds a handler prior to initialization, and then do it again, but after,\n * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible\n * to get rid of the initial handler and it'd stick there forever.\n */\n try {\n // Check via hasOwnProperty so a `__sentry_wrapped__` inherited from a wrapped\n // `Function.prototype` doesn't cause removal of the wrong handler.\n if (Object.prototype.hasOwnProperty.call(fn, '__sentry_wrapped__')) {\n const originalEventHandler = (fn as WrappedFunction).__sentry_wrapped__;\n if (originalEventHandler) {\n originalRemoveEventListener.call(this, eventName, originalEventHandler, options);\n }\n }\n } catch {\n // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments\n }\n return originalRemoveEventListener.call(this, eventName, fn, options);\n };\n });\n}\n\nfunction isEventListenerObject(obj: unknown): obj is EventListenerObject {\n return typeof (obj as EventListenerObject).handleEvent === 'function';\n}\n\nfunction unregisterOriginalCallback(target: unknown, eventName: string, fn: EventListenerOrEventListenerObject): void {\n if (\n target &&\n typeof target === 'object' &&\n 'removeEventListener' in target &&\n typeof target.removeEventListener === 'function'\n ) {\n target.removeEventListener(eventName, fn);\n }\n}\n"],"names":[],"mappings":";;;AAKA,MAAM,uBACJ,yaAAA,CAA0a,KAAA;AAAA,EACxa;AACF,CAAA;AAEF,MAAM,gBAAA,GAAmB,kBAAA;AAqBzB,MAAM,4BAAA,IAAgC,CAAC,OAAA,GAA4C,EAAC,KAAM;AACxF,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,cAAA,EAAgB,IAAA;AAAA,IAChB,WAAA,EAAa,IAAA;AAAA,IACb,qBAAA,EAAuB,IAAA;AAAA,IACvB,WAAA,EAAa,IAAA;AAAA,IACb,UAAA,EAAY,IAAA;AAAA,IACZ,2BAAA,EAA6B,KAAA;AAAA,IAC7B,GAAG;AAAA,GACL;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA;AAAA;AAAA,IAGN,SAAA,GAAY;AACV,MAAA,IAAI,SAAS,UAAA,EAAY;AACvB,QAAA,IAAA,CAAK,MAAA,EAAQ,cAAc,iBAAiB,CAAA;AAAA,MAC9C;AAEA,MAAA,IAAI,SAAS,WAAA,EAAa;AACxB,QAAA,IAAA,CAAK,MAAA,EAAQ,eAAe,iBAAiB,CAAA;AAAA,MAC/C;AAEA,MAAA,IAAI,SAAS,qBAAA,EAAuB;AAClC,QAAA,IAAA,CAAK,MAAA,EAAQ,yBAAyB,QAAQ,CAAA;AAAA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IAAI,OAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,EAAA,EAAI,oBAAoB,CAAA,EAAG;AAClE,UAAA,MAAM,uBAAwB,EAAA,CAAuB,kBAAA;AACrD,UAAA,IAAI,oBAAA,EAAsB;AACxB,YAAA,2BAAA,CAA4B,IAAA,CAAK,IAAA,EAAM,SAAA,EAAW,oBAAA,EAAsB,OAAO,CAAA;AAAA,UACjF;AAAA,QACF;AAAA,MACF,CAAA,CAAA,MAAQ;AAAA,MAER;AACA,MAAA,OAAO,2BAAA,CAA4B,IAAA,CAAK,IAAA,EAAM,SAAA,EAAW,IAAI,OAAO,CAAA;AAAA,IACtE,CAAA;AAAA,EACF,CAAC,CAAA;AACH;AAEA,SAAS,sBAAsB,GAAA,EAA0C;AACvE,EAAA,OAAO,OAAQ,IAA4B,WAAA,KAAgB,UAAA;AAC7D;AAEA,SAAS,0BAAA,CAA2B,MAAA,EAAiB,SAAA,EAAmB,EAAA,EAA8C;AACpH,EAAA,IACE,MAAA,IACA,OAAO,MAAA,KAAW,QAAA,IAClB,yBAAyB,MAAA,IACzB,OAAO,MAAA,CAAO,mBAAA,KAAwB,UAAA,EACtC;AACA,IAAA,MAAA,CAAO,mBAAA,CAAoB,WAAW,EAAE,CAAA;AAAA,EAC1C;AACF;;;;"}
@@ -1,4 +1,4 @@
1
- import { defineIntegration, debug, startSession, captureSession, getIsolationScope } from '@sentry/core/browser';
1
+ import { defineIntegration, debug, startSession, captureSession, getIsolationScope } from '@sentry/core';
2
2
  import { whenIdleOrHidden, addHistoryInstrumentationHandler } from '@sentry/browser-utils';
3
3
  import { DEBUG_BUILD } from '../debug-build.js';
4
4
  import { WINDOW } from '../helpers.js';
@@ -1 +1 @@
1
- {"version":3,"file":"browsersession.js","sources":["../../../../../src/integrations/browsersession.ts"],"sourcesContent":["import { captureSession, debug, defineIntegration, getIsolationScope, startSession } from '@sentry/core/browser';\nimport { addHistoryInstrumentationHandler, whenIdleOrHidden } from '@sentry/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\ninterface BrowserSessionOptions {\n /**\n * Controls the session lifecycle - when new sessions are created.\n *\n * - `'page'`: A session is created once when the page is loaded. Session is not\n * updated on navigation. This is the default behavior.\n * - `'route'`: A session is created on page load and on every navigation.\n *\n * @default 'page'\n */\n lifecycle?: 'route' | 'page';\n}\n\n/**\n * When added, automatically creates sessions which allow you to track adoption and crashes (crash free rate) in your Releases in Sentry.\n * More information: https://docs.sentry.io/product/releases/health/\n *\n * Note: In order for session tracking to work, you need to set up Releases: https://docs.sentry.io/product/releases/\n */\nexport const browserSessionIntegration = defineIntegration((options: BrowserSessionOptions = {}) => {\n const lifecycle = options.lifecycle ?? 'page';\n\n return {\n name: 'BrowserSession' as const,\n setupOnce() {\n if (typeof WINDOW.document === 'undefined') {\n DEBUG_BUILD &&\n debug.warn('Using the `browserSessionIntegration` in non-browser environments is not supported.');\n return;\n }\n\n // The session duration for browser sessions does not track a meaningful\n // concept that can be used as a metric.\n // Automatically captured sessions are akin to page views, and thus we\n // discard their duration.\n startSession({ ignoreDuration: true });\n\n // Sending the session envelope synchronously in `init()` runs the full send\n // pipeline during page load, competing with critical resources for the network and\n // adding overhead that measurably hurts LCP. We defer the initial send until the\n // browser is idle; `whenIdleOrHidden` flushes it on page-hide so we don't lose short\n // (page-view-like) sessions.\n let initialSessionSent = false;\n whenIdleOrHidden(() => {\n // A navigation (in `'route'` lifecycle) may start and send a new session before this\n // deferred callback fires. In that case the current session was already sent, so\n // re-capturing here would send it a second time - guard against that.\n if (!initialSessionSent) {\n captureSession();\n initialSessionSent = true;\n }\n });\n\n // User data can be set at any time, for example async after Sentry.init has run and the initial session\n // envelope was already sent, but still on the initial page.\n // Therefore, we have to update the ongoing session with the new user data if it exists, to send the `did`.\n // In theory, sessions, as well as user data is always put onto the isolation scope. So we listen to the\n // isolation scope for changes and update the session with the new user data if it exists.\n // This will not catch users set onto other scopes, like the current scope. For now, we'll accept this limitation.\n // The alternative is to update and capture the session from within the scope. This could be too costly or would not\n // play well with session aggregates on the server side. Since this happens in the scope class, we'd need change\n // scope behaviour in the browser.\n const isolationScope = getIsolationScope();\n let previousUser = isolationScope.getUser();\n isolationScope.addScopeListener(scope => {\n const maybeNewUser = scope.getUser();\n // sessions only care about user id and ip address, so we only need to capture the session if the user has changed\n if (previousUser?.id !== maybeNewUser?.id || previousUser?.ip_address !== maybeNewUser?.ip_address) {\n previousUser = maybeNewUser;\n // Only emit a dedicated update envelope for user data that arrives _after_ the\n // deferred initial session was sent. User data set during page load is already\n // reflected in that session (the scope writes it onto the session), so capturing\n // here would send a redundant envelope - and do so during page load, which is\n // exactly the overhead we're deferring away from.\n if (initialSessionSent) {\n captureSession();\n }\n }\n });\n\n if (lifecycle === 'route') {\n // We want to create a session for every navigation as well\n addHistoryInstrumentationHandler(({ from, to }) => {\n // Don't create an additional session for the initial route or if the location did not change\n if (from !== to) {\n startSession({ ignoreDuration: true });\n captureSession();\n // A session has now been sent, so the deferred initial capture (if still pending)\n // must not re-send this navigation session.\n initialSessionSent = true;\n }\n });\n }\n },\n };\n});\n"],"names":[],"mappings":";;;;;AAwBO,MAAM,yBAAA,GAA4B,iBAAA,CAAkB,CAAC,OAAA,GAAiC,EAAC,KAAM;AAClG,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,MAAA;AAEvC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,IAAI,OAAO,MAAA,CAAO,QAAA,KAAa,WAAA,EAAa;AAC1C,QAAA,WAAA,IACE,KAAA,CAAM,KAAK,qFAAqF,CAAA;AAClG,QAAA;AAAA,MACF;AAMA,MAAA,YAAA,CAAa,EAAE,cAAA,EAAgB,IAAA,EAAM,CAAA;AAOrC,MAAA,IAAI,kBAAA,GAAqB,KAAA;AACzB,MAAA,gBAAA,CAAiB,MAAM;AAIrB,QAAA,IAAI,CAAC,kBAAA,EAAoB;AACvB,UAAA,cAAA,EAAe;AACf,UAAA,kBAAA,GAAqB,IAAA;AAAA,QACvB;AAAA,MACF,CAAC,CAAA;AAWD,MAAA,MAAM,iBAAiB,iBAAA,EAAkB;AACzC,MAAA,IAAI,YAAA,GAAe,eAAe,OAAA,EAAQ;AAC1C,MAAA,cAAA,CAAe,iBAAiB,CAAA,KAAA,KAAS;AACvC,QAAA,MAAM,YAAA,GAAe,MAAM,OAAA,EAAQ;AAEnC,QAAA,IAAI,cAAc,EAAA,KAAO,YAAA,EAAc,MAAM,YAAA,EAAc,UAAA,KAAe,cAAc,UAAA,EAAY;AAClG,UAAA,YAAA,GAAe,YAAA;AAMf,UAAA,IAAI,kBAAA,EAAoB;AACtB,YAAA,cAAA,EAAe;AAAA,UACjB;AAAA,QACF;AAAA,MACF,CAAC,CAAA;AAED,MAAA,IAAI,cAAc,OAAA,EAAS;AAEzB,QAAA,gCAAA,CAAiC,CAAC,EAAE,IAAA,EAAM,EAAA,EAAG,KAAM;AAEjD,UAAA,IAAI,SAAS,EAAA,EAAI;AACf,YAAA,YAAA,CAAa,EAAE,cAAA,EAAgB,IAAA,EAAM,CAAA;AACrC,YAAA,cAAA,EAAe;AAGf,YAAA,kBAAA,GAAqB,IAAA;AAAA,UACvB;AAAA,QACF,CAAC,CAAA;AAAA,MACH;AAAA,IACF;AAAA,GACF;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"browsersession.js","sources":["../../../../../src/integrations/browsersession.ts"],"sourcesContent":["import { captureSession, debug, defineIntegration, getIsolationScope, startSession } from '@sentry/core';\nimport { addHistoryInstrumentationHandler, whenIdleOrHidden } from '@sentry/browser-utils';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\n\ninterface BrowserSessionOptions {\n /**\n * Controls the session lifecycle - when new sessions are created.\n *\n * - `'page'`: A session is created once when the page is loaded. Session is not\n * updated on navigation. This is the default behavior.\n * - `'route'`: A session is created on page load and on every navigation.\n *\n * @default 'page'\n */\n lifecycle?: 'route' | 'page';\n}\n\n/**\n * When added, automatically creates sessions which allow you to track adoption and crashes (crash free rate) in your Releases in Sentry.\n * More information: https://docs.sentry.io/product/releases/health/\n *\n * Note: In order for session tracking to work, you need to set up Releases: https://docs.sentry.io/product/releases/\n */\nexport const browserSessionIntegration = defineIntegration((options: BrowserSessionOptions = {}) => {\n const lifecycle = options.lifecycle ?? 'page';\n\n return {\n name: 'BrowserSession' as const,\n setupOnce() {\n if (typeof WINDOW.document === 'undefined') {\n DEBUG_BUILD &&\n debug.warn('Using the `browserSessionIntegration` in non-browser environments is not supported.');\n return;\n }\n\n // The session duration for browser sessions does not track a meaningful\n // concept that can be used as a metric.\n // Automatically captured sessions are akin to page views, and thus we\n // discard their duration.\n startSession({ ignoreDuration: true });\n\n // Sending the session envelope synchronously in `init()` runs the full send\n // pipeline during page load, competing with critical resources for the network and\n // adding overhead that measurably hurts LCP. We defer the initial send until the\n // browser is idle; `whenIdleOrHidden` flushes it on page-hide so we don't lose short\n // (page-view-like) sessions.\n let initialSessionSent = false;\n whenIdleOrHidden(() => {\n // A navigation (in `'route'` lifecycle) may start and send a new session before this\n // deferred callback fires. In that case the current session was already sent, so\n // re-capturing here would send it a second time - guard against that.\n if (!initialSessionSent) {\n captureSession();\n initialSessionSent = true;\n }\n });\n\n // User data can be set at any time, for example async after Sentry.init has run and the initial session\n // envelope was already sent, but still on the initial page.\n // Therefore, we have to update the ongoing session with the new user data if it exists, to send the `did`.\n // In theory, sessions, as well as user data is always put onto the isolation scope. So we listen to the\n // isolation scope for changes and update the session with the new user data if it exists.\n // This will not catch users set onto other scopes, like the current scope. For now, we'll accept this limitation.\n // The alternative is to update and capture the session from within the scope. This could be too costly or would not\n // play well with session aggregates on the server side. Since this happens in the scope class, we'd need change\n // scope behaviour in the browser.\n const isolationScope = getIsolationScope();\n let previousUser = isolationScope.getUser();\n isolationScope.addScopeListener(scope => {\n const maybeNewUser = scope.getUser();\n // sessions only care about user id and ip address, so we only need to capture the session if the user has changed\n if (previousUser?.id !== maybeNewUser?.id || previousUser?.ip_address !== maybeNewUser?.ip_address) {\n previousUser = maybeNewUser;\n // Only emit a dedicated update envelope for user data that arrives _after_ the\n // deferred initial session was sent. User data set during page load is already\n // reflected in that session (the scope writes it onto the session), so capturing\n // here would send a redundant envelope - and do so during page load, which is\n // exactly the overhead we're deferring away from.\n if (initialSessionSent) {\n captureSession();\n }\n }\n });\n\n if (lifecycle === 'route') {\n // We want to create a session for every navigation as well\n addHistoryInstrumentationHandler(({ from, to }) => {\n // Don't create an additional session for the initial route or if the location did not change\n if (from !== to) {\n startSession({ ignoreDuration: true });\n captureSession();\n // A session has now been sent, so the deferred initial capture (if still pending)\n // must not re-send this navigation session.\n initialSessionSent = true;\n }\n });\n }\n },\n };\n});\n"],"names":[],"mappings":";;;;;AAwBO,MAAM,yBAAA,GAA4B,iBAAA,CAAkB,CAAC,OAAA,GAAiC,EAAC,KAAM;AAClG,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,MAAA;AAEvC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,IAAI,OAAO,MAAA,CAAO,QAAA,KAAa,WAAA,EAAa;AAC1C,QAAA,WAAA,IACE,KAAA,CAAM,KAAK,qFAAqF,CAAA;AAClG,QAAA;AAAA,MACF;AAMA,MAAA,YAAA,CAAa,EAAE,cAAA,EAAgB,IAAA,EAAM,CAAA;AAOrC,MAAA,IAAI,kBAAA,GAAqB,KAAA;AACzB,MAAA,gBAAA,CAAiB,MAAM;AAIrB,QAAA,IAAI,CAAC,kBAAA,EAAoB;AACvB,UAAA,cAAA,EAAe;AACf,UAAA,kBAAA,GAAqB,IAAA;AAAA,QACvB;AAAA,MACF,CAAC,CAAA;AAWD,MAAA,MAAM,iBAAiB,iBAAA,EAAkB;AACzC,MAAA,IAAI,YAAA,GAAe,eAAe,OAAA,EAAQ;AAC1C,MAAA,cAAA,CAAe,iBAAiB,CAAA,KAAA,KAAS;AACvC,QAAA,MAAM,YAAA,GAAe,MAAM,OAAA,EAAQ;AAEnC,QAAA,IAAI,cAAc,EAAA,KAAO,YAAA,EAAc,MAAM,YAAA,EAAc,UAAA,KAAe,cAAc,UAAA,EAAY;AAClG,UAAA,YAAA,GAAe,YAAA;AAMf,UAAA,IAAI,kBAAA,EAAoB;AACtB,YAAA,cAAA,EAAe;AAAA,UACjB;AAAA,QACF;AAAA,MACF,CAAC,CAAA;AAED,MAAA,IAAI,cAAc,OAAA,EAAS;AAEzB,QAAA,gCAAA,CAAiC,CAAC,EAAE,IAAA,EAAM,EAAA,EAAG,KAAM;AAEjD,UAAA,IAAI,SAAS,EAAA,EAAI;AACf,YAAA,YAAA,CAAa,EAAE,cAAA,EAAgB,IAAA,EAAM,CAAA;AACrC,YAAA,cAAA,EAAe;AAGf,YAAA,kBAAA,GAAqB,IAAA;AAAA,UACvB;AAAA,QACF,CAAC,CAAA;AAAA,MACH;AAAA,IACF;AAAA,GACF;AACF,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- import { defineIntegration, GLOBAL_OBJ, stripUrlQueryAndFragment, addContextToFrame } from '@sentry/core/browser';
1
+ import { defineIntegration, GLOBAL_OBJ, stripUrlQueryAndFragment, addContextToFrame } from '@sentry/core';
2
2
 
3
3
  const WINDOW = GLOBAL_OBJ;
4
4
  const DEFAULT_LINES_OF_CONTEXT = 7;
@@ -1 +1 @@
1
- {"version":3,"file":"contextlines.js","sources":["../../../../../src/integrations/contextlines.ts"],"sourcesContent":["import type { Event, IntegrationFn, StackFrame } from '@sentry/core/browser';\nimport { addContextToFrame, defineIntegration, GLOBAL_OBJ, stripUrlQueryAndFragment } from '@sentry/core/browser';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst DEFAULT_LINES_OF_CONTEXT = 7;\n\nconst INTEGRATION_NAME = 'ContextLines' as const;\n\n// TODO(v11): Use `dataCollection.frameContextLines` default (5)\ninterface ContextLinesOptions {\n /**\n * Sets the number of context lines for each frame when loading a file.\n * Defaults to 7.\n *\n * Set to 0 to disable loading and inclusion of source files.\n *\n * When set, this option takes precedence over `dataCollection.frameContextLines`.\n **/\n frameContextLines?: number;\n}\n\nconst _contextLinesIntegration = ((options: ContextLinesOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n processEvent(event, _hint, client) {\n const contextLines =\n options.frameContextLines ?? client?.getDataCollectionOptions().frameContextLines ?? DEFAULT_LINES_OF_CONTEXT;\n return addSourceContext(event, contextLines);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Collects source context lines around the lines of stackframes pointing to JS embedded in\n * the current page's HTML.\n *\n * This integration DOES NOT work for stack frames pointing to JS files that are loaded by the browser.\n * For frames pointing to files, context lines are added during ingestion and symbolication\n * by attempting to download the JS files to the Sentry backend.\n *\n * Use this integration if you have inline JS code in HTML pages that can't be accessed\n * by our backend (e.g. due to a login-protected page).\n */\nexport const contextLinesIntegration = defineIntegration(_contextLinesIntegration);\n\n/**\n * Processes an event and adds context lines.\n */\nfunction addSourceContext(event: Event, contextLines: number): Event {\n const doc = WINDOW.document;\n const htmlFilename = WINDOW.location && stripUrlQueryAndFragment(WINDOW.location.href);\n if (!doc || !htmlFilename) {\n return event;\n }\n\n const exceptions = event.exception?.values;\n if (!exceptions?.length) {\n return event;\n }\n\n const html = doc.documentElement.innerHTML;\n if (!html) {\n return event;\n }\n\n const htmlLines = ['<!DOCTYPE html>', '<html>', ...html.split('\\n'), '</html>'];\n\n exceptions.forEach(exception => {\n const stacktrace = exception.stacktrace;\n if (stacktrace?.frames) {\n stacktrace.frames = stacktrace.frames.map(frame =>\n applySourceContextToFrame(frame, htmlLines, htmlFilename, contextLines),\n );\n }\n });\n\n return event;\n}\n\n/**\n * Only exported for testing\n */\nexport function applySourceContextToFrame(\n frame: StackFrame,\n htmlLines: string[],\n htmlFilename: string,\n linesOfContext: number,\n): StackFrame {\n if (frame.filename !== htmlFilename || !frame.lineno || !htmlLines.length) {\n return frame;\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AAA,CAAW,QAAQ,CAAA,SAAA,KAAa;AAC9B,IAAA,MAAM,aAAa,SAAA,CAAU,UAAA;AAC7B,IAAA,IAAI,YAAY,MAAA,EAAQ;AACtB,MAAA,UAAA,CAAW,MAAA,GAAS,WAAW,MAAA,CAAO,GAAA;AAAA,QAAI,CAAA,KAAA,KACxC,yBAAA,CAA0B,KAAA,EAAO,SAAA,EAAW,cAAc,YAAY;AAAA,OACxE;AAAA,IACF;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT;AAKO,SAAS,yBAAA,CACd,KAAA,EACA,SAAA,EACA,YAAA,EACA,cAAA,EACY;AACZ,EAAA,IAAI,KAAA,CAAM,aAAa,YAAA,IAAgB,CAAC,MAAM,MAAA,IAAU,CAAC,UAAU,MAAA,EAAQ;AACzE,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,iBAAA,CAAkB,SAAA,EAAW,OAAO,cAAc,CAAA;AAElD,EAAA,OAAO,KAAA;AACT;;;;"}
1
+ {"version":3,"file":"contextlines.js","sources":["../../../../../src/integrations/contextlines.ts"],"sourcesContent":["import type { Event, IntegrationFn, StackFrame } from '@sentry/core';\nimport { addContextToFrame, defineIntegration, GLOBAL_OBJ, stripUrlQueryAndFragment } from '@sentry/core';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst DEFAULT_LINES_OF_CONTEXT = 7;\n\nconst INTEGRATION_NAME = 'ContextLines' as const;\n\n// TODO(v11): Use `dataCollection.frameContextLines` default (5)\ninterface ContextLinesOptions {\n /**\n * Sets the number of context lines for each frame when loading a file.\n * Defaults to 7.\n *\n * Set to 0 to disable loading and inclusion of source files.\n *\n * When set, this option takes precedence over `dataCollection.frameContextLines`.\n **/\n frameContextLines?: number;\n}\n\nconst _contextLinesIntegration = ((options: ContextLinesOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n processEvent(event, _hint, client) {\n const contextLines =\n options.frameContextLines ?? client?.getDataCollectionOptions().frameContextLines ?? DEFAULT_LINES_OF_CONTEXT;\n return addSourceContext(event, contextLines);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Collects source context lines around the lines of stackframes pointing to JS embedded in\n * the current page's HTML.\n *\n * This integration DOES NOT work for stack frames pointing to JS files that are loaded by the browser.\n * For frames pointing to files, context lines are added during ingestion and symbolication\n * by attempting to download the JS files to the Sentry backend.\n *\n * Use this integration if you have inline JS code in HTML pages that can't be accessed\n * by our backend (e.g. due to a login-protected page).\n */\nexport const contextLinesIntegration = defineIntegration(_contextLinesIntegration);\n\n/**\n * Processes an event and adds context lines.\n */\nfunction addSourceContext(event: Event, contextLines: number): Event {\n const doc = WINDOW.document;\n const htmlFilename = WINDOW.location && stripUrlQueryAndFragment(WINDOW.location.href);\n if (!doc || !htmlFilename) {\n return event;\n }\n\n const exceptions = event.exception?.values;\n if (!exceptions?.length) {\n return event;\n }\n\n const html = doc.documentElement.innerHTML;\n if (!html) {\n return event;\n }\n\n const htmlLines = ['<!DOCTYPE html>', '<html>', ...html.split('\\n'), '</html>'];\n\n exceptions.forEach(exception => {\n const stacktrace = exception.stacktrace;\n if (stacktrace?.frames) {\n stacktrace.frames = stacktrace.frames.map(frame =>\n applySourceContextToFrame(frame, htmlLines, htmlFilename, contextLines),\n );\n }\n });\n\n return event;\n}\n\n/**\n * Only exported for testing\n */\nexport function applySourceContextToFrame(\n frame: StackFrame,\n htmlLines: string[],\n htmlFilename: string,\n linesOfContext: number,\n): StackFrame {\n if (frame.filename !== htmlFilename || !frame.lineno || !htmlLines.length) {\n return frame;\n }\n\n addContextToFrame(htmlLines, frame, linesOfContext);\n\n return frame;\n}\n"],"names":[],"mappings":";;AAGA,MAAM,MAAA,GAAS,UAAA;AAEf,MAAM,wBAAA,GAA2B,CAAA;AAEjC,MAAM,gBAAA,GAAmB,cAAA;AAezB,MAAM,wBAAA,IAA4B,CAAC,OAAA,GAA+B,EAAC,KAAM;AACvE,EAAA,OAAO;AAAA,IACL,IAAA,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