@sentry/browser 10.22.0 → 10.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/build/npm/cjs/{client.js → dev/client.js} +16 -3
  2. package/build/npm/cjs/dev/client.js.map +1 -0
  3. package/build/npm/cjs/dev/debug-build.js.map +1 -0
  4. package/build/npm/cjs/dev/diagnose-sdk.js.map +1 -0
  5. package/build/npm/cjs/dev/eventbuilder.js.map +1 -0
  6. package/build/npm/cjs/dev/feedbackAsync.js.map +1 -0
  7. package/build/npm/cjs/dev/feedbackSync.js.map +1 -0
  8. package/build/npm/cjs/dev/helpers.js.map +1 -0
  9. package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -0
  10. package/build/npm/cjs/dev/integrations/browserapierrors.js.map +1 -0
  11. package/build/npm/cjs/dev/integrations/browsersession.js.map +1 -0
  12. package/build/npm/cjs/dev/integrations/contextlines.js.map +1 -0
  13. package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js.map +1 -0
  14. package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
  15. package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js.map +1 -0
  16. package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js.map +1 -0
  17. package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js.map +1 -0
  18. package/build/npm/cjs/{integrations → dev/integrations}/globalhandlers.js +6 -1
  19. package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -0
  20. package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -0
  21. package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -0
  22. package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -0
  23. package/build/npm/cjs/dev/integrations/linkederrors.js.map +1 -0
  24. package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -0
  25. package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -0
  26. package/build/npm/cjs/{integrations → dev/integrations}/webWorker.js +119 -17
  27. package/build/npm/cjs/dev/integrations/webWorker.js.map +1 -0
  28. package/build/npm/cjs/dev/profiling/integration.js.map +1 -0
  29. package/build/npm/cjs/dev/profiling/lifecycleMode/traceLifecycleProfiler.js.map +1 -0
  30. package/build/npm/cjs/dev/profiling/startProfileForSpan.js.map +1 -0
  31. package/build/npm/cjs/dev/profiling/utils.js.map +1 -0
  32. package/build/npm/cjs/dev/report-dialog.js.map +1 -0
  33. package/build/npm/cjs/dev/sdk.js +133 -0
  34. package/build/npm/cjs/dev/sdk.js.map +1 -0
  35. package/build/npm/cjs/dev/stack-parsers.js.map +1 -0
  36. package/build/npm/cjs/dev/tracing/backgroundtab.js.map +1 -0
  37. package/build/npm/cjs/dev/tracing/browserTracingIntegration.js.map +1 -0
  38. package/build/npm/cjs/{tracing → dev/tracing}/linkedTraces.js +1 -0
  39. package/build/npm/cjs/dev/tracing/linkedTraces.js.map +1 -0
  40. package/build/npm/cjs/dev/tracing/reportPageLoaded.js.map +1 -0
  41. package/build/npm/cjs/dev/tracing/request.js.map +1 -0
  42. package/build/npm/cjs/dev/tracing/setActiveSpan.js.map +1 -0
  43. package/build/npm/cjs/dev/tracing/utils.js.map +1 -0
  44. package/build/npm/cjs/{transports → dev/transports}/fetch.js +7 -1
  45. package/build/npm/cjs/dev/transports/fetch.js.map +1 -0
  46. package/build/npm/cjs/dev/transports/offline.js.map +1 -0
  47. package/build/npm/cjs/dev/userfeedback.js.map +1 -0
  48. package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -0
  49. package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -0
  50. package/build/npm/cjs/prod/client.js +125 -0
  51. package/build/npm/cjs/prod/client.js.map +1 -0
  52. package/build/npm/cjs/prod/debug-build.js +11 -0
  53. package/build/npm/cjs/prod/debug-build.js.map +1 -0
  54. package/build/npm/cjs/prod/diagnose-sdk.js +51 -0
  55. package/build/npm/cjs/prod/diagnose-sdk.js.map +1 -0
  56. package/build/npm/cjs/prod/eventbuilder.js +397 -0
  57. package/build/npm/cjs/prod/eventbuilder.js.map +1 -0
  58. package/build/npm/cjs/prod/feedbackAsync.js +15 -0
  59. package/build/npm/cjs/prod/feedbackAsync.js.map +1 -0
  60. package/build/npm/cjs/prod/feedbackSync.js +12 -0
  61. package/build/npm/cjs/prod/feedbackSync.js.map +1 -0
  62. package/build/npm/cjs/prod/helpers.js +185 -0
  63. package/build/npm/cjs/prod/helpers.js.map +1 -0
  64. package/build/npm/cjs/prod/index.js +179 -0
  65. package/build/npm/cjs/prod/index.js.map +1 -0
  66. package/build/npm/cjs/prod/integrations/breadcrumbs.js +341 -0
  67. package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -0
  68. package/build/npm/cjs/prod/integrations/browserapierrors.js +259 -0
  69. package/build/npm/cjs/prod/integrations/browserapierrors.js.map +1 -0
  70. package/build/npm/cjs/prod/integrations/browsersession.js +44 -0
  71. package/build/npm/cjs/prod/integrations/browsersession.js.map +1 -0
  72. package/build/npm/cjs/prod/integrations/contextlines.js +89 -0
  73. package/build/npm/cjs/prod/integrations/contextlines.js.map +1 -0
  74. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js +29 -0
  75. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js.map +1 -0
  76. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js +55 -0
  77. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
  78. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js +38 -0
  79. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js.map +1 -0
  80. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js +48 -0
  81. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js.map +1 -0
  82. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js +74 -0
  83. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js.map +1 -0
  84. package/build/npm/cjs/prod/integrations/globalhandlers.js +210 -0
  85. package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -0
  86. package/build/npm/cjs/prod/integrations/graphqlClient.js +180 -0
  87. package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -0
  88. package/build/npm/cjs/prod/integrations/httpclient.js +395 -0
  89. package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -0
  90. package/build/npm/cjs/prod/integrations/httpcontext.js +35 -0
  91. package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -0
  92. package/build/npm/cjs/prod/integrations/linkederrors.js +39 -0
  93. package/build/npm/cjs/prod/integrations/linkederrors.js.map +1 -0
  94. package/build/npm/cjs/prod/integrations/reportingobserver.js +85 -0
  95. package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -0
  96. package/build/npm/cjs/prod/integrations/spotlight.js +85 -0
  97. package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -0
  98. package/build/npm/cjs/prod/integrations/webWorker.js +251 -0
  99. package/build/npm/cjs/prod/integrations/webWorker.js.map +1 -0
  100. package/build/npm/cjs/prod/profiling/integration.js +150 -0
  101. package/build/npm/cjs/prod/profiling/integration.js.map +1 -0
  102. package/build/npm/cjs/prod/profiling/lifecycleMode/traceLifecycleProfiler.js +343 -0
  103. package/build/npm/cjs/prod/profiling/lifecycleMode/traceLifecycleProfiler.js.map +1 -0
  104. package/build/npm/cjs/prod/profiling/startProfileForSpan.js +144 -0
  105. package/build/npm/cjs/prod/profiling/startProfileForSpan.js.map +1 -0
  106. package/build/npm/cjs/prod/profiling/utils.js +786 -0
  107. package/build/npm/cjs/prod/profiling/utils.js.map +1 -0
  108. package/build/npm/cjs/prod/report-dialog.js +68 -0
  109. package/build/npm/cjs/prod/report-dialog.js.map +1 -0
  110. package/build/npm/cjs/{sdk.js → prod/sdk.js} +5 -2
  111. package/build/npm/cjs/prod/sdk.js.map +1 -0
  112. package/build/npm/cjs/prod/stack-parsers.js +202 -0
  113. package/build/npm/cjs/prod/stack-parsers.js.map +1 -0
  114. package/build/npm/cjs/prod/tracing/backgroundtab.js +46 -0
  115. package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -0
  116. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +577 -0
  117. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -0
  118. package/build/npm/cjs/prod/tracing/linkedTraces.js +227 -0
  119. package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -0
  120. package/build/npm/cjs/prod/tracing/reportPageLoaded.js +18 -0
  121. package/build/npm/cjs/prod/tracing/reportPageLoaded.js.map +1 -0
  122. package/build/npm/cjs/prod/tracing/request.js +342 -0
  123. package/build/npm/cjs/prod/tracing/request.js.map +1 -0
  124. package/build/npm/cjs/prod/tracing/setActiveSpan.js +68 -0
  125. package/build/npm/cjs/prod/tracing/setActiveSpan.js.map +1 -0
  126. package/build/npm/cjs/prod/tracing/utils.js +54 -0
  127. package/build/npm/cjs/prod/tracing/utils.js.map +1 -0
  128. package/build/npm/cjs/prod/transports/fetch.js +71 -0
  129. package/build/npm/cjs/prod/transports/fetch.js.map +1 -0
  130. package/build/npm/cjs/prod/transports/offline.js +168 -0
  131. package/build/npm/cjs/prod/transports/offline.js.map +1 -0
  132. package/build/npm/cjs/prod/userfeedback.js +42 -0
  133. package/build/npm/cjs/prod/userfeedback.js.map +1 -0
  134. package/build/npm/cjs/prod/utils/detectBrowserExtension.js +59 -0
  135. package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -0
  136. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +106 -0
  137. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -0
  138. package/build/npm/esm/{client.js → dev/client.js} +16 -3
  139. package/build/npm/esm/dev/client.js.map +1 -0
  140. package/build/npm/esm/dev/debug-build.js.map +1 -0
  141. package/build/npm/esm/dev/diagnose-sdk.js.map +1 -0
  142. package/build/npm/esm/dev/eventbuilder.js.map +1 -0
  143. package/build/npm/esm/dev/feedbackAsync.js.map +1 -0
  144. package/build/npm/esm/dev/feedbackSync.js.map +1 -0
  145. package/build/npm/esm/dev/helpers.js.map +1 -0
  146. package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -0
  147. package/build/npm/esm/dev/integrations/browserapierrors.js.map +1 -0
  148. package/build/npm/esm/dev/integrations/browsersession.js.map +1 -0
  149. package/build/npm/esm/dev/integrations/contextlines.js.map +1 -0
  150. package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js.map +1 -0
  151. package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
  152. package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js.map +1 -0
  153. package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js.map +1 -0
  154. package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js.map +1 -0
  155. package/build/npm/esm/{integrations → dev/integrations}/globalhandlers.js +5 -2
  156. package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -0
  157. package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -0
  158. package/build/npm/esm/dev/integrations/httpclient.js.map +1 -0
  159. package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -0
  160. package/build/npm/esm/dev/integrations/linkederrors.js.map +1 -0
  161. package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -0
  162. package/build/npm/esm/dev/integrations/spotlight.js.map +1 -0
  163. package/build/npm/esm/dev/integrations/webWorker.js +247 -0
  164. package/build/npm/esm/dev/integrations/webWorker.js.map +1 -0
  165. package/build/npm/esm/dev/package.json +1 -0
  166. package/build/npm/esm/dev/profiling/integration.js.map +1 -0
  167. package/build/npm/esm/dev/profiling/lifecycleMode/traceLifecycleProfiler.js.map +1 -0
  168. package/build/npm/esm/dev/profiling/startProfileForSpan.js.map +1 -0
  169. package/build/npm/esm/dev/profiling/utils.js.map +1 -0
  170. package/build/npm/esm/dev/report-dialog.js.map +1 -0
  171. package/build/npm/esm/dev/sdk.js +128 -0
  172. package/build/npm/esm/dev/sdk.js.map +1 -0
  173. package/build/npm/esm/dev/stack-parsers.js.map +1 -0
  174. package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -0
  175. package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -0
  176. package/build/npm/esm/{tracing → dev/tracing}/linkedTraces.js +1 -0
  177. package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -0
  178. package/build/npm/esm/dev/tracing/reportPageLoaded.js.map +1 -0
  179. package/build/npm/esm/dev/tracing/request.js.map +1 -0
  180. package/build/npm/esm/dev/tracing/setActiveSpan.js.map +1 -0
  181. package/build/npm/esm/dev/tracing/utils.js.map +1 -0
  182. package/build/npm/esm/{transports → dev/transports}/fetch.js +8 -2
  183. package/build/npm/esm/dev/transports/fetch.js.map +1 -0
  184. package/build/npm/esm/dev/transports/offline.js.map +1 -0
  185. package/build/npm/esm/dev/userfeedback.js.map +1 -0
  186. package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -0
  187. package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -0
  188. package/build/npm/esm/prod/client.js +122 -0
  189. package/build/npm/esm/prod/client.js.map +1 -0
  190. package/build/npm/esm/prod/debug-build.js +9 -0
  191. package/build/npm/esm/prod/debug-build.js.map +1 -0
  192. package/build/npm/esm/prod/diagnose-sdk.js +49 -0
  193. package/build/npm/esm/prod/diagnose-sdk.js.map +1 -0
  194. package/build/npm/esm/prod/eventbuilder.js +390 -0
  195. package/build/npm/esm/prod/eventbuilder.js.map +1 -0
  196. package/build/npm/esm/prod/feedbackAsync.js +13 -0
  197. package/build/npm/esm/prod/feedbackAsync.js.map +1 -0
  198. package/build/npm/esm/prod/feedbackSync.js +10 -0
  199. package/build/npm/esm/prod/feedbackSync.js.map +1 -0
  200. package/build/npm/esm/prod/helpers.js +179 -0
  201. package/build/npm/esm/prod/helpers.js.map +1 -0
  202. package/build/npm/esm/prod/index.js +40 -0
  203. package/build/npm/esm/prod/index.js.map +1 -0
  204. package/build/npm/esm/prod/integrations/breadcrumbs.js +339 -0
  205. package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -0
  206. package/build/npm/esm/prod/integrations/browserapierrors.js +257 -0
  207. package/build/npm/esm/prod/integrations/browserapierrors.js.map +1 -0
  208. package/build/npm/esm/prod/integrations/browsersession.js +42 -0
  209. package/build/npm/esm/prod/integrations/browsersession.js.map +1 -0
  210. package/build/npm/esm/prod/integrations/contextlines.js +86 -0
  211. package/build/npm/esm/prod/integrations/contextlines.js.map +1 -0
  212. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js +27 -0
  213. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js.map +1 -0
  214. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js +52 -0
  215. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
  216. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js +35 -0
  217. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js.map +1 -0
  218. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js +46 -0
  219. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js.map +1 -0
  220. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js +72 -0
  221. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js.map +1 -0
  222. package/build/npm/esm/prod/integrations/globalhandlers.js +206 -0
  223. package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -0
  224. package/build/npm/esm/prod/integrations/graphqlClient.js +175 -0
  225. package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -0
  226. package/build/npm/esm/prod/integrations/httpclient.js +393 -0
  227. package/build/npm/esm/prod/integrations/httpclient.js.map +1 -0
  228. package/build/npm/esm/prod/integrations/httpcontext.js +33 -0
  229. package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -0
  230. package/build/npm/esm/prod/integrations/linkederrors.js +37 -0
  231. package/build/npm/esm/prod/integrations/linkederrors.js.map +1 -0
  232. package/build/npm/esm/prod/integrations/reportingobserver.js +83 -0
  233. package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -0
  234. package/build/npm/esm/prod/integrations/spotlight.js +81 -0
  235. package/build/npm/esm/prod/integrations/spotlight.js.map +1 -0
  236. package/build/npm/esm/prod/integrations/webWorker.js +247 -0
  237. package/build/npm/esm/prod/integrations/webWorker.js.map +1 -0
  238. package/build/npm/esm/prod/package.json +1 -0
  239. package/build/npm/esm/prod/profiling/integration.js +148 -0
  240. package/build/npm/esm/prod/profiling/integration.js.map +1 -0
  241. package/build/npm/esm/prod/profiling/lifecycleMode/traceLifecycleProfiler.js +341 -0
  242. package/build/npm/esm/prod/profiling/lifecycleMode/traceLifecycleProfiler.js.map +1 -0
  243. package/build/npm/esm/prod/profiling/startProfileForSpan.js +142 -0
  244. package/build/npm/esm/prod/profiling/startProfileForSpan.js.map +1 -0
  245. package/build/npm/esm/prod/profiling/utils.js +763 -0
  246. package/build/npm/esm/prod/profiling/utils.js.map +1 -0
  247. package/build/npm/esm/prod/report-dialog.js +66 -0
  248. package/build/npm/esm/prod/report-dialog.js.map +1 -0
  249. package/build/npm/esm/{sdk.js → prod/sdk.js} +5 -2
  250. package/build/npm/esm/prod/sdk.js.map +1 -0
  251. package/build/npm/esm/prod/stack-parsers.js +194 -0
  252. package/build/npm/esm/prod/stack-parsers.js.map +1 -0
  253. package/build/npm/esm/prod/tracing/backgroundtab.js +44 -0
  254. package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -0
  255. package/build/npm/esm/prod/tracing/browserTracingIntegration.js +571 -0
  256. package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -0
  257. package/build/npm/esm/prod/tracing/linkedTraces.js +218 -0
  258. package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -0
  259. package/build/npm/esm/prod/tracing/reportPageLoaded.js +16 -0
  260. package/build/npm/esm/prod/tracing/reportPageLoaded.js.map +1 -0
  261. package/build/npm/esm/prod/tracing/request.js +338 -0
  262. package/build/npm/esm/prod/tracing/request.js.map +1 -0
  263. package/build/npm/esm/prod/tracing/setActiveSpan.js +66 -0
  264. package/build/npm/esm/prod/tracing/setActiveSpan.js.map +1 -0
  265. package/build/npm/esm/prod/tracing/utils.js +49 -0
  266. package/build/npm/esm/prod/tracing/utils.js.map +1 -0
  267. package/build/npm/esm/prod/transports/fetch.js +69 -0
  268. package/build/npm/esm/prod/transports/fetch.js.map +1 -0
  269. package/build/npm/esm/prod/transports/offline.js +162 -0
  270. package/build/npm/esm/prod/transports/offline.js.map +1 -0
  271. package/build/npm/esm/prod/userfeedback.js +40 -0
  272. package/build/npm/esm/prod/userfeedback.js.map +1 -0
  273. package/build/npm/esm/prod/utils/detectBrowserExtension.js +57 -0
  274. package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -0
  275. package/build/npm/esm/prod/utils/lazyLoadIntegration.js +104 -0
  276. package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -0
  277. package/build/npm/types/client.d.ts +11 -0
  278. package/build/npm/types/client.d.ts.map +1 -1
  279. package/build/npm/types/integrations/globalhandlers.d.ts +12 -0
  280. package/build/npm/types/integrations/globalhandlers.d.ts.map +1 -1
  281. package/build/npm/types/integrations/webWorker.d.ts +12 -0
  282. package/build/npm/types/integrations/webWorker.d.ts.map +1 -1
  283. package/build/npm/types/sdk.d.ts.map +1 -1
  284. package/build/npm/types/transports/fetch.d.ts.map +1 -1
  285. package/build/npm/types/transports/types.d.ts +0 -4
  286. package/build/npm/types/transports/types.d.ts.map +1 -1
  287. package/build/npm/types-ts3.8/client.d.ts +11 -0
  288. package/build/npm/types-ts3.8/integrations/globalhandlers.d.ts +12 -0
  289. package/build/npm/types-ts3.8/integrations/webWorker.d.ts +12 -0
  290. package/build/npm/types-ts3.8/transports/types.d.ts +0 -4
  291. package/package.json +22 -17
  292. package/build/npm/cjs/client.js.map +0 -1
  293. package/build/npm/cjs/debug-build.js.map +0 -1
  294. package/build/npm/cjs/diagnose-sdk.js.map +0 -1
  295. package/build/npm/cjs/eventbuilder.js.map +0 -1
  296. package/build/npm/cjs/feedbackAsync.js.map +0 -1
  297. package/build/npm/cjs/feedbackSync.js.map +0 -1
  298. package/build/npm/cjs/helpers.js.map +0 -1
  299. package/build/npm/cjs/integrations/breadcrumbs.js.map +0 -1
  300. package/build/npm/cjs/integrations/browserapierrors.js.map +0 -1
  301. package/build/npm/cjs/integrations/browsersession.js.map +0 -1
  302. package/build/npm/cjs/integrations/contextlines.js.map +0 -1
  303. package/build/npm/cjs/integrations/featureFlags/growthbook/integration.js.map +0 -1
  304. package/build/npm/cjs/integrations/featureFlags/launchdarkly/integration.js.map +0 -1
  305. package/build/npm/cjs/integrations/featureFlags/openfeature/integration.js.map +0 -1
  306. package/build/npm/cjs/integrations/featureFlags/statsig/integration.js.map +0 -1
  307. package/build/npm/cjs/integrations/featureFlags/unleash/integration.js.map +0 -1
  308. package/build/npm/cjs/integrations/globalhandlers.js.map +0 -1
  309. package/build/npm/cjs/integrations/graphqlClient.js.map +0 -1
  310. package/build/npm/cjs/integrations/httpclient.js.map +0 -1
  311. package/build/npm/cjs/integrations/httpcontext.js.map +0 -1
  312. package/build/npm/cjs/integrations/linkederrors.js.map +0 -1
  313. package/build/npm/cjs/integrations/reportingobserver.js.map +0 -1
  314. package/build/npm/cjs/integrations/spotlight.js.map +0 -1
  315. package/build/npm/cjs/integrations/webWorker.js.map +0 -1
  316. package/build/npm/cjs/profiling/integration.js.map +0 -1
  317. package/build/npm/cjs/profiling/lifecycleMode/traceLifecycleProfiler.js.map +0 -1
  318. package/build/npm/cjs/profiling/startProfileForSpan.js.map +0 -1
  319. package/build/npm/cjs/profiling/utils.js.map +0 -1
  320. package/build/npm/cjs/report-dialog.js.map +0 -1
  321. package/build/npm/cjs/sdk.js.map +0 -1
  322. package/build/npm/cjs/stack-parsers.js.map +0 -1
  323. package/build/npm/cjs/tracing/backgroundtab.js.map +0 -1
  324. package/build/npm/cjs/tracing/browserTracingIntegration.js.map +0 -1
  325. package/build/npm/cjs/tracing/linkedTraces.js.map +0 -1
  326. package/build/npm/cjs/tracing/reportPageLoaded.js.map +0 -1
  327. package/build/npm/cjs/tracing/request.js.map +0 -1
  328. package/build/npm/cjs/tracing/setActiveSpan.js.map +0 -1
  329. package/build/npm/cjs/tracing/utils.js.map +0 -1
  330. package/build/npm/cjs/transports/fetch.js.map +0 -1
  331. package/build/npm/cjs/transports/offline.js.map +0 -1
  332. package/build/npm/cjs/userfeedback.js.map +0 -1
  333. package/build/npm/cjs/utils/detectBrowserExtension.js.map +0 -1
  334. package/build/npm/cjs/utils/lazyLoadIntegration.js.map +0 -1
  335. package/build/npm/esm/client.js.map +0 -1
  336. package/build/npm/esm/debug-build.js.map +0 -1
  337. package/build/npm/esm/diagnose-sdk.js.map +0 -1
  338. package/build/npm/esm/eventbuilder.js.map +0 -1
  339. package/build/npm/esm/feedbackAsync.js.map +0 -1
  340. package/build/npm/esm/feedbackSync.js.map +0 -1
  341. package/build/npm/esm/helpers.js.map +0 -1
  342. package/build/npm/esm/integrations/breadcrumbs.js.map +0 -1
  343. package/build/npm/esm/integrations/browserapierrors.js.map +0 -1
  344. package/build/npm/esm/integrations/browsersession.js.map +0 -1
  345. package/build/npm/esm/integrations/contextlines.js.map +0 -1
  346. package/build/npm/esm/integrations/featureFlags/growthbook/integration.js.map +0 -1
  347. package/build/npm/esm/integrations/featureFlags/launchdarkly/integration.js.map +0 -1
  348. package/build/npm/esm/integrations/featureFlags/openfeature/integration.js.map +0 -1
  349. package/build/npm/esm/integrations/featureFlags/statsig/integration.js.map +0 -1
  350. package/build/npm/esm/integrations/featureFlags/unleash/integration.js.map +0 -1
  351. package/build/npm/esm/integrations/globalhandlers.js.map +0 -1
  352. package/build/npm/esm/integrations/graphqlClient.js.map +0 -1
  353. package/build/npm/esm/integrations/httpclient.js.map +0 -1
  354. package/build/npm/esm/integrations/httpcontext.js.map +0 -1
  355. package/build/npm/esm/integrations/linkederrors.js.map +0 -1
  356. package/build/npm/esm/integrations/reportingobserver.js.map +0 -1
  357. package/build/npm/esm/integrations/spotlight.js.map +0 -1
  358. package/build/npm/esm/integrations/webWorker.js +0 -145
  359. package/build/npm/esm/integrations/webWorker.js.map +0 -1
  360. package/build/npm/esm/package.json +0 -1
  361. package/build/npm/esm/profiling/integration.js.map +0 -1
  362. package/build/npm/esm/profiling/lifecycleMode/traceLifecycleProfiler.js.map +0 -1
  363. package/build/npm/esm/profiling/startProfileForSpan.js.map +0 -1
  364. package/build/npm/esm/profiling/utils.js.map +0 -1
  365. package/build/npm/esm/report-dialog.js.map +0 -1
  366. package/build/npm/esm/sdk.js.map +0 -1
  367. package/build/npm/esm/stack-parsers.js.map +0 -1
  368. package/build/npm/esm/tracing/backgroundtab.js.map +0 -1
  369. package/build/npm/esm/tracing/browserTracingIntegration.js.map +0 -1
  370. package/build/npm/esm/tracing/linkedTraces.js.map +0 -1
  371. package/build/npm/esm/tracing/reportPageLoaded.js.map +0 -1
  372. package/build/npm/esm/tracing/request.js.map +0 -1
  373. package/build/npm/esm/tracing/setActiveSpan.js.map +0 -1
  374. package/build/npm/esm/tracing/utils.js.map +0 -1
  375. package/build/npm/esm/transports/fetch.js.map +0 -1
  376. package/build/npm/esm/transports/offline.js.map +0 -1
  377. package/build/npm/esm/userfeedback.js.map +0 -1
  378. package/build/npm/esm/utils/detectBrowserExtension.js.map +0 -1
  379. package/build/npm/esm/utils/lazyLoadIntegration.js.map +0 -1
  380. /package/build/npm/cjs/{debug-build.js → dev/debug-build.js} +0 -0
  381. /package/build/npm/cjs/{diagnose-sdk.js → dev/diagnose-sdk.js} +0 -0
  382. /package/build/npm/cjs/{eventbuilder.js → dev/eventbuilder.js} +0 -0
  383. /package/build/npm/cjs/{feedbackAsync.js → dev/feedbackAsync.js} +0 -0
  384. /package/build/npm/cjs/{feedbackSync.js → dev/feedbackSync.js} +0 -0
  385. /package/build/npm/cjs/{helpers.js → dev/helpers.js} +0 -0
  386. /package/build/npm/cjs/{index.js → dev/index.js} +0 -0
  387. /package/build/npm/cjs/{index.js.map → dev/index.js.map} +0 -0
  388. /package/build/npm/cjs/{integrations → dev/integrations}/breadcrumbs.js +0 -0
  389. /package/build/npm/cjs/{integrations → dev/integrations}/browserapierrors.js +0 -0
  390. /package/build/npm/cjs/{integrations → dev/integrations}/browsersession.js +0 -0
  391. /package/build/npm/cjs/{integrations → dev/integrations}/contextlines.js +0 -0
  392. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/growthbook/integration.js +0 -0
  393. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/launchdarkly/integration.js +0 -0
  394. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/openfeature/integration.js +0 -0
  395. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/statsig/integration.js +0 -0
  396. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/unleash/integration.js +0 -0
  397. /package/build/npm/cjs/{integrations → dev/integrations}/graphqlClient.js +0 -0
  398. /package/build/npm/cjs/{integrations → dev/integrations}/httpclient.js +0 -0
  399. /package/build/npm/cjs/{integrations → dev/integrations}/httpcontext.js +0 -0
  400. /package/build/npm/cjs/{integrations → dev/integrations}/linkederrors.js +0 -0
  401. /package/build/npm/cjs/{integrations → dev/integrations}/reportingobserver.js +0 -0
  402. /package/build/npm/cjs/{integrations → dev/integrations}/spotlight.js +0 -0
  403. /package/build/npm/cjs/{profiling → dev/profiling}/integration.js +0 -0
  404. /package/build/npm/cjs/{profiling → dev/profiling}/lifecycleMode/traceLifecycleProfiler.js +0 -0
  405. /package/build/npm/cjs/{profiling → dev/profiling}/startProfileForSpan.js +0 -0
  406. /package/build/npm/cjs/{profiling → dev/profiling}/utils.js +0 -0
  407. /package/build/npm/cjs/{report-dialog.js → dev/report-dialog.js} +0 -0
  408. /package/build/npm/cjs/{stack-parsers.js → dev/stack-parsers.js} +0 -0
  409. /package/build/npm/cjs/{tracing → dev/tracing}/backgroundtab.js +0 -0
  410. /package/build/npm/cjs/{tracing → dev/tracing}/browserTracingIntegration.js +0 -0
  411. /package/build/npm/cjs/{tracing → dev/tracing}/reportPageLoaded.js +0 -0
  412. /package/build/npm/cjs/{tracing → dev/tracing}/request.js +0 -0
  413. /package/build/npm/cjs/{tracing → dev/tracing}/setActiveSpan.js +0 -0
  414. /package/build/npm/cjs/{tracing → dev/tracing}/utils.js +0 -0
  415. /package/build/npm/cjs/{transports → dev/transports}/offline.js +0 -0
  416. /package/build/npm/cjs/{userfeedback.js → dev/userfeedback.js} +0 -0
  417. /package/build/npm/cjs/{utils → dev/utils}/detectBrowserExtension.js +0 -0
  418. /package/build/npm/cjs/{utils → dev/utils}/lazyLoadIntegration.js +0 -0
  419. /package/build/npm/esm/{debug-build.js → dev/debug-build.js} +0 -0
  420. /package/build/npm/esm/{diagnose-sdk.js → dev/diagnose-sdk.js} +0 -0
  421. /package/build/npm/esm/{eventbuilder.js → dev/eventbuilder.js} +0 -0
  422. /package/build/npm/esm/{feedbackAsync.js → dev/feedbackAsync.js} +0 -0
  423. /package/build/npm/esm/{feedbackSync.js → dev/feedbackSync.js} +0 -0
  424. /package/build/npm/esm/{helpers.js → dev/helpers.js} +0 -0
  425. /package/build/npm/esm/{index.js → dev/index.js} +0 -0
  426. /package/build/npm/esm/{index.js.map → dev/index.js.map} +0 -0
  427. /package/build/npm/esm/{integrations → dev/integrations}/breadcrumbs.js +0 -0
  428. /package/build/npm/esm/{integrations → dev/integrations}/browserapierrors.js +0 -0
  429. /package/build/npm/esm/{integrations → dev/integrations}/browsersession.js +0 -0
  430. /package/build/npm/esm/{integrations → dev/integrations}/contextlines.js +0 -0
  431. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/growthbook/integration.js +0 -0
  432. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/launchdarkly/integration.js +0 -0
  433. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/openfeature/integration.js +0 -0
  434. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/statsig/integration.js +0 -0
  435. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/unleash/integration.js +0 -0
  436. /package/build/npm/esm/{integrations → dev/integrations}/graphqlClient.js +0 -0
  437. /package/build/npm/esm/{integrations → dev/integrations}/httpclient.js +0 -0
  438. /package/build/npm/esm/{integrations → dev/integrations}/httpcontext.js +0 -0
  439. /package/build/npm/esm/{integrations → dev/integrations}/linkederrors.js +0 -0
  440. /package/build/npm/esm/{integrations → dev/integrations}/reportingobserver.js +0 -0
  441. /package/build/npm/esm/{integrations → dev/integrations}/spotlight.js +0 -0
  442. /package/build/npm/esm/{profiling → dev/profiling}/integration.js +0 -0
  443. /package/build/npm/esm/{profiling → dev/profiling}/lifecycleMode/traceLifecycleProfiler.js +0 -0
  444. /package/build/npm/esm/{profiling → dev/profiling}/startProfileForSpan.js +0 -0
  445. /package/build/npm/esm/{profiling → dev/profiling}/utils.js +0 -0
  446. /package/build/npm/esm/{report-dialog.js → dev/report-dialog.js} +0 -0
  447. /package/build/npm/esm/{stack-parsers.js → dev/stack-parsers.js} +0 -0
  448. /package/build/npm/esm/{tracing → dev/tracing}/backgroundtab.js +0 -0
  449. /package/build/npm/esm/{tracing → dev/tracing}/browserTracingIntegration.js +0 -0
  450. /package/build/npm/esm/{tracing → dev/tracing}/reportPageLoaded.js +0 -0
  451. /package/build/npm/esm/{tracing → dev/tracing}/request.js +0 -0
  452. /package/build/npm/esm/{tracing → dev/tracing}/setActiveSpan.js +0 -0
  453. /package/build/npm/esm/{tracing → dev/tracing}/utils.js +0 -0
  454. /package/build/npm/esm/{transports → dev/transports}/offline.js +0 -0
  455. /package/build/npm/esm/{userfeedback.js → dev/userfeedback.js} +0 -0
  456. /package/build/npm/esm/{utils → dev/utils}/detectBrowserExtension.js +0 -0
  457. /package/build/npm/esm/{utils → dev/utils}/lazyLoadIntegration.js +0 -0
