@sentry/browser 10.53.1 → 10.54.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 (445) hide show
  1. package/build/npm/cjs/dev/client.js +15 -54
  2. package/build/npm/cjs/dev/client.js.map +1 -1
  3. package/build/npm/cjs/dev/debug-build.js +0 -5
  4. package/build/npm/cjs/dev/debug-build.js.map +1 -1
  5. package/build/npm/cjs/dev/diagnose-sdk.js +15 -37
  6. package/build/npm/cjs/dev/diagnose-sdk.js.map +1 -1
  7. package/build/npm/cjs/dev/eventbuilder.js +59 -217
  8. package/build/npm/cjs/dev/eventbuilder.js.map +1 -1
  9. package/build/npm/cjs/dev/feedbackAsync.js +1 -5
  10. package/build/npm/cjs/dev/feedbackAsync.js.map +1 -1
  11. package/build/npm/cjs/dev/feedbackSync.js +1 -2
  12. package/build/npm/cjs/dev/feedbackSync.js.map +1 -1
  13. package/build/npm/cjs/dev/helpers.js +24 -102
  14. package/build/npm/cjs/dev/helpers.js.map +1 -1
  15. package/build/npm/cjs/dev/index.js +2 -0
  16. package/build/npm/cjs/dev/index.js.map +1 -1
  17. package/build/npm/cjs/dev/integrations/breadcrumbs.js +52 -134
  18. package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -1
  19. package/build/npm/cjs/dev/integrations/browserapierrors.js +45 -111
  20. package/build/npm/cjs/dev/integrations/browserapierrors.js.map +1 -1
  21. package/build/npm/cjs/dev/integrations/browsersession.js +7 -35
  22. package/build/npm/cjs/dev/integrations/browsersession.js.map +1 -1
  23. package/build/npm/cjs/dev/integrations/contextlines.js +9 -45
  24. package/build/npm/cjs/dev/integrations/contextlines.js.map +1 -1
  25. package/build/npm/cjs/dev/integrations/culturecontext.js +11 -36
  26. package/build/npm/cjs/dev/integrations/culturecontext.js.map +1 -1
  27. package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js +1 -22
  28. package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
  29. package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js +6 -31
  30. package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  31. package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js +6 -12
  32. package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
  33. package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js +5 -30
  34. package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
  35. package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js +10 -47
  36. package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
  37. package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js +60 -0
  38. package/build/npm/cjs/dev/integrations/fetchStreamPerformance.js.map +1 -0
  39. package/build/npm/cjs/dev/integrations/globalhandlers.js +38 -99
  40. package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -1
  41. package/build/npm/cjs/dev/integrations/graphqlClient.js +31 -119
  42. package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -1
  43. package/build/npm/cjs/dev/integrations/httpclient.js +43 -203
  44. package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -1
  45. package/build/npm/cjs/dev/integrations/httpcontext.js +7 -17
  46. package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -1
  47. package/build/npm/cjs/dev/integrations/linkederrors.js +7 -15
  48. package/build/npm/cjs/dev/integrations/linkederrors.js.map +1 -1
  49. package/build/npm/cjs/dev/integrations/reportingobserver.js +19 -44
  50. package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -1
  51. package/build/npm/cjs/dev/integrations/spanstreaming.js +11 -29
  52. package/build/npm/cjs/dev/integrations/spanstreaming.js.map +1 -1
  53. package/build/npm/cjs/dev/integrations/spotlight.js +17 -30
  54. package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -1
  55. package/build/npm/cjs/dev/integrations/view-hierarchy.js +19 -46
  56. package/build/npm/cjs/dev/integrations/view-hierarchy.js.map +1 -1
  57. package/build/npm/cjs/dev/integrations/webWorker.js +40 -211
  58. package/build/npm/cjs/dev/integrations/webWorker.js.map +1 -1
  59. package/build/npm/cjs/dev/profiling/UIProfiler.js +87 -190
  60. package/build/npm/cjs/dev/profiling/UIProfiler.js.map +1 -1
  61. package/build/npm/cjs/dev/profiling/index.js +9 -30
  62. package/build/npm/cjs/dev/profiling/index.js.map +1 -1
  63. package/build/npm/cjs/dev/profiling/integration.js +30 -64
  64. package/build/npm/cjs/dev/profiling/integration.js.map +1 -1
  65. package/build/npm/cjs/dev/profiling/startProfileForSpan.js +28 -84
  66. package/build/npm/cjs/dev/profiling/startProfileForSpan.js.map +1 -1
  67. package/build/npm/cjs/dev/profiling/utils.js +131 -398
  68. package/build/npm/cjs/dev/profiling/utils.js.map +1 -1
  69. package/build/npm/cjs/dev/report-dialog.js +10 -25
  70. package/build/npm/cjs/dev/report-dialog.js.map +1 -1
  71. package/build/npm/cjs/dev/sdk.js +8 -76
  72. package/build/npm/cjs/dev/sdk.js.map +1 -1
  73. package/build/npm/cjs/dev/stack-parsers.js +42 -126
  74. package/build/npm/cjs/dev/stack-parsers.js.map +1 -1
  75. package/build/npm/cjs/dev/tracing/backgroundtab.js +4 -16
  76. package/build/npm/cjs/dev/tracing/backgroundtab.js.map +1 -1
  77. package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +102 -291
  78. package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
  79. package/build/npm/cjs/dev/tracing/linkedTraces.js +25 -116
  80. package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -1
  81. package/build/npm/cjs/dev/tracing/reportPageLoaded.js +1 -9
  82. package/build/npm/cjs/dev/tracing/reportPageLoaded.js.map +1 -1
  83. package/build/npm/cjs/dev/tracing/request.js +58 -223
  84. package/build/npm/cjs/dev/tracing/request.js.map +1 -1
  85. package/build/npm/cjs/dev/tracing/setActiveSpan.js +1 -48
  86. package/build/npm/cjs/dev/tracing/setActiveSpan.js.map +1 -1
  87. package/build/npm/cjs/dev/tracing/utils.js +4 -27
  88. package/build/npm/cjs/dev/tracing/utils.js.map +1 -1
  89. package/build/npm/cjs/dev/transports/fetch.js +10 -23
  90. package/build/npm/cjs/dev/transports/fetch.js.map +1 -1
  91. package/build/npm/cjs/dev/transports/offline.js +27 -84
  92. package/build/npm/cjs/dev/transports/offline.js.map +1 -1
  93. package/build/npm/cjs/dev/userfeedback.js +12 -22
  94. package/build/npm/cjs/dev/userfeedback.js.map +1 -1
  95. package/build/npm/cjs/dev/utils/detectBrowserExtension.js +5 -26
  96. package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -1
  97. package/build/npm/cjs/dev/utils/lazyLoadIntegration.js +40 -75
  98. package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -1
  99. package/build/npm/cjs/prod/client.js +15 -54
  100. package/build/npm/cjs/prod/client.js.map +1 -1
  101. package/build/npm/cjs/prod/debug-build.js +0 -5
  102. package/build/npm/cjs/prod/debug-build.js.map +1 -1
  103. package/build/npm/cjs/prod/diagnose-sdk.js +15 -37
  104. package/build/npm/cjs/prod/diagnose-sdk.js.map +1 -1
  105. package/build/npm/cjs/prod/eventbuilder.js +59 -217
  106. package/build/npm/cjs/prod/eventbuilder.js.map +1 -1
  107. package/build/npm/cjs/prod/feedbackAsync.js +1 -5
  108. package/build/npm/cjs/prod/feedbackAsync.js.map +1 -1
  109. package/build/npm/cjs/prod/feedbackSync.js +1 -2
  110. package/build/npm/cjs/prod/feedbackSync.js.map +1 -1
  111. package/build/npm/cjs/prod/helpers.js +24 -102
  112. package/build/npm/cjs/prod/helpers.js.map +1 -1
  113. package/build/npm/cjs/prod/index.js +2 -0
  114. package/build/npm/cjs/prod/index.js.map +1 -1
  115. package/build/npm/cjs/prod/integrations/breadcrumbs.js +52 -134
  116. package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -1
  117. package/build/npm/cjs/prod/integrations/browserapierrors.js +45 -111
  118. package/build/npm/cjs/prod/integrations/browserapierrors.js.map +1 -1
  119. package/build/npm/cjs/prod/integrations/browsersession.js +7 -35
  120. package/build/npm/cjs/prod/integrations/browsersession.js.map +1 -1
  121. package/build/npm/cjs/prod/integrations/contextlines.js +9 -45
  122. package/build/npm/cjs/prod/integrations/contextlines.js.map +1 -1
  123. package/build/npm/cjs/prod/integrations/culturecontext.js +11 -36
  124. package/build/npm/cjs/prod/integrations/culturecontext.js.map +1 -1
  125. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js +1 -22
  126. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
  127. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js +6 -31
  128. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  129. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js +6 -12
  130. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
  131. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js +5 -30
  132. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
  133. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js +10 -47
  134. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
  135. package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js +60 -0
  136. package/build/npm/cjs/prod/integrations/fetchStreamPerformance.js.map +1 -0
  137. package/build/npm/cjs/prod/integrations/globalhandlers.js +38 -99
  138. package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -1
  139. package/build/npm/cjs/prod/integrations/graphqlClient.js +31 -119
  140. package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -1
  141. package/build/npm/cjs/prod/integrations/httpclient.js +43 -203
  142. package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -1
  143. package/build/npm/cjs/prod/integrations/httpcontext.js +7 -17
  144. package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -1
  145. package/build/npm/cjs/prod/integrations/linkederrors.js +7 -15
  146. package/build/npm/cjs/prod/integrations/linkederrors.js.map +1 -1
  147. package/build/npm/cjs/prod/integrations/reportingobserver.js +19 -44
  148. package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -1
  149. package/build/npm/cjs/prod/integrations/spanstreaming.js +11 -29
  150. package/build/npm/cjs/prod/integrations/spanstreaming.js.map +1 -1
  151. package/build/npm/cjs/prod/integrations/spotlight.js +17 -30
  152. package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -1
  153. package/build/npm/cjs/prod/integrations/view-hierarchy.js +19 -46
  154. package/build/npm/cjs/prod/integrations/view-hierarchy.js.map +1 -1
  155. package/build/npm/cjs/prod/integrations/webWorker.js +40 -211
  156. package/build/npm/cjs/prod/integrations/webWorker.js.map +1 -1
  157. package/build/npm/cjs/prod/profiling/UIProfiler.js +87 -190
  158. package/build/npm/cjs/prod/profiling/UIProfiler.js.map +1 -1
  159. package/build/npm/cjs/prod/profiling/index.js +9 -30
  160. package/build/npm/cjs/prod/profiling/index.js.map +1 -1
  161. package/build/npm/cjs/prod/profiling/integration.js +30 -64
  162. package/build/npm/cjs/prod/profiling/integration.js.map +1 -1
  163. package/build/npm/cjs/prod/profiling/startProfileForSpan.js +28 -84
  164. package/build/npm/cjs/prod/profiling/startProfileForSpan.js.map +1 -1
  165. package/build/npm/cjs/prod/profiling/utils.js +131 -398
  166. package/build/npm/cjs/prod/profiling/utils.js.map +1 -1
  167. package/build/npm/cjs/prod/report-dialog.js +10 -25
  168. package/build/npm/cjs/prod/report-dialog.js.map +1 -1
  169. package/build/npm/cjs/prod/sdk.js +5 -73
  170. package/build/npm/cjs/prod/sdk.js.map +1 -1
  171. package/build/npm/cjs/prod/stack-parsers.js +42 -126
  172. package/build/npm/cjs/prod/stack-parsers.js.map +1 -1
  173. package/build/npm/cjs/prod/tracing/backgroundtab.js +4 -16
  174. package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -1
  175. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +102 -291
  176. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
  177. package/build/npm/cjs/prod/tracing/linkedTraces.js +25 -117
  178. package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -1
  179. package/build/npm/cjs/prod/tracing/reportPageLoaded.js +1 -9
  180. package/build/npm/cjs/prod/tracing/reportPageLoaded.js.map +1 -1
  181. package/build/npm/cjs/prod/tracing/request.js +58 -223
  182. package/build/npm/cjs/prod/tracing/request.js.map +1 -1
  183. package/build/npm/cjs/prod/tracing/setActiveSpan.js +1 -48
  184. package/build/npm/cjs/prod/tracing/setActiveSpan.js.map +1 -1
  185. package/build/npm/cjs/prod/tracing/utils.js +4 -27
  186. package/build/npm/cjs/prod/tracing/utils.js.map +1 -1
  187. package/build/npm/cjs/prod/transports/fetch.js +10 -23
  188. package/build/npm/cjs/prod/transports/fetch.js.map +1 -1
  189. package/build/npm/cjs/prod/transports/offline.js +27 -84
  190. package/build/npm/cjs/prod/transports/offline.js.map +1 -1
  191. package/build/npm/cjs/prod/userfeedback.js +12 -22
  192. package/build/npm/cjs/prod/userfeedback.js.map +1 -1
  193. package/build/npm/cjs/prod/utils/detectBrowserExtension.js +5 -26
  194. package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -1
  195. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +40 -75
  196. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -1
  197. package/build/npm/esm/dev/client.js +15 -54
  198. package/build/npm/esm/dev/client.js.map +1 -1
  199. package/build/npm/esm/dev/debug-build.js +0 -5
  200. package/build/npm/esm/dev/debug-build.js.map +1 -1
  201. package/build/npm/esm/dev/diagnose-sdk.js +15 -37
  202. package/build/npm/esm/dev/diagnose-sdk.js.map +1 -1
  203. package/build/npm/esm/dev/eventbuilder.js +59 -217
  204. package/build/npm/esm/dev/eventbuilder.js.map +1 -1
  205. package/build/npm/esm/dev/feedbackAsync.js +1 -5
  206. package/build/npm/esm/dev/feedbackAsync.js.map +1 -1
  207. package/build/npm/esm/dev/feedbackSync.js +1 -2
  208. package/build/npm/esm/dev/feedbackSync.js.map +1 -1
  209. package/build/npm/esm/dev/helpers.js +24 -102
  210. package/build/npm/esm/dev/helpers.js.map +1 -1
  211. package/build/npm/esm/dev/index.js +1 -0
  212. package/build/npm/esm/dev/index.js.map +1 -1
  213. package/build/npm/esm/dev/integrations/breadcrumbs.js +52 -134
  214. package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -1
  215. package/build/npm/esm/dev/integrations/browserapierrors.js +45 -111
  216. package/build/npm/esm/dev/integrations/browserapierrors.js.map +1 -1
  217. package/build/npm/esm/dev/integrations/browsersession.js +7 -35
  218. package/build/npm/esm/dev/integrations/browsersession.js.map +1 -1
  219. package/build/npm/esm/dev/integrations/contextlines.js +9 -45
  220. package/build/npm/esm/dev/integrations/contextlines.js.map +1 -1
  221. package/build/npm/esm/dev/integrations/culturecontext.js +11 -36
  222. package/build/npm/esm/dev/integrations/culturecontext.js.map +1 -1
  223. package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js +1 -22
  224. package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
  225. package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js +6 -31
  226. package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  227. package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js +6 -12
  228. package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
  229. package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js +5 -30
  230. package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
  231. package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js +10 -47
  232. package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
  233. package/build/npm/esm/dev/integrations/fetchStreamPerformance.js +58 -0
  234. package/build/npm/esm/dev/integrations/fetchStreamPerformance.js.map +1 -0
  235. package/build/npm/esm/dev/integrations/globalhandlers.js +38 -99
  236. package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -1
  237. package/build/npm/esm/dev/integrations/graphqlClient.js +31 -119
  238. package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -1
  239. package/build/npm/esm/dev/integrations/httpclient.js +43 -203
  240. package/build/npm/esm/dev/integrations/httpclient.js.map +1 -1
  241. package/build/npm/esm/dev/integrations/httpcontext.js +7 -17
  242. package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -1
  243. package/build/npm/esm/dev/integrations/linkederrors.js +7 -15
  244. package/build/npm/esm/dev/integrations/linkederrors.js.map +1 -1
  245. package/build/npm/esm/dev/integrations/reportingobserver.js +19 -44
  246. package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -1
  247. package/build/npm/esm/dev/integrations/spanstreaming.js +11 -29
  248. package/build/npm/esm/dev/integrations/spanstreaming.js.map +1 -1
  249. package/build/npm/esm/dev/integrations/spotlight.js +17 -30
  250. package/build/npm/esm/dev/integrations/spotlight.js.map +1 -1
  251. package/build/npm/esm/dev/integrations/view-hierarchy.js +19 -46
  252. package/build/npm/esm/dev/integrations/view-hierarchy.js.map +1 -1
  253. package/build/npm/esm/dev/integrations/webWorker.js +40 -211
  254. package/build/npm/esm/dev/integrations/webWorker.js.map +1 -1
  255. package/build/npm/esm/dev/package.json +1 -1
  256. package/build/npm/esm/dev/profiling/UIProfiler.js +87 -190
  257. package/build/npm/esm/dev/profiling/UIProfiler.js.map +1 -1
  258. package/build/npm/esm/dev/profiling/index.js +9 -30
  259. package/build/npm/esm/dev/profiling/index.js.map +1 -1
  260. package/build/npm/esm/dev/profiling/integration.js +30 -64
  261. package/build/npm/esm/dev/profiling/integration.js.map +1 -1
  262. package/build/npm/esm/dev/profiling/startProfileForSpan.js +28 -84
  263. package/build/npm/esm/dev/profiling/startProfileForSpan.js.map +1 -1
  264. package/build/npm/esm/dev/profiling/utils.js +131 -398
  265. package/build/npm/esm/dev/profiling/utils.js.map +1 -1
  266. package/build/npm/esm/dev/report-dialog.js +10 -25
  267. package/build/npm/esm/dev/report-dialog.js.map +1 -1
  268. package/build/npm/esm/dev/sdk.js +8 -76
  269. package/build/npm/esm/dev/sdk.js.map +1 -1
  270. package/build/npm/esm/dev/stack-parsers.js +42 -126
  271. package/build/npm/esm/dev/stack-parsers.js.map +1 -1
  272. package/build/npm/esm/dev/tracing/backgroundtab.js +4 -16
  273. package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -1
  274. package/build/npm/esm/dev/tracing/browserTracingIntegration.js +102 -291
  275. package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
  276. package/build/npm/esm/dev/tracing/linkedTraces.js +25 -116
  277. package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -1
  278. package/build/npm/esm/dev/tracing/reportPageLoaded.js +1 -9
  279. package/build/npm/esm/dev/tracing/reportPageLoaded.js.map +1 -1
  280. package/build/npm/esm/dev/tracing/request.js +59 -224
  281. package/build/npm/esm/dev/tracing/request.js.map +1 -1
  282. package/build/npm/esm/dev/tracing/setActiveSpan.js +1 -48
  283. package/build/npm/esm/dev/tracing/setActiveSpan.js.map +1 -1
  284. package/build/npm/esm/dev/tracing/utils.js +4 -27
  285. package/build/npm/esm/dev/tracing/utils.js.map +1 -1
  286. package/build/npm/esm/dev/transports/fetch.js +10 -23
  287. package/build/npm/esm/dev/transports/fetch.js.map +1 -1
  288. package/build/npm/esm/dev/transports/offline.js +27 -84
  289. package/build/npm/esm/dev/transports/offline.js.map +1 -1
  290. package/build/npm/esm/dev/userfeedback.js +12 -22
  291. package/build/npm/esm/dev/userfeedback.js.map +1 -1
  292. package/build/npm/esm/dev/utils/detectBrowserExtension.js +5 -26
  293. package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -1
  294. package/build/npm/esm/dev/utils/lazyLoadIntegration.js +40 -75
  295. package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -1
  296. package/build/npm/esm/prod/client.js +15 -54
  297. package/build/npm/esm/prod/client.js.map +1 -1
  298. package/build/npm/esm/prod/debug-build.js +0 -5
  299. package/build/npm/esm/prod/debug-build.js.map +1 -1
  300. package/build/npm/esm/prod/diagnose-sdk.js +15 -37
  301. package/build/npm/esm/prod/diagnose-sdk.js.map +1 -1
  302. package/build/npm/esm/prod/eventbuilder.js +59 -217
  303. package/build/npm/esm/prod/eventbuilder.js.map +1 -1
  304. package/build/npm/esm/prod/feedbackAsync.js +1 -5
  305. package/build/npm/esm/prod/feedbackAsync.js.map +1 -1
  306. package/build/npm/esm/prod/feedbackSync.js +1 -2
  307. package/build/npm/esm/prod/feedbackSync.js.map +1 -1
  308. package/build/npm/esm/prod/helpers.js +24 -102
  309. package/build/npm/esm/prod/helpers.js.map +1 -1
  310. package/build/npm/esm/prod/index.js +1 -0
  311. package/build/npm/esm/prod/index.js.map +1 -1
  312. package/build/npm/esm/prod/integrations/breadcrumbs.js +52 -134
  313. package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -1
  314. package/build/npm/esm/prod/integrations/browserapierrors.js +45 -111
  315. package/build/npm/esm/prod/integrations/browserapierrors.js.map +1 -1
  316. package/build/npm/esm/prod/integrations/browsersession.js +7 -35
  317. package/build/npm/esm/prod/integrations/browsersession.js.map +1 -1
  318. package/build/npm/esm/prod/integrations/contextlines.js +9 -45
  319. package/build/npm/esm/prod/integrations/contextlines.js.map +1 -1
  320. package/build/npm/esm/prod/integrations/culturecontext.js +11 -36
  321. package/build/npm/esm/prod/integrations/culturecontext.js.map +1 -1
  322. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js +1 -22
  323. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
  324. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js +6 -31
  325. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  326. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js +6 -12
  327. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
  328. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js +5 -30
  329. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
  330. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js +10 -47
  331. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
  332. package/build/npm/esm/prod/integrations/fetchStreamPerformance.js +58 -0
  333. package/build/npm/esm/prod/integrations/fetchStreamPerformance.js.map +1 -0
  334. package/build/npm/esm/prod/integrations/globalhandlers.js +38 -99
  335. package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -1
  336. package/build/npm/esm/prod/integrations/graphqlClient.js +31 -119
  337. package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -1
  338. package/build/npm/esm/prod/integrations/httpclient.js +43 -203
  339. package/build/npm/esm/prod/integrations/httpclient.js.map +1 -1
  340. package/build/npm/esm/prod/integrations/httpcontext.js +7 -17
  341. package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -1
  342. package/build/npm/esm/prod/integrations/linkederrors.js +7 -15
  343. package/build/npm/esm/prod/integrations/linkederrors.js.map +1 -1
  344. package/build/npm/esm/prod/integrations/reportingobserver.js +19 -44
  345. package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -1
  346. package/build/npm/esm/prod/integrations/spanstreaming.js +11 -29
  347. package/build/npm/esm/prod/integrations/spanstreaming.js.map +1 -1
  348. package/build/npm/esm/prod/integrations/spotlight.js +17 -30
  349. package/build/npm/esm/prod/integrations/spotlight.js.map +1 -1
  350. package/build/npm/esm/prod/integrations/view-hierarchy.js +19 -46
  351. package/build/npm/esm/prod/integrations/view-hierarchy.js.map +1 -1
  352. package/build/npm/esm/prod/integrations/webWorker.js +40 -211
  353. package/build/npm/esm/prod/integrations/webWorker.js.map +1 -1
  354. package/build/npm/esm/prod/package.json +1 -1
  355. package/build/npm/esm/prod/profiling/UIProfiler.js +87 -190
  356. package/build/npm/esm/prod/profiling/UIProfiler.js.map +1 -1
  357. package/build/npm/esm/prod/profiling/index.js +9 -30
  358. package/build/npm/esm/prod/profiling/index.js.map +1 -1
  359. package/build/npm/esm/prod/profiling/integration.js +30 -64
  360. package/build/npm/esm/prod/profiling/integration.js.map +1 -1
  361. package/build/npm/esm/prod/profiling/startProfileForSpan.js +28 -84
  362. package/build/npm/esm/prod/profiling/startProfileForSpan.js.map +1 -1
  363. package/build/npm/esm/prod/profiling/utils.js +131 -398
  364. package/build/npm/esm/prod/profiling/utils.js.map +1 -1
  365. package/build/npm/esm/prod/report-dialog.js +10 -25
  366. package/build/npm/esm/prod/report-dialog.js.map +1 -1
  367. package/build/npm/esm/prod/sdk.js +5 -73
  368. package/build/npm/esm/prod/sdk.js.map +1 -1
  369. package/build/npm/esm/prod/stack-parsers.js +42 -126
  370. package/build/npm/esm/prod/stack-parsers.js.map +1 -1
  371. package/build/npm/esm/prod/tracing/backgroundtab.js +4 -16
  372. package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -1
  373. package/build/npm/esm/prod/tracing/browserTracingIntegration.js +102 -291
  374. package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
  375. package/build/npm/esm/prod/tracing/linkedTraces.js +25 -117
  376. package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -1
  377. package/build/npm/esm/prod/tracing/reportPageLoaded.js +1 -9
  378. package/build/npm/esm/prod/tracing/reportPageLoaded.js.map +1 -1
  379. package/build/npm/esm/prod/tracing/request.js +59 -224
  380. package/build/npm/esm/prod/tracing/request.js.map +1 -1
  381. package/build/npm/esm/prod/tracing/setActiveSpan.js +1 -48
  382. package/build/npm/esm/prod/tracing/setActiveSpan.js.map +1 -1
  383. package/build/npm/esm/prod/tracing/utils.js +4 -27
  384. package/build/npm/esm/prod/tracing/utils.js.map +1 -1
  385. package/build/npm/esm/prod/transports/fetch.js +10 -23
  386. package/build/npm/esm/prod/transports/fetch.js.map +1 -1
  387. package/build/npm/esm/prod/transports/offline.js +27 -84
  388. package/build/npm/esm/prod/transports/offline.js.map +1 -1
  389. package/build/npm/esm/prod/userfeedback.js +12 -22
  390. package/build/npm/esm/prod/userfeedback.js.map +1 -1
  391. package/build/npm/esm/prod/utils/detectBrowserExtension.js +5 -26
  392. package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -1
  393. package/build/npm/esm/prod/utils/lazyLoadIntegration.js +40 -75
  394. package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -1
  395. package/build/npm/types/eventbuilder.d.ts.map +1 -1
  396. package/build/npm/types/helpers.d.ts.map +1 -1
  397. package/build/npm/types/index.bundle.d.ts +2 -2
  398. package/build/npm/types/index.bundle.d.ts.map +1 -1
  399. package/build/npm/types/index.bundle.feedback.d.ts +2 -2
  400. package/build/npm/types/index.bundle.feedback.d.ts.map +1 -1
  401. package/build/npm/types/index.bundle.logs.metrics.d.ts +2 -2
  402. package/build/npm/types/index.bundle.logs.metrics.d.ts.map +1 -1
  403. package/build/npm/types/index.bundle.replay.d.ts +2 -2
  404. package/build/npm/types/index.bundle.replay.d.ts.map +1 -1
  405. package/build/npm/types/index.bundle.replay.feedback.d.ts +2 -2
  406. package/build/npm/types/index.bundle.replay.feedback.d.ts.map +1 -1
  407. package/build/npm/types/index.bundle.replay.logs.metrics.d.ts +2 -2
  408. package/build/npm/types/index.bundle.replay.logs.metrics.d.ts.map +1 -1
  409. package/build/npm/types/index.bundle.tracing.d.ts +1 -0
  410. package/build/npm/types/index.bundle.tracing.d.ts.map +1 -1
  411. package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts +1 -0
  412. package/build/npm/types/index.bundle.tracing.logs.metrics.d.ts.map +1 -1
  413. package/build/npm/types/index.bundle.tracing.replay.d.ts +1 -0
  414. package/build/npm/types/index.bundle.tracing.replay.d.ts.map +1 -1
  415. package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts +1 -0
  416. package/build/npm/types/index.bundle.tracing.replay.feedback.d.ts.map +1 -1
  417. package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +1 -0
  418. package/build/npm/types/index.bundle.tracing.replay.feedback.logs.metrics.d.ts.map +1 -1
  419. package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts +1 -0
  420. package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts.map +1 -1
  421. package/build/npm/types/index.d.ts +1 -0
  422. package/build/npm/types/index.d.ts.map +1 -1
  423. package/build/npm/types/integrations/fetchStreamPerformance.d.ts +14 -0
  424. package/build/npm/types/integrations/fetchStreamPerformance.d.ts.map +1 -0
  425. package/build/npm/types/tracing/browserTracingIntegration.d.ts +3 -0
  426. package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
  427. package/build/npm/types/tracing/request.d.ts +3 -0
  428. package/build/npm/types/tracing/request.d.ts.map +1 -1
  429. package/build/npm/types-ts3.8/index.bundle.d.ts +2 -2
  430. package/build/npm/types-ts3.8/index.bundle.feedback.d.ts +2 -2
  431. package/build/npm/types-ts3.8/index.bundle.logs.metrics.d.ts +2 -2
  432. package/build/npm/types-ts3.8/index.bundle.replay.d.ts +2 -2
  433. package/build/npm/types-ts3.8/index.bundle.replay.feedback.d.ts +2 -2
  434. package/build/npm/types-ts3.8/index.bundle.replay.logs.metrics.d.ts +2 -2
  435. package/build/npm/types-ts3.8/index.bundle.tracing.d.ts +1 -0
  436. package/build/npm/types-ts3.8/index.bundle.tracing.logs.metrics.d.ts +1 -0
  437. package/build/npm/types-ts3.8/index.bundle.tracing.replay.d.ts +1 -0
  438. package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.d.ts +1 -0
  439. package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +1 -0
  440. package/build/npm/types-ts3.8/index.bundle.tracing.replay.logs.metrics.d.ts +1 -0
  441. package/build/npm/types-ts3.8/index.d.ts +1 -0
  442. package/build/npm/types-ts3.8/integrations/fetchStreamPerformance.d.ts +14 -0
  443. package/build/npm/types-ts3.8/tracing/browserTracingIntegration.d.ts +3 -0
  444. package/build/npm/types-ts3.8/tracing/request.d.ts +3 -0
  445. package/package.json +7 -7
