@sentry/browser 10.24.0 → 10.26.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 (450) hide show
  1. package/build/npm/cjs/dev/client.js.map +1 -0
  2. package/build/npm/cjs/dev/debug-build.js.map +1 -0
  3. package/build/npm/cjs/dev/diagnose-sdk.js.map +1 -0
  4. package/build/npm/cjs/dev/eventbuilder.js.map +1 -0
  5. package/build/npm/cjs/dev/feedbackAsync.js.map +1 -0
  6. package/build/npm/cjs/dev/feedbackSync.js.map +1 -0
  7. package/build/npm/cjs/dev/helpers.js.map +1 -0
  8. package/build/npm/cjs/dev/integrations/breadcrumbs.js.map +1 -0
  9. package/build/npm/cjs/dev/integrations/browserapierrors.js.map +1 -0
  10. package/build/npm/cjs/dev/integrations/browsersession.js.map +1 -0
  11. package/build/npm/cjs/dev/integrations/contextlines.js.map +1 -0
  12. package/build/npm/cjs/dev/integrations/featureFlags/growthbook/integration.js.map +1 -0
  13. package/build/npm/cjs/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
  14. package/build/npm/cjs/dev/integrations/featureFlags/openfeature/integration.js.map +1 -0
  15. package/build/npm/cjs/dev/integrations/featureFlags/statsig/integration.js.map +1 -0
  16. package/build/npm/cjs/dev/integrations/featureFlags/unleash/integration.js.map +1 -0
  17. package/build/npm/cjs/{integrations → dev/integrations}/globalhandlers.js +1 -1
  18. package/build/npm/cjs/dev/integrations/globalhandlers.js.map +1 -0
  19. package/build/npm/cjs/dev/integrations/graphqlClient.js.map +1 -0
  20. package/build/npm/cjs/dev/integrations/httpclient.js.map +1 -0
  21. package/build/npm/cjs/dev/integrations/httpcontext.js.map +1 -0
  22. package/build/npm/cjs/dev/integrations/linkederrors.js.map +1 -0
  23. package/build/npm/cjs/dev/integrations/reportingobserver.js.map +1 -0
  24. package/build/npm/cjs/dev/integrations/spotlight.js.map +1 -0
  25. package/build/npm/cjs/dev/integrations/webWorker.js.map +1 -0
  26. package/build/npm/cjs/{profiling/lifecycleMode/traceLifecycleProfiler.js → dev/profiling/UIProfiler.js} +73 -75
  27. package/build/npm/cjs/dev/profiling/UIProfiler.js.map +1 -0
  28. package/build/npm/cjs/{profiling → dev/profiling}/integration.js +5 -5
  29. package/build/npm/cjs/dev/profiling/integration.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/dev/transports/fetch.js.map +1 -0
  45. package/build/npm/cjs/dev/transports/offline.js.map +1 -0
  46. package/build/npm/cjs/dev/userfeedback.js.map +1 -0
  47. package/build/npm/cjs/dev/utils/detectBrowserExtension.js.map +1 -0
  48. package/build/npm/cjs/dev/utils/lazyLoadIntegration.js.map +1 -0
  49. package/build/npm/cjs/prod/client.js +125 -0
  50. package/build/npm/cjs/prod/client.js.map +1 -0
  51. package/build/npm/cjs/prod/debug-build.js +11 -0
  52. package/build/npm/cjs/prod/debug-build.js.map +1 -0
  53. package/build/npm/cjs/prod/diagnose-sdk.js +51 -0
  54. package/build/npm/cjs/prod/diagnose-sdk.js.map +1 -0
  55. package/build/npm/cjs/prod/eventbuilder.js +397 -0
  56. package/build/npm/cjs/prod/eventbuilder.js.map +1 -0
  57. package/build/npm/cjs/prod/feedbackAsync.js +15 -0
  58. package/build/npm/cjs/prod/feedbackAsync.js.map +1 -0
  59. package/build/npm/cjs/prod/feedbackSync.js +12 -0
  60. package/build/npm/cjs/prod/feedbackSync.js.map +1 -0
  61. package/build/npm/cjs/prod/helpers.js +185 -0
  62. package/build/npm/cjs/prod/helpers.js.map +1 -0
  63. package/build/npm/cjs/prod/index.js +179 -0
  64. package/build/npm/cjs/prod/index.js.map +1 -0
  65. package/build/npm/cjs/prod/integrations/breadcrumbs.js +341 -0
  66. package/build/npm/cjs/prod/integrations/breadcrumbs.js.map +1 -0
  67. package/build/npm/cjs/prod/integrations/browserapierrors.js +259 -0
  68. package/build/npm/cjs/prod/integrations/browserapierrors.js.map +1 -0
  69. package/build/npm/cjs/prod/integrations/browsersession.js +44 -0
  70. package/build/npm/cjs/prod/integrations/browsersession.js.map +1 -0
  71. package/build/npm/cjs/prod/integrations/contextlines.js +89 -0
  72. package/build/npm/cjs/prod/integrations/contextlines.js.map +1 -0
  73. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js +29 -0
  74. package/build/npm/cjs/prod/integrations/featureFlags/growthbook/integration.js.map +1 -0
  75. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js +55 -0
  76. package/build/npm/cjs/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
  77. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js +38 -0
  78. package/build/npm/cjs/prod/integrations/featureFlags/openfeature/integration.js.map +1 -0
  79. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js +48 -0
  80. package/build/npm/cjs/prod/integrations/featureFlags/statsig/integration.js.map +1 -0
  81. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js +74 -0
  82. package/build/npm/cjs/prod/integrations/featureFlags/unleash/integration.js.map +1 -0
  83. package/build/npm/cjs/prod/integrations/globalhandlers.js +210 -0
  84. package/build/npm/cjs/prod/integrations/globalhandlers.js.map +1 -0
  85. package/build/npm/cjs/prod/integrations/graphqlClient.js +180 -0
  86. package/build/npm/cjs/prod/integrations/graphqlClient.js.map +1 -0
  87. package/build/npm/cjs/prod/integrations/httpclient.js +395 -0
  88. package/build/npm/cjs/prod/integrations/httpclient.js.map +1 -0
  89. package/build/npm/cjs/prod/integrations/httpcontext.js +35 -0
  90. package/build/npm/cjs/prod/integrations/httpcontext.js.map +1 -0
  91. package/build/npm/cjs/prod/integrations/linkederrors.js +39 -0
  92. package/build/npm/cjs/prod/integrations/linkederrors.js.map +1 -0
  93. package/build/npm/cjs/prod/integrations/reportingobserver.js +85 -0
  94. package/build/npm/cjs/prod/integrations/reportingobserver.js.map +1 -0
  95. package/build/npm/cjs/prod/integrations/spotlight.js +85 -0
  96. package/build/npm/cjs/prod/integrations/spotlight.js.map +1 -0
  97. package/build/npm/cjs/prod/integrations/webWorker.js +251 -0
  98. package/build/npm/cjs/prod/integrations/webWorker.js.map +1 -0
  99. package/build/npm/cjs/prod/profiling/UIProfiler.js +341 -0
  100. package/build/npm/cjs/prod/profiling/UIProfiler.js.map +1 -0
  101. package/build/npm/cjs/prod/profiling/integration.js +150 -0
  102. package/build/npm/cjs/prod/profiling/integration.js.map +1 -0
  103. package/build/npm/cjs/prod/profiling/startProfileForSpan.js +144 -0
  104. package/build/npm/cjs/prod/profiling/startProfileForSpan.js.map +1 -0
  105. package/build/npm/cjs/prod/profiling/utils.js +786 -0
  106. package/build/npm/cjs/prod/profiling/utils.js.map +1 -0
  107. package/build/npm/cjs/prod/report-dialog.js +68 -0
  108. package/build/npm/cjs/prod/report-dialog.js.map +1 -0
  109. package/build/npm/cjs/{sdk.js → prod/sdk.js} +5 -2
  110. package/build/npm/cjs/prod/sdk.js.map +1 -0
  111. package/build/npm/cjs/prod/stack-parsers.js +202 -0
  112. package/build/npm/cjs/prod/stack-parsers.js.map +1 -0
  113. package/build/npm/cjs/prod/tracing/backgroundtab.js +46 -0
  114. package/build/npm/cjs/prod/tracing/backgroundtab.js.map +1 -0
  115. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js +577 -0
  116. package/build/npm/cjs/prod/tracing/browserTracingIntegration.js.map +1 -0
  117. package/build/npm/cjs/prod/tracing/linkedTraces.js +227 -0
  118. package/build/npm/cjs/prod/tracing/linkedTraces.js.map +1 -0
  119. package/build/npm/cjs/prod/tracing/reportPageLoaded.js +18 -0
  120. package/build/npm/cjs/prod/tracing/reportPageLoaded.js.map +1 -0
  121. package/build/npm/cjs/prod/tracing/request.js +342 -0
  122. package/build/npm/cjs/prod/tracing/request.js.map +1 -0
  123. package/build/npm/cjs/prod/tracing/setActiveSpan.js +68 -0
  124. package/build/npm/cjs/prod/tracing/setActiveSpan.js.map +1 -0
  125. package/build/npm/cjs/prod/tracing/utils.js +54 -0
  126. package/build/npm/cjs/prod/tracing/utils.js.map +1 -0
  127. package/build/npm/cjs/prod/transports/fetch.js +71 -0
  128. package/build/npm/cjs/prod/transports/fetch.js.map +1 -0
  129. package/build/npm/cjs/prod/transports/offline.js +168 -0
  130. package/build/npm/cjs/prod/transports/offline.js.map +1 -0
  131. package/build/npm/cjs/prod/userfeedback.js +42 -0
  132. package/build/npm/cjs/prod/userfeedback.js.map +1 -0
  133. package/build/npm/cjs/prod/utils/detectBrowserExtension.js +59 -0
  134. package/build/npm/cjs/prod/utils/detectBrowserExtension.js.map +1 -0
  135. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js +106 -0
  136. package/build/npm/cjs/prod/utils/lazyLoadIntegration.js.map +1 -0
  137. package/build/npm/esm/dev/client.js.map +1 -0
  138. package/build/npm/esm/dev/debug-build.js.map +1 -0
  139. package/build/npm/esm/dev/diagnose-sdk.js.map +1 -0
  140. package/build/npm/esm/dev/eventbuilder.js.map +1 -0
  141. package/build/npm/esm/dev/feedbackAsync.js.map +1 -0
  142. package/build/npm/esm/dev/feedbackSync.js.map +1 -0
  143. package/build/npm/esm/dev/helpers.js.map +1 -0
  144. package/build/npm/esm/dev/integrations/breadcrumbs.js.map +1 -0
  145. package/build/npm/esm/dev/integrations/browserapierrors.js.map +1 -0
  146. package/build/npm/esm/dev/integrations/browsersession.js.map +1 -0
  147. package/build/npm/esm/dev/integrations/contextlines.js.map +1 -0
  148. package/build/npm/esm/dev/integrations/featureFlags/growthbook/integration.js.map +1 -0
  149. package/build/npm/esm/dev/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
  150. package/build/npm/esm/dev/integrations/featureFlags/openfeature/integration.js.map +1 -0
  151. package/build/npm/esm/dev/integrations/featureFlags/statsig/integration.js.map +1 -0
  152. package/build/npm/esm/dev/integrations/featureFlags/unleash/integration.js.map +1 -0
  153. package/build/npm/esm/{integrations → dev/integrations}/globalhandlers.js +1 -1
  154. package/build/npm/esm/dev/integrations/globalhandlers.js.map +1 -0
  155. package/build/npm/esm/dev/integrations/graphqlClient.js.map +1 -0
  156. package/build/npm/esm/dev/integrations/httpclient.js.map +1 -0
  157. package/build/npm/esm/dev/integrations/httpcontext.js.map +1 -0
  158. package/build/npm/esm/dev/integrations/linkederrors.js.map +1 -0
  159. package/build/npm/esm/dev/integrations/reportingobserver.js.map +1 -0
  160. package/build/npm/esm/dev/integrations/spotlight.js.map +1 -0
  161. package/build/npm/esm/dev/integrations/webWorker.js.map +1 -0
  162. package/build/npm/esm/dev/package.json +1 -0
  163. package/build/npm/esm/{profiling/lifecycleMode/traceLifecycleProfiler.js → dev/profiling/UIProfiler.js} +74 -76
  164. package/build/npm/esm/dev/profiling/UIProfiler.js.map +1 -0
  165. package/build/npm/esm/{profiling → dev/profiling}/integration.js +2 -2
  166. package/build/npm/esm/dev/profiling/integration.js.map +1 -0
  167. package/build/npm/esm/dev/profiling/startProfileForSpan.js.map +1 -0
  168. package/build/npm/esm/dev/profiling/utils.js.map +1 -0
  169. package/build/npm/esm/dev/report-dialog.js.map +1 -0
  170. package/build/npm/esm/dev/sdk.js +128 -0
  171. package/build/npm/esm/dev/sdk.js.map +1 -0
  172. package/build/npm/esm/dev/stack-parsers.js.map +1 -0
  173. package/build/npm/esm/dev/tracing/backgroundtab.js.map +1 -0
  174. package/build/npm/esm/dev/tracing/browserTracingIntegration.js.map +1 -0
  175. package/build/npm/esm/{tracing → dev/tracing}/linkedTraces.js +1 -0
  176. package/build/npm/esm/dev/tracing/linkedTraces.js.map +1 -0
  177. package/build/npm/esm/dev/tracing/reportPageLoaded.js.map +1 -0
  178. package/build/npm/esm/dev/tracing/request.js.map +1 -0
  179. package/build/npm/esm/dev/tracing/setActiveSpan.js.map +1 -0
  180. package/build/npm/esm/dev/tracing/utils.js.map +1 -0
  181. package/build/npm/esm/dev/transports/fetch.js.map +1 -0
  182. package/build/npm/esm/dev/transports/offline.js.map +1 -0
  183. package/build/npm/esm/dev/userfeedback.js.map +1 -0
  184. package/build/npm/esm/dev/utils/detectBrowserExtension.js.map +1 -0
  185. package/build/npm/esm/dev/utils/lazyLoadIntegration.js.map +1 -0
  186. package/build/npm/esm/prod/client.js +122 -0
  187. package/build/npm/esm/prod/client.js.map +1 -0
  188. package/build/npm/esm/prod/debug-build.js +9 -0
  189. package/build/npm/esm/prod/debug-build.js.map +1 -0
  190. package/build/npm/esm/prod/diagnose-sdk.js +49 -0
  191. package/build/npm/esm/prod/diagnose-sdk.js.map +1 -0
  192. package/build/npm/esm/prod/eventbuilder.js +390 -0
  193. package/build/npm/esm/prod/eventbuilder.js.map +1 -0
  194. package/build/npm/esm/prod/feedbackAsync.js +13 -0
  195. package/build/npm/esm/prod/feedbackAsync.js.map +1 -0
  196. package/build/npm/esm/prod/feedbackSync.js +10 -0
  197. package/build/npm/esm/prod/feedbackSync.js.map +1 -0
  198. package/build/npm/esm/prod/helpers.js +179 -0
  199. package/build/npm/esm/prod/helpers.js.map +1 -0
  200. package/build/npm/esm/prod/index.js +40 -0
  201. package/build/npm/esm/prod/index.js.map +1 -0
  202. package/build/npm/esm/prod/integrations/breadcrumbs.js +339 -0
  203. package/build/npm/esm/prod/integrations/breadcrumbs.js.map +1 -0
  204. package/build/npm/esm/prod/integrations/browserapierrors.js +257 -0
  205. package/build/npm/esm/prod/integrations/browserapierrors.js.map +1 -0
  206. package/build/npm/esm/prod/integrations/browsersession.js +42 -0
  207. package/build/npm/esm/prod/integrations/browsersession.js.map +1 -0
  208. package/build/npm/esm/prod/integrations/contextlines.js +86 -0
  209. package/build/npm/esm/prod/integrations/contextlines.js.map +1 -0
  210. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js +27 -0
  211. package/build/npm/esm/prod/integrations/featureFlags/growthbook/integration.js.map +1 -0
  212. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js +52 -0
  213. package/build/npm/esm/prod/integrations/featureFlags/launchdarkly/integration.js.map +1 -0
  214. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js +35 -0
  215. package/build/npm/esm/prod/integrations/featureFlags/openfeature/integration.js.map +1 -0
  216. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js +46 -0
  217. package/build/npm/esm/prod/integrations/featureFlags/statsig/integration.js.map +1 -0
  218. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js +72 -0
  219. package/build/npm/esm/prod/integrations/featureFlags/unleash/integration.js.map +1 -0
  220. package/build/npm/esm/prod/integrations/globalhandlers.js +206 -0
  221. package/build/npm/esm/prod/integrations/globalhandlers.js.map +1 -0
  222. package/build/npm/esm/prod/integrations/graphqlClient.js +175 -0
  223. package/build/npm/esm/prod/integrations/graphqlClient.js.map +1 -0
  224. package/build/npm/esm/prod/integrations/httpclient.js +393 -0
  225. package/build/npm/esm/prod/integrations/httpclient.js.map +1 -0
  226. package/build/npm/esm/prod/integrations/httpcontext.js +33 -0
  227. package/build/npm/esm/prod/integrations/httpcontext.js.map +1 -0
  228. package/build/npm/esm/prod/integrations/linkederrors.js +37 -0
  229. package/build/npm/esm/prod/integrations/linkederrors.js.map +1 -0
  230. package/build/npm/esm/prod/integrations/reportingobserver.js +83 -0
  231. package/build/npm/esm/prod/integrations/reportingobserver.js.map +1 -0
  232. package/build/npm/esm/prod/integrations/spotlight.js +81 -0
  233. package/build/npm/esm/prod/integrations/spotlight.js.map +1 -0
  234. package/build/npm/esm/prod/integrations/webWorker.js +247 -0
  235. package/build/npm/esm/prod/integrations/webWorker.js.map +1 -0
  236. package/build/npm/esm/prod/package.json +1 -0
  237. package/build/npm/esm/prod/profiling/UIProfiler.js +339 -0
  238. package/build/npm/esm/prod/profiling/UIProfiler.js.map +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/startProfileForSpan.js +142 -0
  242. package/build/npm/esm/prod/profiling/startProfileForSpan.js.map +1 -0
  243. package/build/npm/esm/prod/profiling/utils.js +763 -0
  244. package/build/npm/esm/prod/profiling/utils.js.map +1 -0
  245. package/build/npm/esm/prod/report-dialog.js +66 -0
  246. package/build/npm/esm/prod/report-dialog.js.map +1 -0
  247. package/build/npm/esm/{sdk.js → prod/sdk.js} +5 -2
  248. package/build/npm/esm/prod/sdk.js.map +1 -0
  249. package/build/npm/esm/prod/stack-parsers.js +194 -0
  250. package/build/npm/esm/prod/stack-parsers.js.map +1 -0
  251. package/build/npm/esm/prod/tracing/backgroundtab.js +44 -0
  252. package/build/npm/esm/prod/tracing/backgroundtab.js.map +1 -0
  253. package/build/npm/esm/prod/tracing/browserTracingIntegration.js +571 -0
  254. package/build/npm/esm/prod/tracing/browserTracingIntegration.js.map +1 -0
  255. package/build/npm/esm/prod/tracing/linkedTraces.js +218 -0
  256. package/build/npm/esm/prod/tracing/linkedTraces.js.map +1 -0
  257. package/build/npm/esm/prod/tracing/reportPageLoaded.js +16 -0
  258. package/build/npm/esm/prod/tracing/reportPageLoaded.js.map +1 -0
  259. package/build/npm/esm/prod/tracing/request.js +338 -0
  260. package/build/npm/esm/prod/tracing/request.js.map +1 -0
  261. package/build/npm/esm/prod/tracing/setActiveSpan.js +66 -0
  262. package/build/npm/esm/prod/tracing/setActiveSpan.js.map +1 -0
  263. package/build/npm/esm/prod/tracing/utils.js +49 -0
  264. package/build/npm/esm/prod/tracing/utils.js.map +1 -0
  265. package/build/npm/esm/prod/transports/fetch.js +69 -0
  266. package/build/npm/esm/prod/transports/fetch.js.map +1 -0
  267. package/build/npm/esm/prod/transports/offline.js +162 -0
  268. package/build/npm/esm/prod/transports/offline.js.map +1 -0
  269. package/build/npm/esm/prod/userfeedback.js +40 -0
  270. package/build/npm/esm/prod/userfeedback.js.map +1 -0
  271. package/build/npm/esm/prod/utils/detectBrowserExtension.js +57 -0
  272. package/build/npm/esm/prod/utils/detectBrowserExtension.js.map +1 -0
  273. package/build/npm/esm/prod/utils/lazyLoadIntegration.js +104 -0
  274. package/build/npm/esm/prod/utils/lazyLoadIntegration.js.map +1 -0
  275. package/build/npm/types/client.d.ts +11 -0
  276. package/build/npm/types/client.d.ts.map +1 -1
  277. package/build/npm/types/profiling/{lifecycleMode/traceLifecycleProfiler.d.ts → UIProfiler.d.ts} +6 -2
  278. package/build/npm/types/profiling/UIProfiler.d.ts.map +1 -0
  279. package/build/npm/types/sdk.d.ts.map +1 -1
  280. package/build/npm/types-ts3.8/client.d.ts +11 -0
  281. package/build/npm/types-ts3.8/profiling/{lifecycleMode/traceLifecycleProfiler.d.ts → UIProfiler.d.ts} +6 -2
  282. package/package.json +21 -16
  283. package/build/npm/cjs/client.js.map +0 -1
  284. package/build/npm/cjs/debug-build.js.map +0 -1
  285. package/build/npm/cjs/diagnose-sdk.js.map +0 -1
  286. package/build/npm/cjs/eventbuilder.js.map +0 -1
  287. package/build/npm/cjs/feedbackAsync.js.map +0 -1
  288. package/build/npm/cjs/feedbackSync.js.map +0 -1
  289. package/build/npm/cjs/helpers.js.map +0 -1
  290. package/build/npm/cjs/integrations/breadcrumbs.js.map +0 -1
  291. package/build/npm/cjs/integrations/browserapierrors.js.map +0 -1
  292. package/build/npm/cjs/integrations/browsersession.js.map +0 -1
  293. package/build/npm/cjs/integrations/contextlines.js.map +0 -1
  294. package/build/npm/cjs/integrations/featureFlags/growthbook/integration.js.map +0 -1
  295. package/build/npm/cjs/integrations/featureFlags/launchdarkly/integration.js.map +0 -1
  296. package/build/npm/cjs/integrations/featureFlags/openfeature/integration.js.map +0 -1
  297. package/build/npm/cjs/integrations/featureFlags/statsig/integration.js.map +0 -1
  298. package/build/npm/cjs/integrations/featureFlags/unleash/integration.js.map +0 -1
  299. package/build/npm/cjs/integrations/globalhandlers.js.map +0 -1
  300. package/build/npm/cjs/integrations/graphqlClient.js.map +0 -1
  301. package/build/npm/cjs/integrations/httpclient.js.map +0 -1
  302. package/build/npm/cjs/integrations/httpcontext.js.map +0 -1
  303. package/build/npm/cjs/integrations/linkederrors.js.map +0 -1
  304. package/build/npm/cjs/integrations/reportingobserver.js.map +0 -1
  305. package/build/npm/cjs/integrations/spotlight.js.map +0 -1
  306. package/build/npm/cjs/integrations/webWorker.js.map +0 -1
  307. package/build/npm/cjs/profiling/integration.js.map +0 -1
  308. package/build/npm/cjs/profiling/lifecycleMode/traceLifecycleProfiler.js.map +0 -1
  309. package/build/npm/cjs/profiling/startProfileForSpan.js.map +0 -1
  310. package/build/npm/cjs/profiling/utils.js.map +0 -1
  311. package/build/npm/cjs/report-dialog.js.map +0 -1
  312. package/build/npm/cjs/sdk.js.map +0 -1
  313. package/build/npm/cjs/stack-parsers.js.map +0 -1
  314. package/build/npm/cjs/tracing/backgroundtab.js.map +0 -1
  315. package/build/npm/cjs/tracing/browserTracingIntegration.js.map +0 -1
  316. package/build/npm/cjs/tracing/linkedTraces.js.map +0 -1
  317. package/build/npm/cjs/tracing/reportPageLoaded.js.map +0 -1
  318. package/build/npm/cjs/tracing/request.js.map +0 -1
  319. package/build/npm/cjs/tracing/setActiveSpan.js.map +0 -1
  320. package/build/npm/cjs/tracing/utils.js.map +0 -1
  321. package/build/npm/cjs/transports/fetch.js.map +0 -1
  322. package/build/npm/cjs/transports/offline.js.map +0 -1
  323. package/build/npm/cjs/userfeedback.js.map +0 -1
  324. package/build/npm/cjs/utils/detectBrowserExtension.js.map +0 -1
  325. package/build/npm/cjs/utils/lazyLoadIntegration.js.map +0 -1
  326. package/build/npm/esm/client.js.map +0 -1
  327. package/build/npm/esm/debug-build.js.map +0 -1
  328. package/build/npm/esm/diagnose-sdk.js.map +0 -1
  329. package/build/npm/esm/eventbuilder.js.map +0 -1
  330. package/build/npm/esm/feedbackAsync.js.map +0 -1
  331. package/build/npm/esm/feedbackSync.js.map +0 -1
  332. package/build/npm/esm/helpers.js.map +0 -1
  333. package/build/npm/esm/integrations/breadcrumbs.js.map +0 -1
  334. package/build/npm/esm/integrations/browserapierrors.js.map +0 -1
  335. package/build/npm/esm/integrations/browsersession.js.map +0 -1
  336. package/build/npm/esm/integrations/contextlines.js.map +0 -1
  337. package/build/npm/esm/integrations/featureFlags/growthbook/integration.js.map +0 -1
  338. package/build/npm/esm/integrations/featureFlags/launchdarkly/integration.js.map +0 -1
  339. package/build/npm/esm/integrations/featureFlags/openfeature/integration.js.map +0 -1
  340. package/build/npm/esm/integrations/featureFlags/statsig/integration.js.map +0 -1
  341. package/build/npm/esm/integrations/featureFlags/unleash/integration.js.map +0 -1
  342. package/build/npm/esm/integrations/globalhandlers.js.map +0 -1
  343. package/build/npm/esm/integrations/graphqlClient.js.map +0 -1
  344. package/build/npm/esm/integrations/httpclient.js.map +0 -1
  345. package/build/npm/esm/integrations/httpcontext.js.map +0 -1
  346. package/build/npm/esm/integrations/linkederrors.js.map +0 -1
  347. package/build/npm/esm/integrations/reportingobserver.js.map +0 -1
  348. package/build/npm/esm/integrations/spotlight.js.map +0 -1
  349. package/build/npm/esm/integrations/webWorker.js.map +0 -1
  350. package/build/npm/esm/package.json +0 -1
  351. package/build/npm/esm/profiling/integration.js.map +0 -1
  352. package/build/npm/esm/profiling/lifecycleMode/traceLifecycleProfiler.js.map +0 -1
  353. package/build/npm/esm/profiling/startProfileForSpan.js.map +0 -1
  354. package/build/npm/esm/profiling/utils.js.map +0 -1
  355. package/build/npm/esm/report-dialog.js.map +0 -1
  356. package/build/npm/esm/sdk.js.map +0 -1
  357. package/build/npm/esm/stack-parsers.js.map +0 -1
  358. package/build/npm/esm/tracing/backgroundtab.js.map +0 -1
  359. package/build/npm/esm/tracing/browserTracingIntegration.js.map +0 -1
  360. package/build/npm/esm/tracing/linkedTraces.js.map +0 -1
  361. package/build/npm/esm/tracing/reportPageLoaded.js.map +0 -1
  362. package/build/npm/esm/tracing/request.js.map +0 -1
  363. package/build/npm/esm/tracing/setActiveSpan.js.map +0 -1
  364. package/build/npm/esm/tracing/utils.js.map +0 -1
  365. package/build/npm/esm/transports/fetch.js.map +0 -1
  366. package/build/npm/esm/transports/offline.js.map +0 -1
  367. package/build/npm/esm/userfeedback.js.map +0 -1
  368. package/build/npm/esm/utils/detectBrowserExtension.js.map +0 -1
  369. package/build/npm/esm/utils/lazyLoadIntegration.js.map +0 -1
  370. package/build/npm/types/profiling/lifecycleMode/traceLifecycleProfiler.d.ts.map +0 -1
  371. /package/build/npm/cjs/{client.js → dev/client.js} +0 -0
  372. /package/build/npm/cjs/{debug-build.js → dev/debug-build.js} +0 -0
  373. /package/build/npm/cjs/{diagnose-sdk.js → dev/diagnose-sdk.js} +0 -0
  374. /package/build/npm/cjs/{eventbuilder.js → dev/eventbuilder.js} +0 -0
  375. /package/build/npm/cjs/{feedbackAsync.js → dev/feedbackAsync.js} +0 -0
  376. /package/build/npm/cjs/{feedbackSync.js → dev/feedbackSync.js} +0 -0
  377. /package/build/npm/cjs/{helpers.js → dev/helpers.js} +0 -0
  378. /package/build/npm/cjs/{index.js → dev/index.js} +0 -0
  379. /package/build/npm/cjs/{index.js.map → dev/index.js.map} +0 -0
  380. /package/build/npm/cjs/{integrations → dev/integrations}/breadcrumbs.js +0 -0
  381. /package/build/npm/cjs/{integrations → dev/integrations}/browserapierrors.js +0 -0
  382. /package/build/npm/cjs/{integrations → dev/integrations}/browsersession.js +0 -0
  383. /package/build/npm/cjs/{integrations → dev/integrations}/contextlines.js +0 -0
  384. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/growthbook/integration.js +0 -0
  385. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/launchdarkly/integration.js +0 -0
  386. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/openfeature/integration.js +0 -0
  387. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/statsig/integration.js +0 -0
  388. /package/build/npm/cjs/{integrations → dev/integrations}/featureFlags/unleash/integration.js +0 -0
  389. /package/build/npm/cjs/{integrations → dev/integrations}/graphqlClient.js +0 -0
  390. /package/build/npm/cjs/{integrations → dev/integrations}/httpclient.js +0 -0
  391. /package/build/npm/cjs/{integrations → dev/integrations}/httpcontext.js +0 -0
  392. /package/build/npm/cjs/{integrations → dev/integrations}/linkederrors.js +0 -0
  393. /package/build/npm/cjs/{integrations → dev/integrations}/reportingobserver.js +0 -0
  394. /package/build/npm/cjs/{integrations → dev/integrations}/spotlight.js +0 -0
  395. /package/build/npm/cjs/{integrations → dev/integrations}/webWorker.js +0 -0
  396. /package/build/npm/cjs/{profiling → dev/profiling}/startProfileForSpan.js +0 -0
  397. /package/build/npm/cjs/{profiling → dev/profiling}/utils.js +0 -0
  398. /package/build/npm/cjs/{report-dialog.js → dev/report-dialog.js} +0 -0
  399. /package/build/npm/cjs/{stack-parsers.js → dev/stack-parsers.js} +0 -0
  400. /package/build/npm/cjs/{tracing → dev/tracing}/backgroundtab.js +0 -0
  401. /package/build/npm/cjs/{tracing → dev/tracing}/browserTracingIntegration.js +0 -0
  402. /package/build/npm/cjs/{tracing → dev/tracing}/reportPageLoaded.js +0 -0
  403. /package/build/npm/cjs/{tracing → dev/tracing}/request.js +0 -0
  404. /package/build/npm/cjs/{tracing → dev/tracing}/setActiveSpan.js +0 -0
  405. /package/build/npm/cjs/{tracing → dev/tracing}/utils.js +0 -0
  406. /package/build/npm/cjs/{transports → dev/transports}/fetch.js +0 -0
  407. /package/build/npm/cjs/{transports → dev/transports}/offline.js +0 -0
  408. /package/build/npm/cjs/{userfeedback.js → dev/userfeedback.js} +0 -0
  409. /package/build/npm/cjs/{utils → dev/utils}/detectBrowserExtension.js +0 -0
  410. /package/build/npm/cjs/{utils → dev/utils}/lazyLoadIntegration.js +0 -0
  411. /package/build/npm/esm/{client.js → dev/client.js} +0 -0
  412. /package/build/npm/esm/{debug-build.js → dev/debug-build.js} +0 -0
  413. /package/build/npm/esm/{diagnose-sdk.js → dev/diagnose-sdk.js} +0 -0
  414. /package/build/npm/esm/{eventbuilder.js → dev/eventbuilder.js} +0 -0
  415. /package/build/npm/esm/{feedbackAsync.js → dev/feedbackAsync.js} +0 -0
  416. /package/build/npm/esm/{feedbackSync.js → dev/feedbackSync.js} +0 -0
  417. /package/build/npm/esm/{helpers.js → dev/helpers.js} +0 -0
  418. /package/build/npm/esm/{index.js → dev/index.js} +0 -0
  419. /package/build/npm/esm/{index.js.map → dev/index.js.map} +0 -0
  420. /package/build/npm/esm/{integrations → dev/integrations}/breadcrumbs.js +0 -0
  421. /package/build/npm/esm/{integrations → dev/integrations}/browserapierrors.js +0 -0
  422. /package/build/npm/esm/{integrations → dev/integrations}/browsersession.js +0 -0
  423. /package/build/npm/esm/{integrations → dev/integrations}/contextlines.js +0 -0
  424. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/growthbook/integration.js +0 -0
  425. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/launchdarkly/integration.js +0 -0
  426. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/openfeature/integration.js +0 -0
  427. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/statsig/integration.js +0 -0
  428. /package/build/npm/esm/{integrations → dev/integrations}/featureFlags/unleash/integration.js +0 -0
  429. /package/build/npm/esm/{integrations → dev/integrations}/graphqlClient.js +0 -0
  430. /package/build/npm/esm/{integrations → dev/integrations}/httpclient.js +0 -0
  431. /package/build/npm/esm/{integrations → dev/integrations}/httpcontext.js +0 -0
  432. /package/build/npm/esm/{integrations → dev/integrations}/linkederrors.js +0 -0
  433. /package/build/npm/esm/{integrations → dev/integrations}/reportingobserver.js +0 -0
  434. /package/build/npm/esm/{integrations → dev/integrations}/spotlight.js +0 -0
  435. /package/build/npm/esm/{integrations → dev/integrations}/webWorker.js +0 -0
  436. /package/build/npm/esm/{profiling → dev/profiling}/startProfileForSpan.js +0 -0
  437. /package/build/npm/esm/{profiling → dev/profiling}/utils.js +0 -0
  438. /package/build/npm/esm/{report-dialog.js → dev/report-dialog.js} +0 -0
  439. /package/build/npm/esm/{stack-parsers.js → dev/stack-parsers.js} +0 -0
  440. /package/build/npm/esm/{tracing → dev/tracing}/backgroundtab.js +0 -0
  441. /package/build/npm/esm/{tracing → dev/tracing}/browserTracingIntegration.js +0 -0
  442. /package/build/npm/esm/{tracing → dev/tracing}/reportPageLoaded.js +0 -0
  443. /package/build/npm/esm/{tracing → dev/tracing}/request.js +0 -0
  444. /package/build/npm/esm/{tracing → dev/tracing}/setActiveSpan.js +0 -0
  445. /package/build/npm/esm/{tracing → dev/tracing}/utils.js +0 -0
  446. /package/build/npm/esm/{transports → dev/transports}/fetch.js +0 -0
  447. /package/build/npm/esm/{transports → dev/transports}/offline.js +0 -0
  448. /package/build/npm/esm/{userfeedback.js → dev/userfeedback.js} +0 -0
  449. /package/build/npm/esm/{utils → dev/utils}/detectBrowserExtension.js +0 -0
  450. /package/build/npm/esm/{utils → dev/utils}/lazyLoadIntegration.js +0 -0