@@ -0,0 +1,763 @@
1
+ import { GLOBAL_OBJ, debug, spanToJSON, getClient, forEachEnvelopeItem, uuid4, timestampInSeconds, DEFAULT_ENVIRONMENT, browserPerformanceTimeOrigin, getDebugImagesForResources } from '@sentry/core';
2
+ import { DEBUG_BUILD } from '../debug-build.js';
3
+ import { WINDOW } from '../helpers.js';
4
+
5
+ const MS_TO_NS = 1e6;
6
+
7
+ // Checking if we are in Main or Worker thread: `self` (not `window`) is the `globalThis` in Web Workers and `importScripts` are only available in Web Workers
8
+ const isMainThread = 'window' in GLOBAL_OBJ && GLOBAL_OBJ.window === GLOBAL_OBJ && typeof importScripts === 'undefined';
9
+
10
+ // Setting ID to 0 as we cannot get an ID from Web Workers
11
+ const PROFILER_THREAD_ID_STRING = String(0);
12
+ const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker';
13
+
14
+ // We force make this optional to be on the safe side...
15
+ const navigator = WINDOW.navigator ;
16
+
17
+ // Machine properties (eval only once)
18
+ let OS_PLATFORM = '';
19
+ let OS_PLATFORM_VERSION = '';
20
+ let OS_ARCH = '';
21
+ let OS_BROWSER = navigator?.userAgent || '';
22
+ let OS_MODEL = '';
23
+ const OS_LOCALE = navigator?.language || navigator?.languages?.[0] || '';
24
+
25
+ function isUserAgentData(data) {
26
+ return typeof data === 'object' && data !== null && 'getHighEntropyValues' in data;
27
+ }
28
+
29
+ // @ts-expect-error userAgentData is not part of the navigator interface yet
30
+ const userAgentData = navigator?.userAgentData;
31
+
32
+ if (isUserAgentData(userAgentData)) {
33
+ userAgentData
34
+ .getHighEntropyValues(['architecture', 'model', 'platform', 'platformVersion', 'fullVersionList'])
35
+ .then((ua) => {
36
+ OS_PLATFORM = ua.platform || '';
37
+ OS_ARCH = ua.architecture || '';
38
+ OS_MODEL = ua.model || '';
39
+ OS_PLATFORM_VERSION = ua.platformVersion || '';
40
+
41
+ if (ua.fullVersionList?.length) {
42
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
43
+ const firstUa = ua.fullVersionList[ua.fullVersionList.length - 1];
44
+ OS_BROWSER = `${firstUa.brand} ${firstUa.version}`;
45
+ }
46
+ })
47
+ .catch(e => void 0);
48
+ }
49
+
50
+ function isProcessedJSSelfProfile(profile) {
51
+ return !('thread_metadata' in profile);
52
+ }
53
+
54
+ // Enriches the profile with threadId of the current thread.
55
+ // This is done in node as we seem to not be able to get the info from C native code.
56
+ /**
57
+ *
58
+ */
59
+ function enrichWithThreadInformation(profile) {
60
+ if (!isProcessedJSSelfProfile(profile)) {
61
+ return profile;
62
+ }
63
+
64
+ return convertJSSelfProfileToSampledFormat(profile);
65
+ }
66
+
67
+ // Profile is marked as optional because it is deleted from the metadata
68
+ // by the integration before the event is processed by other integrations.
69
+
70
+ function getTraceId(event) {
71
+ const traceId = event.contexts?.trace?.trace_id;
72
+ // Log a warning if the profile has an invalid traceId (should be uuidv4).
73
+ // All profiles and transactions are rejected if this is the case and we want to
74
+ // warn users that this is happening if they enable debug flag
75
+ if (typeof traceId === 'string' && traceId.length !== 32) {
76
+ if (DEBUG_BUILD) {
77
+ debug.log(`[Profiling] Invalid traceId: ${traceId} on profiled event`);
78
+ }
79
+ }
80
+ if (typeof traceId !== 'string') {
81
+ return '';
82
+ }
83
+
84
+ return traceId;
85
+ }
86
+ /**
87
+ * Creates a profiling event envelope from a Sentry event. If profile does not pass
88
+ * validation, returns null.
89
+ * @param event
90
+ * @param dsn
91
+ * @param metadata
92
+ * @param tunnel
93
+ * @returns {EventEnvelope | null}
94
+ */
95
+
96
+ /**
97
+ * Creates a profiling event envelope from a Sentry event.
98
+ */
99
+ function createProfilePayload(
100
+ profile_id,
101
+ start_timestamp,
102
+ processed_profile,
103
+ event,
104
+ ) {
105
+ if (event.type !== 'transaction') {
106
+ // createProfilingEventEnvelope should only be called for transactions,
107
+ // we type guard this behavior with isProfiledTransactionEvent.
108
+ throw new TypeError('Profiling events may only be attached to transactions, this should never occur.');
109
+ }
110
+
111
+ if (processed_profile === undefined || processed_profile === null) {
112
+ throw new TypeError(
113
+ `Cannot construct profiling event envelope without a valid profile. Got ${processed_profile} instead.`,
114
+ );
115
+ }
116
+
117
+ const traceId = getTraceId(event);
118
+ const enrichedThreadProfile = enrichWithThreadInformation(processed_profile);
119
+ const transactionStartMs = start_timestamp
120
+ ? start_timestamp
121
+ : typeof event.start_timestamp === 'number'
122
+ ? event.start_timestamp * 1000
123
+ : timestampInSeconds() * 1000;
124
+ const transactionEndMs = typeof event.timestamp === 'number' ? event.timestamp * 1000 : timestampInSeconds() * 1000;
125
+
126
+ const profile = {
127
+ event_id: profile_id,
128
+ timestamp: new Date(transactionStartMs).toISOString(),
129
+ platform: 'javascript',
130
+ version: '1',
131
+ release: event.release || '',
132
+ environment: event.environment || DEFAULT_ENVIRONMENT,
133
+ runtime: {
134
+ name: 'javascript',
135
+ version: WINDOW.navigator.userAgent,
136
+ },
137
+ os: {
138
+ name: OS_PLATFORM,
139
+ version: OS_PLATFORM_VERSION,
140
+ build_number: OS_BROWSER,
141
+ },
142
+ device: {
143
+ locale: OS_LOCALE,
144
+ model: OS_MODEL,
145
+ manufacturer: OS_BROWSER,
146
+ architecture: OS_ARCH,
147
+ is_emulator: false,
148
+ },
149
+ debug_meta: {
150
+ images: applyDebugMetadata(processed_profile.resources),
151
+ },
152
+ profile: enrichedThreadProfile,
153
+ transactions: [
154
+ {
155
+ name: event.transaction || '',
156
+ id: event.event_id || uuid4(),
157
+ trace_id: traceId,
158
+ active_thread_id: PROFILER_THREAD_ID_STRING,
159
+ relative_start_ns: '0',
160
+ relative_end_ns: ((transactionEndMs - transactionStartMs) * 1e6).toFixed(0),
161
+ },
162
+ ],
163
+ };
164
+
165
+ return profile;
166
+ }
167
+
168
+ /**
169
+ * Create a profile chunk envelope item
170
+ */
171
+ function createProfileChunkPayload(
172
+ jsSelfProfile,
173
+ client,
174
+ profilerId,
175
+ ) {
176
+ // only == to catch null and undefined
177
+ if (jsSelfProfile == null) {
178
+ throw new TypeError(
179
+ `Cannot construct profiling event envelope without a valid profile. Got ${jsSelfProfile} instead.`,
180
+ );
181
+ }
182
+
183
+ const continuousProfile = convertToContinuousProfile(jsSelfProfile);
184
+
185
+ const options = client.getOptions();
186
+ const sdk = client.getSdkMetadata?.()?.sdk;
187
+
188
+ return {
189
+ chunk_id: uuid4(),
190
+ client_sdk: {
191
+ name: sdk?.name ?? 'sentry.javascript.browser',
192
+ version: sdk?.version ?? '0.0.0',
193
+ },
194
+ profiler_id: profilerId || uuid4(),
195
+ platform: 'javascript',
196
+ version: '2',
197
+ release: options.release ?? '',
198
+ environment: options.environment ?? 'production',
199
+ debug_meta: {
200
+ // function name obfuscation
201
+ images: applyDebugMetadata(jsSelfProfile.resources),
202
+ },
203
+ profile: continuousProfile,
204
+ };
205
+ }
206
+
207
+ /**
208
+ * Validate a profile chunk against the Sample Format V2 requirements.
209
+ * https://develop.sentry.dev/sdk/telemetry/profiles/sample-format-v2/
210
+ * - Presence of samples, stacks, frames
211
+ * - Required metadata fields
212
+ */
213
+ function validateProfileChunk(chunk) {
214
+ try {
215
+ // Required metadata
216
+ if (!chunk || typeof chunk !== 'object') {
217
+ return { reason: 'chunk is not an object' };
218
+ }
219
+
220
+ // profiler_id and chunk_id must be 32 lowercase hex chars
221
+ const isHex32 = (val) => typeof val === 'string' && /^[a-f0-9]{32}$/.test(val);
222
+ if (!isHex32(chunk.profiler_id)) {
223
+ return { reason: 'missing or invalid profiler_id' };
224
+ }
225
+ if (!isHex32(chunk.chunk_id)) {
226
+ return { reason: 'missing or invalid chunk_id' };
227
+ }
228
+
229
+ if (!chunk.client_sdk) {
230
+ return { reason: 'missing client_sdk metadata' };
231
+ }
232
+
233
+ // Profile data must have frames, stacks, samples
234
+ const profile = chunk.profile ;
235
+ if (!profile) {
236
+ return { reason: 'missing profile data' };
237
+ }
238
+
239
+ if (!Array.isArray(profile.frames) || !profile.frames.length) {
240
+ return { reason: 'profile has no frames' };
241
+ }
242
+ if (!Array.isArray(profile.stacks) || !profile.stacks.length) {
243
+ return { reason: 'profile has no stacks' };
244
+ }
245
+ if (!Array.isArray(profile.samples) || !profile.samples.length) {
246
+ return { reason: 'profile has no samples' };
247
+ }
248
+
249
+ return { valid: true };
250
+ } catch (e) {
251
+ return { reason: `unknown validation error: ${e}` };
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Convert from JSSelfProfile format to ContinuousThreadCpuProfile format.
257
+ */
258
+ function convertToContinuousProfile(input
259
+
260
+ ) {
261
+ // Frames map 1:1 by index; fill only when present to avoid sparse writes
262
+ const frames = [];
263
+ for (let i = 0; i < input.frames.length; i++) {
264
+ const frame = input.frames[i];
265
+ if (!frame) {
266
+ continue;
267
+ }
268
+ frames[i] = {
269
+ function: frame.name,
270
+ abs_path: typeof frame.resourceId === 'number' ? input.resources[frame.resourceId] : undefined,
271
+ lineno: frame.line,
272
+ colno: frame.column,
273
+ };
274
+ }
275
+
276
+ // Build stacks by following parent links, top->down order (root last)
277
+ const stacks = [];
278
+ for (let i = 0; i < input.stacks.length; i++) {
279
+ const stackHead = input.stacks[i];
280
+ if (!stackHead) {
281
+ continue;
282
+ }
283
+ const list = [];
284
+ let current = stackHead;
285
+ while (current) {
286
+ list.push(current.frameId);
287
+ current = current.parentId === undefined ? undefined : input.stacks[current.parentId];
288
+ }
289
+ stacks[i] = list;
290
+ }
291
+
292
+ // Align timestamps to SDK time origin to match span/event timelines
293
+ const perfOrigin = browserPerformanceTimeOrigin();
294
+ const origin = typeof performance.timeOrigin === 'number' ? performance.timeOrigin : perfOrigin || 0;
295
+ const adjustForOriginChange = origin - (perfOrigin || origin);
296
+
297
+ const samples = [];
298
+ for (let i = 0; i < input.samples.length; i++) {
299
+ const sample = input.samples[i];
300
+ if (!sample) {
301
+ continue;
302
+ }
303
+ // Convert ms to seconds epoch-based timestamp
304
+ const timestampSeconds = (origin + (sample.timestamp - adjustForOriginChange)) / 1000;
305
+ samples[i] = {
306
+ stack_id: sample.stackId ?? 0,
307
+ thread_id: PROFILER_THREAD_ID_STRING,
308
+ timestamp: timestampSeconds,
309
+ };
310
+ }
311
+
312
+ return {
313
+ frames,
314
+ stacks,
315
+ samples,
316
+ thread_metadata: { [PROFILER_THREAD_ID_STRING]: { name: PROFILER_THREAD_NAME } },
317
+ };
318
+ }
319
+
320
+ /*
321
+ See packages/browser-utils/src/browser/router.ts
322
+ */
323
+ /**
324
+ *
325
+ */
326
+ function isAutomatedPageLoadSpan(span) {
327
+ return spanToJSON(span).op === 'pageload';
328
+ }
329
+
330
+ /**
331
+ * Converts a JSSelfProfile to a our sampled format.
332
+ * Does not currently perform stack indexing.
333
+ */
334
+ function convertJSSelfProfileToSampledFormat(input) {
335
+ let EMPTY_STACK_ID = undefined;
336
+ let STACK_ID = 0;
337
+
338
+ // Initialize the profile that we will fill with data
339
+ const profile = {
340
+ samples: [],
341
+ stacks: [],
342
+ frames: [],
343
+ thread_metadata: {
344
+ [PROFILER_THREAD_ID_STRING]: { name: PROFILER_THREAD_NAME },
345
+ },
346
+ };
347
+
348
+ const firstSample = input.samples[0];
349
+ if (!firstSample) {
350
+ return profile;
351
+ }
352
+
353
+ // We assert samples.length > 0 above and timestamp should always be present
354
+ const start = firstSample.timestamp;
355
+ // The JS SDK might change it's time origin based on some heuristic (see See packages/utils/src/time.ts)
356
+ // when that happens, we need to ensure we are correcting the profile timings so the two timelines stay in sync.
357
+ // Since JS self profiling time origin is always initialized to performance.timeOrigin, we need to adjust for
358
+ // the drift between the SDK selected value and our profile time origin.
359
+ const perfOrigin = browserPerformanceTimeOrigin();
360
+ const origin = typeof performance.timeOrigin === 'number' ? performance.timeOrigin : perfOrigin || 0;
361
+ const adjustForOriginChange = origin - (perfOrigin || origin);
362
+
363
+ input.samples.forEach((jsSample, i) => {
364
+ // If sample has no stack, add an empty sample
365
+ if (jsSample.stackId === undefined) {
366
+ if (EMPTY_STACK_ID === undefined) {
367
+ EMPTY_STACK_ID = STACK_ID;
368
+ profile.stacks[EMPTY_STACK_ID] = [];
369
+ STACK_ID++;
370
+ }
371
+
372
+ profile['samples'][i] = {
373
+ // convert ms timestamp to ns
374
+ elapsed_since_start_ns: ((jsSample.timestamp + adjustForOriginChange - start) * MS_TO_NS).toFixed(0),
375
+ stack_id: EMPTY_STACK_ID,
376
+ thread_id: PROFILER_THREAD_ID_STRING,
377
+ };
378
+ return;
379
+ }
380
+
381
+ let stackTop = input.stacks[jsSample.stackId];
382
+
383
+ // Functions in top->down order (root is last)
384
+ // We follow the stackTop.parentId trail and collect each visited frameId
385
+ const stack = [];
386
+
387
+ while (stackTop) {
388
+ stack.push(stackTop.frameId);
389
+
390
+ const frame = input.frames[stackTop.frameId];
391
+
392
+ // If our frame has not been indexed yet, index it
393
+ if (frame && profile.frames[stackTop.frameId] === undefined) {
394
+ profile.frames[stackTop.frameId] = {
395
+ function: frame.name,
396
+ abs_path: typeof frame.resourceId === 'number' ? input.resources[frame.resourceId] : undefined,
397
+ lineno: frame.line,
398
+ colno: frame.column,
399
+ };
400
+ }
401
+
402
+ stackTop = stackTop.parentId === undefined ? undefined : input.stacks[stackTop.parentId];
403
+ }
404
+
405
+ const sample = {
406
+ // convert ms timestamp to ns
407
+ elapsed_since_start_ns: ((jsSample.timestamp + adjustForOriginChange - start) * MS_TO_NS).toFixed(0),
408
+ stack_id: STACK_ID,
409
+ thread_id: PROFILER_THREAD_ID_STRING,
410
+ };
411
+
412
+ profile['stacks'][STACK_ID] = stack;
413
+ profile['samples'][i] = sample;
414
+ STACK_ID++;
415
+ });
416
+
417
+ return profile;
418
+ }
419
+
420
+ /**
421
+ * Adds items to envelope if they are not already present - mutates the envelope.
422
+ * @param envelope
423
+ */
424
+ function addProfilesToEnvelope(envelope, profiles) {
425
+ if (!profiles.length) {
426
+ return envelope;
427
+ }
428
+
429
+ for (const profile of profiles) {
430
+ envelope[1].push([{ type: 'profile' }, profile]);
431
+ }
432
+ return envelope;
433
+ }
434
+
435
+ /**
436
+ * Finds transactions with profile_id context in the envelope
437
+ * @param envelope
438
+ * @returns
439
+ */
440
+ function findProfiledTransactionsFromEnvelope(envelope) {
441
+ const events = [];
442
+
443
+ forEachEnvelopeItem(envelope, (item, type) => {
444
+ if (type !== 'transaction') {
445
+ return;
446
+ }
447
+
448
+ for (let j = 1; j < item.length; j++) {
449
+ const event = item[j] ;
450
+
451
+ if (event?.contexts?.profile?.profile_id) {
452
+ events.push(item[j] );
453
+ }
454
+ }
455
+ });
456
+
457
+ return events;
458
+ }
459
+
460
+ /**
461
+ * Applies debug meta data to an event from a list of paths to resources (sourcemaps)
462
+ */
463
+ function applyDebugMetadata(resource_paths) {
464
+ const client = getClient();
465
+ const options = client?.getOptions();
466
+ const stackParser = options?.stackParser;
467
+
468
+ if (!stackParser) {
469
+ return [];
470
+ }
471
+
472
+ return getDebugImagesForResources(stackParser, resource_paths);
473
+ }
474
+
475
+ /**
476
+ * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).
477
+ */
478
+ function isValidSampleRate(rate) {
479
+ // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck
480
+ if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) {
481
+ DEBUG_BUILD &&
482
+ debug.warn(
483
+ `[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(
484
+ rate,
485
+ )} of type ${JSON.stringify(typeof rate)}.`,
486
+ );
487
+ return false;
488
+ }
489
+
490
+ // Boolean sample rates are always valid
491
+ if (rate === true || rate === false) {
492
+ return true;
493
+ }
494
+
495
+ // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false
496
+ if (rate < 0 || rate > 1) {
497
+ DEBUG_BUILD && debug.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${rate}.`);
498
+ return false;
499
+ }
500
+ return true;
501
+ }
502
+
503
+ function isValidProfile(profile) {
504
+ if (profile.samples.length < 2) {
505
+ if (DEBUG_BUILD) {
506
+ // Log a warning if the profile has less than 2 samples so users can know why
507
+ // they are not seeing any profiling data and we cant avoid the back and forth
508
+ // of asking them to provide us with a dump of the profile data.
509
+ debug.log('[Profiling] Discarding profile because it contains less than 2 samples');
510
+ }
511
+ return false;
512
+ }
513
+
514
+ if (!profile.frames.length) {
515
+ if (DEBUG_BUILD) {
516
+ debug.log('[Profiling] Discarding profile because it contains no frames');
517
+ }
518
+ return false;
519
+ }
520
+
521
+ return true;
522
+ }
523
+
524
+ // Keep a flag value to avoid re-initializing the profiler constructor. If it fails
525
+ // once, it will always fail and this allows us to early return.
526
+ let PROFILING_CONSTRUCTOR_FAILED = false;
527
+ const MAX_PROFILE_DURATION_MS = 30000;
528
+
529
+ /**
530
+ * Check if profiler constructor is available.
531
+ * @param maybeProfiler
532
+ */
533
+ function isJSProfilerSupported(maybeProfiler) {
534
+ return typeof maybeProfiler === 'function';
535
+ }
536
+
537
+ /**
538
+ * Starts the profiler and returns the profiler instance.
539
+ */
540
+ function startJSSelfProfile() {
541
+ // Feature support check first
542
+ const JSProfilerConstructor = WINDOW.Profiler;
543
+
544
+ if (!isJSProfilerSupported(JSProfilerConstructor)) {
545
+ if (DEBUG_BUILD) {
546
+ debug.log('[Profiling] Profiling is not supported by this browser, Profiler interface missing on window object.');
547
+ }
548
+ return;
549
+ }
550
+
551
+ // From initial testing, it seems that the minimum value for sampleInterval is 10ms.
552
+ const samplingIntervalMS = 10;
553
+ // Start the profiler
554
+ const maxSamples = Math.floor(MAX_PROFILE_DURATION_MS / samplingIntervalMS);
555
+
556
+ // Attempt to initialize the profiler constructor, if it fails, we disable profiling for the current user session.
557
+ // This is likely due to a missing 'Document-Policy': 'js-profiling' header. We do not want to throw an error if this happens
558
+ // as we risk breaking the user's application, so just disable profiling and log an error.
559
+ try {
560
+ return new JSProfilerConstructor({ sampleInterval: samplingIntervalMS, maxBufferSize: maxSamples });
561
+ } catch (e) {
562
+ if (DEBUG_BUILD) {
563
+ debug.log(
564
+ "[Profiling] Failed to initialize the Profiling constructor, this is likely due to a missing 'Document-Policy': 'js-profiling' header.",
565
+ );
566
+ debug.log('[Profiling] Disabling profiling for current user session.');
567
+ }
568
+ PROFILING_CONSTRUCTOR_FAILED = true;
569
+ }
570
+
571
+ return;
572
+ }
573
+
574
+ /**
575
+ * Determine if a profile should be profiled.
576
+ */
577
+ function shouldProfileSpanLegacy(span) {
578
+ // If constructor failed once, it will always fail, so we can early return.
579
+ if (PROFILING_CONSTRUCTOR_FAILED) {
580
+ if (DEBUG_BUILD) {
581
+ debug.log('[Profiling] Profiling has been disabled for the duration of the current user session.');
582
+ }
583
+ return false;
584
+ }
585
+
586
+ if (!span.isRecording()) {
587
+ DEBUG_BUILD && debug.log('[Profiling] Discarding profile because root span was not sampled.');
588
+ return false;
589
+ }
590
+
591
+ const client = getClient();
592
+ const options = client?.getOptions();
593
+ if (!options) {
594
+ DEBUG_BUILD && debug.log('[Profiling] Profiling disabled, no options found.');
595
+ return false;
596
+ }
597
+
598
+ // @ts-expect-error profilesSampleRate is not part of the browser options yet
599
+ const profilesSampleRate = options.profilesSampleRate;
600
+
601
+ // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
602
+ // only valid values are booleans or numbers between 0 and 1.)
603
+ if (!isValidSampleRate(profilesSampleRate)) {
604
+ DEBUG_BUILD && debug.warn('[Profiling] Discarding profile because of invalid sample rate.');
605
+ return false;
606
+ }
607
+
608
+ // if the function returned 0 (or false), or if `profileSampleRate` is 0, it's a sign the profile should be dropped
609
+ if (!profilesSampleRate) {
610
+ DEBUG_BUILD &&
611
+ debug.log(
612
+ '[Profiling] Discarding profile because a negative sampling decision was inherited or profileSampleRate is set to 0',
613
+ );
614
+ return false;
615
+ }
616
+
617
+ // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is
618
+ // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.
619
+ const sampled = profilesSampleRate === true ? true : Math.random() < profilesSampleRate;
620
+ // Check if we should sample this profile
621
+ if (!sampled) {
622
+ DEBUG_BUILD &&
623
+ debug.log(
624
+ `[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(
625
+ profilesSampleRate,
626
+ )})`,
627
+ );
628
+ return false;
629
+ }
630
+
631
+ return true;
632
+ }
633
+
634
+ /**
635
+ * Determine if a profile should be created for the current session (lifecycle profiling mode).
636
+ */
637
+ function shouldProfileSession(options) {
638
+ // If constructor failed once, it will always fail, so we can early return.
639
+ if (PROFILING_CONSTRUCTOR_FAILED) {
640
+ if (DEBUG_BUILD) {
641
+ debug.log('[Profiling] Profiling has been disabled for the duration of the current user session.');
642
+ }
643
+ return false;
644
+ }
645
+
646
+ if (options.profileLifecycle !== 'trace') {
647
+ return false;
648
+ }
649
+
650
+ // Session sampling: profileSessionSampleRate gates whether profiling is enabled for this session
651
+ const profileSessionSampleRate = options.profileSessionSampleRate;
652
+
653
+ if (!isValidSampleRate(profileSessionSampleRate)) {
654
+ DEBUG_BUILD && debug.warn('[Profiling] Discarding profile because of invalid profileSessionSampleRate.');
655
+ return false;
656
+ }
657
+
658
+ if (!profileSessionSampleRate) {
659
+ DEBUG_BUILD &&
660
+ debug.log('[Profiling] Discarding profile because profileSessionSampleRate is not defined or set to 0');
661
+ return false;
662
+ }
663
+
664
+ return Math.random() <= profileSessionSampleRate;
665
+ }
666
+
667
+ /**
668
+ * Checks if legacy profiling is configured.
669
+ */
670
+ function hasLegacyProfiling(options) {
671
+ return typeof options.profilesSampleRate !== 'undefined';
672
+ }
673
+
674
+ /**
675
+ * Creates a profiling envelope item, if the profile does not pass validation, returns null.
676
+ * @param event
677
+ * @returns {Profile | null}
678
+ */
679
+ function createProfilingEvent(
680
+ profile_id,
681
+ start_timestamp,
682
+ profile,
683
+ event,
684
+ ) {
685
+ if (!isValidProfile(profile)) {
686
+ return null;
687
+ }
688
+
689
+ return createProfilePayload(profile_id, start_timestamp, profile, event);
690
+ }
691
+
692
+ // TODO (v8): We need to obtain profile ids in @sentry-internal/tracing,
693
+ // but we don't have access to this map because importing this map would
694
+ // cause a circular dependency. We need to resolve this in v8.
695
+ const PROFILE_MAP = new Map();
696
+ /**
697
+ *
698
+ */
699
+ function getActiveProfilesCount() {
700
+ return PROFILE_MAP.size;
701
+ }
702
+
703
+ /**
704
+ * Retrieves profile from global cache and removes it.
705
+ */
706
+ function takeProfileFromGlobalCache(profile_id) {
707
+ const profile = PROFILE_MAP.get(profile_id);
708
+ if (profile) {
709
+ PROFILE_MAP.delete(profile_id);
710
+ }
711
+ return profile;
712
+ }
713
+ /**
714
+ * Adds profile to global cache and evicts the oldest profile if the cache is full.
715
+ */
716
+ function addProfileToGlobalCache(profile_id, profile) {
717
+ PROFILE_MAP.set(profile_id, profile);
718
+
719
+ if (PROFILE_MAP.size > 30) {
720
+ const last = PROFILE_MAP.keys().next().value;
721
+ if (last !== undefined) {
722
+ PROFILE_MAP.delete(last);
723
+ }
724
+ }
725
+ }
726
+
727
+ /**
728
+ * Attaches the profiled thread information to the event's trace context.
729
+ */
730
+ function attachProfiledThreadToEvent(event) {
731
+ if (!event?.contexts?.profile) {
732
+ return event;
733
+ }
734
+
735
+ if (!event.contexts) {
736
+ return event;
737
+ }
738
+
739
+ // @ts-expect-error the trace fallback value is wrong, though it should never happen
740
+ // and in case it does, we dont want to override whatever was passed initially.
741
+ event.contexts.trace = {
742
+ ...(event.contexts?.trace ?? {}),
743
+ data: {
744
+ ...(event.contexts?.trace?.data ?? {}),
745
+ ['thread.id']: PROFILER_THREAD_ID_STRING,
746
+ ['thread.name']: PROFILER_THREAD_NAME,
747
+ },
748
+ };
749
+
750
+ // Attach thread info to individual spans so that spans can be associated with the profiled thread on the UI even if contexts are missing.
751
+ event.spans?.forEach(span => {
752
+ span.data = {
753
+ ...(span.data || {}),
754
+ ['thread.id']: PROFILER_THREAD_ID_STRING,
755
+ ['thread.name']: PROFILER_THREAD_NAME,
756
+ };
757
+ });
758
+
759
+ return event;
760
+ }
761
+
762
+ export { MAX_PROFILE_DURATION_MS, PROFILER_THREAD_ID_STRING, PROFILER_THREAD_NAME, addProfileToGlobalCache, addProfilesToEnvelope, applyDebugMetadata, attachProfiledThreadToEvent, convertJSSelfProfileToSampledFormat, createProfileChunkPayload, createProfilePayload, createProfilingEvent, enrichWithThreadInformation, findProfiledTransactionsFromEnvelope, getActiveProfilesCount, hasLegacyProfiling, isAutomatedPageLoadSpan, isValidSampleRate, shouldProfileSession, shouldProfileSpanLegacy, startJSSelfProfile, takeProfileFromGlobalCache, validateProfileChunk };
763
+ //# sourceMappingURL=utils.js.map