@@ -4,295 +4,124 @@ import { eventFromUnknownInput } from '../eventbuilder.js';
4
4
  import { WINDOW } from '../helpers.js';
5
5
  import { _eventFromRejectionWithPrimitive, _getUnhandledRejectionError } from './globalhandlers.js';
6
6
 
7
- const INTEGRATION_NAME = 'WebWorker';
8
-
9
- /**
10
- * Use this integration to set up Sentry with web workers.
11
- *
12
- * IMPORTANT: This integration must be added **before** you start listening to
13
- * any messages from the worker. Otherwise, your message handlers will receive
14
- * messages from the Sentry SDK which you need to ignore.
15
- *
16
- * This integration only has an effect, if you call `Sentry.registerWebWorker(self)`
17
- * from within the worker(s) you're adding to the integration.
18
- *
19
- * Given that you want to initialize the SDK as early as possible, you most likely
20
- * want to add this integration **after** initializing the SDK:
21
- *
22
- * @example:
23
- * ```ts filename={main.js}
24
- * import * as Sentry from '@sentry/<your-sdk>';
25
- *
26
- * // some time earlier:
27
- * Sentry.init(...)
28
- *
29
- * // 1. Initialize the worker
30
- * const worker = new Worker(new URL('./worker.ts', import.meta.url));
31
- *
32
- * // 2. Add the integration
33
- * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker });
34
- * Sentry.addIntegration(webWorkerIntegration);
35
- *
36
- * // 3. Register message listeners on the worker
37
- * worker.addEventListener('message', event => {
38
- * // ...
39
- * });
40
- * ```
41
- *
42
- * If you initialize multiple workers at the same time, you can also pass an array of workers
43
- * to the integration:
44
- *
45
- * ```ts filename={main.js}
46
- * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: [worker1, worker2] });
47
- * Sentry.addIntegration(webWorkerIntegration);
48
- * ```
49
- *
50
- * If you have any additional workers that you initialize at a later point,
51
- * you can add them to the integration as follows:
52
- *
53
- * ```ts filename={main.js}
54
- * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: worker1 });
55
- * Sentry.addIntegration(webWorkerIntegration);
56
- *
57
- * // sometime later:
58
- * webWorkerIntegration.addWorker(worker2);
59
- * ```
60
- *
61
- * Of course, you can also directly add the integration in Sentry.init:
62
- * ```ts filename={main.js}
63
- * import * as Sentry from '@sentry/<your-sdk>';
64
- *
65
- * // 1. Initialize the worker
66
- * const worker = new Worker(new URL('./worker.ts', import.meta.url));
67
- *
68
- * // 2. Initialize the SDK
69
- * Sentry.init({
70
- * integrations: [Sentry.webWorkerIntegration({ worker })]
71
- * });
72
- *
73
- * // 3. Register message listeners on the worker
74
- * worker.addEventListener('message', event => {
75
- * // ...
76
- * });
77
- * ```
78
- *
79
- * @param options {WebWorkerIntegrationOptions} Integration options:
80
- * - `worker`: The worker instance.
81
- */
7
+ const INTEGRATION_NAME = "WebWorker";
82
8
  const webWorkerIntegration = defineIntegration(({ worker }) => ({
83
9
  name: INTEGRATION_NAME,
84
10
  setupOnce: () => {
85
- (Array.isArray(worker) ? worker : [worker]).forEach(w => listenForSentryMessages(w));
11
+ (Array.isArray(worker) ? worker : [worker]).forEach((w) => listenForSentryMessages(w));
86
12
  },
87
- addWorker: (worker) => listenForSentryMessages(worker),
88
- })) ;
89
-
13
+ addWorker: (worker2) => listenForSentryMessages(worker2)
14
+ }));
90
15
  function listenForSentryMessages(worker) {
91
- worker.addEventListener('message', event => {
16
+ worker.addEventListener("message", (event) => {
92
17
  if (isSentryMessage(event.data)) {
93
- event.stopImmediatePropagation(); // other listeners should not receive this message
94
-
95
- // Handle debug IDs
18
+ event.stopImmediatePropagation();
96
19
  if (event.data._sentryDebugIds) {
97
- DEBUG_BUILD && debug.log('Sentry debugId web worker message received', event.data);
20
+ DEBUG_BUILD && debug.log("Sentry debugId web worker message received", event.data);
98
21
  WINDOW._sentryDebugIds = {
99
22
  ...event.data._sentryDebugIds,
100
23
  // debugIds of the main thread have precedence over the worker's in case of a collision.
101
- ...WINDOW._sentryDebugIds,
24
+ ...WINDOW._sentryDebugIds
102
25
  };
103
26
  }
104
-
105
- // Handle module metadata
106
27
  if (event.data._sentryModuleMetadata) {
107
- DEBUG_BUILD && debug.log('Sentry module metadata web worker message received', event.data);
108
- // Merge worker's raw metadata into the global object
109
- // It will be parsed lazily when needed by getMetadataForUrl
28
+ DEBUG_BUILD && debug.log("Sentry module metadata web worker message received", event.data);
110
29
  WINDOW._sentryModuleMetadata = {
111
30
  ...event.data._sentryModuleMetadata,
112
31
  // Module metadata of the main thread have precedence over the worker's in case of a collision.
113
- ...WINDOW._sentryModuleMetadata,
32
+ ...WINDOW._sentryModuleMetadata
114
33
  };
115
34
  }
116
-
117
- // Handle WASM images from worker
118
35
  if (event.data._sentryWasmImages) {
119
- DEBUG_BUILD && debug.log('Sentry WASM images web worker message received', event.data);
120
- const existingImages =
121
- (WINDOW )._sentryWasmImages || [];
36
+ DEBUG_BUILD && debug.log("Sentry WASM images web worker message received", event.data);
37
+ const existingImages = WINDOW._sentryWasmImages || [];
122
38
  const newImages = event.data._sentryWasmImages.filter(
123
- (newImg) =>
124
- isPlainObject(newImg) &&
125
- typeof newImg.code_file === 'string' &&
126
- !existingImages.some(existing => existing.code_file === newImg.code_file),
39
+ (newImg) => isPlainObject(newImg) && typeof newImg.code_file === "string" && !existingImages.some((existing) => existing.code_file === newImg.code_file)
127
40
  );
128
- (WINDOW )._sentryWasmImages = [
41
+ WINDOW._sentryWasmImages = [
129
42
  ...existingImages,
130
- ...newImages,
43
+ ...newImages
131
44
  ];
132
45
  }
133
-
134
- // Handle unhandled rejections forwarded from worker
135
46
  if (event.data._sentryWorkerError) {
136
- DEBUG_BUILD && debug.log('Sentry worker rejection message received', event.data._sentryWorkerError);
47
+ DEBUG_BUILD && debug.log("Sentry worker rejection message received", event.data._sentryWorkerError);
137
48
  handleForwardedWorkerRejection(event.data._sentryWorkerError);
138
49
  }
139
50
  }
140
51
  });
141
52
  }
142
-
143
53
  function handleForwardedWorkerRejection(workerError) {
144
54
  const client = getClient();
145
55
  if (!client) {
146
56
  return;
147
57
  }
148
-
149
58
  const stackParser = client.getOptions().stackParser;
150
59
  const attachStacktrace = client.getOptions().attachStacktrace;
151
-
152
60
  const error = workerError.reason;
153
-
154
- // Follow same pattern as globalHandlers for unhandledrejection
155
- // Handle both primitives and errors the same way
156
- const event = isPrimitive(error)
157
- ? _eventFromRejectionWithPrimitive(error)
158
- : eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);
159
-
160
- event.level = 'error';
161
-
162
- // Add worker-specific context
61
+ const event = isPrimitive(error) ? _eventFromRejectionWithPrimitive(error) : eventFromUnknownInput(stackParser, error, void 0, attachStacktrace, true);
62
+ event.level = "error";
163
63
  if (workerError.filename) {
164
64
  event.contexts = {
165
65
  ...event.contexts,
166
66
  worker: {
167
- filename: workerError.filename,
168
- },
67
+ filename: workerError.filename
68
+ }
169
69
  };
170
70
  }
171
-
172
71
  captureEvent(event, {
173
72
  originalException: error,
174
73
  mechanism: {
175
74
  handled: false,
176
- type: 'auto.browser.web_worker.onunhandledrejection',
177
- },
75
+ type: "auto.browser.web_worker.onunhandledrejection"
76
+ }
178
77
  });
179
-
180
- DEBUG_BUILD && debug.log('Captured worker unhandled rejection', error);
78
+ DEBUG_BUILD && debug.log("Captured worker unhandled rejection", error);
181
79
  }
