@sentry/browser 10.52.0 → 10.53.1

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 (507) hide show
  1. package/build/npm/cjs/dev/client.js +7 -7
  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 +23 -23
  6. package/build/npm/cjs/dev/eventbuilder.js.map +1 -1
  7. package/build/npm/cjs/dev/feedbackAsync.js.map +1 -1
  8. package/build/npm/cjs/dev/feedbackSync.js.map +1 -1
  9. package/build/npm/cjs/dev/helpers.js +10 -10
  10. package/build/npm/cjs/dev/helpers.js.map +1 -1
  11. package/build/npm/cjs/dev/index.js +84 -84
  12. package/build/npm/cjs/dev/integrations/breadcrumbs.js +29 -29
  13. package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -1
  14. package/build/npm/cjs/dev/integrations/browserapierrors.js +16 -16
  15. package/build/npm/cjs/dev/integrations/browserapierrors.js.map +1 -1
  16. package/build/npm/cjs/dev/integrations/browsersession.js +9 -9
  17. package/build/npm/cjs/dev/integrations/browsersession.js.map +1 -1
  18. package/build/npm/cjs/dev/integrations/contextlines.js +5 -5
  19. package/build/npm/cjs/dev/integrations/contextlines.js.map +1 -1
  20. package/build/npm/cjs/dev/integrations/culturecontext.js +3 -3
  21. package/build/npm/cjs/dev/integrations/culturecontext.js.map +1 -1
  22. package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js +2 -2
  23. package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
  24. package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js +5 -5
  25. package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  26. package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js +7 -7
  27. package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
  28. package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js +5 -5
  29. package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
  30. package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js +7 -7
  31. package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
  32. package/build/npm/cjs/dev/integrations/globalhandlers.js +16 -16
  33. package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -1
  34. package/build/npm/cjs/dev/integrations/graphqlClient.js +9 -9
  35. package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -1
  36. package/build/npm/cjs/dev/integrations/httpclient.js +14 -14
  37. package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -1
  38. package/build/npm/cjs/dev/integrations/httpcontext.js +3 -3
  39. package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -1
  40. package/build/npm/cjs/dev/integrations/linkederrors.js +3 -3
  41. package/build/npm/cjs/dev/integrations/linkederrors.js.map +1 -1
  42. package/build/npm/cjs/dev/integrations/reportingobserver.js +7 -7
  43. package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -1
  44. package/build/npm/cjs/dev/integrations/spanstreaming.js +10 -10
  45. package/build/npm/cjs/dev/integrations/spanstreaming.js.map +1 -1
  46. package/build/npm/cjs/dev/integrations/spotlight.js +6 -6
  47. package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -1
  48. package/build/npm/cjs/dev/integrations/view-hierarchy.js +3 -3
  49. package/build/npm/cjs/dev/integrations/view-hierarchy.js.map +1 -1
  50. package/build/npm/cjs/dev/integrations/webWorker.js +18 -18
  51. package/build/npm/cjs/dev/integrations/webWorker.js.map +1 -1
  52. package/build/npm/cjs/dev/profiling/UIProfiler.js +43 -33
  53. package/build/npm/cjs/dev/profiling/UIProfiler.js.map +1 -1
  54. package/build/npm/cjs/dev/profiling/index.js +7 -7
  55. package/build/npm/cjs/dev/profiling/index.js.map +1 -1
  56. package/build/npm/cjs/dev/profiling/integration.js +20 -18
  57. package/build/npm/cjs/dev/profiling/integration.js.map +1 -1
  58. package/build/npm/cjs/dev/profiling/startProfileForSpan.js +14 -11
  59. package/build/npm/cjs/dev/profiling/startProfileForSpan.js.map +1 -1
  60. package/build/npm/cjs/dev/profiling/utils.js +39 -68
  61. package/build/npm/cjs/dev/profiling/utils.js.map +1 -1
  62. package/build/npm/cjs/dev/report-dialog.js +7 -7
  63. package/build/npm/cjs/dev/report-dialog.js.map +1 -1
  64. package/build/npm/cjs/dev/sdk.js +8 -8
  65. package/build/npm/cjs/dev/sdk.js.map +1 -1
  66. package/build/npm/cjs/dev/stack-parsers.js +10 -10
  67. package/build/npm/cjs/dev/stack-parsers.js.map +1 -1
  68. package/build/npm/cjs/dev/tracing/backgroundtab.js +7 -7
  69. package/build/npm/cjs/dev/tracing/backgroundtab.js.map +1 -1
  70. package/build/npm/cjs/dev/tracing/browserTracingIntegration.js +52 -52
  71. package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -1
  72. package/build/npm/cjs/dev/tracing/linkedTraces.js +11 -11
  73. package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -1
  74. package/build/npm/cjs/dev/tracing/reportPageLoaded.js +2 -2
  75. package/build/npm/cjs/dev/tracing/reportPageLoaded.js.map +1 -1
  76. package/build/npm/cjs/dev/tracing/request.js +28 -28
  77. package/build/npm/cjs/dev/tracing/request.js.map +1 -1
  78. package/build/npm/cjs/dev/tracing/setActiveSpan.js +5 -5
  79. package/build/npm/cjs/dev/tracing/setActiveSpan.js.map +1 -1
  80. package/build/npm/cjs/dev/transports/fetch.js +3 -3
  81. package/build/npm/cjs/dev/transports/fetch.js.map +1 -1
  82. package/build/npm/cjs/dev/transports/offline.js +5 -5
  83. package/build/npm/cjs/dev/transports/offline.js.map +1 -1
  84. package/build/npm/cjs/dev/userfeedback.js +3 -3
  85. package/build/npm/cjs/dev/userfeedback.js.map +1 -1
  86. package/build/npm/cjs/dev/utils/detectBrowserExtension.js +3 -3
  87. package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -1
  88. package/build/npm/cjs/dev/utils/lazyLoadIntegration.js +3 -3
  89. package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -1
  90. package/build/npm/cjs/prod/client.js +7 -7
  91. package/build/npm/cjs/prod/client.js.map +1 -1
  92. package/build/npm/cjs/prod/diagnose-sdk.js +3 -3
  93. package/build/npm/cjs/prod/diagnose-sdk.js.map +1 -1
  94. package/build/npm/cjs/prod/eventbuilder.js +23 -23
  95. package/build/npm/cjs/prod/eventbuilder.js.map +1 -1
  96. package/build/npm/cjs/prod/feedbackAsync.js.map +1 -1
  97. package/build/npm/cjs/prod/feedbackSync.js.map +1 -1
  98. package/build/npm/cjs/prod/helpers.js +10 -10
  99. package/build/npm/cjs/prod/helpers.js.map +1 -1
  100. package/build/npm/cjs/prod/index.js +84 -84
  101. package/build/npm/cjs/prod/integrations/breadcrumbs.js +29 -29
  102. package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -1
  103. package/build/npm/cjs/prod/integrations/browserapierrors.js +16 -16
  104. package/build/npm/cjs/prod/integrations/browserapierrors.js.map +1 -1
  105. package/build/npm/cjs/prod/integrations/browsersession.js +9 -9
  106. package/build/npm/cjs/prod/integrations/browsersession.js.map +1 -1
  107. package/build/npm/cjs/prod/integrations/contextlines.js +5 -5
  108. package/build/npm/cjs/prod/integrations/contextlines.js.map +1 -1
  109. package/build/npm/cjs/prod/integrations/culturecontext.js +3 -3
  110. package/build/npm/cjs/prod/integrations/culturecontext.js.map +1 -1
  111. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js +2 -2
  112. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
  113. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js +5 -5
  114. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  115. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js +7 -7
  116. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
  117. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js +5 -5
  118. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
  119. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js +7 -7
  120. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
  121. package/build/npm/cjs/prod/integrations/globalhandlers.js +16 -16
  122. package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -1
  123. package/build/npm/cjs/prod/integrations/graphqlClient.js +9 -9
  124. package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -1
  125. package/build/npm/cjs/prod/integrations/httpclient.js +14 -14
  126. package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -1
  127. package/build/npm/cjs/prod/integrations/httpcontext.js +3 -3
  128. package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -1
  129. package/build/npm/cjs/prod/integrations/linkederrors.js +3 -3
  130. package/build/npm/cjs/prod/integrations/linkederrors.js.map +1 -1
  131. package/build/npm/cjs/prod/integrations/reportingobserver.js +7 -7
  132. package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -1
  133. package/build/npm/cjs/prod/integrations/spanstreaming.js +10 -10
  134. package/build/npm/cjs/prod/integrations/spanstreaming.js.map +1 -1
  135. package/build/npm/cjs/prod/integrations/spotlight.js +6 -6
  136. package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -1
  137. package/build/npm/cjs/prod/integrations/view-hierarchy.js +3 -3
  138. package/build/npm/cjs/prod/integrations/view-hierarchy.js.map +1 -1
  139. package/build/npm/cjs/prod/integrations/webWorker.js +18 -18
  140. package/build/npm/cjs/prod/integrations/webWorker.js.map +1 -1
  141. package/build/npm/cjs/prod/profiling/UIProfiler.js +43 -33
  142. package/build/npm/cjs/prod/profiling/UIProfiler.js.map +1 -1
  143. package/build/npm/cjs/prod/profiling/index.js +7 -7
  144. package/build/npm/cjs/prod/profiling/index.js.map +1 -1
  145. package/build/npm/cjs/prod/profiling/integration.js +20 -18
  146. package/build/npm/cjs/prod/profiling/integration.js.map +1 -1
  147. package/build/npm/cjs/prod/profiling/startProfileForSpan.js +14 -11
  148. package/build/npm/cjs/prod/profiling/startProfileForSpan.js.map +1 -1
  149. package/build/npm/cjs/prod/profiling/utils.js +39 -68
  150. package/build/npm/cjs/prod/profiling/utils.js.map +1 -1
  151. package/build/npm/cjs/prod/report-dialog.js +7 -7
  152. package/build/npm/cjs/prod/report-dialog.js.map +1 -1
  153. package/build/npm/cjs/prod/sdk.js +8 -8
  154. package/build/npm/cjs/prod/sdk.js.map +1 -1
  155. package/build/npm/cjs/prod/stack-parsers.js +10 -10
  156. package/build/npm/cjs/prod/stack-parsers.js.map +1 -1
  157. package/build/npm/cjs/prod/tracing/backgroundtab.js +7 -7
  158. package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -1
  159. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +52 -52
  160. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -1
  161. package/build/npm/cjs/prod/tracing/linkedTraces.js +11 -11
  162. package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -1
  163. package/build/npm/cjs/prod/tracing/reportPageLoaded.js +2 -2
  164. package/build/npm/cjs/prod/tracing/reportPageLoaded.js.map +1 -1
  165. package/build/npm/cjs/prod/tracing/request.js +28 -28
  166. package/build/npm/cjs/prod/tracing/request.js.map +1 -1
  167. package/build/npm/cjs/prod/tracing/setActiveSpan.js +5 -5
  168. package/build/npm/cjs/prod/tracing/setActiveSpan.js.map +1 -1
  169. package/build/npm/cjs/prod/transports/fetch.js +3 -3
  170. package/build/npm/cjs/prod/transports/fetch.js.map +1 -1
  171. package/build/npm/cjs/prod/transports/offline.js +5 -5
  172. package/build/npm/cjs/prod/transports/offline.js.map +1 -1
  173. package/build/npm/cjs/prod/userfeedback.js +3 -3
  174. package/build/npm/cjs/prod/userfeedback.js.map +1 -1
  175. package/build/npm/cjs/prod/utils/detectBrowserExtension.js +3 -3
  176. package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -1
  177. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +3 -3
  178. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -1
  179. package/build/npm/esm/dev/client.js +1 -1
  180. package/build/npm/esm/dev/client.js.map +1 -1
  181. package/build/npm/esm/dev/diagnose-sdk.js +1 -1
  182. package/build/npm/esm/dev/diagnose-sdk.js.map +1 -1
  183. package/build/npm/esm/dev/eventbuilder.js +1 -1
  184. package/build/npm/esm/dev/eventbuilder.js.map +1 -1
  185. package/build/npm/esm/dev/feedbackAsync.js.map +1 -1
  186. package/build/npm/esm/dev/feedbackSync.js.map +1 -1
  187. package/build/npm/esm/dev/helpers.js +1 -1
  188. package/build/npm/esm/dev/helpers.js.map +1 -1
  189. package/build/npm/esm/dev/index.js +1 -1
  190. package/build/npm/esm/dev/integrations/breadcrumbs.js +1 -1
  191. package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -1
  192. package/build/npm/esm/dev/integrations/browserapierrors.js +1 -1
  193. package/build/npm/esm/dev/integrations/browserapierrors.js.map +1 -1
  194. package/build/npm/esm/dev/integrations/browsersession.js +1 -1
  195. package/build/npm/esm/dev/integrations/browsersession.js.map +1 -1
  196. package/build/npm/esm/dev/integrations/contextlines.js +1 -1
  197. package/build/npm/esm/dev/integrations/contextlines.js.map +1 -1
  198. package/build/npm/esm/dev/integrations/culturecontext.js +1 -1
  199. package/build/npm/esm/dev/integrations/culturecontext.js.map +1 -1
  200. package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js +1 -1
  201. package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js.map +1 -1
  202. package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js +1 -1
  203. package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  204. package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js +1 -1
  205. package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js.map +1 -1
  206. package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js +1 -1
  207. package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js.map +1 -1
  208. package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js +1 -1
  209. package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js.map +1 -1
  210. package/build/npm/esm/dev/integrations/globalhandlers.js +1 -1
  211. package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -1
  212. package/build/npm/esm/dev/integrations/graphqlClient.js +1 -1
  213. package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -1
  214. package/build/npm/esm/dev/integrations/httpclient.js +1 -1
  215. package/build/npm/esm/dev/integrations/httpclient.js.map +1 -1
  216. package/build/npm/esm/dev/integrations/httpcontext.js +1 -1
  217. package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -1
  218. package/build/npm/esm/dev/integrations/linkederrors.js +1 -1
  219. package/build/npm/esm/dev/integrations/linkederrors.js.map +1 -1
  220. package/build/npm/esm/dev/integrations/reportingobserver.js +1 -1
  221. package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -1
  222. package/build/npm/esm/dev/integrations/spanstreaming.js +1 -1
  223. package/build/npm/esm/dev/integrations/spanstreaming.js.map +1 -1
  224. package/build/npm/esm/dev/integrations/spotlight.js +1 -1
  225. package/build/npm/esm/dev/integrations/spotlight.js.map +1 -1
  226. package/build/npm/esm/dev/integrations/view-hierarchy.js +1 -1
  227. package/build/npm/esm/dev/integrations/view-hierarchy.js.map +1 -1
  228. package/build/npm/esm/dev/integrations/webWorker.js +1 -1
  229. package/build/npm/esm/dev/integrations/webWorker.js.map +1 -1
  230. package/build/npm/esm/dev/package.json +1 -1
  231. package/build/npm/esm/dev/profiling/UIProfiler.js +12 -2
  232. package/build/npm/esm/dev/profiling/UIProfiler.js.map +1 -1
  233. package/build/npm/esm/dev/profiling/index.js +1 -1
  234. package/build/npm/esm/dev/profiling/index.js.map +1 -1
  235. package/build/npm/esm/dev/profiling/integration.js +9 -7
  236. package/build/npm/esm/dev/profiling/integration.js.map +1 -1
  237. package/build/npm/esm/dev/profiling/startProfileForSpan.js +5 -2
  238. package/build/npm/esm/dev/profiling/startProfileForSpan.js.map +1 -1
  239. package/build/npm/esm/dev/profiling/utils.js +6 -36
  240. package/build/npm/esm/dev/profiling/utils.js.map +1 -1
  241. package/build/npm/esm/dev/report-dialog.js +1 -1
  242. package/build/npm/esm/dev/report-dialog.js.map +1 -1
  243. package/build/npm/esm/dev/sdk.js +1 -1
  244. package/build/npm/esm/dev/sdk.js.map +1 -1
  245. package/build/npm/esm/dev/stack-parsers.js +1 -1
  246. package/build/npm/esm/dev/stack-parsers.js.map +1 -1
  247. package/build/npm/esm/dev/tracing/backgroundtab.js +1 -1
  248. package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -1
  249. package/build/npm/esm/dev/tracing/browserTracingIntegration.js +1 -1
  250. package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -1
  251. package/build/npm/esm/dev/tracing/linkedTraces.js +2 -2
  252. package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -1
  253. package/build/npm/esm/dev/tracing/reportPageLoaded.js +1 -1
  254. package/build/npm/esm/dev/tracing/reportPageLoaded.js.map +1 -1
  255. package/build/npm/esm/dev/tracing/request.js +1 -1
  256. package/build/npm/esm/dev/tracing/request.js.map +1 -1
  257. package/build/npm/esm/dev/tracing/setActiveSpan.js +1 -1
  258. package/build/npm/esm/dev/tracing/setActiveSpan.js.map +1 -1
  259. package/build/npm/esm/dev/transports/fetch.js +1 -1
  260. package/build/npm/esm/dev/transports/fetch.js.map +1 -1
  261. package/build/npm/esm/dev/transports/offline.js +1 -1
  262. package/build/npm/esm/dev/transports/offline.js.map +1 -1
  263. package/build/npm/esm/dev/userfeedback.js +1 -1
  264. package/build/npm/esm/dev/userfeedback.js.map +1 -1
  265. package/build/npm/esm/dev/utils/detectBrowserExtension.js +1 -1
  266. package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -1
  267. package/build/npm/esm/dev/utils/lazyLoadIntegration.js +1 -1
  268. package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -1
  269. package/build/npm/esm/prod/client.js +1 -1
  270. package/build/npm/esm/prod/client.js.map +1 -1
  271. package/build/npm/esm/prod/diagnose-sdk.js +1 -1
  272. package/build/npm/esm/prod/diagnose-sdk.js.map +1 -1
  273. package/build/npm/esm/prod/eventbuilder.js +1 -1
  274. package/build/npm/esm/prod/eventbuilder.js.map +1 -1
  275. package/build/npm/esm/prod/feedbackAsync.js.map +1 -1
  276. package/build/npm/esm/prod/feedbackSync.js.map +1 -1
  277. package/build/npm/esm/prod/helpers.js +1 -1
  278. package/build/npm/esm/prod/helpers.js.map +1 -1
  279. package/build/npm/esm/prod/index.js +1 -1
  280. package/build/npm/esm/prod/integrations/breadcrumbs.js +1 -1
  281. package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -1
  282. package/build/npm/esm/prod/integrations/browserapierrors.js +1 -1
  283. package/build/npm/esm/prod/integrations/browserapierrors.js.map +1 -1
  284. package/build/npm/esm/prod/integrations/browsersession.js +1 -1
  285. package/build/npm/esm/prod/integrations/browsersession.js.map +1 -1
  286. package/build/npm/esm/prod/integrations/contextlines.js +1 -1
  287. package/build/npm/esm/prod/integrations/contextlines.js.map +1 -1
  288. package/build/npm/esm/prod/integrations/culturecontext.js +1 -1
  289. package/build/npm/esm/prod/integrations/culturecontext.js.map +1 -1
  290. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js +1 -1
  291. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js.map +1 -1
  292. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js +1 -1
  293. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -1
  294. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js +1 -1
  295. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js.map +1 -1
  296. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js +1 -1
  297. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js.map +1 -1
  298. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js +1 -1
  299. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js.map +1 -1
  300. package/build/npm/esm/prod/integrations/globalhandlers.js +1 -1
  301. package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -1
  302. package/build/npm/esm/prod/integrations/graphqlClient.js +1 -1
  303. package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -1
  304. package/build/npm/esm/prod/integrations/httpclient.js +1 -1
  305. package/build/npm/esm/prod/integrations/httpclient.js.map +1 -1
  306. package/build/npm/esm/prod/integrations/httpcontext.js +1 -1
  307. package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -1
  308. package/build/npm/esm/prod/integrations/linkederrors.js +1 -1
  309. package/build/npm/esm/prod/integrations/linkederrors.js.map +1 -1
  310. package/build/npm/esm/prod/integrations/reportingobserver.js +1 -1
  311. package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -1
  312. package/build/npm/esm/prod/integrations/spanstreaming.js +1 -1
  313. package/build/npm/esm/prod/integrations/spanstreaming.js.map +1 -1
  314. package/build/npm/esm/prod/integrations/spotlight.js +1 -1
  315. package/build/npm/esm/prod/integrations/spotlight.js.map +1 -1
  316. package/build/npm/esm/prod/integrations/view-hierarchy.js +1 -1
  317. package/build/npm/esm/prod/integrations/view-hierarchy.js.map +1 -1
  318. package/build/npm/esm/prod/integrations/webWorker.js +1 -1
  319. package/build/npm/esm/prod/integrations/webWorker.js.map +1 -1
  320. package/build/npm/esm/prod/package.json +1 -1
  321. package/build/npm/esm/prod/profiling/UIProfiler.js +12 -2
  322. package/build/npm/esm/prod/profiling/UIProfiler.js.map +1 -1
  323. package/build/npm/esm/prod/profiling/index.js +1 -1
  324. package/build/npm/esm/prod/profiling/index.js.map +1 -1
  325. package/build/npm/esm/prod/profiling/integration.js +9 -7
  326. package/build/npm/esm/prod/profiling/integration.js.map +1 -1
  327. package/build/npm/esm/prod/profiling/startProfileForSpan.js +5 -2
  328. package/build/npm/esm/prod/profiling/startProfileForSpan.js.map +1 -1
  329. package/build/npm/esm/prod/profiling/utils.js +6 -36
  330. package/build/npm/esm/prod/profiling/utils.js.map +1 -1
  331. package/build/npm/esm/prod/report-dialog.js +1 -1
  332. package/build/npm/esm/prod/report-dialog.js.map +1 -1
  333. package/build/npm/esm/prod/sdk.js +1 -1
  334. package/build/npm/esm/prod/sdk.js.map +1 -1
  335. package/build/npm/esm/prod/stack-parsers.js +1 -1
  336. package/build/npm/esm/prod/stack-parsers.js.map +1 -1
  337. package/build/npm/esm/prod/tracing/backgroundtab.js +1 -1
  338. package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -1
  339. package/build/npm/esm/prod/tracing/browserTracingIntegration.js +1 -1
  340. package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -1
  341. package/build/npm/esm/prod/tracing/linkedTraces.js +2 -2
  342. package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -1
  343. package/build/npm/esm/prod/tracing/reportPageLoaded.js +1 -1
  344. package/build/npm/esm/prod/tracing/reportPageLoaded.js.map +1 -1
  345. package/build/npm/esm/prod/tracing/request.js +1 -1
  346. package/build/npm/esm/prod/tracing/request.js.map +1 -1
  347. package/build/npm/esm/prod/tracing/setActiveSpan.js +1 -1
  348. package/build/npm/esm/prod/tracing/setActiveSpan.js.map +1 -1
  349. package/build/npm/esm/prod/transports/fetch.js +1 -1
  350. package/build/npm/esm/prod/transports/fetch.js.map +1 -1
  351. package/build/npm/esm/prod/transports/offline.js +1 -1
  352. package/build/npm/esm/prod/transports/offline.js.map +1 -1
  353. package/build/npm/esm/prod/userfeedback.js +1 -1
  354. package/build/npm/esm/prod/userfeedback.js.map +1 -1
  355. package/build/npm/esm/prod/utils/detectBrowserExtension.js +1 -1
  356. package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -1
  357. package/build/npm/esm/prod/utils/lazyLoadIntegration.js +1 -1
  358. package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -1
  359. package/build/npm/types/client.d.ts +2 -2
  360. package/build/npm/types/client.d.ts.map +1 -1
  361. package/build/npm/types/eventbuilder.d.ts +1 -1
  362. package/build/npm/types/eventbuilder.d.ts.map +1 -1
  363. package/build/npm/types/exports.d.ts +3 -3
  364. package/build/npm/types/exports.d.ts.map +1 -1
  365. package/build/npm/types/feedbackAsync.d.ts +2 -7
  366. package/build/npm/types/feedbackAsync.d.ts.map +1 -1
  367. package/build/npm/types/feedbackSync.d.ts +2 -7
  368. package/build/npm/types/feedbackSync.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 +1 -1
  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 +2 -2
  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 +1 -1
  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 +1 -1
  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 +1 -1
  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 +2 -2
  386. package/build/npm/types/index.bundle.tracing.replay.logs.metrics.d.ts.map +1 -1
  387. package/build/npm/types/index.d.ts +3 -3
  388. package/build/npm/types/index.d.ts.map +1 -1
  389. package/build/npm/types/integrations/contextlines.d.ts +1 -1
  390. package/build/npm/types/integrations/contextlines.d.ts.map +1 -1
  391. package/build/npm/types/integrations/globalhandlers.d.ts +1 -1
  392. package/build/npm/types/integrations/globalhandlers.d.ts.map +1 -1
  393. package/build/npm/types/integrations/view-hierarchy.d.ts +1 -1
  394. package/build/npm/types/integrations/view-hierarchy.d.ts.map +1 -1
  395. package/build/npm/types/integrations/webWorker.d.ts +1 -1
  396. package/build/npm/types/integrations/webWorker.d.ts.map +1 -1
  397. package/build/npm/types/integrations-bundle/index.captureconsole.d.ts +1 -1
  398. package/build/npm/types/integrations-bundle/index.captureconsole.d.ts.map +1 -1
  399. package/build/npm/types/integrations-bundle/index.createlangchaincallbackhandler.d.ts +1 -1
  400. package/build/npm/types/integrations-bundle/index.createlangchaincallbackhandler.d.ts.map +1 -1
  401. package/build/npm/types/integrations-bundle/index.dedupe.d.ts +1 -1
  402. package/build/npm/types/integrations-bundle/index.dedupe.d.ts.map +1 -1
  403. package/build/npm/types/integrations-bundle/index.extraerrordata.d.ts +1 -1
  404. package/build/npm/types/integrations-bundle/index.extraerrordata.d.ts.map +1 -1
  405. package/build/npm/types/integrations-bundle/index.feedback.d.ts +1 -1
  406. package/build/npm/types/integrations-bundle/index.feedback.d.ts.map +1 -1
  407. package/build/npm/types/integrations-bundle/index.instrumentanthropicaiclient.d.ts +1 -1
  408. package/build/npm/types/integrations-bundle/index.instrumentanthropicaiclient.d.ts.map +1 -1
  409. package/build/npm/types/integrations-bundle/index.instrumentgooglegenaiclient.d.ts +1 -1
  410. package/build/npm/types/integrations-bundle/index.instrumentgooglegenaiclient.d.ts.map +1 -1
  411. package/build/npm/types/integrations-bundle/index.instrumentlangchainembeddings.d.ts +1 -1
  412. package/build/npm/types/integrations-bundle/index.instrumentlangchainembeddings.d.ts.map +1 -1
  413. package/build/npm/types/integrations-bundle/index.instrumentlanggraph.d.ts +1 -1
  414. package/build/npm/types/integrations-bundle/index.instrumentlanggraph.d.ts.map +1 -1
  415. package/build/npm/types/integrations-bundle/index.instrumentopenaiclient.d.ts +1 -1
  416. package/build/npm/types/integrations-bundle/index.instrumentopenaiclient.d.ts.map +1 -1
  417. package/build/npm/types/integrations-bundle/index.modulemetadata.d.ts +1 -1
  418. package/build/npm/types/integrations-bundle/index.modulemetadata.d.ts.map +1 -1
  419. package/build/npm/types/integrations-bundle/index.rewriteframes.d.ts +1 -1
  420. package/build/npm/types/integrations-bundle/index.rewriteframes.d.ts.map +1 -1
  421. package/build/npm/types/pluggable-exports-bundle/index.multiplexedtransport.d.ts +1 -1
  422. package/build/npm/types/pluggable-exports-bundle/index.multiplexedtransport.d.ts.map +1 -1
  423. package/build/npm/types/profiling/UIProfiler.d.ts +1 -1
  424. package/build/npm/types/profiling/UIProfiler.d.ts.map +1 -1
  425. package/build/npm/types/profiling/index.d.ts +1 -1
  426. package/build/npm/types/profiling/index.d.ts.map +1 -1
  427. package/build/npm/types/profiling/integration.d.ts.map +1 -1
  428. package/build/npm/types/profiling/startProfileForSpan.d.ts +1 -1
  429. package/build/npm/types/profiling/startProfileForSpan.d.ts.map +1 -1
  430. package/build/npm/types/profiling/utils.d.ts +3 -5
  431. package/build/npm/types/profiling/utils.d.ts.map +1 -1
  432. package/build/npm/types/report-dialog.d.ts +1 -1
  433. package/build/npm/types/report-dialog.d.ts.map +1 -1
  434. package/build/npm/types/sdk.d.ts +1 -1
  435. package/build/npm/types/sdk.d.ts.map +1 -1
  436. package/build/npm/types/stack-parsers.d.ts +1 -1
  437. package/build/npm/types/stack-parsers.d.ts.map +1 -1
  438. package/build/npm/types/tracing/browserTracingIntegration.d.ts +1 -1
  439. package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
  440. package/build/npm/types/tracing/linkedTraces.d.ts +2 -2
  441. package/build/npm/types/tracing/linkedTraces.d.ts.map +1 -1
  442. package/build/npm/types/tracing/reportPageLoaded.d.ts +1 -1
  443. package/build/npm/types/tracing/reportPageLoaded.d.ts.map +1 -1
  444. package/build/npm/types/tracing/request.d.ts +1 -1
  445. package/build/npm/types/tracing/request.d.ts.map +1 -1
  446. package/build/npm/types/tracing/setActiveSpan.d.ts +1 -1
  447. package/build/npm/types/tracing/setActiveSpan.d.ts.map +1 -1
  448. package/build/npm/types/transports/fetch.d.ts +1 -1
  449. package/build/npm/types/transports/fetch.d.ts.map +1 -1
  450. package/build/npm/types/transports/offline.d.ts +1 -1
  451. package/build/npm/types/transports/offline.d.ts.map +1 -1
  452. package/build/npm/types/transports/types.d.ts +1 -1
  453. package/build/npm/types/transports/types.d.ts.map +1 -1
  454. package/build/npm/types/userfeedback.d.ts +1 -1
  455. package/build/npm/types/userfeedback.d.ts.map +1 -1
  456. package/build/npm/types/utils/lazyLoadIntegration.d.ts +1 -1
  457. package/build/npm/types/utils/lazyLoadIntegration.d.ts.map +1 -1
  458. package/build/npm/types-ts3.8/client.d.ts +2 -2
  459. package/build/npm/types-ts3.8/eventbuilder.d.ts +1 -1
  460. package/build/npm/types-ts3.8/exports.d.ts +3 -3
  461. package/build/npm/types-ts3.8/feedbackAsync.d.ts +2 -7
  462. package/build/npm/types-ts3.8/feedbackSync.d.ts +2 -7
  463. package/build/npm/types-ts3.8/helpers.d.ts +2 -2
  464. package/build/npm/types-ts3.8/index.bundle.logs.metrics.d.ts +1 -1
  465. package/build/npm/types-ts3.8/index.bundle.replay.logs.metrics.d.ts +1 -1
  466. package/build/npm/types-ts3.8/index.bundle.tracing.d.ts +1 -1
  467. package/build/npm/types-ts3.8/index.bundle.tracing.logs.metrics.d.ts +2 -2
  468. package/build/npm/types-ts3.8/index.bundle.tracing.replay.d.ts +1 -1
  469. package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.d.ts +1 -1
  470. package/build/npm/types-ts3.8/index.bundle.tracing.replay.feedback.logs.metrics.d.ts +1 -1
  471. package/build/npm/types-ts3.8/index.bundle.tracing.replay.logs.metrics.d.ts +2 -2
  472. package/build/npm/types-ts3.8/index.d.ts +3 -3
  473. package/build/npm/types-ts3.8/integrations/contextlines.d.ts +1 -1
  474. package/build/npm/types-ts3.8/integrations/globalhandlers.d.ts +1 -1
  475. package/build/npm/types-ts3.8/integrations/view-hierarchy.d.ts +1 -1
  476. package/build/npm/types-ts3.8/integrations/webWorker.d.ts +1 -1
  477. package/build/npm/types-ts3.8/integrations-bundle/index.captureconsole.d.ts +1 -1
  478. package/build/npm/types-ts3.8/integrations-bundle/index.createlangchaincallbackhandler.d.ts +1 -1
  479. package/build/npm/types-ts3.8/integrations-bundle/index.dedupe.d.ts +1 -1
  480. package/build/npm/types-ts3.8/integrations-bundle/index.extraerrordata.d.ts +1 -1
  481. package/build/npm/types-ts3.8/integrations-bundle/index.feedback.d.ts +1 -1
  482. package/build/npm/types-ts3.8/integrations-bundle/index.instrumentanthropicaiclient.d.ts +1 -1
  483. package/build/npm/types-ts3.8/integrations-bundle/index.instrumentgooglegenaiclient.d.ts +1 -1
  484. package/build/npm/types-ts3.8/integrations-bundle/index.instrumentlangchainembeddings.d.ts +1 -1
  485. package/build/npm/types-ts3.8/integrations-bundle/index.instrumentlanggraph.d.ts +1 -1
  486. package/build/npm/types-ts3.8/integrations-bundle/index.instrumentopenaiclient.d.ts +1 -1
  487. package/build/npm/types-ts3.8/integrations-bundle/index.modulemetadata.d.ts +1 -1
  488. package/build/npm/types-ts3.8/integrations-bundle/index.rewriteframes.d.ts +1 -1
  489. package/build/npm/types-ts3.8/pluggable-exports-bundle/index.multiplexedtransport.d.ts +1 -1
  490. package/build/npm/types-ts3.8/profiling/UIProfiler.d.ts +1 -1
  491. package/build/npm/types-ts3.8/profiling/index.d.ts +1 -1
  492. package/build/npm/types-ts3.8/profiling/startProfileForSpan.d.ts +1 -1
  493. package/build/npm/types-ts3.8/profiling/utils.d.ts +3 -5
  494. package/build/npm/types-ts3.8/report-dialog.d.ts +1 -1
  495. package/build/npm/types-ts3.8/sdk.d.ts +1 -1
  496. package/build/npm/types-ts3.8/stack-parsers.d.ts +1 -1
  497. package/build/npm/types-ts3.8/tracing/browserTracingIntegration.d.ts +1 -1
  498. package/build/npm/types-ts3.8/tracing/linkedTraces.d.ts +2 -2
  499. package/build/npm/types-ts3.8/tracing/reportPageLoaded.d.ts +1 -1
  500. package/build/npm/types-ts3.8/tracing/request.d.ts +1 -1
  501. package/build/npm/types-ts3.8/tracing/setActiveSpan.d.ts +1 -1
  502. package/build/npm/types-ts3.8/transports/fetch.d.ts +1 -1
  503. package/build/npm/types-ts3.8/transports/offline.d.ts +1 -1
  504. package/build/npm/types-ts3.8/transports/types.d.ts +1 -1
  505. package/build/npm/types-ts3.8/userfeedback.d.ts +1 -1
  506. package/build/npm/types-ts3.8/utils/lazyLoadIntegration.d.ts +1 -1
  507. package/package.json +7 -7
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const core = require('@sentry/core');
3
+ const browser = require('@sentry/core/browser');
4
4
  const debugBuild = require('../debug-build.js');