@@ -0,0 +1,74 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const debugBuild = require('../../../debug-build.js');
5
+
6
+ /**
7
+ * Sentry integration for capturing feature flag evaluations from the Unleash SDK.
8
+ *
9
+ * See the [feature flag documentation](https://develop.sentry.dev/sdk/expected-features/#feature-flags) for more information.
10
+ *
11
+ * @example
12
+ * ```
13
+ * import { UnleashClient } from 'unleash-proxy-client';
14
+ * import * as Sentry from '@sentry/browser';
15
+ *
16
+ * Sentry.init({
17
+ * dsn: '___PUBLIC_DSN___',
18
+ * integrations: [Sentry.unleashIntegration({featureFlagClientClass: UnleashClient})],
19
+ * });
20
+ *
21
+ * const unleash = new UnleashClient(...);
22
+ * unleash.start();
23
+ *
24
+ * unleash.isEnabled('my-feature');
25
+ * Sentry.captureException(new Error('something went wrong'));
26
+ * ```
27
+ */
28
+ const unleashIntegration = core.defineIntegration(
29
+ ({ featureFlagClientClass: unleashClientClass }) => {
30
+ return {
31
+ name: 'Unleash',
32
+
33
+ setupOnce() {
34
+ const unleashClientPrototype = unleashClientClass.prototype ;
35
+ core.fill(unleashClientPrototype, 'isEnabled', _wrappedIsEnabled);
36
+ },
37
+
38
+ processEvent(event, _hint, _client) {
39
+ return core._INTERNAL_copyFlagsFromScopeToEvent(event);
40
+ },
41
+ };
42
+ },
43
+ ) ;
44
+
45
+ /**
46
+ * Wraps the UnleashClient.isEnabled method to capture feature flag evaluations. Its only side effect is writing to Sentry scope.
47
+ *
48
+ * This wrapper is safe for all isEnabled signatures. If the signature does not match (this: UnleashClient, toggleName: string, ...args: unknown[]) => boolean,
49
+ * we log an error and return the original result.
50
+ *
51
+ * @param original - The original method.
52
+ * @returns Wrapped method. Results should match the original.
53
+ */
54
+ function _wrappedIsEnabled(
55
+ original,
56
+ ) {
57
+ return function ( ...args) {
58
+ const toggleName = args[0];
59
+ const result = original.apply(this, args);
60
+
61
+ if (typeof toggleName === 'string' && typeof result === 'boolean') {
62
+ core._INTERNAL_insertFlagToScope(toggleName, result);
63
+ core._INTERNAL_addFeatureFlagToActiveSpan(toggleName, result);
64
+ } else if (debugBuild.DEBUG_BUILD) {
65
+ core.debug.error(
66
+ `[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: ${toggleName} (${typeof toggleName}), result: ${result} (${typeof result})`,
67
+ );
68
+ }
69
+ return result;
70
+ };
71
+ }
72
+
73
+ exports.unleashIntegration = unleashIntegration;
74
+ //# sourceMappingURL=integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.js","sources":["../../../../../../../src/integrations/featureFlags/unleash/integration.ts"],"sourcesContent":["import type { Client, Event, EventHint, IntegrationFn } from '@sentry/core';\nimport {\n _INTERNAL_addFeatureFlagToActiveSpan,\n _INTERNAL_copyFlagsFromScopeToEvent,\n _INTERNAL_insertFlagToScope,\n debug,\n defineIntegration,\n fill,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport type { UnleashClient, UnleashClientClass } from './types';\n\ntype UnleashIntegrationOptions = {\n featureFlagClientClass: UnleashClientClass;\n};\n\n/**\n * Sentry integration for capturing feature flag evaluations from the Unleash SDK.\n *\n * See the [feature flag documentation](https://develop.sentry.dev/sdk/expected-features/#feature-flags) for more information.\n *\n * @example\n * ```\n * import { UnleashClient } from 'unleash-proxy-client';\n * import * as Sentry from '@sentry/browser';\n *\n * Sentry.init({\n * dsn: '___PUBLIC_DSN___',\n * integrations: [Sentry.unleashIntegration({featureFlagClientClass: UnleashClient})],\n * });\n *\n * const unleash = new UnleashClient(...);\n * unleash.start();\n *\n * unleash.isEnabled('my-feature');\n * Sentry.captureException(new Error('something went wrong'));\n * ```\n */\nexport const unleashIntegration = defineIntegration(\n ({ featureFlagClientClass: unleashClientClass }: UnleashIntegrationOptions) => {\n return {\n name: 'Unleash',\n\n setupOnce() {\n const unleashClientPrototype = unleashClientClass.prototype as UnleashClient;\n fill(unleashClientPrototype, 'isEnabled', _wrappedIsEnabled);\n },\n\n processEvent(event: Event, _hint: EventHint, _client: Client): Event {\n return _INTERNAL_copyFlagsFromScopeToEvent(event);\n },\n };\n },\n) satisfies IntegrationFn;\n\n/**\n * Wraps the UnleashClient.isEnabled method to capture feature flag evaluations. Its only side effect is writing to Sentry scope.\n *\n * This wrapper is safe for all isEnabled signatures. If the signature does not match (this: UnleashClient, toggleName: string, ...args: unknown[]) => boolean,\n * we log an error and return the original result.\n *\n * @param original - The original method.\n * @returns Wrapped method. Results should match the original.\n */\nfunction _wrappedIsEnabled(\n original: (this: UnleashClient, ...args: unknown[]) => unknown,\n): (this: UnleashClient, ...args: unknown[]) => unknown {\n return function (this: UnleashClient, ...args: unknown[]): unknown {\n const toggleName = args[0];\n const result = original.apply(this, args);\n\n if (typeof toggleName === 'string' && typeof result === 'boolean') {\n _INTERNAL_insertFlagToScope(toggleName, result);\n _INTERNAL_addFeatureFlagToActiveSpan(toggleName, result);\n } else if (DEBUG_BUILD) {\n debug.error(\n `[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: ${toggleName} (${typeof toggleName}), result: ${result} (${typeof result})`,\n );\n }\n return result;\n };\n}\n"],"names":["defineIntegration","fill","_INTERNAL_copyFlagsFromScopeToEvent","_INTERNAL_insertFlagToScope","_INTERNAL_addFeatureFlagToActiveSpan","DEBUG_BUILD","debug"],"mappings":";;;;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kBAAA,GAAqBA,sBAAiB;AACnD,EAAE,CAAC,EAAE,sBAAsB,EAAE,kBAAA,EAAoB,KAAgC;AACjF,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,SAAS;;AAErB,MAAM,SAAS,GAAG;AAClB,QAAQ,MAAM,sBAAA,GAAyB,kBAAkB,CAAC,SAAA;AAC1D,QAAQC,SAAI,CAAC,sBAAsB,EAAE,WAAW,EAAE,iBAAiB,CAAC;AACpE,MAAM,CAAC;;AAEP,MAAM,YAAY,CAAC,KAAK,EAAS,KAAK,EAAa,OAAO,EAAiB;AAC3E,QAAQ,OAAOC,wCAAmC,CAAC,KAAK,CAAC;AACzD,MAAM,CAAC;AACP,KAAK;AACL,EAAE,CAAC;AACH,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB;AAC1B,EAAE,QAAQ;AACV,EAAwD;AACxD,EAAE,OAAO,WAA+B,GAAG,IAAI,EAAsB;AACrE,IAAI,MAAM,UAAA,GAAa,IAAI,CAAC,CAAC,CAAC;AAC9B,IAAI,MAAM,MAAA,GAAS,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;;AAE7C,IAAI,IAAI,OAAO,UAAA,KAAe,QAAA,IAAY,OAAO,MAAA,KAAW,SAAS,EAAE;AACvE,MAAMC,gCAA2B,CAAC,UAAU,EAAE,MAAM,CAAC;AACrD,MAAMC,yCAAoC,CAAC,UAAU,EAAE,MAAM,CAAC;AAC9D,IAAI,CAAA,MAAO,IAAIC,sBAAW,EAAE;AAC5B,MAAMC,UAAK,CAAC,KAAK;AACjB,QAAQ,CAAC,iFAAiF,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,OAAO,MAAM,CAAC,CAAC,CAAC;AACrK,OAAO;AACP,IAAI;AACJ,IAAI,OAAO,MAAM;AACjB,EAAE,CAAC;AACH;;;;"}
@@ -0,0 +1,210 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const debugBuild = require('../debug-build.js');
5
+ const eventbuilder = require('../eventbuilder.js');
6
+ const helpers = require('../helpers.js');
7
+
8
+ const INTEGRATION_NAME = 'GlobalHandlers';
9
+
10
+ const _globalHandlersIntegration = ((options = {}) => {
11
+ const _options = {
12
+ onerror: true,
13
+ onunhandledrejection: true,
14
+ ...options,
15
+ };
16
+
17
+ return {
18
+ name: INTEGRATION_NAME,
19
+ setupOnce() {
20
+ Error.stackTraceLimit = 50;
21
+ },
22
+ setup(client) {
23
+ if (_options.onerror) {
24
+ _installGlobalOnErrorHandler(client);
25
+ globalHandlerLog('onerror');
26
+ }
27
+ if (_options.onunhandledrejection) {
28
+ _installGlobalOnUnhandledRejectionHandler(client);
29
+ globalHandlerLog('onunhandledrejection');
30
+ }
31
+ },
32
+ };
33
+ }) ;
34
+
35
+ const globalHandlersIntegration = core.defineIntegration(_globalHandlersIntegration);
36
+
37
+ function _installGlobalOnErrorHandler(client) {
38
+ core.addGlobalErrorInstrumentationHandler(data => {
39
+ const { stackParser, attachStacktrace } = getOptions();
40
+
41
+ if (core.getClient() !== client || helpers.shouldIgnoreOnError()) {
42
+ return;
43
+ }
44
+
45
+ const { msg, url, line, column, error } = data;
46
+
47
+ const event = _enhanceEventWithInitialFrame(
48
+ eventbuilder.eventFromUnknownInput(stackParser, error || msg, undefined, attachStacktrace, false),
49
+ url,
50
+ line,
51
+ column,
52
+ );
53
+
54
+ event.level = 'error';
55
+
56
+ core.captureEvent(event, {
57
+ originalException: error,
58
+ mechanism: {
59
+ handled: false,
60
+ type: 'auto.browser.global_handlers.onerror',
61
+ },
62
+ });
63
+ });
64
+ }
65
+
66
+ function _installGlobalOnUnhandledRejectionHandler(client) {
67
+ core.addGlobalUnhandledRejectionInstrumentationHandler(e => {
68
+ const { stackParser, attachStacktrace } = getOptions();
69
+
70
+ if (core.getClient() !== client || helpers.shouldIgnoreOnError()) {
71
+ return;
72
+ }
73
+
74
+ const error = _getUnhandledRejectionError(e);
75
+
76
+ const event = core.isPrimitive(error)
77
+ ? _eventFromRejectionWithPrimitive(error)
78
+ : eventbuilder.eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);
79
+
80
+ event.level = 'error';
81
+
82
+ core.captureEvent(event, {
83
+ originalException: error,
84
+ mechanism: {
85
+ handled: false,
86
+ type: 'auto.browser.global_handlers.onunhandledrejection',
87
+ },
88
+ });
89
+ });
90
+ }
91
+
92
+ /**
93
+ *
94
+ */
95
+ function _getUnhandledRejectionError(error) {
96
+ if (core.isPrimitive(error)) {
97
+ return error;
98
+ }
99
+
100
+ // dig the object of the rejection out of known event types
101
+ try {
102
+
103
+ // PromiseRejectionEvents store the object of the rejection under 'reason'
104
+ // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent
105
+ if ('reason' in (error )) {
106
+ return (error ).reason;
107
+ }
108
+
109
+ // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents
110
+ // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into
111
+ // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec
112
+ // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and
113
+ // https://github.com/getsentry/sentry-javascript/issues/2380
114
+ if ('detail' in (error ) && 'reason' in (error ).detail) {
115
+ return (error ).detail.reason;
116
+ }
117
+ } catch {} // eslint-disable-line no-empty
118
+
119
+ return error;
120
+ }
121
+
122
+ /**
123
+ * Create an event from a promise rejection where the `reason` is a primitive.
124
+ *
125
+ * @param reason: The `reason` property of the promise rejection
126
+ * @returns An Event object with an appropriate `exception` value
127
+ */
128
+ function _eventFromRejectionWithPrimitive(reason) {
129
+ return {
130
+ exception: {
131
+ values: [
132
+ {
133
+ type: 'UnhandledRejection',
134
+ // String() is needed because the Primitive type includes symbols (which can't be automatically stringified)
135
+ value: `Non-Error promise rejection captured with value: ${String(reason)}`,
136
+ },
137
+ ],
138
+ },
139
+ };
140
+ }
141
+
142
+ function _enhanceEventWithInitialFrame(
143
+ event,
144
+ url,
145
+ line,
146
+ column,
147
+ ) {
148
+ // event.exception
149
+ const e = (event.exception = event.exception || {});
150
+ // event.exception.values
151
+ const ev = (e.values = e.values || []);
152
+ // event.exception.values[0]
153
+ const ev0 = (ev[0] = ev[0] || {});
154
+ // event.exception.values[0].stacktrace
155
+ const ev0s = (ev0.stacktrace = ev0.stacktrace || {});
156
+ // event.exception.values[0].stacktrace.frames
157
+ const ev0sf = (ev0s.frames = ev0s.frames || []);
158
+
159
+ const colno = column;
160
+ const lineno = line;
161
+ const filename = getFilenameFromUrl(url) ?? core.getLocationHref();
162
+
163
+ // event.exception.values[0].stacktrace.frames
164
+ if (ev0sf.length === 0) {
165
+ ev0sf.push({
166
+ colno,
167
+ filename,
168
+ function: core.UNKNOWN_FUNCTION,
169
+ in_app: true,
170
+ lineno,
171
+ });
172
+ }
173
+
174
+ return event;
175
+ }
176
+
177
+ function globalHandlerLog(type) {
178
+ debugBuild.DEBUG_BUILD && core.debug.log(`Global Handler attached: ${type}`);
179
+ }
180
+
181
+ function getOptions() {
182
+ const client = core.getClient();
183
+ const options = client?.getOptions() || {
184
+ stackParser: () => [],
185
+ attachStacktrace: false,
186
+ };
187
+ return options;
188
+ }
189
+
190
+ function getFilenameFromUrl(url) {
191
+ if (!core.isString(url) || url.length === 0) {
192
+ return undefined;
193
+ }
194
+
195
+ // stack frame urls can be data urls, for example when initializing a Worker with a base64 encoded script
196
+ // in this case we just show the data prefix and mime type to avoid too long raw data urls
197
+ if (url.startsWith('data:')) {
198
+ const match = url.match(/^data:([^;]+)/);
199
+ const mimeType = match ? match[1] : 'text/javascript';
200
+ const isBase64 = url.includes('base64,');
201
+ return `<data:${mimeType}${isBase64 ? ',base64' : ''}>`;
202
+ }
203
+
204
+ return url; // it's fine to not truncate it as it's not put in a regex (https://codeql.github.com/codeql-query-help/javascript/js-polynomial-redos)
205
+ }
206
+
207
+ exports._eventFromRejectionWithPrimitive = _eventFromRejectionWithPrimitive;
208
+ exports._getUnhandledRejectionError = _getUnhandledRejectionError;
209
+ exports.globalHandlersIntegration = globalHandlersIntegration;
210
+ //# sourceMappingURL=globalhandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalhandlers.js","sources":["../../../../../src/integrations/globalhandlers.ts"],"sourcesContent":["import type { Client, Event, IntegrationFn, Primitive, StackParser } from '@sentry/core';\nimport {\n addGlobalErrorInstrumentationHandler,\n addGlobalUnhandledRejectionInstrumentationHandler,\n captureEvent,\n debug,\n defineIntegration,\n getClient,\n getLocationHref,\n isPrimitive,\n isString,\n UNKNOWN_FUNCTION,\n} from '@sentry/core';\nimport type { BrowserClient } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { eventFromUnknownInput } from '../eventbuilder';\nimport { shouldIgnoreOnError } from '../helpers';\n\ntype GlobalHandlersIntegrationsOptionKeys = 'onerror' | 'onunhandledrejection';\n\ntype GlobalHandlersIntegrations = Record<GlobalHandlersIntegrationsOptionKeys, boolean>;\n\nconst INTEGRATION_NAME = 'GlobalHandlers';\n\nconst _globalHandlersIntegration = ((options: Partial<GlobalHandlersIntegrations> = {}) => {\n const _options = {\n onerror: true,\n onunhandledrejection: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n Error.stackTraceLimit = 50;\n },\n setup(client) {\n if (_options.onerror) {\n _installGlobalOnErrorHandler(client);\n globalHandlerLog('onerror');\n }\n if (_options.onunhandledrejection) {\n _installGlobalOnUnhandledRejectionHandler(client);\n globalHandlerLog('onunhandledrejection');\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const globalHandlersIntegration = defineIntegration(_globalHandlersIntegration);\n\nfunction _installGlobalOnErrorHandler(client: Client): void {\n addGlobalErrorInstrumentationHandler(data => {\n const { stackParser, attachStacktrace } = getOptions();\n\n if (getClient() !== client || shouldIgnoreOnError()) {\n return;\n }\n\n const { msg, url, line, column, error } = data;\n\n const event = _enhanceEventWithInitialFrame(\n eventFromUnknownInput(stackParser, error || msg, undefined, attachStacktrace, false),\n url,\n line,\n column,\n );\n\n event.level = 'error';\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'auto.browser.global_handlers.onerror',\n },\n });\n });\n}\n\nfunction _installGlobalOnUnhandledRejectionHandler(client: Client): void {\n addGlobalUnhandledRejectionInstrumentationHandler(e => {\n const { stackParser, attachStacktrace } = getOptions();\n\n if (getClient() !== client || shouldIgnoreOnError()) {\n return;\n }\n\n const error = _getUnhandledRejectionError(e);\n\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);\n\n event.level = 'error';\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'auto.browser.global_handlers.onunhandledrejection',\n },\n });\n });\n}\n\n/**\n *\n */\nexport function _getUnhandledRejectionError(error: unknown): unknown {\n if (isPrimitive(error)) {\n return error;\n }\n\n // dig the object of the rejection out of known event types\n try {\n type ErrorWithReason = { reason: unknown };\n // PromiseRejectionEvents store the object of the rejection under 'reason'\n // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent\n if ('reason' in (error as ErrorWithReason)) {\n return (error as ErrorWithReason).reason;\n }\n\n type CustomEventWithDetail = { detail: { reason: unknown } };\n // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents\n // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into\n // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and\n // https://github.com/getsentry/sentry-javascript/issues/2380\n if ('detail' in (error as CustomEventWithDetail) && 'reason' in (error as CustomEventWithDetail).detail) {\n return (error as CustomEventWithDetail).detail.reason;\n }\n } catch {} // eslint-disable-line no-empty\n\n return error;\n}\n\n/**\n * Create an event from a promise rejection where the `reason` is a primitive.\n *\n * @param reason: The `reason` property of the promise rejection\n * @returns An Event object with an appropriate `exception` value\n */\nexport function _eventFromRejectionWithPrimitive(reason: Primitive): Event {\n return {\n exception: {\n values: [\n {\n type: 'UnhandledRejection',\n // String() is needed because the Primitive type includes symbols (which can't be automatically stringified)\n value: `Non-Error promise rejection captured with value: ${String(reason)}`,\n },\n ],\n },\n };\n}\n\nfunction _enhanceEventWithInitialFrame(\n event: Event,\n url: string | undefined,\n line: number | undefined,\n column: number | undefined,\n): Event {\n // event.exception\n const e = (event.exception = event.exception || {});\n // event.exception.values\n const ev = (e.values = e.values || []);\n // event.exception.values[0]\n const ev0 = (ev[0] = ev[0] || {});\n // event.exception.values[0].stacktrace\n const ev0s = (ev0.stacktrace = ev0.stacktrace || {});\n // event.exception.values[0].stacktrace.frames\n const ev0sf = (ev0s.frames = ev0s.frames || []);\n\n const colno = column;\n const lineno = line;\n const filename = getFilenameFromUrl(url) ?? getLocationHref();\n\n // event.exception.values[0].stacktrace.frames\n if (ev0sf.length === 0) {\n ev0sf.push({\n colno,\n filename,\n function: UNKNOWN_FUNCTION,\n in_app: true,\n lineno,\n });\n }\n\n return event;\n}\n\nfunction globalHandlerLog(type: string): void {\n DEBUG_BUILD && debug.log(`Global Handler attached: ${type}`);\n}\n\nfunction getOptions(): { stackParser: StackParser; attachStacktrace?: boolean } {\n const client = getClient<BrowserClient>();\n const options = client?.getOptions() || {\n stackParser: () => [],\n attachStacktrace: false,\n };\n return options;\n}\n\nfunction getFilenameFromUrl(url: string | undefined): string | undefined {\n if (!isString(url) || url.length === 0) {\n return undefined;\n }\n\n // stack frame urls can be data urls, for example when initializing a Worker with a base64 encoded script\n // in this case we just show the data prefix and mime type to avoid too long raw data urls\n if (url.startsWith('data:')) {\n const match = url.match(/^data:([^;]+)/);\n const mimeType = match ? match[1] : 'text/javascript';\n const isBase64 = url.includes('base64,');\n return `<data:${mimeType}${isBase64 ? ',base64' : ''}>`;\n }\n\n return url; // it's fine to not truncate it as it's not put in a regex (https://codeql.github.com/codeql-query-help/javascript/js-polynomial-redos)\n}\n"],"names":["defineIntegration","addGlobalErrorInstrumentationHandler","getClient","shouldIgnoreOnError","eventFromUnknownInput","captureEvent","addGlobalUnhandledRejectionInstrumentationHandler","isPrimitive","getLocationHref","UNKNOWN_FUNCTION","DEBUG_BUILD","debug","isString"],"mappings":";;;;;;;AAsBA,MAAM,gBAAA,GAAmB,gBAAgB;;AAEzC,MAAM,0BAAA,IAA8B,CAAC,OAAO,GAAwC,EAAE,KAAK;AAC3F,EAAE,MAAM,WAAW;AACnB,IAAI,OAAO,EAAE,IAAI;AACjB,IAAI,oBAAoB,EAAE,IAAI;AAC9B,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,KAAK,CAAC,eAAA,GAAkB,EAAE;AAChC,IAAI,CAAC;AACL,IAAI,K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ACA,MAAA,MAAA,EAAA,IAAA;AACA,MAAA,MAAA;AACA,KAAA,CAAA;AACA,EAAA;;AAEA,EAAA,OAAA,KAAA;AACA;;AAEA,SAAA,gBAAA,CAAA,IAAA,EAAA;AACA,EAAAC,sBAAA,IAAAC,UAAA,CAAA,GAAA,CAAA,CAAA,yBAAA,EAAA,IAAA,CAAA,CAAA,CAAA;AACA;;AAEA,SAAA,UAAA,GAAA;AACA,EAAA,MAAA,MAAA,GAAAT,cAAA,EAAA;AACA,EAAA,MAAA,OAAA,GAAA,MAAA,EAAA,UAAA,EAAA,IAAA;AACA,IAAA,WAAA,EAAA,MAAA,EAAA;AACA,IAAA,gBAAA,EAAA,KAAA;AACA,GAAA;AACA,EAAA,OAAA,OAAA;AACA;;AAEA,SAAA,kBAAA,CAAA,GAAA,EAAA;AACA,EAAA,IAAA,CAAAU,aAAA,CAAA,GAAA,CAAA,IAAA,GAAA,CAAA,MAAA,KAAA,CAAA,EAAA;AACA,IAAA,OAAA,SAAA;AACA,EAAA;;AAEA;AACA;AACA,EAAA,IAAA,GAAA,CAAA,UAAA,CAAA,OAAA,CAAA,EAAA;AACA,IAAA,MAAA,KAAA,GAAA,GAAA,CAAA,KAAA,CAAA,eAAA,CAAA;AACA,IAAA,MAAA,QAAA,GAAA,KAAA,GAAA,KAAA,CAAA,CAAA,CAAA,GAAA,iBAAA;AACA,IAAA,MAAA,QAAA,GAAA,GAAA,CAAA,QAAA,CAAA,SAAA,CAAA;AACA,IAAA,OAAA,CAAA,MAAA,EAAA,QAAA,CAAA,EAAA,QAAA,GAAA,SAAA,GAAA,EAAA,CAAA,CAAA,CAAA;AACA,EAAA;;AAEA,EAAA,OAAA,GAAA,CAAA;AACA;;;;;;"}
@@ -0,0 +1,180 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const browserUtils = require('@sentry-internal/browser-utils');
5
+
6
+ const INTEGRATION_NAME = 'GraphQLClient';
7
+
8
+ const _graphqlClientIntegration = ((options) => {
9
+ return {
10
+ name: INTEGRATION_NAME,
11
+ setup(client) {
12
+ _updateSpanWithGraphQLData(client, options);
13
+ _updateBreadcrumbWithGraphQLData(client, options);
14
+ },
15
+ };
16
+ }) ;
17
+
18
+ function _updateSpanWithGraphQLData(client, options) {
19
+ client.on('beforeOutgoingRequestSpan', (span, hint) => {
20
+ const spanJSON = core.spanToJSON(span);
21
+
22
+ const spanAttributes = spanJSON.data || {};
23
+ const spanOp = spanAttributes[core.SEMANTIC_ATTRIBUTE_SENTRY_OP];
24
+
25
+ const isHttpClientSpan = spanOp === 'http.client';
26
+
27
+ if (!isHttpClientSpan) {
28
+ return;
29
+ }
30
+
31
+ const httpUrl = spanAttributes[core.SEMANTIC_ATTRIBUTE_URL_FULL] || spanAttributes['http.url'];
32
+ const httpMethod = spanAttributes[core.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD] || spanAttributes['http.method'];
33
+
34
+ if (!core.isString(httpUrl) || !core.isString(httpMethod)) {
35
+ return;
36
+ }
37
+
38
+ const { endpoints } = options;
39
+ const isTracedGraphqlEndpoint = core.stringMatchesSomePattern(httpUrl, endpoints);
40
+ const payload = getRequestPayloadXhrOrFetch(hint );
41
+
42
+ if (isTracedGraphqlEndpoint && payload) {
43
+ const graphqlBody = getGraphQLRequestPayload(payload);
44
+
45
+ if (graphqlBody) {
46
+ const operationInfo = _getGraphQLOperation(graphqlBody);
47
+ span.updateName(`${httpMethod} ${httpUrl} (${operationInfo})`);
48
+ span.setAttribute('graphql.document', payload);
49
+ }
50
+ }
51
+ });
52
+ }
53
+
54
+ function _updateBreadcrumbWithGraphQLData(client, options) {
55
+ client.on('beforeOutgoingRequestBreadcrumb', (breadcrumb, handlerData) => {
56
+ const { category, type, data } = breadcrumb;
57
+
58
+ const isFetch = category === 'fetch';
59
+ const isXhr = category === 'xhr';
60
+ const isHttpBreadcrumb = type === 'http';
61
+
62
+ if (isHttpBreadcrumb && (isFetch || isXhr)) {
63
+ const httpUrl = data?.url;
64
+ const { endpoints } = options;
65
+
66
+ const isTracedGraphqlEndpoint = core.stringMatchesSomePattern(httpUrl, endpoints);
67
+ const payload = getRequestPayloadXhrOrFetch(handlerData );
68
+
69
+ if (isTracedGraphqlEndpoint && data && payload) {
70
+ const graphqlBody = getGraphQLRequestPayload(payload);
71
+
72
+ if (!data.graphql && graphqlBody) {
73
+ const operationInfo = _getGraphQLOperation(graphqlBody);
74
+ data['graphql.document'] = graphqlBody.query;
75
+ data['graphql.operation'] = operationInfo;
76
+ }
77
+ }
78
+ }
79
+ });
80
+ }
81
+
82
+ /**
83
+ * @param requestBody - GraphQL request
84
+ * @returns A formatted version of the request: 'TYPE NAME' or 'TYPE'
85
+ */
86
+ function _getGraphQLOperation(requestBody) {
87
+ const { query: graphqlQuery, operationName: graphqlOperationName } = requestBody;
88
+
89
+ const { operationName = graphqlOperationName, operationType } = parseGraphQLQuery(graphqlQuery);
90
+ const operationInfo = operationName ? `${operationType} ${operationName}` : `${operationType}`;
91
+
92
+ return operationInfo;
93
+ }
94
+
95
+ /**
96
+ * Get the request body/payload based on the shape of the hint.
97
+ *
98
+ * Exported for tests only.
99
+ */
100
+ function getRequestPayloadXhrOrFetch(hint) {
101
+ const isXhr = 'xhr' in hint;
102
+
103
+ let body;
104
+
105
+ if (isXhr) {
106
+ const sentryXhrData = hint.xhr[browserUtils.SENTRY_XHR_DATA_KEY];
107
+ body = sentryXhrData && browserUtils.getBodyString(sentryXhrData.body)[0];
108
+ } else {
109
+ const sentryFetchData = browserUtils.getFetchRequestArgBody(hint.input);
110
+ body = browserUtils.getBodyString(sentryFetchData)[0];
111
+ }
112
+
113
+ return body;
114
+ }
115
+
116
+ /**
117
+ * Extract the name and type of the operation from the GraphQL query.
118
+ *
119
+ * Exported for tests only.
120
+ */
121
+ function parseGraphQLQuery(query) {
122
+ const namedQueryRe = /^(?:\s*)(query|mutation|subscription)(?:\s*)(\w+)(?:\s*)[{(]/;
123
+ const unnamedQueryRe = /^(?:\s*)(query|mutation|subscription)(?:\s*)[{(]/;
124
+
125
+ const namedMatch = query.match(namedQueryRe);
126
+ if (namedMatch) {
127
+ return {
128
+ operationType: namedMatch[1],
129
+ operationName: namedMatch[2],
130
+ };
131
+ }
132
+
133
+ const unnamedMatch = query.match(unnamedQueryRe);
134
+ if (unnamedMatch) {
135
+ return {
136
+ operationType: unnamedMatch[1],
137
+ operationName: undefined,
138
+ };
139
+ }
140
+ return {
141
+ operationType: undefined,
142
+ operationName: undefined,
143
+ };
144
+ }
145
+
146
+ /**
147
+ * Extract the payload of a request if it's GraphQL.
148
+ * Exported for tests only.
149
+ * @param payload - A valid JSON string
150
+ * @returns A POJO or undefined
151
+ */
152
+ function getGraphQLRequestPayload(payload) {
153
+ let graphqlBody = undefined;
154
+ try {
155
+ const requestBody = JSON.parse(payload) ;
156
+
157
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
158
+ const isGraphQLRequest = !!requestBody['query'];
159
+ if (isGraphQLRequest) {
160
+ graphqlBody = requestBody;
161
+ }
162
+ } finally {
163
+ // Fallback to undefined if payload is an invalid JSON (SyntaxError)
164
+
165
+ /* eslint-disable no-unsafe-finally */
166
+ return graphqlBody;
167
+ }
168
+ }
169
+
170
+ /**
171
+ * This integration ensures that GraphQL requests made in the browser
172
+ * have their GraphQL-specific data captured and attached to spans and breadcrumbs.
173
+ */
174
+ const graphqlClientIntegration = core.defineIntegration(_graphqlClientIntegration);
175
+
176
+ exports.getGraphQLRequestPayload = getGraphQLRequestPayload;
177
+ exports.getRequestPayloadXhrOrFetch = getRequestPayloadXhrOrFetch;
178
+ exports.graphqlClientIntegration = graphqlClientIntegration;
179
+ exports.parseGraphQLQuery = parseGraphQLQuery;
180
+ //# sourceMappingURL=graphqlClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphqlClient.js","sources":["../../../../../src/integrations/graphqlClient.ts"],"sourcesContent":["import type { Client, IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n isString,\n SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n spanToJSON,\n stringMatchesSomePattern,\n} from '@sentry/core';\nimport type { FetchHint, XhrHint } from '@sentry-internal/browser-utils';\nimport { getBodyString, getFetchRequestArgBody, SENTRY_XHR_DATA_KEY } from '@sentry-internal/browser-utils';\n\ninterface GraphQLClientOptions {\n endpoints: Array<string | RegExp>;\n}\n\n/** Standard graphql request shape: https://graphql.org/learn/serving-over-http/#post-request-and-body */\ninterface GraphQLRequestPayload {\n query: string;\n operationName?: string;\n variables?: Record<string, unknown>;\n extensions?: Record<string, unknown>;\n}\n\ninterface GraphQLOperation {\n operationType?: string;\n operationName?: string;\n}\n\nconst INTEGRATION_NAME = 'GraphQLClient';\n\nconst _graphqlClientIntegration = ((options: GraphQLClientOptions) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n _updateSpanWithGraphQLData(client, options);\n _updateBreadcrumbWithGraphQLData(client, options);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction _updateSpanWithGraphQLData(client: Client, options: GraphQLClientOptions): void {\n client.on('beforeOutgoingRequestSpan', (span, hint) => {\n const spanJSON = spanToJSON(span);\n\n const spanAttributes = spanJSON.data || {};\n const spanOp = spanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_OP];\n\n const isHttpClientSpan = spanOp === 'http.client';\n\n if (!isHttpClientSpan) {\n return;\n }\n\n const httpUrl = spanAttributes[SEMANTIC_ATTRIBUTE_URL_FULL] || spanAttributes['http.url'];\n const httpMethod = spanAttributes[SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD] || spanAttributes['http.method'];\n\n if (!isString(httpUrl) || !isString(httpMethod)) {\n return;\n }\n\n const { endpoints } = options;\n const isTracedGraphqlEndpoint = stringMatchesSomePattern(httpUrl, endpoints);\n const payload = getRequestPayloadXhrOrFetch(hint as XhrHint | FetchHint);\n\n if (isTracedGraphqlEndpoint && payload) {\n const graphqlBody = getGraphQLRequestPayload(payload);\n\n if (graphqlBody) {\n const operationInfo = _getGraphQLOperation(graphqlBody);\n span.updateName(`${httpMethod} ${httpUrl} (${operationInfo})`);\n span.setAttribute('graphql.document', payload);\n }\n }\n });\n}\n\nfunction _updateBreadcrumbWithGraphQLData(client: Client, options: GraphQLClientOptions): void {\n client.on('beforeOutgoingRequestBreadcrumb', (breadcrumb, handlerData) => {\n const { category, type, data } = breadcrumb;\n\n const isFetch = category === 'fetch';\n const isXhr = category === 'xhr';\n const isHttpBreadcrumb = type === 'http';\n\n if (isHttpBreadcrumb && (isFetch || isXhr)) {\n const httpUrl = data?.url;\n const { endpoints } = options;\n\n const isTracedGraphqlEndpoint = stringMatchesSomePattern(httpUrl, endpoints);\n const payload = getRequestPayloadXhrOrFetch(handlerData as XhrHint | FetchHint);\n\n if (isTracedGraphqlEndpoint && data && payload) {\n const graphqlBody = getGraphQLRequestPayload(payload);\n\n if (!data.graphql && graphqlBody) {\n const operationInfo = _getGraphQLOperation(graphqlBody);\n data['graphql.document'] = graphqlBody.query;\n data['graphql.operation'] = operationInfo;\n }\n }\n }\n });\n}\n\n/**\n * @param requestBody - GraphQL request\n * @returns A formatted version of the request: 'TYPE NAME' or 'TYPE'\n */\nfunction _getGraphQLOperation(requestBody: GraphQLRequestPayload): string {\n const { query: graphqlQuery, operationName: graphqlOperationName } = requestBody;\n\n const { operationName = graphqlOperationName, operationType } = parseGraphQLQuery(graphqlQuery);\n const operationInfo = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n\n return operationInfo;\n}\n\n/**\n * Get the request body/payload based on the shape of the hint.\n *\n * Exported for tests only.\n */\nexport function getRequestPayloadXhrOrFetch(hint: XhrHint | FetchHint): string | undefined {\n const isXhr = 'xhr' in hint;\n\n let body: string | undefined;\n\n if (isXhr) {\n const sentryXhrData = hint.xhr[SENTRY_XHR_DATA_KEY];\n body = sentryXhrData && getBodyString(sentryXhrData.body)[0];\n } else {\n const sentryFetchData = getFetchRequestArgBody(hint.input);\n body = getBodyString(sentryFetchData)[0];\n }\n\n return body;\n}\n\n/**\n * Extract the name and type of the operation from the GraphQL query.\n *\n * Exported for tests only.\n */\nexport function parseGraphQLQuery(query: string): GraphQLOperation {\n const namedQueryRe = /^(?:\\s*)(query|mutation|subscription)(?:\\s*)(\\w+)(?:\\s*)[{(]/;\n const unnamedQueryRe = /^(?:\\s*)(query|mutation|subscription)(?:\\s*)[{(]/;\n\n const namedMatch = query.match(namedQueryRe);\n if (namedMatch) {\n return {\n operationType: namedMatch[1],\n operationName: namedMatch[2],\n };\n }\n\n const unnamedMatch = query.match(unnamedQueryRe);\n if (unnamedMatch) {\n return {\n operationType: unnamedMatch[1],\n operationName: undefined,\n };\n }\n return {\n operationType: undefined,\n operationName: undefined,\n };\n}\n\n/**\n * Extract the payload of a request if it's GraphQL.\n * Exported for tests only.\n * @param payload - A valid JSON string\n * @returns A POJO or undefined\n */\nexport function getGraphQLRequestPayload(payload: string): GraphQLRequestPayload | undefined {\n let graphqlBody = undefined;\n try {\n const requestBody = JSON.parse(payload) satisfies GraphQLRequestPayload;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const isGraphQLRequest = !!requestBody['query'];\n if (isGraphQLRequest) {\n graphqlBody = requestBody;\n }\n } finally {\n // Fallback to undefined if payload is an invalid JSON (SyntaxError)\n\n /* eslint-disable no-unsafe-finally */\n return graphqlBody;\n }\n}\n\n/**\n * This integration ensures that GraphQL requests made in the browser\n * have their GraphQL-specific data captured and attached to spans and breadcrumbs.\n */\nexport const graphqlClientIntegration = defineIntegration(_graphqlClientIntegration);\n"],"names":["spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_URL_FULL","SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD","isString","stringMatchesSomePattern","SENTRY_XHR_DATA_KEY","getBodyString","getFetchRequestArgBody","defineIntegration"],"mappings":";;;;;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