182
-
183
- /**
184
- * Minimal interface for DedicatedWorkerGlobalScope, only requiring the postMessage method.
185
- * (which is the only thing we need from the worker's global object)
186
- *
187
- * @see https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope
188
- *
189
- * We can't use the actual type because it breaks everyone who doesn't have {"lib": ["WebWorker"]}
190
- * but uses {"skipLibCheck": true} in their tsconfig.json.
191
- */
192
-
193
- /**
194
- * Use this function to register the worker with the Sentry SDK.
195
- *
196
- * This function will:
197
- * - Send debug IDs to the parent thread
198
- * - Send module metadata to the parent thread (for thirdPartyErrorFilterIntegration)
199
- * - Set up a handler for unhandled rejections in the worker
200
- * - Forward unhandled rejections to the parent thread for capture
201
- *
202
- * Note: Synchronous errors in workers are already captured by globalHandlers.
203
- * This only handles unhandled promise rejections which don't bubble to the parent.
204
- *
205
- * @example
206
- * ```ts filename={worker.js}
207
- * import * as Sentry from '@sentry/<your-sdk>';
208
- *
209
- * // Do this as early as possible in your worker.
210
- * Sentry.registerWebWorker({ self });
211
- *
212
- * // continue setting up your worker
213
- * self.postMessage(...)
214
- * ```
215
- * @param options {RegisterWebWorkerOptions} Integration options:
216
- * - `self`: The worker instance you're calling this function from (self).
217
- */
218
80
  function registerWebWorker({ self }) {
219
- // Send debug IDs and raw module metadata to parent thread
220
- // The metadata will be parsed lazily on the main thread when needed
221
81
  self.postMessage({
222
82
  _sentryMessage: true,
223
- _sentryDebugIds: self._sentryDebugIds ?? undefined,
224
- _sentryModuleMetadata: self._sentryModuleMetadata ?? undefined,
83
+ _sentryDebugIds: self._sentryDebugIds ?? void 0,
84
+ _sentryModuleMetadata: self._sentryModuleMetadata ?? void 0
225
85
  });
226
-
227
- // Set up unhandledrejection handler inside the worker
228
- // Following the same pattern as globalHandlers
229
- // unhandled rejections don't bubble to the parent thread, so we need to handle them here
230
- self.addEventListener('unhandledrejection', (event) => {
86
+ self.addEventListener("unhandledrejection", (event) => {
231
87
  const reason = _getUnhandledRejectionError(event);
232
-
233
- // Forward the raw reason to parent thread
234
- // The parent will handle primitives vs errors the same way globalHandlers does
235
88
  const serializedError = {
236
- reason: reason,
237
- filename: self.location?.href,
89
+ reason,
90
+ filename: self.location?.href
238
91
  };
239
-
240
- // Forward to parent thread
241
92
  self.postMessage({
242
93
  _sentryMessage: true,
243
- _sentryWorkerError: serializedError,
94
+ _sentryWorkerError: serializedError
244
95
  });
245
-
246
- DEBUG_BUILD && debug.log('[Sentry Worker] Forwarding unhandled rejection to parent', serializedError);
96
+ DEBUG_BUILD && debug.log("[Sentry Worker] Forwarding unhandled rejection to parent", serializedError);
247
97
  });
248
-
249
- DEBUG_BUILD && debug.log('[Sentry Worker] Registered worker with unhandled rejection handling');
98
+ DEBUG_BUILD && debug.log("[Sentry Worker] Registered worker with unhandled rejection handling");
250
99
  }
251
-
252
100
  function isSentryMessage(eventData) {
253
101
  if (!isPlainObject(eventData) || eventData._sentryMessage !== true) {
254
102
  return false;
255
103
  }
256
-
257
- // Must have at least one of: debug IDs, module metadata, worker error, or WASM images
258
- const hasDebugIds = '_sentryDebugIds' in eventData;
259
- const hasModuleMetadata = '_sentryModuleMetadata' in eventData;
260
- const hasWorkerError = '_sentryWorkerError' in eventData;
261
- const hasWasmImages = '_sentryWasmImages' in eventData;
262
-
104
+ const hasDebugIds = "_sentryDebugIds" in eventData;
105
+ const hasModuleMetadata = "_sentryModuleMetadata" in eventData;
106
+ const hasWorkerError = "_sentryWorkerError" in eventData;
107
+ const hasWasmImages = "_sentryWasmImages" in eventData;
263
108
  if (!hasDebugIds && !hasModuleMetadata && !hasWorkerError && !hasWasmImages) {
264
109
  return false;
265
110
  }
266
-
267
- // Validate debug IDs if present
268
- if (hasDebugIds && !(isPlainObject(eventData._sentryDebugIds) || eventData._sentryDebugIds === undefined)) {
111
+ if (hasDebugIds && !(isPlainObject(eventData._sentryDebugIds) || eventData._sentryDebugIds === void 0)) {
269
112
  return false;
270
113
  }
271
-
272
- // Validate module metadata if present
273
- if (
274
- hasModuleMetadata &&
275
- !(isPlainObject(eventData._sentryModuleMetadata) || eventData._sentryModuleMetadata === undefined)
276
- ) {
114
+ if (hasModuleMetadata && !(isPlainObject(eventData._sentryModuleMetadata) || eventData._sentryModuleMetadata === void 0)) {
277
115
  return false;
278
116
  }
279
-
280
- // Validate worker error if present
281
117
  if (hasWorkerError && !isPlainObject(eventData._sentryWorkerError)) {
282
118
  return false;
283
119
  }
284
-
285
- // Validate WASM images if present
286
- if (
287
- hasWasmImages &&
288
- (!Array.isArray(eventData._sentryWasmImages) ||
289
- !eventData._sentryWasmImages.every(
290
- (img) => isPlainObject(img) && typeof (img ).code_file === 'string',
291
- ))
292
- ) {
120
+ if (hasWasmImages && (!Array.isArray(eventData._sentryWasmImages) || !eventData._sentryWasmImages.every(
121
+ (img) => isPlainObject(img) && typeof img.code_file === "string"
122
+ ))) {
293
123
  return false;
294
124
  }
295
-
296
125
  return true;
297
126
  }
298
127
 
@@ -1 +1 @@
1
- {"version":3,"file":"webWorker.js","sources":["../../../../../src/integrations/webWorker.ts"],"sourcesContent":["import type { DebugImage, Integration, IntegrationFn } from '@sentry/core/browser';\nimport { captureEvent, debug, defineIntegration, getClient, isPlainObject, isPrimitive } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { eventFromUnknownInput } from '../eventbuilder';\nimport { WINDOW } from '../helpers';\nimport { _eventFromRejectionWithPrimitive, _getUnhandledRejectionError } from './globalhandlers';\n\nexport const INTEGRATION_NAME = 'WebWorker';\n\ninterface WebWorkerMessage {\n _sentryMessage: boolean;\n _sentryDebugIds?: Record<string, string>;\n _sentryModuleMetadata?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n _sentryWorkerError?: SerializedWorkerError;\n _sentryWasmImages?: Array<DebugImage>;\n}\n\ninterface SerializedWorkerError {\n reason: unknown;\n filename?: string;\n}\n\ninterface WebWorkerIntegrationOptions {\n worker: Worker | Array<Worker>;\n}\n\ninterface WebWorkerIntegration extends Integration {\n addWorker: (worker: Worker) => void;\n}\n\n/**\n * Use this integration to set up Sentry with web workers.\n *\n * IMPORTANT: This integration must be added **before** you start listening to\n * any messages from the worker. Otherwise, your message handlers will receive\n * messages from the Sentry SDK which you need to ignore.\n *\n * This integration only has an effect, if you call `Sentry.registerWebWorker(self)`\n * from within the worker(s) you're adding to the integration.\n *\n * Given that you want to initialize the SDK as early as possible, you most likely\n * want to add this integration **after** initializing the SDK:\n *\n * @example:\n * ```ts filename={main.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // some time earlier:\n * Sentry.init(...)\n *\n * // 1. Initialize the worker\n * const worker = new Worker(new URL('./worker.ts', import.meta.url));\n *\n * // 2. Add the integration\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker });\n * Sentry.addIntegration(webWorkerIntegration);\n *\n * // 3. Register message listeners on the worker\n * worker.addEventListener('message', event => {\n * // ...\n * });\n * ```\n *\n * If you initialize multiple workers at the same time, you can also pass an array of workers\n * to the integration:\n *\n * ```ts filename={main.js}\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: [worker1, worker2] });\n * Sentry.addIntegration(webWorkerIntegration);\n * ```\n *\n * If you have any additional workers that you initialize at a later point,\n * you can add them to the integration as follows:\n *\n * ```ts filename={main.js}\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: worker1 });\n * Sentry.addIntegration(webWorkerIntegration);\n *\n * // sometime later:\n * webWorkerIntegration.addWorker(worker2);\n * ```\n *\n * Of course, you can also directly add the integration in Sentry.init:\n * ```ts filename={main.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // 1. Initialize the worker\n * const worker = new Worker(new URL('./worker.ts', import.meta.url));\n *\n * // 2. Initialize the SDK\n * Sentry.init({\n * integrations: [Sentry.webWorkerIntegration({ worker })]\n * });\n *\n * // 3. Register message listeners on the worker\n * worker.addEventListener('message', event => {\n * // ...\n * });\n * ```\n *\n * @param options {WebWorkerIntegrationOptions} Integration options:\n * - `worker`: The worker instance.\n */\nexport const webWorkerIntegration = defineIntegration(({ worker }: WebWorkerIntegrationOptions) => ({\n name: INTEGRATION_NAME,\n setupOnce: () => {\n (Array.isArray(worker) ? worker : [worker]).forEach(w => listenForSentryMessages(w));\n },\n addWorker: (worker: Worker) => listenForSentryMessages(worker),\n})) as IntegrationFn<WebWorkerIntegration>;\n\nfunction listenForSentryMessages(worker: Worker): void {\n worker.addEventListener('message', event => {\n if (isSentryMessage(event.data)) {\n event.stopImmediatePropagation(); // other listeners should not receive this message\n\n // Handle debug IDs\n if (event.data._sentryDebugIds) {\n DEBUG_BUILD && debug.log('Sentry debugId web worker message received', event.data);\n WINDOW._sentryDebugIds = {\n ...event.data._sentryDebugIds,\n // debugIds of the main thread have precedence over the worker's in case of a collision.\n ...WINDOW._sentryDebugIds,\n };\n }\n\n // Handle module metadata\n if (event.data._sentryModuleMetadata) {\n DEBUG_BUILD && debug.log('Sentry module metadata web worker message received', event.data);\n // Merge worker's raw metadata into the global object\n // It will be parsed lazily when needed by getMetadataForUrl\n WINDOW._sentryModuleMetadata = {\n ...event.data._sentryModuleMetadata,\n // Module metadata of the main thread have precedence over the worker's in case of a collision.\n ...WINDOW._sentryModuleMetadata,\n };\n }\n\n // Handle WASM images from worker\n if (event.data._sentryWasmImages) {\n DEBUG_BUILD && debug.log('Sentry WASM images web worker message received', event.data);\n const existingImages =\n (WINDOW as typeof WINDOW & { _sentryWasmImages?: Array<DebugImage> })._sentryWasmImages || [];\n const newImages = event.data._sentryWasmImages.filter(\n (newImg: unknown) =>\n isPlainObject(newImg) &&\n typeof newImg.code_file === 'string' &&\n !existingImages.some(existing => existing.code_file === newImg.code_file),\n );\n (WINDOW as typeof WINDOW & { _sentryWasmImages?: Array<DebugImage> })._sentryWasmImages = [\n ...existingImages,\n ...newImages,\n ];\n }\n\n // Handle unhandled rejections forwarded from worker\n if (event.data._sentryWorkerError) {\n DEBUG_BUILD && debug.log('Sentry worker rejection message received', event.data._sentryWorkerError);\n handleForwardedWorkerRejection(event.data._sentryWorkerError);\n }\n }\n });\n}\n\nfunction handleForwardedWorkerRejection(workerError: SerializedWorkerError): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const stackParser = client.getOptions().stackParser;\n const attachStacktrace = client.getOptions().attachStacktrace;\n\n const error = workerError.reason;\n\n // Follow same pattern as globalHandlers for unhandledrejection\n // Handle both primitives and errors the same way\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);\n\n event.level = 'error';\n\n // Add worker-specific context\n if (workerError.filename) {\n event.contexts = {\n ...event.contexts,\n worker: {\n filename: workerError.filename,\n },\n };\n }\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'auto.browser.web_worker.onunhandledrejection',\n },\n });\n\n DEBUG_BUILD && debug.log('Captured worker unhandled rejection', error);\n}\n\n/**\n * Minimal interface for DedicatedWorkerGlobalScope, only requiring the postMessage method.\n * (which is the only thing we need from the worker's global object)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope\n *\n * We can't use the actual type because it breaks everyone who doesn't have {\"lib\": [\"WebWorker\"]}\n * but uses {\"skipLibCheck\": true} in their tsconfig.json.\n */\ninterface MinimalDedicatedWorkerGlobalScope {\n postMessage: (message: unknown) => void;\n addEventListener: (type: string, listener: (event: unknown) => void) => void;\n location?: { href?: string };\n}\n\ninterface RegisterWebWorkerOptions {\n self: MinimalDedicatedWorkerGlobalScope & {\n _sentryDebugIds?: Record<string, string>;\n _sentryModuleMetadata?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n };\n}\n\n/**\n * Use this function to register the worker with the Sentry SDK.\n *\n * This function will:\n * - Send debug IDs to the parent thread\n * - Send module metadata to the parent thread (for thirdPartyErrorFilterIntegration)\n * - Set up a handler for unhandled rejections in the worker\n * - Forward unhandled rejections to the parent thread for capture\n *\n * Note: Synchronous errors in workers are already captured by globalHandlers.\n * This only handles unhandled promise rejections which don't bubble to the parent.\n *\n * @example\n * ```ts filename={worker.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // Do this as early as possible in your worker.\n * Sentry.registerWebWorker({ self });\n *\n * // continue setting up your worker\n * self.postMessage(...)\n * ```\n * @param options {RegisterWebWorkerOptions} Integration options:\n * - `self`: The worker instance you're calling this function from (self).\n */\nexport function registerWebWorker({ self }: RegisterWebWorkerOptions): void {\n // Send debug IDs and raw module metadata to parent thread\n // The metadata will be parsed lazily on the main thread when needed\n self.postMessage({\n _sentryMessage: true,\n _sentryDebugIds: self._sentryDebugIds ?? undefined,\n _sentryModuleMetadata: self._sentryModuleMetadata ?? undefined,\n });\n\n // Set up unhandledrejection handler inside the worker\n // Following the same pattern as globalHandlers\n // unhandled rejections don't bubble to the parent thread, so we need to handle them here\n self.addEventListener('unhandledrejection', (event: unknown) => {\n const reason = _getUnhandledRejectionError(event);\n\n // Forward the raw reason to parent thread\n // The parent will handle primitives vs errors the same way globalHandlers does\n const serializedError: SerializedWorkerError = {\n reason: reason,\n filename: self.location?.href,\n };\n\n // Forward to parent thread\n self.postMessage({\n _sentryMessage: true,\n _sentryWorkerError: serializedError,\n });\n\n DEBUG_BUILD && debug.log('[Sentry Worker] Forwarding unhandled rejection to parent', serializedError);\n });\n\n DEBUG_BUILD && debug.log('[Sentry Worker] Registered worker with unhandled rejection handling');\n}\n\nfunction isSentryMessage(eventData: unknown): eventData is WebWorkerMessage {\n if (!isPlainObject(eventData) || eventData._sentryMessage !== true) {\n return false;\n }\n\n // Must have at least one of: debug IDs, module metadata, worker error, or WASM images\n const hasDebugIds = '_sentryDebugIds' in eventData;\n const hasModuleMetadata = '_sentryModuleMetadata' in eventData;\n const hasWorkerError = '_sentryWorkerError' in eventData;\n const hasWasmImages = '_sentryWasmImages' in eventData;\n\n if (!hasDebugIds && !hasModuleMetadata && !hasWorkerError && !hasWasmImages) {\n return false;\n }\n\n // Validate debug IDs if present\n if (hasDebugIds && !(isPlainObject(eventData._sentryDebugIds) || eventData._sentryDebugIds === undefined)) {\n return false;\n }\n\n // Validate module metadata if present\n if (\n hasModuleMetadata &&\n !(isPlainObject(eventData._sentryModuleMetadata) || eventData._sentryModuleMetadata === undefined)\n ) {\n return false;\n }\n\n // Validate worker error if present\n if (hasWorkerError && !isPlainObject(eventData._sentryWorkerError)) {\n return false;\n }\n\n // Validate WASM images if present\n if (\n hasWasmImages &&\n (!Array.isArray(eventData._sentryWasmImages) ||\n !eventData._sentryWasmImages.every(\n (img: unknown) => isPlainObject(img) && typeof (img as { code_file?: unknown }).code_file === 'string',\n ))\n ) {\n return false;\n }\n\n return true;\n}\n"],"names":[],"mappings":";;;;;;AAOO,MAAM,gBAAA,GAAmB;;AA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EAAE,IAAI,CAAC,WAAA,IAAe,CAAC,iBAAA,IAAqB,CAAC,cAAA,IAAkB,CAAC,aAAa,EAAE;AAC/E,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF;AACA,EAAE,IAAI,WAAA,IAAe,EAAE,aAAa,CAAC,SAAS,CAAC,eAAe,CAAA,IAAK,SAAS,CAAC,oBAAoB,SAAS,CAAC,EAAE;AAC7G,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF;AACA,EAAE;AACF,IAAI,iBAAA;AACJ,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,qBAAqB,CAAA,IAAK,SAAS,CAAC,qBAAA,KAA0B,SAAS;AACrG,IAAI;AACJ,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF;AACA,EAAE,IAAI,cAAA,IAAkB,CAAC,aAAa,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE;AACtE,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF;AACA,EAAE;AACF,IAAI,aAAA;AACJ,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAA;AAC/C,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK;AACxC,QAAQ,CAAC,GAAG,KAAc,aAAa,CAAC,GAAG,CAAA,IAAK,OAAO,CAAC,GAAA,GAAgC,SAAA,KAAc,QAAQ;AAC9G,OAAO;AACP,IAAI;AACJ,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,OAAO,IAAI;AACb;;;;"}
1
+ {"version":3,"file":"webWorker.js","sources":["../../../../../src/integrations/webWorker.ts"],"sourcesContent":["import type { DebugImage, Integration, IntegrationFn } from '@sentry/core/browser';\nimport { captureEvent, debug, defineIntegration, getClient, isPlainObject, isPrimitive } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { eventFromUnknownInput } from '../eventbuilder';\nimport { WINDOW } from '../helpers';\nimport { _eventFromRejectionWithPrimitive, _getUnhandledRejectionError } from './globalhandlers';\n\nexport const INTEGRATION_NAME = 'WebWorker';\n\ninterface WebWorkerMessage {\n _sentryMessage: boolean;\n _sentryDebugIds?: Record<string, string>;\n _sentryModuleMetadata?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n _sentryWorkerError?: SerializedWorkerError;\n _sentryWasmImages?: Array<DebugImage>;\n}\n\ninterface SerializedWorkerError {\n reason: unknown;\n filename?: string;\n}\n\ninterface WebWorkerIntegrationOptions {\n worker: Worker | Array<Worker>;\n}\n\ninterface WebWorkerIntegration extends Integration {\n addWorker: (worker: Worker) => void;\n}\n\n/**\n * Use this integration to set up Sentry with web workers.\n *\n * IMPORTANT: This integration must be added **before** you start listening to\n * any messages from the worker. Otherwise, your message handlers will receive\n * messages from the Sentry SDK which you need to ignore.\n *\n * This integration only has an effect, if you call `Sentry.registerWebWorker(self)`\n * from within the worker(s) you're adding to the integration.\n *\n * Given that you want to initialize the SDK as early as possible, you most likely\n * want to add this integration **after** initializing the SDK:\n *\n * @example:\n * ```ts filename={main.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // some time earlier:\n * Sentry.init(...)\n *\n * // 1. Initialize the worker\n * const worker = new Worker(new URL('./worker.ts', import.meta.url));\n *\n * // 2. Add the integration\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker });\n * Sentry.addIntegration(webWorkerIntegration);\n *\n * // 3. Register message listeners on the worker\n * worker.addEventListener('message', event => {\n * // ...\n * });\n * ```\n *\n * If you initialize multiple workers at the same time, you can also pass an array of workers\n * to the integration:\n *\n * ```ts filename={main.js}\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: [worker1, worker2] });\n * Sentry.addIntegration(webWorkerIntegration);\n * ```\n *\n * If you have any additional workers that you initialize at a later point,\n * you can add them to the integration as follows:\n *\n * ```ts filename={main.js}\n * const webWorkerIntegration = Sentry.webWorkerIntegration({ worker: worker1 });\n * Sentry.addIntegration(webWorkerIntegration);\n *\n * // sometime later:\n * webWorkerIntegration.addWorker(worker2);\n * ```\n *\n * Of course, you can also directly add the integration in Sentry.init:\n * ```ts filename={main.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // 1. Initialize the worker\n * const worker = new Worker(new URL('./worker.ts', import.meta.url));\n *\n * // 2. Initialize the SDK\n * Sentry.init({\n * integrations: [Sentry.webWorkerIntegration({ worker })]\n * });\n *\n * // 3. Register message listeners on the worker\n * worker.addEventListener('message', event => {\n * // ...\n * });\n * ```\n *\n * @param options {WebWorkerIntegrationOptions} Integration options:\n * - `worker`: The worker instance.\n */\nexport const webWorkerIntegration = defineIntegration(({ worker }: WebWorkerIntegrationOptions) => ({\n name: INTEGRATION_NAME,\n setupOnce: () => {\n (Array.isArray(worker) ? worker : [worker]).forEach(w => listenForSentryMessages(w));\n },\n addWorker: (worker: Worker) => listenForSentryMessages(worker),\n})) as IntegrationFn<WebWorkerIntegration>;\n\nfunction listenForSentryMessages(worker: Worker): void {\n worker.addEventListener('message', event => {\n if (isSentryMessage(event.data)) {\n event.stopImmediatePropagation(); // other listeners should not receive this message\n\n // Handle debug IDs\n if (event.data._sentryDebugIds) {\n DEBUG_BUILD && debug.log('Sentry debugId web worker message received', event.data);\n WINDOW._sentryDebugIds = {\n ...event.data._sentryDebugIds,\n // debugIds of the main thread have precedence over the worker's in case of a collision.\n ...WINDOW._sentryDebugIds,\n };\n }\n\n // Handle module metadata\n if (event.data._sentryModuleMetadata) {\n DEBUG_BUILD && debug.log('Sentry module metadata web worker message received', event.data);\n // Merge worker's raw metadata into the global object\n // It will be parsed lazily when needed by getMetadataForUrl\n WINDOW._sentryModuleMetadata = {\n ...event.data._sentryModuleMetadata,\n // Module metadata of the main thread have precedence over the worker's in case of a collision.\n ...WINDOW._sentryModuleMetadata,\n };\n }\n\n // Handle WASM images from worker\n if (event.data._sentryWasmImages) {\n DEBUG_BUILD && debug.log('Sentry WASM images web worker message received', event.data);\n const existingImages =\n (WINDOW as typeof WINDOW & { _sentryWasmImages?: Array<DebugImage> })._sentryWasmImages || [];\n const newImages = event.data._sentryWasmImages.filter(\n (newImg: unknown) =>\n isPlainObject(newImg) &&\n typeof newImg.code_file === 'string' &&\n !existingImages.some(existing => existing.code_file === newImg.code_file),\n );\n (WINDOW as typeof WINDOW & { _sentryWasmImages?: Array<DebugImage> })._sentryWasmImages = [\n ...existingImages,\n ...newImages,\n ];\n }\n\n // Handle unhandled rejections forwarded from worker\n if (event.data._sentryWorkerError) {\n DEBUG_BUILD && debug.log('Sentry worker rejection message received', event.data._sentryWorkerError);\n handleForwardedWorkerRejection(event.data._sentryWorkerError);\n }\n }\n });\n}\n\nfunction handleForwardedWorkerRejection(workerError: SerializedWorkerError): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const stackParser = client.getOptions().stackParser;\n const attachStacktrace = client.getOptions().attachStacktrace;\n\n const error = workerError.reason;\n\n // Follow same pattern as globalHandlers for unhandledrejection\n // Handle both primitives and errors the same way\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);\n\n event.level = 'error';\n\n // Add worker-specific context\n if (workerError.filename) {\n event.contexts = {\n ...event.contexts,\n worker: {\n filename: workerError.filename,\n },\n };\n }\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'auto.browser.web_worker.onunhandledrejection',\n },\n });\n\n DEBUG_BUILD && debug.log('Captured worker unhandled rejection', error);\n}\n\n/**\n * Minimal interface for DedicatedWorkerGlobalScope, only requiring the postMessage method.\n * (which is the only thing we need from the worker's global object)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope\n *\n * We can't use the actual type because it breaks everyone who doesn't have {\"lib\": [\"WebWorker\"]}\n * but uses {\"skipLibCheck\": true} in their tsconfig.json.\n */\ninterface MinimalDedicatedWorkerGlobalScope {\n postMessage: (message: unknown) => void;\n addEventListener: (type: string, listener: (event: unknown) => void) => void;\n location?: { href?: string };\n}\n\ninterface RegisterWebWorkerOptions {\n self: MinimalDedicatedWorkerGlobalScope & {\n _sentryDebugIds?: Record<string, string>;\n _sentryModuleMetadata?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n };\n}\n\n/**\n * Use this function to register the worker with the Sentry SDK.\n *\n * This function will:\n * - Send debug IDs to the parent thread\n * - Send module metadata to the parent thread (for thirdPartyErrorFilterIntegration)\n * - Set up a handler for unhandled rejections in the worker\n * - Forward unhandled rejections to the parent thread for capture\n *\n * Note: Synchronous errors in workers are already captured by globalHandlers.\n * This only handles unhandled promise rejections which don't bubble to the parent.\n *\n * @example\n * ```ts filename={worker.js}\n * import * as Sentry from '@sentry/<your-sdk>';\n *\n * // Do this as early as possible in your worker.\n * Sentry.registerWebWorker({ self });\n *\n * // continue setting up your worker\n * self.postMessage(...)\n * ```\n * @param options {RegisterWebWorkerOptions} Integration options:\n * - `self`: The worker instance you're calling this function from (self).\n */\nexport function registerWebWorker({ self }: RegisterWebWorkerOptions): void {\n // Send debug IDs and raw module metadata to parent thread\n // The metadata will be parsed lazily on the main thread when needed\n self.postMessage({\n _sentryMessage: true,\n _sentryDebugIds: self._sentryDebugIds ?? undefined,\n _sentryModuleMetadata: self._sentryModuleMetadata ?? undefined,\n });\n\n // Set up unhandledrejection handler inside the worker\n // Following the same pattern as globalHandlers\n // unhandled rejections don't bubble to the parent thread, so we need to handle them here\n self.addEventListener('unhandledrejection', (event: unknown) => {\n const reason = _getUnhandledRejectionError(event);\n\n // Forward the raw reason to parent thread\n // The parent will handle primitives vs errors the same way globalHandlers does\n const serializedError: SerializedWorkerError = {\n reason: reason,\n filename: self.location?.href,\n };\n\n // Forward to parent thread\n self.postMessage({\n _sentryMessage: true,\n _sentryWorkerError: serializedError,\n });\n\n DEBUG_BUILD && debug.log('[Sentry Worker] Forwarding unhandled rejection to parent', serializedError);\n });\n\n DEBUG_BUILD && debug.log('[Sentry Worker] Registered worker with unhandled rejection handling');\n}\n\nfunction isSentryMessage(eventData: unknown): eventData is WebWorkerMessage {\n if (!isPlainObject(eventData) || eventData._sentryMessage !== true) {\n return false;\n }\n\n // Must have at least one of: debug IDs, module metadata, worker error, or WASM images\n const hasDebugIds = '_sentryDebugIds' in eventData;\n const hasModuleMetadata = '_sentryModuleMetadata' in eventData;\n const hasWorkerError = '_sentryWorkerError' in eventData;\n const hasWasmImages = '_sentryWasmImages' in eventData;\n\n if (!hasDebugIds && !hasModuleMetadata && !hasWorkerError && !hasWasmImages) {\n return false;\n }\n\n // Validate debug IDs if present\n if (hasDebugIds && !(isPlainObject(eventData._sentryDebugIds) || eventData._sentryDebugIds === undefined)) {\n return false;\n }\n\n // Validate module metadata if present\n if (\n hasModuleMetadata &&\n !(isPlainObject(eventData._sentryModuleMetadata) || eventData._sentryModuleMetadata === undefined)\n ) {\n return false;\n }\n\n // Validate worker error if present\n if (hasWorkerError && !isPlainObject(eventData._sentryWorkerError)) {\n return false;\n }\n\n // Validate WASM images if present\n if (\n hasWasmImages &&\n (!Array.isArray(eventData._sentryWasmImages) ||\n !eventData._sentryWasmImages.every(\n (img: unknown) => isPlainObject(img) && typeof (img as { code_file?: unknown }).code_file === 'string',\n ))\n ) {\n return false;\n }\n\n return true;\n}\n"],"names":["worker"],"mappings":";;;;;;AAOO,MAAM,gBAAA,GAAmB;AAgGzB,MAAM,oBAAA,GAAuB,iBAAA,CAAkB,CAAC,EAAE,QAAO,MAAoC;AAAA,EAClG,IAAA,EAAM,gBAAA;AAAA,EACN,WAAW,MAAM;AACf,IAAA,CAAC,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,GAAI,MAAA,GAAS,CAAC,MAAM,CAAA,EAAG,OAAA,CAAQ,CAAA,CAAA,KAAK,uBAAA,CAAwB,CAAC,CAAC,CAAA;AAAA,EACrF,CAAA;AAAA,EACA,SAAA,EAAW,CAACA,OAAAA,KAAmB,uBAAA,CAAwBA,OAAM;AAC/D,CAAA,CAAE;AAEF,SAAS,wBAAwB,MAAA,EAAsB;AACrD,EAAA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