5
5
  const utils = require('./utils.js');
6
6
 
@@ -48,14 +48,14 @@ class UIProfiler {
48
48
  const lifecycleMode = (client.getOptions() ).profileLifecycle;
49
49
  const sessionSampled = utils.shouldProfileSession(client.getOptions());
50
50
 
51
- debugBuild.DEBUG_BUILD && core.debug.log(`[Profiling] Initializing profiler (lifecycle='${lifecycleMode}').`);
51
+ debugBuild.DEBUG_BUILD && browser.debug.log(`[Profiling] Initializing profiler (lifecycle='${lifecycleMode}').`);
52
52
 
53
53
  if (!sessionSampled) {
54
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Session not sampled. Skipping lifecycle profiler initialization.');
54
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] Session not sampled. Skipping lifecycle profiler initialization.');
55
55
  }
56
56
 
57
57
  // One Profiler ID per profiling session (user session)
58
- this._profilerId = core.uuid4();
58
+ this._profilerId = browser.uuid4();
59
59
  this._client = client;
60
60
  this._sessionSampled = sessionSampled;
61
61
  this._lifecycleMode = lifecycleMode;
@@ -63,25 +63,31 @@ class UIProfiler {
63
63
  if (lifecycleMode === 'trace') {
64
64
  this._setupTraceLifecycleListeners(client);
65
65
  }
66
+
67
+ client.on('spanStart', span => {
68
+ if (this._isRunning) {
69
+ utils.setThreadAttributes(span);
70
+ }
71
+ });
66
72
  }
