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