67
73
 
68
74
  /** Starts UI profiling (only effective in 'manual' mode and when sampled). */
69
75
  start() {
70
76
  if (this._lifecycleMode === 'trace') {
71
77
  debugBuild.DEBUG_BUILD &&
72
- core.debug.warn(
78
+ browser.debug.warn(
73
79
  '[Profiling] `profileLifecycle` is set to "trace". Calls to `uiProfiler.start()` are ignored in trace mode.',
74
80
  );
75
81
  return;
76
82
  }
77
83
 
78
84
  if (this._isRunning) {
79
- debugBuild.DEBUG_BUILD && core.debug.warn('[Profiling] Profile session is already running, `uiProfiler.start()` is a no-op.');
85
+ debugBuild.DEBUG_BUILD && browser.debug.warn('[Profiling] Profile session is already running, `uiProfiler.start()` is a no-op.');
80
86
  return;
81
87
  }
82
88
 
83
89
  if (!this._sessionSampled) {
84
- debugBuild.DEBUG_BUILD && core.debug.warn('[Profiling] Session is not sampled, `uiProfiler.start()` is a no-op.');
90
+ debugBuild.DEBUG_BUILD && browser.debug.warn('[Profiling] Session is not sampled, `uiProfiler.start()` is a no-op.');
85
91
  return;
86
92
  }
87
93
 
@@ -92,14 +98,14 @@ class UIProfiler {
92
98
  stop() {
93
99
  if (this._lifecycleMode === 'trace') {
94
100
  debugBuild.DEBUG_BUILD &&
95
- core.debug.warn(
101
+ browser.debug.warn(
96
102
  '[Profiling] `profileLifecycle` is set to "trace". Calls to `uiProfiler.stop()` are ignored in trace mode.',
97
103
  );
98
104
  return;
99
105
  }
100
106
 
101
107
  if (!this._isRunning) {
102
- debugBuild.DEBUG_BUILD && core.debug.warn('[Profiling] Profiler is not running, `uiProfiler.stop()` is a no-op.');
108
+ debugBuild.DEBUG_BUILD && browser.debug.warn('[Profiling] Profiler is not running, `uiProfiler.stop()` is a no-op.');
103
109
  return;
104
110
  }
105
111
 
@@ -123,10 +129,14 @@ class UIProfiler {
123
129
 
124
130
  if (rootSpanCount === 1) {
125
131
  debugBuild.DEBUG_BUILD &&
126
- core.debug.log('[Profiling] Detected already active root span during setup. Active root spans now:', rootSpanCount);
132
+ browser.debug.log('[Profiling] Detected already active root span during setup. Active root spans now:', rootSpanCount);
127
133
 
128
134
  this._beginProfiling();
129
135
  }
136
+
137
+ if (this._isRunning) {
138
+ utils.setThreadAttributes(rootSpan);
139
+ }
130
140
  }
131
141
 
132
142
  /**
@@ -138,15 +148,15 @@ class UIProfiler {
138
148
  }
139
149
  this._isRunning = true;
140
150
 
141
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Started profiling with profiler ID:', this._profilerId);
151
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] Started profiling with profiler ID:', this._profilerId);
142
152
 
143
153
  // Expose profiler_id to match root spans with profiles
144
- core.getGlobalScope().setContext('profile', { profiler_id: this._profilerId });
154
+ browser.getGlobalScope().setContext('profile', { profiler_id: this._profilerId });
145
155
 
146
156
  this._startProfilerInstance();
147
157
 
148
158
  if (!this._profiler) {
149
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Failed to start JS Profiler; stopping.');
159
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] Failed to start JS Profiler; stopping.');
150
160
  this._resetProfilerInfo();
151
161
  return;
152
162
  }
@@ -170,13 +180,13 @@ class UIProfiler {
170
180
 
171
181
  // Collect whatever was currently recording
172
182
  this._collectCurrentChunk().catch(e => {
173
- debugBuild.DEBUG_BUILD && core.debug.error('[Profiling] Failed to collect current profile chunk on `stop()`:', e);
183
+ debugBuild.DEBUG_BUILD && browser.debug.error('[Profiling] Failed to collect current profile chunk on `stop()`:', e);
174
184
  });
175
185
 
176
186
  // Manual: Clear profiling context so spans outside start()/stop() aren't marked as profiled
177
187
  // Trace: Profile context is kept for the whole session duration
178
188
  if (this._lifecycleMode === 'manual') {
179
- core.getGlobalScope().setContext('profile', {});
189
+ browser.getGlobalScope().setContext('profile', {});
180
190
  }
181
191
  }
182
192
 
@@ -185,15 +195,15 @@ class UIProfiler {
185
195
  client.on('spanStart', span => {
186
196
  if (!this._sessionSampled) {
187
197
  debugBuild.DEBUG_BUILD &&
188
- core.debug.log('[Profiling] Span not profiled because of negative sampling decision for user session.');
198
+ browser.debug.log('[Profiling] Span not profiled because of negative sampling decision for user session.');
189
199
  return;
190
200
  }
191
- if (span !== core.getRootSpan(span)) {
201
+ if (span !== browser.getRootSpan(span)) {
192
202
  return; // only care about root spans
193
203
  }
194
204
  // Only count sampled root spans
195
205
  if (!span.isRecording()) {
196
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Discarding profile because root span was not sampled.');
206
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] Discarding profile because root span was not sampled.');
197
207
  return;
198
208
  }
199
209
 
@@ -207,7 +217,7 @@ class UIProfiler {
207
217
  const rootSpanCount = this._activeRootSpanIds.size;
208
218
  if (rootSpanCount === 1) {
209
219
  debugBuild.DEBUG_BUILD &&
210
- core.debug.log(
220
+ browser.debug.log(
211
221
  `[Profiling] Root span ${spanId} started. Profiling active while there are active root spans (count=${rootSpanCount}).`,
212
222
  );
213
223
  this._beginProfiling();
@@ -226,12 +236,12 @@ class UIProfiler {
226
236
  const rootSpanCount = this._activeRootSpanIds.size;
227
237
 
228
238
  debugBuild.DEBUG_BUILD &&
229
- core.debug.log(
239
+ browser.debug.log(
230
240
  `[Profiling] Root span with ID ${spanId} ended. Will continue profiling for as long as there are active root spans (currently: ${rootSpanCount}).`,
231
241
  );
232
242
  if (rootSpanCount === 0) {
233
243
  this._collectCurrentChunk().catch(e => {
234
- debugBuild.DEBUG_BUILD && core.debug.error('[Profiling] Failed to collect current profile chunk on last `spanEnd`:', e);
244
+ debugBuild.DEBUG_BUILD && browser.debug.error('[Profiling] Failed to collect current profile chunk on last `spanEnd`:', e);
235
245
  });
236
246
  this._endProfiling();
237
247
  }
@@ -243,7 +253,7 @@ class UIProfiler {
243
253
  */
244
254
  _resetProfilerInfo() {
245
255
  this._isRunning = false;
246
- core.getGlobalScope().setContext('profile', {});
256
+ browser.getGlobalScope().setContext('profile', {});
247
257
  }
248
258
 
249
259
  /**
@@ -270,7 +280,7 @@ class UIProfiler {
270
280
  }
271
281
  const profiler = utils.startJSSelfProfile();
272
282
  if (!profiler) {
273
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Failed to start JS Profiler.');
283
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] Failed to start JS Profiler.');
274
284
  return;
275
285
  }
276
286
  this._profiler = profiler;
@@ -288,7 +298,7 @@ class UIProfiler {
288
298
 
289
299
  this._chunkTimer = setTimeout(() => {
290
300
  this._collectCurrentChunk().catch(e => {
291
- debugBuild.DEBUG_BUILD && core.debug.error('[Profiling] Failed to collect current profile chunk during periodic chunking:', e);
301
+ debugBuild.DEBUG_BUILD && browser.debug.error('[Profiling] Failed to collect current profile chunk during periodic chunking:', e);
292
302
  });
293
303
 
294
304
  if (this._isRunning) {
@@ -321,7 +331,7 @@ class UIProfiler {
321
331
  }
322
332
 
323
333
  debugBuild.DEBUG_BUILD &&
324
- core.debug.log(
334
+ browser.debug.log(
325
335
  `[Profiling] Reached 5-minute timeout for root span ${rootSpanId}. You likely started a manual root span that never called \`.end()\`.`,
326
336
  );
327
337
 
@@ -353,7 +363,7 @@ class UIProfiler {
353
363
  const validationReturn = utils.validateProfileChunk(chunk);
354
364
  if ('reason' in validationReturn) {
355
365
  debugBuild.DEBUG_BUILD &&
356
- core.debug.log(
366
+ browser.debug.log(
357
367
  '[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):',
358
368
  validationReturn.reason,
359
369
  );
@@ -362,9 +372,9 @@ class UIProfiler {
362
372
 
363
373
  this._sendProfileChunk(chunk);
364
374
 
365
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Collected browser profile chunk.');
375
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] Collected browser profile chunk.');
366
376
  } catch (e) {
367
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Error while stopping JS Profiler for chunk:', e);
377
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] Error while stopping JS Profiler for chunk:', e);
368
378
  }
369
379
  }
370
380
 
@@ -375,22 +385,22 @@ class UIProfiler {
375
385
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
376
386
  const client = this._client;
377
387
 
378
- const sdkInfo = core.getSdkMetadataForEnvelopeHeader(client.getSdkMetadata?.());
388
+ const sdkInfo = browser.getSdkMetadataForEnvelopeHeader(client.getSdkMetadata?.());
379
389
  const dsn = client.getDsn();
380
390
  const tunnel = client.getOptions().tunnel;
381
391
 
382
- const envelope = core.createEnvelope(
392
+ const envelope = browser.createEnvelope(
383
393
  {
384
- event_id: core.uuid4(),
394
+ event_id: browser.uuid4(),
385
395
  sent_at: new Date().toISOString(),
386
396
  ...(sdkInfo && { sdk: sdkInfo }),
387
- ...(!!tunnel && dsn && { dsn: core.dsnToString(dsn) }),
397
+ ...(!!tunnel && dsn && { dsn: browser.dsnToString(dsn) }),
388
398
  },
389
399
  [[{ type: 'profile_chunk', platform: 'javascript' }, chunk]],
390
400
  );
391
401
 
392
402
  client.sendEnvelope(envelope).then(null, reason => {
393
- debugBuild.DEBUG_BUILD && core.debug.error('Error while sending profile chunk envelope:', reason);
403
+ debugBuild.DEBUG_BUILD && browser.debug.error('Error while sending profile chunk envelope:', reason);
394
404
  });
395
405
  }
396
406
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UIProfiler.js","sources":["../../../../../src/profiling/UIProfiler.ts"],"sourcesContent":["import type { Client, ContinuousProfiler, ProfileChunk, ProfileChunkEnvelope, Span } from '@sentry/core';\nimport {\n createEnvelope,\n debug,\n dsnToString,\n getGlobalScope,\n getRootSpan,\n getSdkMetadataForEnvelopeHeader,\n uuid4,\n} from '@sentry/core';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from './../debug-build';\nimport type { JSSelfProfiler } from './jsSelfProfiling';\nimport { createProfileChunkPayload, shouldProfileSession, startJSSelfProfile, validateProfileChunk } from './utils';\n\nconst CHUNK_INTERVAL_MS = 60_000; // 1 minute\n// Maximum length for trace lifecycle profiling per root span (e.g. if spanEnd never fires)\nconst MAX_ROOT_SPAN_PROFILE_MS = 300_000; // 5 minutes max per root span in trace mode\n\n/**\n * UIProfiler (Profiling V2):\n * Supports two lifecycle modes:\n * - 'manual': controlled explicitly via start()/stop()\n * - 'trace': automatically runs while there are active sampled root spans\n *\n * Profiles are emitted as standalone `profile_chunk` envelopes either when:\n * - there are no more sampled root spans, or\n * - the 60s chunk timer elapses while profiling is running.\n */\nexport class UIProfiler implements ContinuousProfiler<Client> {\n private _client: Client | undefined;\n private _profiler: JSSelfProfiler | undefined;\n private _chunkTimer: ReturnType<typeof setTimeout> | undefined;\n\n // Manual + Trace\n private _profilerId: string | undefined; // one per Profiler session\n private _isRunning: boolean; // current profiler instance active flag\n private _sessionSampled: boolean; // sampling decision for entire session\n private _lifecycleMode: 'manual' | 'trace' | undefined;\n\n // Trace-only\n private _activeRootSpanIds: Set<string>;\n private _rootSpanTimeouts: Map<string, ReturnType<typeof setTimeout>>;\n\n public constructor() {\n this._client = undefined;\n this._profiler = undefined;\n this._chunkTimer = undefined;\n\n this._profilerId = undefined;\n this._isRunning = false;\n this._sessionSampled = false;\n this._lifecycleMode = undefined;\n\n this._activeRootSpanIds = new Set();\n this._rootSpanTimeouts = new Map();\n }\n\n /**\n * Initialize the profiler with client, session sampling and lifecycle mode.\n */\n public initialize(client: Client): void {\n const lifecycleMode = (client.getOptions() as BrowserOptions).profileLifecycle;\n const sessionSampled = shouldProfileSession(client.getOptions());\n\n DEBUG_BUILD && debug.log(`[Profiling] Initializing profiler (lifecycle='${lifecycleMode}').`);\n\n if (!sessionSampled) {\n DEBUG_BUILD && debug.log('[Profiling] Session not sampled. Skipping lifecycle profiler initialization.');\n }\n\n // One Profiler ID per profiling session (user session)\n this._profilerId = uuid4();\n this._client = client;\n this._sessionSampled = sessionSampled;\n this._lifecycleMode = lifecycleMode;\n\n if (lifecycleMode === 'trace') {\n this._setupTraceLifecycleListeners(client);\n }\n }\n\n /** Starts UI profiling (only effective in 'manual' mode and when sampled). */\n public start(): void {\n if (this._lifecycleMode === 'trace') {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.start()` are ignored in trace mode.',\n );\n return;\n }\n\n if (this._isRunning) {\n DEBUG_BUILD && debug.warn('[Profiling] Profile session is already running, `uiProfiler.start()` is a no-op.');\n return;\n }\n\n if (!this._sessionSampled) {\n DEBUG_BUILD && debug.warn('[Profiling] Session is not sampled, `uiProfiler.start()` is a no-op.');\n return;\n }\n\n this._beginProfiling();\n }\n\n /** Stops UI profiling (only effective in 'manual' mode). */\n public stop(): void {\n if (this._lifecycleMode === 'trace') {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.stop()` are ignored in trace mode.',\n );\n return;\n }\n\n if (!this._isRunning) {\n DEBUG_BUILD && debug.warn('[Profiling] Profiler is not running, `uiProfiler.stop()` is a no-op.');\n return;\n }\n\n this._endProfiling();\n }\n\n /** Handle an already-active root span at integration setup time (used only in trace mode). */\n public notifyRootSpanActive(rootSpan: Span): void {\n if (this._lifecycleMode !== 'trace' || !this._sessionSampled) {\n return;\n }\n\n const spanId = rootSpan.spanContext().spanId;\n if (!spanId || this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._registerTraceRootSpan(spanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Detected already active root span during setup. Active root spans now:', rootSpanCount);\n\n this._beginProfiling();\n }\n }\n\n /**\n * Begin profiling if not already running.\n */\n private _beginProfiling(): void {\n if (this._isRunning) {\n return;\n }\n this._isRunning = true;\n\n DEBUG_BUILD && debug.log('[Profiling] Started profiling with profiler ID:', this._profilerId);\n\n // Expose profiler_id to match root spans with profiles\n getGlobalScope().setContext('profile', { profiler_id: this._profilerId });\n\n this._startProfilerInstance();\n\n if (!this._profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start JS Profiler; stopping.');\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n\n /** End profiling session; final chunk will be collected and sent. */\n private _endProfiling(): void {\n if (!this._isRunning) {\n return;\n }\n this._isRunning = false;\n\n if (this._chunkTimer) {\n clearTimeout(this._chunkTimer);\n this._chunkTimer = undefined;\n }\n\n this._clearAllRootSpanTimeouts();\n\n // Collect whatever was currently recording\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on `stop()`:', e);\n });\n\n // Manual: Clear profiling context so spans outside start()/stop() aren't marked as profiled\n // Trace: Profile context is kept for the whole session duration\n if (this._lifecycleMode === 'manual') {\n getGlobalScope().setContext('profile', {});\n }\n }\n\n /** Trace-mode: attach spanStart/spanEnd listeners. */\n private _setupTraceLifecycleListeners(client: Client): void {\n client.on('spanStart', span => {\n if (!this._sessionSampled) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Span not profiled because of negative sampling decision for user session.');\n return;\n }\n if (span !== getRootSpan(span)) {\n return; // only care about root spans\n }\n // Only count sampled root spans\n if (!span.isRecording()) {\n DEBUG_BUILD && debug.log('[Profiling] Discarding profile because root span was not sampled.');\n return;\n }\n\n const spanId = span.spanContext().spanId;\n if (!spanId || this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._registerTraceRootSpan(spanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span ${spanId} started. Profiling active while there are active root spans (count=${rootSpanCount}).`,\n );\n this._beginProfiling();\n }\n });\n\n client.on('spanEnd', span => {\n if (!this._sessionSampled) {\n return;\n }\n const spanId = span.spanContext().spanId;\n if (!spanId || !this._activeRootSpanIds.has(spanId)) {\n return;\n }\n this._activeRootSpanIds.delete(spanId);\n const rootSpanCount = this._activeRootSpanIds.size;\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span with ID ${spanId} ended. Will continue profiling for as long as there are active root spans (currently: ${rootSpanCount}).`,\n );\n if (rootSpanCount === 0) {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on last `spanEnd`:', e);\n });\n this._endProfiling();\n }\n });\n }\n\n /**\n * Resets profiling information from scope and resets running state (used on failure)\n */\n private _resetProfilerInfo(): void {\n this._isRunning = false;\n getGlobalScope().setContext('profile', {});\n }\n\n /**\n * Clear and reset all per-root-span timeouts.\n */\n private _clearAllRootSpanTimeouts(): void {\n this._rootSpanTimeouts.forEach(timeout => clearTimeout(timeout));\n this._rootSpanTimeouts.clear();\n }\n\n /** Keep track of root spans and schedule safeguard timeout (trace mode). */\n private _registerTraceRootSpan(spanId: string): void {\n this._activeRootSpanIds.add(spanId);\n const timeout = setTimeout(() => this._onRootSpanTimeout(spanId), MAX_ROOT_SPAN_PROFILE_MS);\n this._rootSpanTimeouts.set(spanId, timeout);\n }\n\n /**\n * Start a profiler instance if needed.\n */\n private _startProfilerInstance(): void {\n if (this._profiler?.stopped === false) {\n return; // already running\n }\n const profiler = startJSSelfProfile();\n if (!profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start JS Profiler.');\n return;\n }\n this._profiler = profiler;\n }\n\n /**\n * Schedule the next 60s chunk while running.\n * Each tick collects a chunk and restarts the profiler.\n * A chunk should be closed when there are no active root spans anymore OR when the maximum chunk interval is reached.\n */\n private _startPeriodicChunking(): void {\n if (!this._isRunning) {\n return;\n }\n\n this._chunkTimer = setTimeout(() => {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk during periodic chunking:', e);\n });\n\n if (this._isRunning) {\n this._startProfilerInstance();\n\n if (!this._profiler) {\n // If restart failed, stop scheduling further chunks and reset context.\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n }, CHUNK_INTERVAL_MS);\n }\n\n /**\n * Handle timeout for a specific root span ID to avoid indefinitely running profiler if `spanEnd` never fires.\n * If this was the last active root span, collect the current chunk and stop profiling.\n */\n private _onRootSpanTimeout(rootSpanId: string): void {\n // If span already ended, ignore\n if (!this._rootSpanTimeouts.has(rootSpanId)) {\n return;\n }\n this._rootSpanTimeouts.delete(rootSpanId);\n\n if (!this._activeRootSpanIds.has(rootSpanId)) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Reached 5-minute timeout for root span ${rootSpanId}. You likely started a manual root span that never called \\`.end()\\`.`,\n );\n\n this._activeRootSpanIds.delete(rootSpanId);\n\n if (this._activeRootSpanIds.size === 0) {\n this._endProfiling();\n }\n }\n\n /**\n * Stop current profiler instance, convert profile to chunk & send.\n */\n private async _collectCurrentChunk(): Promise<void> {\n const prevProfiler = this._profiler;\n this._profiler = undefined;\n\n if (!prevProfiler) {\n return;\n }\n\n try {\n const profile = await prevProfiler.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const chunk = createProfileChunkPayload(profile, this._client!, this._profilerId);\n\n // Validate chunk before sending\n const validationReturn = validateProfileChunk(chunk);\n if ('reason' in validationReturn) {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):',\n validationReturn.reason,\n );\n return;\n }\n\n this._sendProfileChunk(chunk);\n\n DEBUG_BUILD && debug.log('[Profiling] Collected browser profile chunk.');\n } catch (e) {\n DEBUG_BUILD && debug.log('[Profiling] Error while stopping JS Profiler for chunk:', e);\n }\n }\n\n /**\n * Send a profile chunk as a standalone envelope.\n */\n private _sendProfileChunk(chunk: ProfileChunk): void {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const client = this._client!;\n\n const sdkInfo = getSdkMetadataForEnvelopeHeader(client.getSdkMetadata?.());\n const dsn = client.getDsn();\n const tunnel = client.getOptions().tunnel;\n\n const envelope = createEnvelope<ProfileChunkEnvelope>(\n {\n event_id: uuid4(),\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n },\n [[{ type: 'profile_chunk', platform: 'javascript' }, chunk]],\n );\n\n client.sendEnvelope(envelope).then(null, reason => {\n DEBUG_BUILD && debug.error('Error while sending profile chunk envelope:', reason);\n });\n }\n}\n"],"names":["shouldProfileSession","DEBUG_BUILD","debug","uuid4","getGlobalScope","getRootSpan","startJSSelfProfile","createProfileChunkPayload","validateProfileChunk","getSdkMetadataForEnvelopeHeader","createEnvelope","dsnToString"],"mappings":";;;;;;AAeA,MAAM,iBAAA,GAAoB,KAAM,CAAA;AAChC;AACA,MAAM,wBAAA,GAA2B,MAAO,CAAA;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,YAAiD;;AAK9D;AACA;AACA;AACA;;AAGA;;AAIA,GAAS,WAAW,GAAG;AACvB,IAAI,IAAI,CAAC,OAAA,GAAU,SAAS;AAC5B,IAAI,IAAI,CAAC,SAAA,GAAY,SAAS;AAC9B,IAAI,IAAI,CAAC,WAAA,GAAc,SAAS;;AAEhC,IAAI,IAAI,CAAC,WAAA,GAAc,SAAS;AAChC,IAAI,IAAI,CAAC,UAAA,GAAa,KAAK;AAC3B,IAAI,IAAI,CAAC,eAAA,GAAkB,KAAK;AAChC,IAAI,IAAI,CAAC,cAAA,GAAiB,SAAS;;AAEnC,IAAI,IAAI,CA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UIProfiler.ts"],"sourcesContent":["import type { Client, ContinuousProfiler, ProfileChunk, ProfileChunkEnvelope, Span } from '@sentry/core/browser';\nimport {\n createEnvelope,\n debug,\n dsnToString,\n getGlobalScope,\n getRootSpan,\n getSdkMetadataForEnvelopeHeader,\n uuid4,\n} from '@sentry/core/browser';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from './../debug-build';\nimport type { JSSelfProfiler } from './jsSelfProfiling';\nimport {\n createProfileChunkPayload,\n setThreadAttributes,\n shouldProfileSession,\n startJSSelfProfile,\n validateProfileChunk,\n} from './utils';\n\nconst CHUNK_INTERVAL_MS = 60_000; // 1 minute\n// Maximum length for trace lifecycle profiling per root span (e.g. if spanEnd never fires)\nconst MAX_ROOT_SPAN_PROFILE_MS = 300_000; // 5 minutes max per root span in trace mode\n\n/**\n * UIProfiler (Profiling V2):\n * Supports two lifecycle modes:\n * - 'manual': controlled explicitly via start()/stop()\n * - 'trace': automatically runs while there are active sampled root spans\n *\n * Profiles are emitted as standalone `profile_chunk` envelopes either when:\n * - there are no more sampled root spans, or\n * - the 60s chunk timer elapses while profiling is running.\n */\nexport class UIProfiler implements ContinuousProfiler<Client> {\n private _client: Client | undefined;\n private _profiler: JSSelfProfiler | undefined;\n private _chunkTimer: ReturnType<typeof setTimeout> | undefined;\n\n // Manual + Trace\n private _profilerId: string | undefined; // one per Profiler session\n private _isRunning: boolean; // current profiler instance active flag\n private _sessionSampled: boolean; // sampling decision for entire session\n private _lifecycleMode: 'manual' | 'trace' | undefined;\n\n // Trace-only\n private _activeRootSpanIds: Set<string>;\n private _rootSpanTimeouts: Map<string, ReturnType<typeof setTimeout>>;\n\n public constructor() {\n this._client = undefined;\n this._profiler = undefined;\n this._chunkTimer = undefined;\n\n this._profilerId = undefined;\n this._isRunning = false;\n this._sessionSampled = false;\n this._lifecycleMode = undefined;\n\n this._activeRootSpanIds = new Set();\n this._rootSpanTimeouts = new Map();\n }\n\n /**\n * Initialize the profiler with client, session sampling and lifecycle mode.\n */\n public initialize(client: Client): void {\n const lifecycleMode = (client.getOptions() as BrowserOptions).profileLifecycle;\n const sessionSampled = shouldProfileSession(client.getOptions());\n\n DEBUG_BUILD && debug.log(`[Profiling] Initializing profiler (lifecycle='${lifecycleMode}').`);\n\n if (!sessionSampled) {\n DEBUG_BUILD && debug.log('[Profiling] Session not sampled. Skipping lifecycle profiler initialization.');\n }\n\n // One Profiler ID per profiling session (user session)\n this._profilerId = uuid4();\n this._client = client;\n this._sessionSampled = sessionSampled;\n this._lifecycleMode = lifecycleMode;\n\n if (lifecycleMode === 'trace') {\n this._setupTraceLifecycleListeners(client);\n }\n\n client.on('spanStart', span => {\n if (this._isRunning) {\n setThreadAttributes(span);\n }\n });\n }\n\n /** Starts UI profiling (only effective in 'manual' mode and when sampled). */\n public start(): void {\n if (this._lifecycleMode === 'trace') {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.start()` are ignored in trace mode.',\n );\n return;\n }\n\n if (this._isRunning) {\n DEBUG_BUILD && debug.warn('[Profiling] Profile session is already running, `uiProfiler.start()` is a no-op.');\n return;\n }\n\n if (!this._sessionSampled) {\n DEBUG_BUILD && debug.warn('[Profiling] Session is not sampled, `uiProfiler.start()` is a no-op.');\n return;\n }\n\n this._beginProfiling();\n }\n\n /** Stops UI profiling (only effective in 'manual' mode). */\n public stop(): void {\n if (this._lifecycleMode === 'trace') {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.stop()` are ignored in trace mode.',\n );\n return;\n }\n\n if (!this._isRunning) {\n DEBUG_BUILD && debug.warn('[Profiling] Profiler is not running, `uiProfiler.stop()` is a no-op.');\n return;\n }\n\n this._endProfiling();\n }\n\n /** Handle an already-active root span at integration setup time (used only in trace mode). */\n public notifyRootSpanActive(rootSpan: Span): void {\n if (this._lifecycleMode !== 'trace' || !this._sessionSampled) {\n return;\n }\n\n const spanId = rootSpan.spanContext().spanId;\n if (!spanId || this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._registerTraceRootSpan(spanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Detected already active root span during setup. Active root spans now:', rootSpanCount);\n\n this._beginProfiling();\n }\n\n if (this._isRunning) {\n setThreadAttributes(rootSpan);\n }\n }\n\n /**\n * Begin profiling if not already running.\n */\n private _beginProfiling(): void {\n if (this._isRunning) {\n return;\n }\n this._isRunning = true;\n\n DEBUG_BUILD && debug.log('[Profiling] Started profiling with profiler ID:', this._profilerId);\n\n // Expose profiler_id to match root spans with profiles\n getGlobalScope().setContext('profile', { profiler_id: this._profilerId });\n\n this._startProfilerInstance();\n\n if (!this._profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start JS Profiler; stopping.');\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n\n /** End profiling session; final chunk will be collected and sent. */\n private _endProfiling(): void {\n if (!this._isRunning) {\n return;\n }\n this._isRunning = false;\n\n if (this._chunkTimer) {\n clearTimeout(this._chunkTimer);\n this._chunkTimer = undefined;\n }\n\n this._clearAllRootSpanTimeouts();\n\n // Collect whatever was currently recording\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on `stop()`:', e);\n });\n\n // Manual: Clear profiling context so spans outside start()/stop() aren't marked as profiled\n // Trace: Profile context is kept for the whole session duration\n if (this._lifecycleMode === 'manual') {\n getGlobalScope().setContext('profile', {});\n }\n }\n\n /** Trace-mode: attach spanStart/spanEnd listeners. */\n private _setupTraceLifecycleListeners(client: Client): void {\n client.on('spanStart', span => {\n if (!this._sessionSampled) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Span not profiled because of negative sampling decision for user session.');\n return;\n }\n if (span !== getRootSpan(span)) {\n return; // only care about root spans\n }\n // Only count sampled root spans\n if (!span.isRecording()) {\n DEBUG_BUILD && debug.log('[Profiling] Discarding profile because root span was not sampled.');\n return;\n }\n\n const spanId = span.spanContext().spanId;\n if (!spanId || this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._registerTraceRootSpan(spanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span ${spanId} started. Profiling active while there are active root spans (count=${rootSpanCount}).`,\n );\n this._beginProfiling();\n }\n });\n\n client.on('spanEnd', span => {\n if (!this._sessionSampled) {\n return;\n }\n const spanId = span.spanContext().spanId;\n if (!spanId || !this._activeRootSpanIds.has(spanId)) {\n return;\n }\n this._activeRootSpanIds.delete(spanId);\n const rootSpanCount = this._activeRootSpanIds.size;\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span with ID ${spanId} ended. Will continue profiling for as long as there are active root spans (currently: ${rootSpanCount}).`,\n );\n if (rootSpanCount === 0) {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on last `spanEnd`:', e);\n });\n this._endProfiling();\n }\n });\n }\n\n /**\n * Resets profiling information from scope and resets running state (used on failure)\n */\n private _resetProfilerInfo(): void {\n this._isRunning = false;\n getGlobalScope().setContext('profile', {});\n }\n\n /**\n * Clear and reset all per-root-span timeouts.\n */\n private _clearAllRootSpanTimeouts(): void {\n this._rootSpanTimeouts.forEach(timeout => clearTimeout(timeout));\n this._rootSpanTimeouts.clear();\n }\n\n /** Keep track of root spans and schedule safeguard timeout (trace mode). */\n private _registerTraceRootSpan(spanId: string): void {\n this._activeRootSpanIds.add(spanId);\n const timeout = setTimeout(() => this._onRootSpanTimeout(spanId), MAX_ROOT_SPAN_PROFILE_MS);\n this._rootSpanTimeouts.set(spanId, timeout);\n }\n\n /**\n * Start a profiler instance if needed.\n */\n private _startProfilerInstance(): void {\n if (this._profiler?.stopped === false) {\n return; // already running\n }\n const profiler = startJSSelfProfile();\n if (!profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start JS Profiler.');\n return;\n }\n this._profiler = profiler;\n }\n\n /**\n * Schedule the next 60s chunk while running.\n * Each tick collects a chunk and restarts the profiler.\n * A chunk should be closed when there are no active root spans anymore OR when the maximum chunk interval is reached.\n */\n private _startPeriodicChunking(): void {\n if (!this._isRunning) {\n return;\n }\n\n this._chunkTimer = setTimeout(() => {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk during periodic chunking:', e);\n });\n\n if (this._isRunning) {\n this._startProfilerInstance();\n\n if (!this._profiler) {\n // If restart failed, stop scheduling further chunks and reset context.\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n }, CHUNK_INTERVAL_MS);\n }\n\n /**\n * Handle timeout for a specific root span ID to avoid indefinitely running profiler if `spanEnd` never fires.\n * If this was the last active root span, collect the current chunk and stop profiling.\n */\n private _onRootSpanTimeout(rootSpanId: string): void {\n // If span already ended, ignore\n if (!this._rootSpanTimeouts.has(rootSpanId)) {\n return;\n }\n this._rootSpanTimeouts.delete(rootSpanId);\n\n if (!this._activeRootSpanIds.has(rootSpanId)) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Reached 5-minute timeout for root span ${rootSpanId}. You likely started a manual root span that never called \\`.end()\\`.`,\n );\n\n this._activeRootSpanIds.delete(rootSpanId);\n\n if (this._activeRootSpanIds.size === 0) {\n this._endProfiling();\n }\n }\n\n /**\n * Stop current profiler instance, convert profile to chunk & send.\n */\n private async _collectCurrentChunk(): Promise<void> {\n const prevProfiler = this._profiler;\n this._profiler = undefined;\n\n if (!prevProfiler) {\n return;\n }\n\n try {\n const profile = await prevProfiler.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const chunk = createProfileChunkPayload(profile, this._client!, this._profilerId);\n\n // Validate chunk before sending\n const validationReturn = validateProfileChunk(chunk);\n if ('reason' in validationReturn) {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):',\n validationReturn.reason,\n );\n return;\n }\n\n this._sendProfileChunk(chunk);\n\n DEBUG_BUILD && debug.log('[Profiling] Collected browser profile chunk.');\n } catch (e) {\n DEBUG_BUILD && debug.log('[Profiling] Error while stopping JS Profiler for chunk:', e);\n }\n }\n\n /**\n * Send a profile chunk as a standalone envelope.\n */\n private _sendProfileChunk(chunk: ProfileChunk): void {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const client = this._client!;\n\n const sdkInfo = getSdkMetadataForEnvelopeHeader(client.getSdkMetadata?.());\n const dsn = client.getDsn();\n const tunnel = client.getOptions().tunnel;\n\n const envelope = createEnvelope<ProfileChunkEnvelope>(\n {\n event_id: uuid4(),\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n },\n [[{ type: 'profile_chunk', platform: 'javascript' }, chunk]],\n );\n\n client.sendEnvelope(envelope).then(null, reason => {\n DEBUG_BUILD && debug.error('Error while sending profile chunk envelope:', reason);\n });\n }\n}\n"],"names":["shouldProfileSession","DEBUG_BUILD","debug","uuid4","setThreadAttributes","getGlobalScope","getRootSpan","startJSSelfProfile","createProfileChunkPayload","validateProfileChunk","getSdkMetadataForEnvelopeHeader","createEnvelope","dsnToString"],"mappings":";;;;;;AAqBA,MAAM,iBAAA,GAAoB,KAAM,CAAA;AAChC;AACA,MAAM,wBAAA,GAA2B,MAAO,CAAA;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,YAAiD;;AAK9D;AACA;AACA;AACA;;AAGA;;AAIA,GAAS,WAAW,GAAG;AACvB,IAAI,IAAI,CAAC,OAAA,GAAU,SAAS;AAC5B,IAAI,IAAI,CAAC,SAAA,GAAY,SAAS;AAC9B,IAAI,IAAI,CAAC,WAAA,GAAc,SAAS;;AAEhC,IAAI,IAAI,CAAC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EAAE,GAAG,EAAES,mBAAW,CAAC,GAAG,CAAA,EAAG,CAAC;AACzD,OAAO;AACP,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAA,EAAc,EAAE,KAAK,CAAC,CAAC;AAClE,KAAK;;AAEL,IAAI,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,MAAA,IAAU;AACvD,MAAMX,sBAAA,IAAeC,aAAK,CAAC,KAAK,CAAC,6CAA6C,EAAE,MAAM,CAAC;AACvF,IAAI,CAAC,CAAC;AACN,EAAE;AACF;;;;"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const core = require('@sentry/core');
3
+ const browser = require('@sentry/core/browser');
4
4
  const debugBuild = require('../debug-build.js');
5
5
 
6
6
  /**
@@ -9,16 +9,16 @@ const debugBuild = require('../debug-build.js');
9
9
  * In UI profiling mode, the profiler will keep reporting profile chunks to Sentry until it is stopped, which allows for continuous profiling of the application.
10
10
  */
11
11
  function startProfiler() {
12
- const client = core.getClient();
12
+ const client = browser.getClient();
13
13
  if (!client) {
14
- debugBuild.DEBUG_BUILD && core.debug.warn('No Sentry client available, profiling is not started');
14
+ debugBuild.DEBUG_BUILD && browser.debug.warn('No Sentry client available, profiling is not started');
15
15
  return;
16
16
  }
17
17
 
18
18
  const integration = client.getIntegrationByName('BrowserProfiling');
19
19
 
20
20
  if (!integration) {
21
- debugBuild.DEBUG_BUILD && core.debug.warn('BrowserProfiling integration is not available');
21
+ debugBuild.DEBUG_BUILD && browser.debug.warn('BrowserProfiling integration is not available');
22
22
  return;
23
23
  }
24
24
 
@@ -30,15 +30,15 @@ function startProfiler() {
30
30
  * Calls to stop will stop the profiler and flush the currently collected profile data to Sentry.
31
31
  */
32
32
  function stopProfiler() {
33
- const client = core.getClient();
33
+ const client = browser.getClient();
34
34
  if (!client) {
35
- debugBuild.DEBUG_BUILD && core.debug.warn('No Sentry client available, profiling is not started');
35
+ debugBuild.DEBUG_BUILD && browser.debug.warn('No Sentry client available, profiling is not started');
36
36
  return;
37
37
  }
38
38
 
39
39
  const integration = client.getIntegrationByName('BrowserProfiling');
40
40
  if (!integration) {
41
- debugBuild.DEBUG_BUILD && core.debug.warn('ProfilingIntegration is not available');
41
+ debugBuild.DEBUG_BUILD && browser.debug.warn('ProfilingIntegration is not available');
42
42
  return;
43
43
  }
44
44
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/profiling/index.ts"],"sourcesContent":["import type { Profiler } from '@sentry/core';\nimport { debug, getClient } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Starts the Sentry UI profiler.\n * This mode is exclusive with the transaction profiler and will only work if the profilesSampleRate is set to a falsy value.\n * In UI profiling mode, the profiler will keep reporting profile chunks to Sentry until it is stopped, which allows for continuous profiling of the application.\n */\nfunction startProfiler(): void {\n const client = getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No Sentry client available, profiling is not started');\n return;\n }\n\n const integration = client.getIntegrationByName('BrowserProfiling');\n\n if (!integration) {\n DEBUG_BUILD && debug.warn('BrowserProfiling integration is not available');\n return;\n }\n\n client.emit('startUIProfiler');\n}\n\n/**\n * Stops the Sentry UI profiler.\n * Calls to stop will stop the profiler and flush the currently collected profile data to Sentry.\n */\nfunction stopProfiler(): void {\n const client = getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No Sentry client available, profiling is not started');\n return;\n }\n\n const integration = client.getIntegrationByName('BrowserProfiling');\n if (!integration) {\n DEBUG_BUILD && debug.warn('ProfilingIntegration is not available');\n return;\n }\n\n client.emit('stopUIProfiler');\n}\n\n/**\n * Profiler namespace for controlling the JS profiler in 'manual' mode.\n *\n * Requires the `browserProfilingIntegration` from the `@sentry/browser` package.\n */\nexport const uiProfiler: Profiler = {\n startProfiler,\n stopProfiler,\n};\n"],"names":["getClient","DEBUG_BUILD","debug"],"mappings":";;;;;AAIA;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,GAAS;AAC/B,EAAE,MAAM,MAAA,GAASA,cAAS,EAAE;AAC5B,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAIC,0BAAeC,UAAK,CAAC,IAAI,CAAC,sDAAsD,CAAC;AACrF,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,cAAc,MAAM,CAAC,oBAAoB,CAAC,kBAAkB,CAAC;;AAErE,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAID,0BAAeC,UAAK,CAAC,IAAI,CAAC,+CAA+C,CAAC;AAC9E,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA,SAAS,YAAY,GAAS;AAC9B,EAAE,MAAM,MAAA,GAASF,cAAS,EAAE;AAC5B,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAIC,0BAAeC,UAAK,CAAC,IAAI,CAAC,sDAAsD,CAAC;AACrF,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,cAAc,MAAM,CAAC,oBAAoB,CAAC,kBAAkB,CAAC;AACrE,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAID,0BAAeC,UAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC;AACtE,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC;AAC/B;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,UAAU,GAAa;AACpC,EAAE,aAAa;AACf,EAAE,YAAY;AACd;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/profiling/index.ts"],"sourcesContent":["import type { Profiler } from '@sentry/core/browser';\nimport { debug, getClient } from '@sentry/core/browser';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Starts the Sentry UI profiler.\n * This mode is exclusive with the transaction profiler and will only work if the profilesSampleRate is set to a falsy value.\n * In UI profiling mode, the profiler will keep reporting profile chunks to Sentry until it is stopped, which allows for continuous profiling of the application.\n */\nfunction startProfiler(): void {\n const client = getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No Sentry client available, profiling is not started');\n return;\n }\n\n const integration = client.getIntegrationByName('BrowserProfiling');\n\n if (!integration) {\n DEBUG_BUILD && debug.warn('BrowserProfiling integration is not available');\n return;\n }\n\n client.emit('startUIProfiler');\n}\n\n/**\n * Stops the Sentry UI profiler.\n * Calls to stop will stop the profiler and flush the currently collected profile data to Sentry.\n */\nfunction stopProfiler(): void {\n const client = getClient();\n if (!client) {\n DEBUG_BUILD && debug.warn('No Sentry client available, profiling is not started');\n return;\n }\n\n const integration = client.getIntegrationByName('BrowserProfiling');\n if (!integration) {\n DEBUG_BUILD && debug.warn('ProfilingIntegration is not available');\n return;\n }\n\n client.emit('stopUIProfiler');\n}\n\n/**\n * Profiler namespace for controlling the JS profiler in 'manual' mode.\n *\n * Requires the `browserProfilingIntegration` from the `@sentry/browser` package.\n */\nexport const uiProfiler: Profiler = {\n startProfiler,\n stopProfiler,\n};\n"],"names":["getClient","DEBUG_BUILD","debug"],"mappings":";;;;;AAIA;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,GAAS;AAC/B,EAAE,MAAM,MAAA,GAASA,iBAAS,EAAE;AAC5B,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAIC,0BAAeC,aAAK,CAAC,IAAI,CAAC,sDAAsD,CAAC;AACrF,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,cAAc,MAAM,CAAC,oBAAoB,CAAC,kBAAkB,CAAC;;AAErE,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAID,0BAAeC,aAAK,CAAC,IAAI,CAAC,+CAA+C,CAAC;AAC9E,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA,SAAS,YAAY,GAAS;AAC9B,EAAE,MAAM,MAAA,GAASF,iBAAS,EAAE;AAC5B,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAIC,0BAAeC,aAAK,CAAC,IAAI,CAAC,sDAAsD,CAAC;AACrF,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,cAAc,MAAM,CAAC,oBAAoB,CAAC,kBAAkB,CAAC;AACrE,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAID,0BAAeC,aAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC;AACtE,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC;AAC/B;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,UAAU,GAAa;AACpC,EAAE,aAAa;AACf,EAAE,YAAY;AACd;;;;"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const core = require('@sentry/core');
3
+ const browser = require('@sentry/core/browser');
4
4
  const debugBuild = require('../debug-build.js');
5
5
  const helpers = require('../helpers.js');
6
6
  const startProfileForSpan = require('./startProfileForSpan.js');
@@ -23,16 +23,16 @@ const _browserProfilingIntegration = (() => {
23
23
 
24
24
  // eslint-disable-next-line deprecation/deprecation
25
25
  if (utils.hasLegacyProfiling(options) && !options.profilesSampleRate) {
26
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Profiling disabled, no profiling options found.');
26
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] Profiling disabled, no profiling options found.');
27
27
  return;
28
28
  }
29
29
 
30
- const activeSpan = core.getActiveSpan();
31
- const rootSpan = activeSpan && core.getRootSpan(activeSpan);
30
+ const activeSpan = browser.getActiveSpan();
31
+ const rootSpan = activeSpan && browser.getRootSpan(activeSpan);
32
32
 
33
33
  if (utils.hasLegacyProfiling(options) && options.profileSessionSampleRate !== undefined) {
34
34
  debugBuild.DEBUG_BUILD &&
35
- core.debug.warn(
35
+ browser.debug.warn(
36
36
  '[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled.',
37
37
  );
38
38
  }
@@ -48,9 +48,9 @@ const _browserProfilingIntegration = (() => {
48
48
  if (lifecycleMode === 'manual') {
49
49
  profiler.initialize(client);
50
50
  } else if (lifecycleMode === 'trace') {
51
- if (!core.hasSpansEnabled(options)) {
51
+ if (!browser.hasSpansEnabled(options)) {
52
52
  debugBuild.DEBUG_BUILD &&
53
- core.debug.warn(
53
+ browser.debug.warn(
54
54
  "[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing.",
55
55
  );
56
56
  return;
@@ -65,8 +65,8 @@ const _browserProfilingIntegration = (() => {
65
65
 
66
66
  // In case rootSpan is created slightly after setup -> schedule microtask to re-check and notify.
67
67
  helpers.WINDOW.setTimeout(() => {
68
- const laterActiveSpan = core.getActiveSpan();
69
- const laterRootSpan = laterActiveSpan && core.getRootSpan(laterActiveSpan);
68
+ const laterActiveSpan = browser.getActiveSpan();
69
+ const laterRootSpan = laterActiveSpan && browser.getRootSpan(laterActiveSpan);
70
70
  if (laterRootSpan) {
71
71
  profiler.notifyRootSpanActive(laterRootSpan);
72
72
  }
@@ -81,8 +81,13 @@ const _browserProfilingIntegration = (() => {
81
81
  }
82
82
 
83
83
  client.on('spanStart', (span) => {
84
- if (span === core.getRootSpan(span) && utils.shouldProfileSpanLegacy(span)) {
85
- startProfileForSpan.startProfileForSpan(span);
84
+ const rootSpan = browser.getRootSpan(span);
85
+ if (span === rootSpan) {
86
+ if (utils.shouldProfileSpanLegacy(span)) {
87
+ startProfileForSpan.startProfileForSpan(span);
88
+ }
89
+ } else if (utils.PROFILED_ROOT_SPANS.has(rootSpan)) {
90
+ utils.setThreadAttributes(span);
86
91
  }
87
92
  });
88
93
 
@@ -105,12 +110,12 @@ const _browserProfilingIntegration = (() => {
105
110
  const start_timestamp = context?.profile?.['start_timestamp'];
106
111
 
107
112
  if (typeof profile_id !== 'string') {
108
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] cannot find profile for a span without a profile context');
113
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] cannot find profile for a span without a profile context');
109
114
  continue;
110
115
  }
111
116
 
112
117
  if (!profile_id) {
113
- debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] cannot find profile for a span without a profile context');
118
+ debugBuild.DEBUG_BUILD && browser.debug.log('[Profiling] cannot find profile for a span without a profile context');
114
119
  continue;
115
120
  }
116
121
 
@@ -121,7 +126,7 @@ const _browserProfilingIntegration = (() => {
121
126
 
122
127
  const profile = utils.takeProfileFromGlobalCache(profile_id);
123
128
  if (!profile) {
124
- debugBuild.DEBUG_BUILD && core.debug.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);
129
+ debugBuild.DEBUG_BUILD && browser.debug.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);
125
130
  continue;
126
131
  }
127
132
 
@@ -140,13 +145,10 @@ const _browserProfilingIntegration = (() => {
140
145
  });
141
146
  }
142
147
  },
143
- processEvent(event) {
144
- return utils.attachProfiledThreadToEvent(event);
145
- },
146
148
  };
147
149
  }) ;
148
150
 
149
- const browserProfilingIntegration = core.defineIntegration(_browserProfilingIntegration);
151
+ const browserProfilingIntegration = browser.defineIntegration(_browserProfilingIntegration);
150
152
 
151
153
  exports.browserProfilingIntegration = browserProfilingIntegration;
152
154
  //# sourceMappingURL=integration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"integration.js","sources":["../../../../../src/profiling/integration.ts"],"sourcesContent":["import type { EventEnvelope, IntegrationFn, Profile, Span } from '@sentry/core';\nimport { debug, defineIntegration, getActiveSpan, getRootSpan, hasSpansEnabled } from '@sentry/core';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport { startProfileForSpan } from './startProfileForSpan';\nimport { UIProfiler } from './UIProfiler';\nimport type { ProfiledEvent } from './utils';\nimport {\n addProfilesToEnvelope,\n attachProfiledThreadToEvent,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n getActiveProfilesCount,\n hasLegacyProfiling,\n isAutomatedPageLoadSpan,\n shouldProfileSpanLegacy,\n takeProfileFromGlobalCache,\n} from './utils';\n\nconst INTEGRATION_NAME = 'BrowserProfiling';\n\nconst _browserProfilingIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const options = client.getOptions() as BrowserOptions;\n const profiler = new UIProfiler();\n\n if (!hasLegacyProfiling(options) && !options.profileLifecycle) {\n // Set default lifecycle mode\n options.profileLifecycle = 'manual';\n }\n\n // eslint-disable-next-line deprecation/deprecation\n if (hasLegacyProfiling(options) && !options.profilesSampleRate) {\n DEBUG_BUILD && debug.log('[Profiling] Profiling disabled, no profiling options found.');\n return;\n }\n\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n\n if (hasLegacyProfiling(options) && options.profileSessionSampleRate !== undefined) {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled.',\n );\n }\n\n // UI PROFILING (Profiling V2)\n if (!hasLegacyProfiling(options)) {\n const lifecycleMode = options.profileLifecycle;\n\n // Registering hooks in all lifecycle modes to be able to notify users in case they want to start/stop the profiler manually in `trace` mode\n client.on('startUIProfiler', () => profiler.start());\n client.on('stopUIProfiler', () => profiler.stop());\n\n if (lifecycleMode === 'manual') {\n profiler.initialize(client);\n } else if (lifecycleMode === 'trace') {\n if (!hasSpansEnabled(options)) {\n DEBUG_BUILD &&\n debug.warn(\n \"[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing.\",\n );\n return;\n }\n\n profiler.initialize(client);\n\n // If there is an active, sampled root span already, notify the profiler\n if (rootSpan) {\n profiler.notifyRootSpanActive(rootSpan);\n }\n\n // In case rootSpan is created slightly after setup -> schedule microtask to re-check and notify.\n WINDOW.setTimeout(() => {\n const laterActiveSpan = getActiveSpan();\n const laterRootSpan = laterActiveSpan && getRootSpan(laterActiveSpan);\n if (laterRootSpan) {\n profiler.notifyRootSpanActive(laterRootSpan);\n }\n }, 0);\n }\n } else {\n // LEGACY PROFILING (v1)\n if (rootSpan && isAutomatedPageLoadSpan(rootSpan)) {\n if (shouldProfileSpanLegacy(rootSpan)) {\n startProfileForSpan(rootSpan);\n }\n }\n\n client.on('spanStart', (span: Span) => {\n if (span === getRootSpan(span) && shouldProfileSpanLegacy(span)) {\n startProfileForSpan(span);\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!getActiveProfilesCount()) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const context = profiledTransaction?.contexts;\n const profile_id = context?.profile?.['profile_id'];\n const start_timestamp = context?.profile?.['start_timestamp'];\n\n if (typeof profile_id !== 'string') {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n if (!profile_id) {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n // Remove the profile from the span context before sending, relay will take care of the rest.\n if (context?.profile) {\n delete context.profile;\n }\n\n const profile = takeProfileFromGlobalCache(profile_id);\n if (!profile) {\n DEBUG_BUILD && debug.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);\n continue;\n }\n\n const profileEvent = createProfilingEvent(\n profile_id,\n start_timestamp as number | undefined,\n profile,\n profiledTransaction as ProfiledEvent,\n );\n if (profileEvent) {\n profilesToAddToEnvelope.push(profileEvent);\n }\n }\n\n addProfilesToEnvelope(envelope as EventEnvelope, profilesToAddToEnvelope);\n });\n }\n },\n processEvent(event) {\n return attachProfiledThreadToEvent(event);\n },\n };\n}) satisfies IntegrationFn;\n\nexport const browserProfilingIntegration = defineIntegration(_browserProfilingIntegration);\n"],"names":["UIProfiler","hasLegacyProfiling","DEBUG_BUILD","debug","getActiveSpan","getRootSpan","hasSpansEnabled","WINDOW","isAutomatedPageLoadSpan","shouldProfileSpanLegacy","startProfileForSpan","getActiveProfilesCount","findProfiledTransactionsFromEnvelope","takeProfileFromGlobalCache","createProfilingEvent","addProfilesToEnvelope","attachProfiledThreadToEvent","defineIntegration"],"mappings":";;;;;;;;;AAoBA,MAAM,gBAAA,GAAmB,kBAAkB;;AAE3C,MAAM,4BAAA,IAAgC,MAAM;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,OAAA,GAAU,MAAM,CAAC,UAAU,EAAC;AACxC,MAAM,MAAM,QAAA,GAAW,IAAIA,qBAAU,EAAE;;AAEvC,MAAM,IAAI,CAACC,wBAAkB,CAAC,OAAO,CAAA,IAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE;AACrE;AACA,QAAQ,OAAO,CAAC,gBAAA,GAAmB,QAAQ;AAC3C,MAAM;;AAEN;AACA,MAAM,IAAIA,wBAAkB,CAAC,OAAO,CAAA,IAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE;AACtE,QAAQC,0BAAeC,UAAK,CAAC,GAAG,CAAC,6DAA6D,CAAC;AAC/F,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM,UAAA,GAAaC,kBAAa,EAAE;AACxC,MAAM,MAAM,WAAW,UAAA,IAAcC,gBAAW,CAAC,UAAU,CAAC;;AAE5D,MAAM,IAAIJ,wBAAkB,CAAC,OAAO,CAAA,IAAK,OAAO,CAAC,wBAAA,KAA6B,SAAS,EAAE;AACzF,QAAQC,sBAAA;AACR,UAAUC,UAAK,CAAC,IAAI;AACpB,YAAY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YAAY;;AAEZ,YAAY,MAAM,OAAA,GAAUU,gCAA0B,CAAC,UAAU,CAAC;AAClE,YAAY,IAAI,CAAC,OAAO,EAAE;AAC1B,cAAcX,sBAAA,IAAeC,UAAK,CAAC,GAAG,CAAC,CAAC,iDAAiD,EAAE,UAAU,CAAC,CAAA,CAAA;AACA,cAAA;AACA,YAAA;;AAEA,YAAA,MAAA,YAAA,GAAAW,0BAAA;AACA,cAAA,UAAA;AACA,cAAA,eAAA;AACA,cAAA,OAAA;AACA,cAAA,mBAAA;AACA,aAAA;AACA,YAAA,IAAA,YAAA,EAAA;AACA,cAAA,uBAAA,CAAA,IAAA,CAAA,YAAA,CAAA;AACA,YAAA;AACA,UAAA;;AAEA,UAAAC,2BAAA,CAAA,QAAA,GAAA,uBAAA,CAAA;AACA,QAAA,CAAA,CAAA;AACA,MAAA;AACA,IAAA,CAAA;AACA,IAAA,YAAA,CAAA,KAAA,EAAA;AACA,MAAA,OAAAC,iCAAA,CAAA,KAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA,MAAA,2BAAA,GAAAC,sBAAA,CAAA,4BAAA;;;;"}
1
+ {"version":3,"file":"integration.js","sources":["../../../../../src/profiling/integration.ts"],"sourcesContent":["import type { EventEnvelope, IntegrationFn, Profile, Span } from '@sentry/core/browser';\nimport { debug, defineIntegration, getActiveSpan, getRootSpan, hasSpansEnabled } from '@sentry/core/browser';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport { startProfileForSpan } from './startProfileForSpan';\nimport { UIProfiler } from './UIProfiler';\nimport type { ProfiledEvent } from './utils';\nimport {\n addProfilesToEnvelope,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n getActiveProfilesCount,\n hasLegacyProfiling,\n isAutomatedPageLoadSpan,\n PROFILED_ROOT_SPANS,\n setThreadAttributes,\n shouldProfileSpanLegacy,\n takeProfileFromGlobalCache,\n} from './utils';\n\nconst INTEGRATION_NAME = 'BrowserProfiling';\n\nconst _browserProfilingIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const options = client.getOptions() as BrowserOptions;\n const profiler = new UIProfiler();\n\n if (!hasLegacyProfiling(options) && !options.profileLifecycle) {\n // Set default lifecycle mode\n options.profileLifecycle = 'manual';\n }\n\n // eslint-disable-next-line deprecation/deprecation\n if (hasLegacyProfiling(options) && !options.profilesSampleRate) {\n DEBUG_BUILD && debug.log('[Profiling] Profiling disabled, no profiling options found.');\n return;\n }\n\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n\n if (hasLegacyProfiling(options) && options.profileSessionSampleRate !== undefined) {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled.',\n );\n }\n\n // UI PROFILING (Profiling V2)\n if (!hasLegacyProfiling(options)) {\n const lifecycleMode = options.profileLifecycle;\n\n // Registering hooks in all lifecycle modes to be able to notify users in case they want to start/stop the profiler manually in `trace` mode\n client.on('startUIProfiler', () => profiler.start());\n client.on('stopUIProfiler', () => profiler.stop());\n\n if (lifecycleMode === 'manual') {\n profiler.initialize(client);\n } else if (lifecycleMode === 'trace') {\n if (!hasSpansEnabled(options)) {\n DEBUG_BUILD &&\n debug.warn(\n \"[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing.\",\n );\n return;\n }\n\n profiler.initialize(client);\n\n // If there is an active, sampled root span already, notify the profiler\n if (rootSpan) {\n profiler.notifyRootSpanActive(rootSpan);\n }\n\n // In case rootSpan is created slightly after setup -> schedule microtask to re-check and notify.\n WINDOW.setTimeout(() => {\n const laterActiveSpan = getActiveSpan();\n const laterRootSpan = laterActiveSpan && getRootSpan(laterActiveSpan);\n if (laterRootSpan) {\n profiler.notifyRootSpanActive(laterRootSpan);\n }\n }, 0);\n }\n } else {\n // LEGACY PROFILING (v1)\n if (rootSpan && isAutomatedPageLoadSpan(rootSpan)) {\n if (shouldProfileSpanLegacy(rootSpan)) {\n startProfileForSpan(rootSpan);\n }\n }\n\n client.on('spanStart', (span: Span) => {\n const rootSpan = getRootSpan(span);\n if (span === rootSpan) {\n if (shouldProfileSpanLegacy(span)) {\n startProfileForSpan(span);\n }\n } else if (PROFILED_ROOT_SPANS.has(rootSpan)) {\n setThreadAttributes(span);\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!getActiveProfilesCount()) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const context = profiledTransaction?.contexts;\n const profile_id = context?.profile?.['profile_id'];\n const start_timestamp = context?.profile?.['start_timestamp'];\n\n if (typeof profile_id !== 'string') {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n if (!profile_id) {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n // Remove the profile from the span context before sending, relay will take care of the rest.\n if (context?.profile) {\n delete context.profile;\n }\n\n const profile = takeProfileFromGlobalCache(profile_id);\n if (!profile) {\n DEBUG_BUILD && debug.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);\n continue;\n }\n\n const profileEvent = createProfilingEvent(\n profile_id,\n start_timestamp as number | undefined,\n profile,\n profiledTransaction as ProfiledEvent,\n );\n if (profileEvent) {\n profilesToAddToEnvelope.push(profileEvent);\n }\n }\n\n addProfilesToEnvelope(envelope as EventEnvelope, profilesToAddToEnvelope);\n });\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const browserProfilingIntegration = defineIntegration(_browserProfilingIntegration);\n"],"names":["UIProfiler","hasLegacyProfiling","DEBUG_BUILD","debug","getActiveSpan","getRootSpan","hasSpansEnabled","WINDOW","isAutomatedPageLoadSpan","shouldProfileSpanLegacy","startProfileForSpan","PROFILED_ROOT_SPANS","setThreadAttributes","getActiveProfilesCount","findProfiledTransactionsFromEnvelope","takeProfileFromGlobalCache","createProfilingEvent","addProfilesToEnvelope","defineIntegration"],"mappings":";;;;;;;;;AAqBA,MAAM,gBAAA,GAAmB,kBAAkB;;AAE3C,MAAM,4BAAA,IAAgC,MAAM;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,OAAA,GAAU,MAAM,CAAC,UAAU,EAAC;AACxC,MAAM,MAAM,QAAA,GAAW,IAAIA,qBAAU,EAAE;;AAEvC,MAAM,IAAI,CAACC,wBAAkB,CAAC,OAAO,CAAA,IAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE;AACrE;AACA,QAAQ,OAAO,CAAC,gBAAA,GAAmB,QAAQ;AAC3C,MAAM;;AAEN;AACA,MAAM,IAAIA,wBAAkB,CAAC,OAAO,CAAA,IAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE;AACtE,QAAQC,0BAAeC,aAAK,CAAC,GAAG,CAAC,6DAA6D,CAAC;AAC/F,QAAQ;AACR,MAAM;;AAEN,MAAM,MAAM,UAAA,GAAaC,qBAAa,EAAE;AACxC,MAAM,MAAM,WAAW,UAAA,IAAcC,mBAAW,CAAC,UAAU,CAAC;;AAE5D,MAAM,IAAIJ,wBAAkB,CAAC,OAAO,CAAA,IAAK,OAAO,CAAC,wBAAA,KAA6B,SAAS,EAAE;AACzF,QAAQC,sBAAA;AACR,UAAUC,aAAK,CAAC,IAAI;AACpB,YAAY,4KAA4K;AACxL,WAAW;AACX,MAAM;;AAEN;AACA,MAAM,IAAI,CAACF,wBAAkB,CAAC,OAAO,CAAC,EAAE;AACxC,QAAQ,MAAM,aAAA,GAAgB,OAAO,CAAC,gBA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