@sentry/core 10.50.0 → 10.52.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 (347) hide show
  1. package/build/cjs/client.js +33 -5
  2. package/build/cjs/client.js.map +1 -1
  3. package/build/cjs/envelope.js +4 -1
  4. package/build/cjs/envelope.js.map +1 -1
  5. package/build/cjs/fetch.js +7 -4
  6. package/build/cjs/fetch.js.map +1 -1
  7. package/build/cjs/index.js +37 -13
  8. package/build/cjs/index.js.map +1 -1
  9. package/build/cjs/instrument/console.js +3 -1
  10. package/build/cjs/instrument/console.js.map +1 -1
  11. package/build/cjs/instrument/fetch.js +6 -2
  12. package/build/cjs/instrument/fetch.js.map +1 -1
  13. package/build/cjs/instrument/handlers.js +11 -1
  14. package/build/cjs/instrument/handlers.js.map +1 -1
  15. package/build/cjs/integrations/console.js +3 -1
  16. package/build/cjs/integrations/console.js.map +1 -1
  17. package/build/cjs/integrations/express/index.js +2 -4
  18. package/build/cjs/integrations/express/index.js.map +1 -1
  19. package/build/cjs/integrations/express/utils.js +0 -7
  20. package/build/cjs/integrations/express/utils.js.map +1 -1
  21. package/build/cjs/integrations/extraerrordata.js +2 -2
  22. package/build/cjs/integrations/extraerrordata.js.map +1 -1
  23. package/build/cjs/integrations/http/add-outgoing-request-breadcrumb.js +43 -0
  24. package/build/cjs/integrations/http/add-outgoing-request-breadcrumb.js.map +1 -0
  25. package/build/cjs/integrations/http/client-patch.js +113 -0
  26. package/build/cjs/integrations/http/client-patch.js.map +1 -0
  27. package/build/cjs/integrations/http/client-subscriptions.js +166 -0
  28. package/build/cjs/integrations/http/client-subscriptions.js.map +1 -0
  29. package/build/cjs/integrations/http/constants.js +10 -0
  30. package/build/cjs/integrations/http/constants.js.map +1 -0
  31. package/build/cjs/integrations/http/double-wrap-warning.js +29 -0
  32. package/build/cjs/integrations/http/double-wrap-warning.js.map +1 -0
  33. package/build/cjs/integrations/http/get-outgoing-span-data.js +88 -0
  34. package/build/cjs/integrations/http/get-outgoing-span-data.js.map +1 -0
  35. package/build/cjs/integrations/http/get-request-url.js +54 -0
  36. package/build/cjs/integrations/http/get-request-url.js.map +1 -0
  37. package/build/cjs/integrations/http/inject-trace-propagation-headers.js +81 -0
  38. package/build/cjs/integrations/http/inject-trace-propagation-headers.js.map +1 -0
  39. package/build/cjs/integrations/postgresjs.js +10 -1
  40. package/build/cjs/integrations/postgresjs.js.map +1 -1
  41. package/build/cjs/integrations/requestdata.js +92 -6
  42. package/build/cjs/integrations/requestdata.js.map +1 -1
  43. package/build/cjs/integrations/supabase.js +39 -12
  44. package/build/cjs/integrations/supabase.js.map +1 -1
  45. package/build/cjs/logs/console-integration.js +3 -1
  46. package/build/cjs/logs/console-integration.js.map +1 -1
  47. package/build/cjs/logs/envelope.js +12 -2
  48. package/build/cjs/logs/envelope.js.map +1 -1
  49. package/build/cjs/logs/internal.js +7 -1
  50. package/build/cjs/logs/internal.js.map +1 -1
  51. package/build/cjs/metrics/envelope.js +15 -2
  52. package/build/cjs/metrics/envelope.js.map +1 -1
  53. package/build/cjs/metrics/internal.js +7 -1
  54. package/build/cjs/metrics/internal.js.map +1 -1
  55. package/build/cjs/server-runtime-client.js +20 -2
  56. package/build/cjs/server-runtime-client.js.map +1 -1
  57. package/build/cjs/tracing/ai/gen-ai-attributes.js +6 -0
  58. package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
  59. package/build/cjs/tracing/idleSpan.js +7 -1
  60. package/build/cjs/tracing/idleSpan.js.map +1 -1
  61. package/build/cjs/tracing/langchain/index.js +43 -8
  62. package/build/cjs/tracing/langchain/index.js.map +1 -1
  63. package/build/cjs/tracing/langchain/utils.js +44 -10
  64. package/build/cjs/tracing/langchain/utils.js.map +1 -1
  65. package/build/cjs/tracing/langgraph/index.js +105 -2
  66. package/build/cjs/tracing/langgraph/index.js.map +1 -1
  67. package/build/cjs/tracing/langgraph/utils.js +168 -0
  68. package/build/cjs/tracing/langgraph/utils.js.map +1 -1
  69. package/build/cjs/tracing/spans/captureSpan.js +169 -9
  70. package/build/cjs/tracing/spans/captureSpan.js.map +1 -1
  71. package/build/cjs/tracing/spans/envelope.js +13 -3
  72. package/build/cjs/tracing/spans/envelope.js.map +1 -1
  73. package/build/cjs/tracing/trace.js +2 -0
  74. package/build/cjs/tracing/trace.js.map +1 -1
  75. package/build/cjs/tracing/vercel-ai/constants.js +8 -0
  76. package/build/cjs/tracing/vercel-ai/constants.js.map +1 -1
  77. package/build/cjs/tracing/vercel-ai/index.js +93 -14
  78. package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
  79. package/build/cjs/trpc.js +2 -3
  80. package/build/cjs/trpc.js.map +1 -1
  81. package/build/cjs/utils/baggage.js +73 -0
  82. package/build/cjs/utils/baggage.js.map +1 -1
  83. package/build/cjs/utils/chain-and-copy-promiselike.js +1 -0
  84. package/build/cjs/utils/chain-and-copy-promiselike.js.map +1 -1
  85. package/build/cjs/utils/get-default-export.js +32 -0
  86. package/build/cjs/utils/get-default-export.js.map +1 -0
  87. package/build/cjs/utils/isSentryRequestUrl.js +9 -1
  88. package/build/cjs/utils/isSentryRequestUrl.js.map +1 -1
  89. package/build/cjs/utils/normalizationHints.js +38 -0
  90. package/build/cjs/utils/normalizationHints.js.map +1 -0
  91. package/build/cjs/utils/normalize.js +7 -11
  92. package/build/cjs/utils/normalize.js.map +1 -1
  93. package/build/cjs/utils/object.js +1 -1
  94. package/build/cjs/utils/object.js.map +1 -1
  95. package/build/cjs/utils/request.js +192 -12
  96. package/build/cjs/utils/request.js.map +1 -1
  97. package/build/cjs/utils/should-ignore-span.js +27 -8
  98. package/build/cjs/utils/should-ignore-span.js.map +1 -1
  99. package/build/cjs/utils/spanUtils.js +1 -1
  100. package/build/cjs/utils/spanUtils.js.map +1 -1
  101. package/build/cjs/utils/version.js +1 -1
  102. package/build/esm/client.js +33 -5
  103. package/build/esm/client.js.map +1 -1
  104. package/build/esm/envelope.js +4 -1
  105. package/build/esm/envelope.js.map +1 -1
  106. package/build/esm/fetch.js +7 -4
  107. package/build/esm/fetch.js.map +1 -1
  108. package/build/esm/index.js +11 -5
  109. package/build/esm/index.js.map +1 -1
  110. package/build/esm/instrument/console.js +3 -1
  111. package/build/esm/instrument/console.js.map +1 -1
  112. package/build/esm/instrument/fetch.js +6 -2
  113. package/build/esm/instrument/fetch.js.map +1 -1
  114. package/build/esm/instrument/handlers.js +11 -1
  115. package/build/esm/instrument/handlers.js.map +1 -1
  116. package/build/esm/integrations/console.js +3 -1
  117. package/build/esm/integrations/console.js.map +1 -1
  118. package/build/esm/integrations/express/index.js +3 -5
  119. package/build/esm/integrations/express/index.js.map +1 -1
  120. package/build/esm/integrations/express/utils.js +1 -7
  121. package/build/esm/integrations/express/utils.js.map +1 -1
  122. package/build/esm/integrations/extraerrordata.js +2 -2
  123. package/build/esm/integrations/extraerrordata.js.map +1 -1
  124. package/build/esm/integrations/http/add-outgoing-request-breadcrumb.js +41 -0
  125. package/build/esm/integrations/http/add-outgoing-request-breadcrumb.js.map +1 -0
  126. package/build/esm/integrations/http/client-patch.js +111 -0
  127. package/build/esm/integrations/http/client-patch.js.map +1 -0
  128. package/build/esm/integrations/http/client-subscriptions.js +164 -0
  129. package/build/esm/integrations/http/client-subscriptions.js.map +1 -0
  130. package/build/esm/integrations/http/constants.js +6 -0
  131. package/build/esm/integrations/http/constants.js.map +1 -0
  132. package/build/esm/integrations/http/double-wrap-warning.js +26 -0
  133. package/build/esm/integrations/http/double-wrap-warning.js.map +1 -0
  134. package/build/esm/integrations/http/get-outgoing-span-data.js +85 -0
  135. package/build/esm/integrations/http/get-outgoing-span-data.js.map +1 -0
  136. package/build/esm/integrations/http/get-request-url.js +49 -0
  137. package/build/esm/integrations/http/get-request-url.js.map +1 -0
  138. package/build/esm/integrations/http/inject-trace-propagation-headers.js +79 -0
  139. package/build/esm/integrations/http/inject-trace-propagation-headers.js.map +1 -0
  140. package/build/esm/integrations/postgresjs.js +10 -1
  141. package/build/esm/integrations/postgresjs.js.map +1 -1
  142. package/build/esm/integrations/requestdata.js +92 -6
  143. package/build/esm/integrations/requestdata.js.map +1 -1
  144. package/build/esm/integrations/supabase.js +39 -12
  145. package/build/esm/integrations/supabase.js.map +1 -1
  146. package/build/esm/logs/console-integration.js +3 -1
  147. package/build/esm/logs/console-integration.js.map +1 -1
  148. package/build/esm/logs/envelope.js +12 -2
  149. package/build/esm/logs/envelope.js.map +1 -1
  150. package/build/esm/logs/internal.js +7 -1
  151. package/build/esm/logs/internal.js.map +1 -1
  152. package/build/esm/metrics/envelope.js +15 -2
  153. package/build/esm/metrics/envelope.js.map +1 -1
  154. package/build/esm/metrics/internal.js +7 -1
  155. package/build/esm/metrics/internal.js.map +1 -1
  156. package/build/esm/package.json +1 -1
  157. package/build/esm/server-runtime-client.js +20 -2
  158. package/build/esm/server-runtime-client.js.map +1 -1
  159. package/build/esm/tracing/ai/gen-ai-attributes.js +6 -1
  160. package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
  161. package/build/esm/tracing/idleSpan.js +7 -1
  162. package/build/esm/tracing/idleSpan.js.map +1 -1
  163. package/build/esm/tracing/langchain/index.js +45 -10
  164. package/build/esm/tracing/langchain/index.js.map +1 -1
  165. package/build/esm/tracing/langchain/utils.js +44 -12
  166. package/build/esm/tracing/langchain/utils.js.map +1 -1
  167. package/build/esm/tracing/langgraph/index.js +107 -5
  168. package/build/esm/tracing/langgraph/index.js.map +1 -1
  169. package/build/esm/tracing/langgraph/utils.js +166 -2
  170. package/build/esm/tracing/langgraph/utils.js.map +1 -1
  171. package/build/esm/tracing/spans/captureSpan.js +170 -11
  172. package/build/esm/tracing/spans/captureSpan.js.map +1 -1
  173. package/build/esm/tracing/spans/envelope.js +13 -3
  174. package/build/esm/tracing/spans/envelope.js.map +1 -1
  175. package/build/esm/tracing/trace.js +2 -1
  176. package/build/esm/tracing/trace.js.map +1 -1
  177. package/build/esm/tracing/vercel-ai/constants.js +8 -1
  178. package/build/esm/tracing/vercel-ai/constants.js.map +1 -1
  179. package/build/esm/tracing/vercel-ai/index.js +95 -17
  180. package/build/esm/tracing/vercel-ai/index.js.map +1 -1
  181. package/build/esm/trpc.js +2 -3
  182. package/build/esm/trpc.js.map +1 -1
  183. package/build/esm/utils/baggage.js +73 -1
  184. package/build/esm/utils/baggage.js.map +1 -1
  185. package/build/esm/utils/chain-and-copy-promiselike.js +1 -0
  186. package/build/esm/utils/chain-and-copy-promiselike.js.map +1 -1
  187. package/build/esm/utils/get-default-export.js +30 -0
  188. package/build/esm/utils/get-default-export.js.map +1 -0
  189. package/build/esm/utils/isSentryRequestUrl.js +9 -1
  190. package/build/esm/utils/isSentryRequestUrl.js.map +1 -1
  191. package/build/esm/utils/normalizationHints.js +33 -0
  192. package/build/esm/utils/normalizationHints.js.map +1 -0
  193. package/build/esm/utils/normalize.js +7 -11
  194. package/build/esm/utils/normalize.js.map +1 -1
  195. package/build/esm/utils/object.js +1 -1
  196. package/build/esm/utils/object.js.map +1 -1
  197. package/build/esm/utils/request.js +190 -13
  198. package/build/esm/utils/request.js.map +1 -1
  199. package/build/esm/utils/should-ignore-span.js +27 -8
  200. package/build/esm/utils/should-ignore-span.js.map +1 -1
  201. package/build/esm/utils/spanUtils.js +1 -1
  202. package/build/esm/utils/spanUtils.js.map +1 -1
  203. package/build/esm/utils/version.js +1 -1
  204. package/build/types/client.d.ts +12 -1
  205. package/build/types/client.d.ts.map +1 -1
  206. package/build/types/envelope.d.ts.map +1 -1
  207. package/build/types/fetch.d.ts.map +1 -1
  208. package/build/types/index.d.ts +17 -6
  209. package/build/types/index.d.ts.map +1 -1
  210. package/build/types/instrument/console.d.ts +2 -1
  211. package/build/types/instrument/console.d.ts.map +1 -1
  212. package/build/types/instrument/fetch.d.ts +4 -2
  213. package/build/types/instrument/fetch.d.ts.map +1 -1
  214. package/build/types/instrument/handlers.d.ts +2 -2
  215. package/build/types/instrument/handlers.d.ts.map +1 -1
  216. package/build/types/integrations/console.d.ts.map +1 -1
  217. package/build/types/integrations/express/index.d.ts.map +1 -1
  218. package/build/types/integrations/express/utils.d.ts +1 -5
  219. package/build/types/integrations/express/utils.d.ts.map +1 -1
  220. package/build/types/integrations/http/add-outgoing-request-breadcrumb.d.ts +6 -0
  221. package/build/types/integrations/http/add-outgoing-request-breadcrumb.d.ts.map +1 -0
  222. package/build/types/integrations/http/client-patch.d.ts +46 -0
  223. package/build/types/integrations/http/client-patch.d.ts.map +1 -0
  224. package/build/types/integrations/http/client-subscriptions.d.ts +21 -0
  225. package/build/types/integrations/http/client-subscriptions.d.ts.map +1 -0
  226. package/build/types/integrations/http/constants.d.ts +6 -0
  227. package/build/types/integrations/http/constants.d.ts.map +1 -0
  228. package/build/types/integrations/http/double-wrap-warning.d.ts +4 -0
  229. package/build/types/integrations/http/double-wrap-warning.d.ts.map +1 -0
  230. package/build/types/integrations/http/get-outgoing-span-data.d.ts +13 -0
  231. package/build/types/integrations/http/get-outgoing-span-data.d.ts.map +1 -0
  232. package/build/types/integrations/http/get-request-url.d.ts +10 -0
  233. package/build/types/integrations/http/get-request-url.d.ts.map +1 -0
  234. package/build/types/integrations/http/index.d.ts +4 -0
  235. package/build/types/integrations/http/index.d.ts.map +1 -0
  236. package/build/types/integrations/http/inject-trace-propagation-headers.d.ts +12 -0
  237. package/build/types/integrations/http/inject-trace-propagation-headers.d.ts.map +1 -0
  238. package/build/types/integrations/http/types.d.ts +249 -0
  239. package/build/types/integrations/http/types.d.ts.map +1 -0
  240. package/build/types/integrations/postgresjs.d.ts.map +1 -1
  241. package/build/types/integrations/requestdata.d.ts.map +1 -1
  242. package/build/types/integrations/supabase.d.ts.map +1 -1
  243. package/build/types/logs/console-integration.d.ts.map +1 -1
  244. package/build/types/logs/envelope.d.ts +5 -2
  245. package/build/types/logs/envelope.d.ts.map +1 -1
  246. package/build/types/logs/internal.d.ts.map +1 -1
  247. package/build/types/metrics/envelope.d.ts +5 -2
  248. package/build/types/metrics/envelope.d.ts.map +1 -1
  249. package/build/types/metrics/internal.d.ts.map +1 -1
  250. package/build/types/server-runtime-client.d.ts +5 -0
  251. package/build/types/server-runtime-client.d.ts.map +1 -1
  252. package/build/types/tracing/idleSpan.d.ts.map +1 -1
  253. package/build/types/tracing/index.d.ts +1 -1
  254. package/build/types/tracing/index.d.ts.map +1 -1
  255. package/build/types/tracing/langchain/index.d.ts.map +1 -1
  256. package/build/types/tracing/langchain/types.d.ts +8 -0
  257. package/build/types/tracing/langchain/types.d.ts.map +1 -1
  258. package/build/types/tracing/langchain/utils.d.ts +2 -0
  259. package/build/types/tracing/langchain/utils.d.ts.map +1 -1
  260. package/build/types/tracing/langgraph/index.d.ts +4 -0
  261. package/build/types/tracing/langgraph/index.d.ts.map +1 -1
  262. package/build/types/tracing/langgraph/utils.d.ts +18 -2
  263. package/build/types/tracing/langgraph/utils.d.ts.map +1 -1
  264. package/build/types/tracing/spans/captureSpan.d.ts +13 -3
  265. package/build/types/tracing/spans/captureSpan.d.ts.map +1 -1
  266. package/build/types/tracing/spans/envelope.d.ts.map +1 -1
  267. package/build/types/tracing/trace.d.ts +1 -0
  268. package/build/types/tracing/trace.d.ts.map +1 -1
  269. package/build/types/tracing/vercel-ai/constants.d.ts +1 -0
  270. package/build/types/tracing/vercel-ai/constants.d.ts.map +1 -1
  271. package/build/types/tracing/vercel-ai/index.d.ts +9 -0
  272. package/build/types/tracing/vercel-ai/index.d.ts.map +1 -1
  273. package/build/types/trpc.d.ts.map +1 -1
  274. package/build/types/types-hoist/feedback/config.d.ts +20 -0
  275. package/build/types/types-hoist/feedback/config.d.ts.map +1 -1
  276. package/build/types/types-hoist/feedback/index.d.ts +2 -2
  277. package/build/types/types-hoist/feedback/index.d.ts.map +1 -1
  278. package/build/types/types-hoist/feedback/sendFeedback.d.ts +3 -0
  279. package/build/types/types-hoist/feedback/sendFeedback.d.ts.map +1 -1
  280. package/build/types/types-hoist/log.d.ts +5 -0
  281. package/build/types/types-hoist/log.d.ts.map +1 -1
  282. package/build/types/types-hoist/metric.d.ts +5 -0
  283. package/build/types/types-hoist/metric.d.ts.map +1 -1
  284. package/build/types/types-hoist/options.d.ts +37 -2
  285. package/build/types/types-hoist/options.d.ts.map +1 -1
  286. package/build/types/types-hoist/span.d.ts +5 -0
  287. package/build/types/types-hoist/span.d.ts.map +1 -1
  288. package/build/types/types-hoist/webfetchapi.d.ts +2 -0
  289. package/build/types/types-hoist/webfetchapi.d.ts.map +1 -1
  290. package/build/types/utils/baggage.d.ts +13 -0
  291. package/build/types/utils/baggage.d.ts.map +1 -1
  292. package/build/types/utils/get-default-export.d.ts +22 -0
  293. package/build/types/utils/get-default-export.d.ts.map +1 -0
  294. package/build/types/utils/normalizationHints.d.ts +9 -0
  295. package/build/types/utils/normalizationHints.d.ts.map +1 -0
  296. package/build/types/utils/normalize.d.ts.map +1 -1
  297. package/build/types/utils/object.d.ts +1 -1
  298. package/build/types/utils/object.d.ts.map +1 -1
  299. package/build/types/utils/request.d.ts +30 -0
  300. package/build/types/utils/request.d.ts.map +1 -1
  301. package/build/types/utils/should-ignore-span.d.ts +3 -1
  302. package/build/types/utils/should-ignore-span.d.ts.map +1 -1
  303. package/build/types/utils/spanUtils.d.ts +1 -1
  304. package/build/types-ts3.8/client.d.ts +12 -1
  305. package/build/types-ts3.8/index.d.ts +17 -6
  306. package/build/types-ts3.8/instrument/console.d.ts +2 -1
  307. package/build/types-ts3.8/instrument/fetch.d.ts +4 -2
  308. package/build/types-ts3.8/instrument/handlers.d.ts +2 -2
  309. package/build/types-ts3.8/integrations/express/utils.d.ts +1 -5
  310. package/build/types-ts3.8/integrations/http/add-outgoing-request-breadcrumb.d.ts +6 -0
  311. package/build/types-ts3.8/integrations/http/client-patch.d.ts +46 -0
  312. package/build/types-ts3.8/integrations/http/client-subscriptions.d.ts +21 -0
  313. package/build/types-ts3.8/integrations/http/constants.d.ts +6 -0
  314. package/build/types-ts3.8/integrations/http/double-wrap-warning.d.ts +4 -0
  315. package/build/types-ts3.8/integrations/http/get-outgoing-span-data.d.ts +13 -0
  316. package/build/types-ts3.8/integrations/http/get-request-url.d.ts +10 -0
  317. package/build/types-ts3.8/integrations/http/index.d.ts +4 -0
  318. package/build/types-ts3.8/integrations/http/inject-trace-propagation-headers.d.ts +12 -0
  319. package/build/types-ts3.8/integrations/http/types.d.ts +252 -0
  320. package/build/types-ts3.8/logs/envelope.d.ts +5 -2
  321. package/build/types-ts3.8/metrics/envelope.d.ts +5 -2
  322. package/build/types-ts3.8/server-runtime-client.d.ts +5 -0
  323. package/build/types-ts3.8/tracing/index.d.ts +1 -1
  324. package/build/types-ts3.8/tracing/langchain/types.d.ts +8 -0
  325. package/build/types-ts3.8/tracing/langchain/utils.d.ts +2 -0
  326. package/build/types-ts3.8/tracing/langgraph/index.d.ts +4 -0
  327. package/build/types-ts3.8/tracing/langgraph/utils.d.ts +18 -2
  328. package/build/types-ts3.8/tracing/spans/captureSpan.d.ts +13 -3
  329. package/build/types-ts3.8/tracing/trace.d.ts +1 -0
  330. package/build/types-ts3.8/tracing/vercel-ai/constants.d.ts +1 -0
  331. package/build/types-ts3.8/tracing/vercel-ai/index.d.ts +9 -0
  332. package/build/types-ts3.8/types-hoist/feedback/config.d.ts +20 -0
  333. package/build/types-ts3.8/types-hoist/feedback/index.d.ts +2 -2
  334. package/build/types-ts3.8/types-hoist/feedback/sendFeedback.d.ts +3 -0
  335. package/build/types-ts3.8/types-hoist/log.d.ts +5 -0
  336. package/build/types-ts3.8/types-hoist/metric.d.ts +5 -0
  337. package/build/types-ts3.8/types-hoist/options.d.ts +37 -2
  338. package/build/types-ts3.8/types-hoist/span.d.ts +5 -0
  339. package/build/types-ts3.8/types-hoist/webfetchapi.d.ts +2 -0
  340. package/build/types-ts3.8/utils/baggage.d.ts +13 -0
  341. package/build/types-ts3.8/utils/get-default-export.d.ts +22 -0
  342. package/build/types-ts3.8/utils/normalizationHints.d.ts +9 -0
  343. package/build/types-ts3.8/utils/object.d.ts +1 -1
  344. package/build/types-ts3.8/utils/request.d.ts +30 -0
  345. package/build/types-ts3.8/utils/should-ignore-span.d.ts +3 -1
  346. package/build/types-ts3.8/utils/spanUtils.d.ts +1 -1
  347. package/package.json +1 -1
@@ -168,11 +168,84 @@ function objectToBaggageHeader(object) {
168
168
  }, '');
169
169
  }
170
170
 
171
+ /**
172
+ * Merge two baggage headers into one.
173
+ * - Sentry-specific entries (keys starting with "sentry-") from the new
174
+ * baggage take precedence
175
+ * - Non-Sentry entries from existing baggage take precedence
176
+ *
177
+ * The order of the existing baggage will be preserved, and new entries will
178
+ * be added to the end.
179
+ *
180
+ * This matches the behavior of OTEL's propagation.inject() which uses
181
+ * `baggage.setEntry()` to overwrite existing entries with the same key.
182
+ */
183
+ function mergeBaggageHeaders(
184
+ existing,
185
+ incoming,
186
+ ) {
187
+ if (!existing) {
188
+ return incoming;
189
+ }
190
+
191
+ const existingEntries = parseBaggageHeader(existing);
192
+ const incomingEntries = parseBaggageHeader(incoming);
193
+
194
+ if (!incomingEntries) {
195
+ return existing;
196
+ }
197
+
198
+ // 1. All non-sentry entries from existing are kept
199
+ // 2. All sentry- entries from the new baggage are retained
200
+ // 3. If sentry- entries present in new, ignore from old, else keep from old.
201
+ // 4. Non-sentry entries from new are only kept if not in existing.
202
+
203
+ const merged = {};
204
+
205
+ // partition incoming entries into sentry and non-sentry prefixed
206
+ let hasNewSentryEntries = false;
207
+ const newSentryEntries = {};
208
+ const newNonSentryEntries = {};
209
+ for (const [key, value] of Object.entries(incomingEntries)) {
210
+ if (key.startsWith(SENTRY_BAGGAGE_KEY_PREFIX)) {
211
+ newSentryEntries[key] = value;
212
+ hasNewSentryEntries = true;
213
+ } else {
214
+ newNonSentryEntries[key] = value;
215
+ }
216
+ }
217
+
218
+ // If new baggage contains at least one sentry- value, we remove all old
219
+ // sentry- values otherwise, we keep old sentry- values. If we don't remove
220
+ // old sentry- values, we end up with an inconsistent dynamic sampling
221
+ // context propagation.
222
+ if (existingEntries) {
223
+ for (const [key, value] of Object.entries(existingEntries)) {
224
+ if (!hasNewSentryEntries || !key.startsWith(SENTRY_BAGGAGE_KEY_PREFIX)) {
225
+ merged[key] = value;
226
+ }
227
+ }
228
+ }
229
+
230
+ // Assign new sentry fields.
231
+ if (hasNewSentryEntries) {
232
+ Object.assign(merged, newSentryEntries);
233
+ }
234
+
235
+ // assign new non-sentry fields not found on existing object.
236
+ for (const [key, value] of Object.entries(newNonSentryEntries)) {
237
+ merged[key] ??= value;
238
+ }
239
+
240
+ return objectToBaggageHeader(merged);
241
+ }
242
+
171
243
  exports.MAX_BAGGAGE_STRING_LENGTH = MAX_BAGGAGE_STRING_LENGTH;
172
244
  exports.SENTRY_BAGGAGE_KEY_PREFIX = SENTRY_BAGGAGE_KEY_PREFIX;
173
245
  exports.SENTRY_BAGGAGE_KEY_PREFIX_REGEX = SENTRY_BAGGAGE_KEY_PREFIX_REGEX;
174
246
  exports.baggageHeaderToDynamicSamplingContext = baggageHeaderToDynamicSamplingContext;
175
247
  exports.dynamicSamplingContextToSentryBaggageHeader = dynamicSamplingContextToSentryBaggageHeader;
248
+ exports.mergeBaggageHeaders = mergeBaggageHeaders;
176
249
  exports.objectToBaggageHeader = objectToBaggageHeader;
177
250
  exports.parseBaggageHeader = parseBaggageHeader;
178
251
  //# sourceMappingURL=baggage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"baggage.js","sources":["../../../src/utils/baggage.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../debug-build';\nimport type { DynamicSamplingContext } from '../types-hoist/envelope';\nimport { debug } from './debug-logger';\nimport { isString } from './is';\n\nexport const SENTRY_BAGGAGE_KEY_PREFIX = 'sentry-';\n\nexport const SENTRY_BAGGAGE_KEY_PREFIX_REGEX = /^sentry-/;\n\n/**\n * Max length of a serialized baggage string\n *\n * https://www.w3.org/TR/baggage/#limits\n */\nexport const MAX_BAGGAGE_STRING_LENGTH = 8192;\n\n/**\n * Takes a baggage header and turns it into Dynamic Sampling Context, by extracting all the \"sentry-\" prefixed values\n * from it.\n *\n * @param baggageHeader A very bread definition of a baggage header as it might appear in various frameworks.\n * @returns The Dynamic Sampling Context that was found on `baggageHeader`, if there was any, `undefined` otherwise.\n */\nexport function baggageHeaderToDynamicSamplingContext(\n // Very liberal definition of what any incoming header might look like\n baggageHeader: string | string[] | number | null | undefined | boolean,\n): Partial<DynamicSamplingContext> | undefined {\n const baggageObject = parseBaggageHeader(baggageHeader);\n\n if (!baggageObject) {\n return undefined;\n }\n\n // Read all \"sentry-\" prefixed values out of the baggage object and put it onto a dynamic sampling context object.\n const dynamicSamplingContext = Object.entries(baggageObject).reduce<Record<string, string>>((acc, [key, value]) => {\n if (key.startsWith(SENTRY_BAGGAGE_KEY_PREFIX)) {\n const nonPrefixedKey = key.slice(SENTRY_BAGGAGE_KEY_PREFIX.length);\n acc[nonPrefixedKey] = value;\n }\n return acc;\n }, {});\n\n // Only return a dynamic sampling context object if there are keys in it.\n // A keyless object means there were no sentry values on the header, which means that there is no DSC.\n if (Object.keys(dynamicSamplingContext).length > 0) {\n return dynamicSamplingContext as Partial<DynamicSamplingContext>;\n } else {\n return undefined;\n }\n}\n\n/**\n * Turns a Dynamic Sampling Object into a baggage header by prefixing all the keys on the object with \"sentry-\".\n *\n * @param dynamicSamplingContext The Dynamic Sampling Context to turn into a header. For convenience and compatibility\n * with the `getDynamicSamplingContext` method on the Transaction class ,this argument can also be `undefined`. If it is\n * `undefined` the function will return `undefined`.\n * @returns a baggage header, created from `dynamicSamplingContext`, or `undefined` either if `dynamicSamplingContext`\n * was `undefined`, or if `dynamicSamplingContext` didn't contain any values.\n */\nexport function dynamicSamplingContextToSentryBaggageHeader(\n // this also takes undefined for convenience and bundle size in other places\n dynamicSamplingContext?: Partial<DynamicSamplingContext>,\n): string | undefined {\n if (!dynamicSamplingContext) {\n return undefined;\n }\n\n // Prefix all DSC keys with \"sentry-\" and put them into a new object\n const sentryPrefixedDSC = Object.entries(dynamicSamplingContext).reduce<Record<string, string>>(\n (acc, [dscKey, dscValue]) => {\n if (dscValue) {\n acc[`${SENTRY_BAGGAGE_KEY_PREFIX}${dscKey}`] = dscValue;\n }\n return acc;\n },\n {},\n );\n\n return objectToBaggageHeader(sentryPrefixedDSC);\n}\n\n/**\n * Take a baggage header and parse it into an object.\n */\nexport function parseBaggageHeader(\n baggageHeader: string | string[] | number | null | undefined | boolean,\n): Record<string, string> | undefined {\n if (!baggageHeader || (!isString(baggageHeader) && !Array.isArray(baggageHeader))) {\n return undefined;\n }\n\n if (Array.isArray(baggageHeader)) {\n // Combine all baggage headers into one object containing the baggage values so we can later read the Sentry-DSC-values from it\n return baggageHeader.reduce<Record<string, string>>((acc, curr) => {\n const currBaggageObject = baggageHeaderToObject(curr);\n Object.entries(currBaggageObject).forEach(([key, value]) => {\n acc[key] = value;\n });\n return acc;\n }, {});\n }\n\n return baggageHeaderToObject(baggageHeader);\n}\n\n/**\n * Will parse a baggage header, which is a simple key-value map, into a flat object.\n *\n * @param baggageHeader The baggage header to parse.\n * @returns a flat object containing all the key-value pairs from `baggageHeader`.\n */\nfunction baggageHeaderToObject(baggageHeader: string): Record<string, string> {\n return baggageHeader\n .split(',')\n .map(baggageEntry => {\n const eqIdx = baggageEntry.indexOf('=');\n if (eqIdx === -1) {\n // Likely an invalid entry\n return [];\n }\n const key = baggageEntry.slice(0, eqIdx);\n const value = baggageEntry.slice(eqIdx + 1);\n return [key, value].map(keyOrValue => {\n try {\n return decodeURIComponent(keyOrValue.trim());\n } catch {\n // We ignore errors here, e.g. if the value cannot be URL decoded.\n // This will then be skipped in the next step\n return;\n }\n });\n })\n .reduce<Record<string, string>>((acc, [key, value]) => {\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Turns a flat object (key-value pairs) into a baggage header, which is also just key-value pairs.\n *\n * @param object The object to turn into a baggage header.\n * @returns a baggage header string, or `undefined` if the object didn't have any values, since an empty baggage header\n * is not spec compliant.\n */\nexport function objectToBaggageHeader(object: Record<string, string>): string | undefined {\n if (Object.keys(object).length === 0) {\n // An empty baggage header is not spec compliant: We return undefined.\n return undefined;\n }\n\n return Object.entries(object).reduce((baggageHeader, [objectKey, objectValue], currentIndex) => {\n const baggageEntry = `${encodeURIComponent(objectKey)}=${encodeURIComponent(objectValue)}`;\n const newBaggageHeader = currentIndex === 0 ? baggageEntry : `${baggageHeader},${baggageEntry}`;\n if (newBaggageHeader.length > MAX_BAGGAGE_STRING_LENGTH) {\n DEBUG_BUILD &&\n debug.warn(\n `Not adding key: ${objectKey} with val: ${objectValue} to baggage header due to exceeding baggage size limits.`,\n );\n return baggageHeader;\n } else {\n return newBaggageHeader;\n }\n }, '');\n}\n"],"names":["isString","DEBUG_BUILD","debug"],"mappings":";;;;;;AAKO,MAAM,yBAAA,GAA4B;;AAElC,MAAM,+BAAA,GAAkC;;AAE/C;AACA;AACA;AACA;AACA;AACO,MAAM,yBAAA,GAA4B;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,qCAAqC;AACrD;AACA,EAAE,aAAa;AACf,EAA+C;AAC/C,EAAE,MAAM,aAAA,GAAgB,kBAAkB,CAAC,aAAa,CAAC;;AAEzD,EAAE,IAAI,CAAC,aAAa,EAAE;AACtB,IAAI,OAAO,SAAS;AACpB,EAAE;;AAEF;AACA,EAAE,MAAM,yBAAyB,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,MAAM,CAAyB,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AACrH,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,yBAAyB,CAAC,EAAE;AACnD,MAAM,MAAM,cAAA,GAAiB,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,MAAM,CAAC;AACxE,MAAM,GAAG,CAAC,cAAc,CAAA,GAAI,KAAK;AACjC,IAAI;AACJ,IAAI,OAAO,GAAG;AACd,EAAE,CAAC,EAAE,EAAE,CAAC;;AAER;AACA;AACA,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,MAAA,GAAS,CAAC,EAAE;AACt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A,EAAA;AACA;AACA,IAAA,OAAA,SAAA;AACA,EAAA;;AAEA,EAAA,OAAA,MAAA,CAAA,OAAA,CAAA,MAAA,CAAA,CAAA,MAAA,CAAA,CAAA,aAAA,EAAA,CAAA,SAAA,EAAA,WAAA,CAAA,EAAA,YAAA,KAAA;AACA,IAAA,MAAA,YAAA,GAAA,CAAA,EAAA,kBAAA,CAAA,SAAA,CAAA,CAAA,CAAA,EAAA,kBAAA,CAAA,WAAA,CAAA,CAAA,CAAA;AACA,IAAA,MAAA,gBAAA,GAAA,YAAA,KAAA,CAAA,GAAA,YAAA,GAAA,CAAA,EAAA,aAAA,CAAA,CAAA,EAAA,YAAA,CAAA,CAAA;AACA,IAAA,IAAA,gBAAA,CAAA,MAAA,GAAA,yBAAA,EAAA;AACA,MAAAC,sBAAA;AACA,QAAAC,iBAAA,CAAA,IAAA;AACA,UAAA,CAAA,gBAAA,EAAA,SAAA,CAAA,WAAA,EAAA,WAAA,CAAA,wDAAA,CAAA;AACA,SAAA;AACA,MAAA,OAAA,aAAA;AACA,IAAA,CAAA,MAAA;AACA,MAAA,OAAA,gBAAA;AACA,IAAA;AACA,EAAA,CAAA,EAAA,EAAA,CAAA;AACA;;;;;;;;;;"}
1
+ {"version":3,"file":"baggage.js","sources":["../../../src/utils/baggage.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../debug-build';\nimport type { DynamicSamplingContext } from '../types-hoist/envelope';\nimport { debug } from './debug-logger';\nimport { isString } from './is';\n\nexport const SENTRY_BAGGAGE_KEY_PREFIX = 'sentry-';\n\nexport const SENTRY_BAGGAGE_KEY_PREFIX_REGEX = /^sentry-/;\n\n/**\n * Max length of a serialized baggage string\n *\n * https://www.w3.org/TR/baggage/#limits\n */\nexport const MAX_BAGGAGE_STRING_LENGTH = 8192;\n\n/**\n * Takes a baggage header and turns it into Dynamic Sampling Context, by extracting all the \"sentry-\" prefixed values\n * from it.\n *\n * @param baggageHeader A very bread definition of a baggage header as it might appear in various frameworks.\n * @returns The Dynamic Sampling Context that was found on `baggageHeader`, if there was any, `undefined` otherwise.\n */\nexport function baggageHeaderToDynamicSamplingContext(\n // Very liberal definition of what any incoming header might look like\n baggageHeader: string | string[] | number | null | undefined | boolean,\n): Partial<DynamicSamplingContext> | undefined {\n const baggageObject = parseBaggageHeader(baggageHeader);\n\n if (!baggageObject) {\n return undefined;\n }\n\n // Read all \"sentry-\" prefixed values out of the baggage object and put it onto a dynamic sampling context object.\n const dynamicSamplingContext = Object.entries(baggageObject).reduce<Record<string, string>>((acc, [key, value]) => {\n if (key.startsWith(SENTRY_BAGGAGE_KEY_PREFIX)) {\n const nonPrefixedKey = key.slice(SENTRY_BAGGAGE_KEY_PREFIX.length);\n acc[nonPrefixedKey] = value;\n }\n return acc;\n }, {});\n\n // Only return a dynamic sampling context object if there are keys in it.\n // A keyless object means there were no sentry values on the header, which means that there is no DSC.\n if (Object.keys(dynamicSamplingContext).length > 0) {\n return dynamicSamplingContext as Partial<DynamicSamplingContext>;\n } else {\n return undefined;\n }\n}\n\n/**\n * Turns a Dynamic Sampling Object into a baggage header by prefixing all the keys on the object with \"sentry-\".\n *\n * @param dynamicSamplingContext The Dynamic Sampling Context to turn into a header. For convenience and compatibility\n * with the `getDynamicSamplingContext` method on the Transaction class ,this argument can also be `undefined`. If it is\n * `undefined` the function will return `undefined`.\n * @returns a baggage header, created from `dynamicSamplingContext`, or `undefined` either if `dynamicSamplingContext`\n * was `undefined`, or if `dynamicSamplingContext` didn't contain any values.\n */\nexport function dynamicSamplingContextToSentryBaggageHeader(\n // this also takes undefined for convenience and bundle size in other places\n dynamicSamplingContext?: Partial<DynamicSamplingContext>,\n): string | undefined {\n if (!dynamicSamplingContext) {\n return undefined;\n }\n\n // Prefix all DSC keys with \"sentry-\" and put them into a new object\n const sentryPrefixedDSC = Object.entries(dynamicSamplingContext).reduce<Record<string, string>>(\n (acc, [dscKey, dscValue]) => {\n if (dscValue) {\n acc[`${SENTRY_BAGGAGE_KEY_PREFIX}${dscKey}`] = dscValue;\n }\n return acc;\n },\n {},\n );\n\n return objectToBaggageHeader(sentryPrefixedDSC);\n}\n\n/**\n * Take a baggage header and parse it into an object.\n */\nexport function parseBaggageHeader(\n baggageHeader: string | string[] | number | null | undefined | boolean,\n): Record<string, string> | undefined {\n if (!baggageHeader || (!isString(baggageHeader) && !Array.isArray(baggageHeader))) {\n return undefined;\n }\n\n if (Array.isArray(baggageHeader)) {\n // Combine all baggage headers into one object containing the baggage values so we can later read the Sentry-DSC-values from it\n return baggageHeader.reduce<Record<string, string>>((acc, curr) => {\n const currBaggageObject = baggageHeaderToObject(curr);\n Object.entries(currBaggageObject).forEach(([key, value]) => {\n acc[key] = value;\n });\n return acc;\n }, {});\n }\n\n return baggageHeaderToObject(baggageHeader);\n}\n\n/**\n * Will parse a baggage header, which is a simple key-value map, into a flat object.\n *\n * @param baggageHeader The baggage header to parse.\n * @returns a flat object containing all the key-value pairs from `baggageHeader`.\n */\nfunction baggageHeaderToObject(baggageHeader: string): Record<string, string> {\n return baggageHeader\n .split(',')\n .map(baggageEntry => {\n const eqIdx = baggageEntry.indexOf('=');\n if (eqIdx === -1) {\n // Likely an invalid entry\n return [];\n }\n const key = baggageEntry.slice(0, eqIdx);\n const value = baggageEntry.slice(eqIdx + 1);\n return [key, value].map(keyOrValue => {\n try {\n return decodeURIComponent(keyOrValue.trim());\n } catch {\n // We ignore errors here, e.g. if the value cannot be URL decoded.\n // This will then be skipped in the next step\n return;\n }\n });\n })\n .reduce<Record<string, string>>((acc, [key, value]) => {\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Turns a flat object (key-value pairs) into a baggage header, which is also just key-value pairs.\n *\n * @param object The object to turn into a baggage header.\n * @returns a baggage header string, or `undefined` if the object didn't have any values, since an empty baggage header\n * is not spec compliant.\n */\nexport function objectToBaggageHeader(object: Record<string, string>): string | undefined {\n if (Object.keys(object).length === 0) {\n // An empty baggage header is not spec compliant: We return undefined.\n return undefined;\n }\n\n return Object.entries(object).reduce((baggageHeader, [objectKey, objectValue], currentIndex) => {\n const baggageEntry = `${encodeURIComponent(objectKey)}=${encodeURIComponent(objectValue)}`;\n const newBaggageHeader = currentIndex === 0 ? baggageEntry : `${baggageHeader},${baggageEntry}`;\n if (newBaggageHeader.length > MAX_BAGGAGE_STRING_LENGTH) {\n DEBUG_BUILD &&\n debug.warn(\n `Not adding key: ${objectKey} with val: ${objectValue} to baggage header due to exceeding baggage size limits.`,\n );\n return baggageHeader;\n } else {\n return newBaggageHeader;\n }\n }, '');\n}\n\n/**\n * Merge two baggage headers into one.\n * - Sentry-specific entries (keys starting with \"sentry-\") from the new\n * baggage take precedence\n * - Non-Sentry entries from existing baggage take precedence\n *\n * The order of the existing baggage will be preserved, and new entries will\n * be added to the end.\n *\n * This matches the behavior of OTEL's propagation.inject() which uses\n * `baggage.setEntry()` to overwrite existing entries with the same key.\n */\nexport function mergeBaggageHeaders<Existing extends string | string[] | number | undefined>(\n existing: Existing,\n incoming: string,\n): string | undefined | Existing {\n if (!existing) {\n return incoming;\n }\n\n const existingEntries = parseBaggageHeader(existing);\n const incomingEntries = parseBaggageHeader(incoming);\n\n if (!incomingEntries) {\n return existing;\n }\n\n // 1. All non-sentry entries from existing are kept\n // 2. All sentry- entries from the new baggage are retained\n // 3. If sentry- entries present in new, ignore from old, else keep from old.\n // 4. Non-sentry entries from new are only kept if not in existing.\n\n const merged: Record<string, string> = {};\n\n // partition incoming entries into sentry and non-sentry prefixed\n let hasNewSentryEntries = false;\n const newSentryEntries: Record<string, string> = {};\n const newNonSentryEntries: Record<string, string> = {};\n for (const [key, value] of Object.entries(incomingEntries)) {\n if (key.startsWith(SENTRY_BAGGAGE_KEY_PREFIX)) {\n newSentryEntries[key] = value;\n hasNewSentryEntries = true;\n } else {\n newNonSentryEntries[key] = value;\n }\n }\n\n // If new baggage contains at least one sentry- value, we remove all old\n // sentry- values otherwise, we keep old sentry- values. If we don't remove\n // old sentry- values, we end up with an inconsistent dynamic sampling\n // context propagation.\n if (existingEntries) {\n for (const [key, value] of Object.entries(existingEntries)) {\n if (!hasNewSentryEntries || !key.startsWith(SENTRY_BAGGAGE_KEY_PREFIX)) {\n merged[key] = value;\n }\n }\n }\n\n // Assign new sentry fields.\n if (hasNewSentryEntries) {\n Object.assign(merged, newSentryEntries);\n }\n\n // assign new non-sentry fields not found on existing object.\n for (const [key, value] of Object.entries(newNonSentryEntries)) {\n merged[key] ??= value;\n }\n\n return objectToBaggageHeader(merged);\n}\n"],"names":["isString","DEBUG_BUILD","debug"],"mappings":";;;;;;AAKO,MAAM,yBAAA,GAA4B;;AAElC,MAAM,+BAAA,GAAkC;;AAE/C;AACA;AACA;AACA;AACA;AACO,MAAM,yBAAA,GAA4B;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,qCAAqC;AACrD;AACA,EAAE,aAAa;AACf,EAA+C;AAC/C,EAAE,MAAM,aAAA,GAAgB,kBAAkB,CAAC,aAAa,CAAC;;AAEzD,EAAE,IAAI,CAAC,aAAa,EAAE;AACtB,IAAI,OAAO,SAAS;AACpB,EAAE;;AAEF;AACA,EAAE,MAAM,yBAAyB,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,MAAM,CAAyB,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AACrH,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,yBAAyB,CAAC,EAAE;AACnD,MAAM,MAAM,cAAA,GAAiB,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,MAAM,CAAC;AACxE,MAAM,GAAG,CAAC,cAAc,CAAA,GAAI,KAAK;AACjC,IAAI;AACJ,IAAI,OAAO,GAAG;AACd,EAAE,CAAC,EAAE,EAAE,CAAC;;AAER;AACA;AACA,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,MAAA,GAAS,CAAC,EAAE;AACtD,IAAI,OAAO,sBAAA;AACX,EAAE,OAAO;AACT,IAAI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GAAA,EAAA;AACA,EAAA,KAAA,MAAA,CAAA,GAAA,EAAA,KAAA,CAAA,IAAA,MAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA;AACA,IAAA,IAAA,GAAA,CAAA,UAAA,CAAA,yBAAA,CAAA,EAAA;AACA,MAAA,gBAAA,CAAA,GAAA,CAAA,GAAA,KAAA;AACA,MAAA,mBAAA,GAAA,IAAA;AACA,IAAA,CAAA,MAAA;AACA,MAAA,mBAAA,CAAA,GAAA,CAAA,GAAA,KAAA;AACA,IAAA;AACA,EAAA;;AAEA;AACA;AACA;AACA;AACA,EAAA,IAAA,eAAA,EAAA;AACA,IAAA,KAAA,MAAA,CAAA,GAAA,EAAA,KAAA,CAAA,IAAA,MAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA;AACA,MAAA,IAAA,CAAA,mBAAA,IAAA,CAAA,GAAA,CAAA,UAAA,CAAA,yBAAA,CAAA,EAAA;AACA,QAAA,MAAA,CAAA,GAAA,CAAA,GAAA,KAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;;AAEA;AACA,EAAA,IAAA,mBAAA,EAAA;AACA,IAAA,MAAA,CAAA,MAAA,CAAA,MAAA,EAAA,gBAAA,CAAA;AACA,EAAA;;AAEA;AACA,EAAA,KAAA,MAAA,CAAA,GAAA,EAAA,KAAA,CAAA,IAAA,MAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA;AACA,IAAA,MAAA,CAAA,GAAA,CAAA,KAAA,KAAA;AACA,EAAA;;AAEA,EAAA,OAAA,qBAAA,CAAA,MAAA,CAAA;AACA;;;;;;;;;;;"}
@@ -31,6 +31,7 @@ const chainAndCopyPromiseLike = (
31
31
 
32
32
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
33
  const copyProps = (original, chained) => {
34
+ if (!chained) return original;
34
35
  let mutated = false;
35
36
  //oxlint-disable-next-line guard-for-in
36
37
  for (const key in original) {
@@ -1 +1 @@
1
- {"version":3,"file":"chain-and-copy-promiselike.js","sources":["../../../src/utils/chain-and-copy-promiselike.ts"],"sourcesContent":["const isActualPromise = (p: unknown) =>\n p instanceof Promise && !(p as unknown as ChainedPromiseLike<unknown>)[kChainedCopy];\n\ntype ChainedPromiseLike<T> = PromiseLike<T> & {\n [kChainedCopy]: true;\n};\nconst kChainedCopy = Symbol('chained PromiseLike');\n\n/**\n * Copy the properties from a decorated promiselike object onto its chained\n * actual promise.\n */\nexport const chainAndCopyPromiseLike = <V, T extends PromiseLike<V>>(\n original: T,\n onSuccess: (value: V) => void,\n onError: (e: unknown) => void,\n): T => {\n const chained = original.then(\n value => {\n onSuccess(value);\n return value;\n },\n err => {\n onError(err);\n throw err;\n },\n ) as T;\n\n // if we're just dealing with \"normal\" Promise objects, return the chain\n return isActualPromise(chained) && isActualPromise(original) ? chained : copyProps(original, chained);\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst copyProps = <T extends Record<string, any>>(original: T, chained: T): T => {\n let mutated = false;\n //oxlint-disable-next-line guard-for-in\n for (const key in original) {\n if (key in chained) continue;\n mutated = true;\n const value = original[key];\n if (typeof value === 'function') {\n Object.defineProperty(chained, key, {\n value: (...args: unknown[]) => value.apply(original, args),\n enumerable: true,\n configurable: true,\n writable: true,\n });\n } else {\n (chained as Record<string, unknown>)[key] = value;\n }\n }\n\n if (mutated) Object.assign(chained, { [kChainedCopy]: true });\n return chained;\n};\n"],"names":[],"mappings":";;AAAA,MAAM,eAAA,GAAkB,CAAC,CAAC;AAC1B,EAAE,CAAA,YAAa,OAAA,IAAW,CAAC,CAAC,CAAA,GAA6C,YAAY,CAAC;;AAKtF,MAAM,YAAA,GAAe,MAAM,CAAC,qBAAqB,CAAC;;AAElD;AACA;AACA;AACA;AACO,MAAM,0BAA0B;AACvC,EAAE,QAAQ;AACV,EAAE,SAAS;AACX,EAAE,OAAO;AACT,KAAQ;AACR,EAAE,MAAM,OAAA,GAAU,QAAQ,CAAC,IAAI;AAC/B,IAAI,SAAS;AACb,MAAM,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ent":["const isActualPromise = (p: unknown) =>\n p instanceof Promise && !(p as unknown as ChainedPromiseLike<unknown>)[kChainedCopy];\n\ntype ChainedPromiseLike<T> = PromiseLike<T> & {\n [kChainedCopy]: true;\n};\nconst kChainedCopy = Symbol('chained PromiseLike');\n\n/**\n * Copy the properties from a decorated promiselike object onto its chained\n * actual promise.\n */\nexport const chainAndCopyPromiseLike = <V, T extends PromiseLike<V>>(\n original: T,\n onSuccess: (value: V) => void,\n onError: (e: unknown) => void,\n): T => {\n const chained = original.then(\n value => {\n onSuccess(value);\n return value;\n },\n err => {\n onError(err);\n throw err;\n },\n ) as T;\n\n // if we're just dealing with \"normal\" Promise objects, return the chain\n return isActualPromise(chained) && isActualPromise(original) ? chained : copyProps(original, chained);\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst copyProps = <T extends Record<string, any>>(original: T, chained: T): T => {\n if (!chained) return original;\n let mutated = false;\n //oxlint-disable-next-line guard-for-in\n for (const key in original) {\n if (key in chained) continue;\n mutated = true;\n const value = original[key];\n if (typeof value === 'function') {\n Object.defineProperty(chained, key, {\n value: (...args: unknown[]) => value.apply(original, args),\n enumerable: true,\n configurable: true,\n writable: true,\n });\n } else {\n (chained as Record<string, unknown>)[key] = value;\n }\n }\n\n if (mutated) Object.assign(chained, { [kChainedCopy]: true });\n return chained;\n};\n"],"names":[],"mappings":";;AAAA,MAAM,eAAA,GAAkB,CAAC,CAAC;AAC1B,EAAE,CAAA,YAAa,OAAA,IAAW,CAAC,CAAC,CAAA,GAA6C,YAAY,CAAC;;AAKtF,MAAM,YAAA,GAAe,MAAM,CAAC,qBAAqB,CAAC;;AAElD;AACA;AACA;AACA;AACO,MAAM,0BAA0B;AACvC,EAAE,QAAQ;AACV,EAAE,SAAS;AACX,EAAE,OAAO;AACT,KAAQ;AACR,EAAE,MAAM,OAAA,GAAU,QAAQ,CAAC,IAAI;AAC/B,IAAI,SAAS;AACb,MAAM,SAAS,CAAC,KAAK,CAAC;AACtB,MAAM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});
2
+
3
+ /**
4
+ * Often we patch a module's default export, but we want to be able to do
5
+ * something like this:
6
+ *
7
+ * ```ts
8
+ * patchTheThing(await import('the-thing'));
9
+ * ```
10
+ *
11
+ * Or like this:
12
+ *
13
+ * ```ts
14
+ * import theThing from 'the-thing';
15
+ * patchTheThing(theThing);
16
+ * ```
17
+ *
18
+ * Note: this does not support modules with a falsey default export. However,
19
+ * presumably in those cases, there's no default export to patch anyway.
20
+ */
21
+ function getDefaultExport(moduleExport) {
22
+ return (
23
+ (!!moduleExport &&
24
+ typeof moduleExport === 'object' &&
25
+ 'default' in moduleExport &&
26
+ (moduleExport ).default) ||
27
+ (moduleExport )
28
+ );
29
+ }
30
+
31
+ exports.getDefaultExport = getDefaultExport;
32
+ //# sourceMappingURL=get-default-export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-default-export.js","sources":["../../../src/utils/get-default-export.ts"],"sourcesContent":["/**\n * Often we patch a module's default export, but we want to be able to do\n * something like this:\n *\n * ```ts\n * patchTheThing(await import('the-thing'));\n * ```\n *\n * Or like this:\n *\n * ```ts\n * import theThing from 'the-thing';\n * patchTheThing(theThing);\n * ```\n *\n * Note: this does not support modules with a falsey default export. However,\n * presumably in those cases, there's no default export to patch anyway.\n */\nexport function getDefaultExport<T>(moduleExport: T | { default: T }): T {\n return (\n (!!moduleExport &&\n typeof moduleExport === 'object' &&\n 'default' in moduleExport &&\n (moduleExport as { default: T }).default) ||\n (moduleExport as T)\n );\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAI,YAAY,EAAyB;AACzE,EAAE;AACF,IAAI,CAAC,CAAC,CAAC,YAAA;AACP,MAAM,OAAO,YAAA,KAAiB,QAAA;AAC9B,MAAM,SAAA,IAAa,YAAA;AACnB,MAAM,CAAC,YAAA,GAAgC,OAAO;AAC9C,KAAK,YAAA;AACL;AACA;;;;"}
@@ -32,7 +32,15 @@ function checkDsn(url$1, dsn) {
32
32
  return false;
33
33
  }
34
34
 
35
- return dsn ? urlParts.host.includes(dsn.host) && /(^|&|\?)sentry_key=/.test(urlParts.search) : false;
35
+ if (!dsn) {
36
+ return false;
37
+ }
38
+
39
+ return hostnameMatchesDsnHost(urlParts.hostname, dsn.host) && /(^|&|\?)sentry_key=/.test(urlParts.search);
40
+ }
41
+
42
+ function hostnameMatchesDsnHost(hostname, dsnHost) {
43
+ return hostname === dsnHost || (dsnHost.length > 0 && hostname.endsWith(`.${dsnHost}`));
36
44
  }
37
45
 
38
46
  function removeTrailingSlash(str) {
@@ -1 +1 @@
1
- {"version":3,"file":"isSentryRequestUrl.js","sources":["../../../src/utils/isSentryRequestUrl.ts"],"sourcesContent":["import type { Client } from '../client';\nimport type { DsnComponents } from '../types-hoist/dsn';\nimport { isURLObjectRelative, parseStringToURLObject } from './url';\n\n/**\n * Checks whether given url points to Sentry server\n *\n * @param url url to verify\n */\nexport function isSentryRequestUrl(url: string, client: Client | undefined): boolean {\n const dsn = client?.getDsn();\n const tunnel = client?.getOptions().tunnel;\n return checkDsn(url, dsn) || checkTunnel(url, tunnel);\n}\n\nfunction checkTunnel(url: string, tunnel: string | undefined): boolean {\n if (!tunnel) {\n return false;\n }\n\n return removeTrailingSlash(url) === removeTrailingSlash(tunnel);\n}\n\nfunction checkDsn(url: string, dsn: DsnComponents | undefined): boolean {\n // Requests to Sentry's ingest endpoint must have a `sentry_key` in the query string\n // This is equivalent to the public_key which is required in the DSN\n // see https://develop.sentry.dev/sdk/overview/#parsing-the-dsn\n // Therefore, a request to the same host and with a `sentry_key` in the query string\n // can be considered a request to the ingest endpoint.\n const urlParts = parseStringToURLObject(url);\n if (!urlParts || isURLObjectRelative(urlParts)) {\n return false;\n }\n\n return dsn ? urlParts.host.includes(dsn.host) && /(^|&|\\?)sentry_key=/.test(urlParts.search) : false;\n}\n\nfunction removeTrailingSlash(str: string): string {\n return str[str.length - 1] === '/' ? str.slice(0, -1) : str;\n}\n"],"names":["url","parseStringToURLObject","isURLObjectRelative"],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,GAAG,EAAU,MAAM,EAA+B;AACrF,EAAE,MAAM,GAAA,GAAM,MAAM,EAAE,MAAM,EAAE;AAC9B,EAAE,MAAM,SAAS,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM;AAC5C,EAAE,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA,IAAK,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC;AACvD;;AAEA,SAAS,WAAW,CAAC,GAAG,EAAU,MAAM,EAA+B;AACvE,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,OAAO,mBAAmB,CAAC,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC;AACjE;;AAEA,SAAS,QAAQ,CAACA,KAAG,EAAU,GAAG,EAAsC;AACxE;AACA;AACA;AACA;AACA;AACA,EAAE,MAAM,QAAA,GAAWC,0BAAsB,CAACD,KAAG,CAAC;AAC9C,EAAE,IAAI,CAAC,QAAA,IAAYE,uBAAmB,CAAC,QAAQ,CAAC,EAAE;AAClD,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAA,IAAK,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAA,GAAI,KAAK;AACtG;;AAEA,SAAS,mBAAmB,CAAC,GAAG,EAAkB;AAClD,EAAE,OAAO,GAAG,CAAC,GAAG,CAAC,MAAA,GAAS,CAAC,CAAA,KAAM,GAAA,GAAM,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAA,GAAI,GAAG;AAC7D;;;;"}
1
+ {"version":3,"file":"isSentryRequestUrl.js","sources":["../../../src/utils/isSentryRequestUrl.ts"],"sourcesContent":["import type { Client } from '../client';\nimport type { DsnComponents } from '../types-hoist/dsn';\nimport { isURLObjectRelative, parseStringToURLObject } from './url';\n\n/**\n * Checks whether given url points to Sentry server\n *\n * @param url url to verify\n */\nexport function isSentryRequestUrl(url: string, client: Client | undefined): boolean {\n const dsn = client?.getDsn();\n const tunnel = client?.getOptions().tunnel;\n return checkDsn(url, dsn) || checkTunnel(url, tunnel);\n}\n\nfunction checkTunnel(url: string, tunnel: string | undefined): boolean {\n if (!tunnel) {\n return false;\n }\n\n return removeTrailingSlash(url) === removeTrailingSlash(tunnel);\n}\n\nfunction checkDsn(url: string, dsn: DsnComponents | undefined): boolean {\n // Requests to Sentry's ingest endpoint must have a `sentry_key` in the query string\n // This is equivalent to the public_key which is required in the DSN\n // see https://develop.sentry.dev/sdk/overview/#parsing-the-dsn\n // Therefore, a request to the same host and with a `sentry_key` in the query string\n // can be considered a request to the ingest endpoint.\n const urlParts = parseStringToURLObject(url);\n if (!urlParts || isURLObjectRelative(urlParts)) {\n return false;\n }\n\n if (!dsn) {\n return false;\n }\n\n return hostnameMatchesDsnHost(urlParts.hostname, dsn.host) && /(^|&|\\?)sentry_key=/.test(urlParts.search);\n}\n\nfunction hostnameMatchesDsnHost(hostname: string, dsnHost: string): boolean {\n return hostname === dsnHost || (dsnHost.length > 0 && hostname.endsWith(`.${dsnHost}`));\n}\n\nfunction removeTrailingSlash(str: string): string {\n return str[str.length - 1] === '/' ? str.slice(0, -1) : str;\n}\n"],"names":["url","parseStringToURLObject","isURLObjectRelative"],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,GAAG,EAAU,MAAM,EAA+B;AACrF,EAAE,MAAM,GAAA,GAAM,MAAM,EAAE,MAAM,EAAE;AAC9B,EAAE,MAAM,SAAS,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM;AAC5C,EAAE,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA,IAAK,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC;AACvD;;AAEA,SAAS,WAAW,CAAC,GAAG,EAAU,MAAM,EAA+B;AACvE,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,OAAO,mBAAmB,CAAC,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC;AACjE;;AAEA,SAAS,QAAQ,CAACA,KAAG,EAAU,GAAG,EAAsC;AACxE;AACA;AACA;AACA;AACA;AACA,EAAE,MAAM,QAAA,GAAWC,0BAAsB,CAACD,KAAG,CAAC;AAC9C,EAAE,IAAI,CAAC,QAAA,IAAYE,uBAAmB,CAAC,QAAQ,CAAC,EAAE;AAClD,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,IAAI,CAAC,GAAG,EAAE;AACZ,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,OAAO,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAA,IAAK,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AAC3G;;AAEA,SAAS,sBAAsB,CAAC,QAAQ,EAAU,OAAO,EAAmB;AAC5E,EAAE,OAAO,aAAa,OAAA,KAAY,OAAO,CAAC,MAAA,GAAS,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA,CAAA,CAAA;AACA;;AAEA,SAAA,mBAAA,CAAA,GAAA,EAAA;AACA,EAAA,OAAA,GAAA,CAAA,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,KAAA,GAAA,GAAA,GAAA,CAAA,KAAA,CAAA,CAAA,EAAA,EAAA,CAAA,GAAA,GAAA;AACA;;;;"}
@@ -0,0 +1,38 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const object = require('./object.js');
4
+
5
+ /**
6
+ * Internal symbols for normalization behavior. JSON and other structured user payloads cannot
7
+ * carry these keys, so they cannot spoof SDK-only normalization hints.
8
+ * We use Symbol.for to ensure that the symbols are the same across different modules/files.
9
+ */
10
+ const SENTRY_SKIP_NORMALIZATION = Symbol.for('sentry.skipNormalization');
11
+ const SENTRY_OVERRIDE_NORMALIZATION_DEPTH = Symbol.for('sentry.overrideNormalizationDepth');
12
+
13
+ /** Marks an object so `normalize` returns it unchanged (already-normalized SDK data). */
14
+ function setSkipNormalizationHint(obj) {
15
+ object.addNonEnumerableProperty(obj, SENTRY_SKIP_NORMALIZATION, true);
16
+ }
17
+
18
+ /** Overrides remaining normalization depth from this object downward (e.g. Redux / Pinia state). */
19
+ function setNormalizationDepthOverrideHint(obj, depth) {
20
+ object.addNonEnumerableProperty(obj, SENTRY_OVERRIDE_NORMALIZATION_DEPTH, depth);
21
+ }
22
+
23
+ /** @internal */
24
+ function hasSkipNormalizationHint(value) {
25
+ return Boolean((value )[SENTRY_SKIP_NORMALIZATION]);
26
+ }
27
+
28
+ /** @internal */
29
+ function getNormalizationDepthOverrideHint(value) {
30
+ const v = (value )[SENTRY_OVERRIDE_NORMALIZATION_DEPTH];
31
+ return typeof v === 'number' ? v : undefined;
32
+ }
33
+
34
+ exports.getNormalizationDepthOverrideHint = getNormalizationDepthOverrideHint;
35
+ exports.hasSkipNormalizationHint = hasSkipNormalizationHint;
36
+ exports.setNormalizationDepthOverrideHint = setNormalizationDepthOverrideHint;
37
+ exports.setSkipNormalizationHint = setSkipNormalizationHint;
38
+ //# sourceMappingURL=normalizationHints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizationHints.js","sources":["../../../src/utils/normalizationHints.ts"],"sourcesContent":["import { addNonEnumerableProperty } from './object';\n\n/**\n * Internal symbols for normalization behavior. JSON and other structured user payloads cannot\n * carry these keys, so they cannot spoof SDK-only normalization hints.\n * We use Symbol.for to ensure that the symbols are the same across different modules/files.\n */\nconst SENTRY_SKIP_NORMALIZATION = Symbol.for('sentry.skipNormalization');\nconst SENTRY_OVERRIDE_NORMALIZATION_DEPTH = Symbol.for('sentry.overrideNormalizationDepth');\n\n/** Marks an object so `normalize` returns it unchanged (already-normalized SDK data). */\nexport function setSkipNormalizationHint(obj: object): void {\n addNonEnumerableProperty(obj, SENTRY_SKIP_NORMALIZATION, true);\n}\n\n/** Overrides remaining normalization depth from this object downward (e.g. Redux / Pinia state). */\nexport function setNormalizationDepthOverrideHint(obj: object, depth: number): void {\n addNonEnumerableProperty(obj, SENTRY_OVERRIDE_NORMALIZATION_DEPTH, depth);\n}\n\n/** @internal */\nexport function hasSkipNormalizationHint(value: object) {\n return Boolean((value as Record<symbol, unknown>)[SENTRY_SKIP_NORMALIZATION]);\n}\n\n/** @internal */\nexport function getNormalizationDepthOverrideHint(value: object): number | undefined {\n const v = (value as Record<symbol, unknown>)[SENTRY_OVERRIDE_NORMALIZATION_DEPTH];\n return typeof v === 'number' ? v : undefined;\n}\n"],"names":["addNonEnumerableProperty"],"mappings":";;;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAM,4BAA4B,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC;AACxE,MAAM,sCAAsC,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC;;AAE3F;AACO,SAAS,wBAAwB,CAAC,GAAG,EAAgB;AAC5D,EAAEA,+BAAwB,CAAC,GAAG,EAAE,yBAAyB,EAAE,IAAI,CAAC;AAChE;;AAEA;AACO,SAAS,iCAAiC,CAAC,GAAG,EAAU,KAAK,EAAgB;AACpF,EAAEA,+BAAwB,CAAC,GAAG,EAAE,mCAAmC,EAAE,KAAK,CAAC;AAC3E;;AAEA;AACO,SAAS,wBAAwB,CAAC,KAAK,EAAU;AACxD,EAAE,OAAO,OAAO,CAAC,CAAC,QAAkC,yBAAyB,CAAC,CAAC;AAC/E;;AAEA;AACO,SAAS,iCAAiC,CAAC,KAAK,EAA8B;AACrF,EAAE,MAAM,IAAI,CAAC,QAAkC,mCAAmC,CAAC;AACnF,EAAE,OAAO,OAAO,CAAA,KAAM,WAAW,CAAA,GAAI,SAAS;AAC9C;;;;;;;"}
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const is = require('./is.js');
4
+ const normalizationHints = require('./normalizationHints.js');
4
5
  const object = require('./object.js');
5
6
  const stacktrace = require('./stacktrace.js');
6
7
 
@@ -88,20 +89,15 @@ function visit(
88
89
 
89
90
  // From here on, we can assert that `value` is either an object or an array.
90
91
 
91
- // Do not normalize objects that we know have already been normalized. As a general rule, the
92
- // "__sentry_skip_normalization__" property should only be used sparingly and only should only be set on objects that
93
- // have already been normalized.
94
- if ((value )['__sentry_skip_normalization__']) {
92
+ // Do not normalize objects that we know have already been normalized. Hints use internal symbols
93
+ // (see normalizationHints.ts) so user-controlled JSON cannot spoof them.
94
+ if (normalizationHints.hasSkipNormalizationHint(value)) {
95
95
  return value ;
96
96
  }
97
97
 
98
- // We can set `__sentry_override_normalization_depth__` on an object to ensure that from there
99
- // We keep a certain amount of depth.
100
- // This should be used sparingly, e.g. we use it for the redux integration to ensure we get a certain amount of state.
101
- const remainingDepth =
102
- typeof (value )['__sentry_override_normalization_depth__'] === 'number'
103
- ? ((value )['__sentry_override_normalization_depth__'] )
104
- : depth;
98
+ // Override remaining depth from this node (e.g. Redux / Pinia state). Set via setNormalizationDepthOverrideHint.
99
+ const overrideDepth = normalizationHints.getNormalizationDepthOverrideHint(value);
100
+ const remainingDepth = overrideDepth !== undefined ? overrideDepth : depth;
105
101
 
106
102
  // We're also done if we've reached the max depth
107
103
  if (remainingDepth === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.js","sources":["../../../src/utils/normalize.ts"],"sourcesContent":["import type { Primitive } from '../types-hoist/misc';\nimport { isSyntheticEvent, isVueViewModel } from './is';\nimport { convertToPlainObject } from './object';\nimport { getFunctionName, getVueInternalName } from './stacktrace';\n\ntype Prototype = { constructor?: (...args: unknown[]) => unknown };\n// This is a hack to placate TS, relying on the fact that technically, arrays are objects with integer keys. Normally we\n// think of those keys as actual numbers, but `arr['0']` turns out to work just as well as `arr[0]`, and doing it this\n// way lets us use a single type in the places where behave as if we are only dealing with objects, even if some of them\n// might be arrays.\ntype ObjOrArray<T> = { [key: string]: T };\n\ntype MemoFunc = [\n // memoize\n (obj: object) => boolean,\n // unmemoize\n (obj: object) => void,\n];\n\n/**\n * Recursively normalizes the given object.\n *\n * - Creates a copy to prevent original input mutation\n * - Skips non-enumerable properties\n * - When stringifying, calls `toJSON` if implemented\n * - Removes circular references\n * - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format\n * - Translates known global objects/classes to a string representations\n * - Takes care of `Error` object serialization\n * - Optionally limits depth of final output\n * - Optionally limits number of properties/elements included in any single object/array\n *\n * @param input The object to be normalized.\n * @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)\n * @param maxProperties The max number of elements or properties to be included in any single array or\n * object in the normalized output.\n * @returns A normalized version of the object, or `\"**non-serializable**\"` if any errors are thrown during normalization.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function normalize(input: unknown, depth: number = 100, maxProperties: number = +Infinity): any {\n try {\n // since we're at the outermost level, we don't provide a key\n return visit('', input, depth, maxProperties);\n } catch (err) {\n return { ERROR: `**non-serializable** (${err})` };\n }\n}\n\n/** JSDoc */\nexport function normalizeToSize<T>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n object: { [key: string]: any },\n // Default Node.js REPL depth\n depth: number = 3,\n // 100kB, as 200kB is max payload size, so half sounds reasonable\n maxSize: number = 100 * 1024,\n): T {\n const normalized = normalize(object, depth);\n\n if (jsonSize(normalized) > maxSize) {\n return normalizeToSize(object, depth - 1, maxSize);\n }\n\n return normalized as T;\n}\n\n/**\n * Visits a node to perform normalization on it\n *\n * @param key The key corresponding to the given node\n * @param value The node to be visited\n * @param depth Optional number indicating the maximum recursion depth\n * @param maxProperties Optional maximum number of properties/elements included in any single object/array\n * @param memo Optional Memo class handling decycling\n */\nfunction visit(\n key: string,\n value: unknown,\n depth: number = +Infinity,\n maxProperties: number = +Infinity,\n memo = memoBuilder(),\n): Primitive | ObjOrArray<unknown> {\n const [memoize, unmemoize] = memo;\n\n // Get the simple cases out of the way first\n if (\n value == null || // this matches null and undefined -> eqeq not eqeqeq\n ['boolean', 'string'].includes(typeof value) ||\n (typeof value === 'number' && Number.isFinite(value))\n ) {\n return value as Primitive;\n }\n\n const stringified = stringifyValue(key, value);\n\n // Anything we could potentially dig into more (objects or arrays) will have come back as `\"[object XXXX]\"`.\n // Everything else will have already been serialized, so if we don't see that pattern, we're done.\n if (!stringified.startsWith('[object ')) {\n return stringified;\n }\n\n // From here on, we can assert that `value` is either an object or an array.\n\n // Do not normalize objects that we know have already been normalized. As a general rule, the\n // \"__sentry_skip_normalization__\" property should only be used sparingly and only should only be set on objects that\n // have already been normalized.\n if ((value as ObjOrArray<unknown>)['__sentry_skip_normalization__']) {\n return value as ObjOrArray<unknown>;\n }\n\n // We can set `__sentry_override_normalization_depth__` on an object to ensure that from there\n // We keep a certain amount of depth.\n // This should be used sparingly, e.g. we use it for the redux integration to ensure we get a certain amount of state.\n const remainingDepth =\n typeof (value as ObjOrArray<unknown>)['__sentry_override_normalization_depth__'] === 'number'\n ? ((value as ObjOrArray<unknown>)['__sentry_override_normalization_depth__'] as number)\n : depth;\n\n // We're also done if we've reached the max depth\n if (remainingDepth === 0) {\n // At this point we know `serialized` is a string of the form `\"[object XXXX]\"`. Clean it up so it's just `\"[XXXX]\"`.\n return stringified.replace('object ', '');\n }\n\n // If we've already visited this branch, bail out, as it's circular reference. If not, note that we're seeing it now.\n if (memoize(value)) {\n return '[Circular ~]';\n }\n\n // If the value has a `toJSON` method, we call it to extract more information\n const valueWithToJSON = value as unknown & { toJSON?: () => unknown };\n if (valueWithToJSON && typeof valueWithToJSON.toJSON === 'function') {\n try {\n const jsonValue = valueWithToJSON.toJSON();\n // We need to normalize the return value of `.toJSON()` in case it has circular references\n return visit('', jsonValue, remainingDepth - 1, maxProperties, memo);\n } catch {\n // pass (The built-in `toJSON` failed, but we can still try to do it ourselves)\n }\n }\n\n // At this point we know we either have an object or an array, we haven't seen it before, and we're going to recurse\n // because we haven't yet reached the max depth. Create an accumulator to hold the results of visiting each\n // property/entry, and keep track of the number of items we add to it.\n const normalized = (Array.isArray(value) ? [] : {}) as ObjOrArray<unknown>;\n let numAdded = 0;\n\n // Before we begin, convert`Error` and`Event` instances into plain objects, since some of each of their relevant\n // properties are non-enumerable and otherwise would get missed.\n const visitable = convertToPlainObject(value as ObjOrArray<unknown>);\n\n for (const visitKey in visitable) {\n // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.\n if (!Object.prototype.hasOwnProperty.call(visitable, visitKey)) {\n continue;\n }\n\n if (numAdded >= maxProperties) {\n normalized[visitKey] = '[MaxProperties ~]';\n break;\n }\n\n // Recursively visit all the child nodes\n const visitValue = visitable[visitKey];\n normalized[visitKey] = visit(visitKey, visitValue, remainingDepth - 1, maxProperties, memo);\n\n numAdded++;\n }\n\n // Once we've visited all the branches, remove the parent from memo storage\n unmemoize(value);\n\n // Return accumulated values\n return normalized;\n}\n\n/* eslint-disable complexity */\n/**\n * Stringify the given value. Handles various known special values and types.\n *\n * Not meant to be used on simple primitives which already have a string representation, as it will, for example, turn\n * the number 1231 into \"[Object Number]\", nor on `null`, as it will throw.\n *\n * @param value The value to stringify\n * @returns A stringified representation of the given value\n */\nfunction stringifyValue(\n key: unknown,\n // this type is a tiny bit of a cheat, since this function does handle NaN (which is technically a number), but for\n // our internal use, it'll do\n value: Exclude<unknown, string | number | boolean | null>,\n): string {\n try {\n if (key === 'domain' && value && typeof value === 'object' && (value as { _events: unknown })._events) {\n return '[Domain]';\n }\n\n if (key === 'domainEmitter') {\n return '[DomainEmitter]';\n }\n\n // It's safe to use `global`, `window`, and `document` here in this manner, as we are asserting using `typeof` first\n // which won't throw if they are not present.\n\n if (typeof global !== 'undefined' && value === global) {\n return '[Global]';\n }\n\n // eslint-disable-next-line no-restricted-globals\n if (typeof window !== 'undefined' && value === window) {\n return '[Window]';\n }\n\n // eslint-disable-next-line no-restricted-globals\n if (typeof document !== 'undefined' && value === document) {\n return '[Document]';\n }\n\n if (isVueViewModel(value)) {\n return getVueInternalName(value);\n }\n\n // React's SyntheticEvent thingy\n if (isSyntheticEvent(value)) {\n return '[SyntheticEvent]';\n }\n\n if (typeof value === 'number' && !Number.isFinite(value)) {\n return `[${value}]`;\n }\n\n if (typeof value === 'function') {\n return `[Function: ${getFunctionName(value)}]`;\n }\n\n if (typeof value === 'symbol') {\n return `[${String(value)}]`;\n }\n\n // stringified BigInts are indistinguishable from regular numbers, so we need to label them to avoid confusion\n if (typeof value === 'bigint') {\n return `[BigInt: ${String(value)}]`;\n }\n\n // Now that we've knocked out all the special cases and the primitives, all we have left are objects. Simply casting\n // them to strings means that instances of classes which haven't defined their `toStringTag` will just come out as\n // `\"[object Object]\"`. If we instead look at the constructor's name (which is the same as the name of the class),\n // we can make sure that only plain objects come out that way.\n const objName = getConstructorName(value);\n\n // Handle HTML Elements\n if (/^HTML(\\w*)Element$/.test(objName)) {\n return `[HTMLElement: ${objName}]`;\n }\n\n return `[object ${objName}]`;\n } catch (err) {\n return `**non-serializable** (${err})`;\n }\n}\n/* eslint-enable complexity */\n\nfunction getConstructorName(value: unknown): string {\n const prototype: Prototype | null = Object.getPrototypeOf(value);\n\n return prototype?.constructor ? prototype.constructor.name : 'null prototype';\n}\n\n/** Calculates bytes size of input string */\nfunction utf8Length(value: string): number {\n // eslint-disable-next-line no-bitwise\n return ~-encodeURI(value).split(/%..|./).length;\n}\n\n/** Calculates bytes size of input object */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction jsonSize(value: any): number {\n return utf8Length(JSON.stringify(value));\n}\n\n/**\n * Normalizes URLs in exceptions and stacktraces to a base path so Sentry can fingerprint\n * across platforms and working directory.\n *\n * @param url The URL to be normalized.\n * @param basePath The application base path.\n * @returns The normalized URL.\n */\nexport function normalizeUrlToBase(url: string, basePath: string): string {\n const escapedBase = basePath\n // Backslash to forward\n .replace(/\\\\/g, '/')\n // Escape RegExp special characters\n .replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&');\n\n let newUrl = url;\n try {\n newUrl = decodeURI(url);\n } catch {\n // Sometime this breaks\n }\n return (\n newUrl\n .replace(/\\\\/g, '/')\n .replace(/webpack:\\/?/g, '') // Remove intermediate base path\n // oxlint-disable-next-line sdk/no-regexp-constructor\n .replace(new RegExp(`(file://)?/*${escapedBase}/*`, 'ig'), 'app:///')\n );\n}\n\n/**\n * Helper to decycle json objects\n */\nfunction memoBuilder(): MemoFunc {\n const inner = new WeakSet<object>();\n function memoize(obj: object): boolean {\n if (inner.has(obj)) {\n return true;\n }\n inner.add(obj);\n return false;\n }\n\n function unmemoize(obj: object): void {\n inner.delete(obj);\n }\n return [memoize, unmemoize];\n}\n"],"names":["convertToPlainObject","isVueViewModel","getVueInternalName","isSyntheticEvent","getFunctionName"],"mappings":";;;;;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAC,KAAK,EAAW,KAAK,GAAW,GAAG,EAAE,aAAa,GAAW,CAAC,QAAQ,EAAO;AACvG,EAAE,IAAI;AACN;AACA,IAAI,OAAO,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC;AACjD,EAAE,CAAA,CAAE,OAAO,GAAG,EAAE;AAChB,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC,CAAA,EAAG;AACrD,EAAE;AACF;;AAEA;AACO,SAAS,eAAe;AAC/B;AACA,EAAE,MAAM;AACR;AACA,EAAE,KAAK,GAAW,CAAC;AACnB;AACA,EAAE,OAAO,GAAW,GAAA,GAAM,IAAI;AAC9B,EAAK;AACL,EAAE,MAAM,aAAa,SAAS,CAAC,MAAM,E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,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,GAAG,EAAU,QAAQ,EAAkB;AAC1E,EAAE,MAAM,cAAc;AACtB;AACA,KAAK,OAAO,CAAC,KAAK,EAAE,GAAG;AACvB;AACA,KAAK,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC;;AAE3C,EAAE,IAAI,MAAA,GAAS,GAAG;AAClB,EAAE,IAAI;AACN,IAAI,MAAA,GAAS,SAAS,CAAC,GAAG,CAAC;AAC3B,EAAE,EAAE,MAAM;AACV;AACA,EAAE;AACF,EAAE;AACF,IAAI;AACJ,OAAO,OAAO,CAAC,KAAK,EAAE,GAAG;AACzB,OAAO,OAAO,CAAC,cAAc,EAAE,EAAE,CAAA;AACjC;AACA,OAAO,OAAO,CAAC,IAAI,MAAM,CAAC,CAAC,YAAY,EAAE,WAAW,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS;AAC1E;AACA;;AAEA;AACA;AACA;AACA,SAAS,WAAW,GAAa;AACjC,EAAE,MAAM,KAAA,GAAQ,IAAI,OAAO,EAAU;AACrC,EAAE,SAAS,OAAO,CAAC,GAAG,EAAmB;AACzC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACxB,MAAM,OAAO,IAAI;AACjB,IAAI;AACJ,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;AAClB,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,SAAS,SAAS,CAAC,GAAG,EAAgB;AACxC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;AACrB,EAAE;AACF,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC;AAC7B;;;;;;"}
1
+ {"version":3,"file":"normalize.js","sources":["../../../src/utils/normalize.ts"],"sourcesContent":["import type { Primitive } from '../types-hoist/misc';\nimport { isSyntheticEvent, isVueViewModel } from './is';\nimport { getNormalizationDepthOverrideHint, hasSkipNormalizationHint } from './normalizationHints';\nimport { convertToPlainObject } from './object';\nimport { getFunctionName, getVueInternalName } from './stacktrace';\n\ntype Prototype = { constructor?: (...args: unknown[]) => unknown };\n// This is a hack to placate TS, relying on the fact that technically, arrays are objects with integer keys. Normally we\n// think of those keys as actual numbers, but `arr['0']` turns out to work just as well as `arr[0]`, and doing it this\n// way lets us use a single type in the places where behave as if we are only dealing with objects, even if some of them\n// might be arrays.\ntype ObjOrArray<T> = { [key: string]: T };\n\ntype MemoFunc = [\n // memoize\n (obj: object) => boolean,\n // unmemoize\n (obj: object) => void,\n];\n\n/**\n * Recursively normalizes the given object.\n *\n * - Creates a copy to prevent original input mutation\n * - Skips non-enumerable properties\n * - When stringifying, calls `toJSON` if implemented\n * - Removes circular references\n * - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format\n * - Translates known global objects/classes to a string representations\n * - Takes care of `Error` object serialization\n * - Optionally limits depth of final output\n * - Optionally limits number of properties/elements included in any single object/array\n *\n * @param input The object to be normalized.\n * @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)\n * @param maxProperties The max number of elements or properties to be included in any single array or\n * object in the normalized output.\n * @returns A normalized version of the object, or `\"**non-serializable**\"` if any errors are thrown during normalization.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function normalize(input: unknown, depth: number = 100, maxProperties: number = +Infinity): any {\n try {\n // since we're at the outermost level, we don't provide a key\n return visit('', input, depth, maxProperties);\n } catch (err) {\n return { ERROR: `**non-serializable** (${err})` };\n }\n}\n\n/** JSDoc */\nexport function normalizeToSize<T>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n object: { [key: string]: any },\n // Default Node.js REPL depth\n depth: number = 3,\n // 100kB, as 200kB is max payload size, so half sounds reasonable\n maxSize: number = 100 * 1024,\n): T {\n const normalized = normalize(object, depth);\n\n if (jsonSize(normalized) > maxSize) {\n return normalizeToSize(object, depth - 1, maxSize);\n }\n\n return normalized as T;\n}\n\n/**\n * Visits a node to perform normalization on it\n *\n * @param key The key corresponding to the given node\n * @param value The node to be visited\n * @param depth Optional number indicating the maximum recursion depth\n * @param maxProperties Optional maximum number of properties/elements included in any single object/array\n * @param memo Optional Memo class handling decycling\n */\nfunction visit(\n key: string,\n value: unknown,\n depth: number = +Infinity,\n maxProperties: number = +Infinity,\n memo = memoBuilder(),\n): Primitive | ObjOrArray<unknown> {\n const [memoize, unmemoize] = memo;\n\n // Get the simple cases out of the way first\n if (\n value == null || // this matches null and undefined -> eqeq not eqeqeq\n ['boolean', 'string'].includes(typeof value) ||\n (typeof value === 'number' && Number.isFinite(value))\n ) {\n return value as Primitive;\n }\n\n const stringified = stringifyValue(key, value);\n\n // Anything we could potentially dig into more (objects or arrays) will have come back as `\"[object XXXX]\"`.\n // Everything else will have already been serialized, so if we don't see that pattern, we're done.\n if (!stringified.startsWith('[object ')) {\n return stringified;\n }\n\n // From here on, we can assert that `value` is either an object or an array.\n\n // Do not normalize objects that we know have already been normalized. Hints use internal symbols\n // (see normalizationHints.ts) so user-controlled JSON cannot spoof them.\n if (hasSkipNormalizationHint(value)) {\n return value as ObjOrArray<unknown>;\n }\n\n // Override remaining depth from this node (e.g. Redux / Pinia state). Set via setNormalizationDepthOverrideHint.\n const overrideDepth = getNormalizationDepthOverrideHint(value);\n const remainingDepth = overrideDepth !== undefined ? overrideDepth : depth;\n\n // We're also done if we've reached the max depth\n if (remainingDepth === 0) {\n // At this point we know `serialized` is a string of the form `\"[object XXXX]\"`. Clean it up so it's just `\"[XXXX]\"`.\n return stringified.replace('object ', '');\n }\n\n // If we've already visited this branch, bail out, as it's circular reference. If not, note that we're seeing it now.\n if (memoize(value)) {\n return '[Circular ~]';\n }\n\n // If the value has a `toJSON` method, we call it to extract more information\n const valueWithToJSON = value as unknown & { toJSON?: () => unknown };\n if (valueWithToJSON && typeof valueWithToJSON.toJSON === 'function') {\n try {\n const jsonValue = valueWithToJSON.toJSON();\n // We need to normalize the return value of `.toJSON()` in case it has circular references\n return visit('', jsonValue, remainingDepth - 1, maxProperties, memo);\n } catch {\n // pass (The built-in `toJSON` failed, but we can still try to do it ourselves)\n }\n }\n\n // At this point we know we either have an object or an array, we haven't seen it before, and we're going to recurse\n // because we haven't yet reached the max depth. Create an accumulator to hold the results of visiting each\n // property/entry, and keep track of the number of items we add to it.\n const normalized = (Array.isArray(value) ? [] : {}) as ObjOrArray<unknown>;\n let numAdded = 0;\n\n // Before we begin, convert`Error` and`Event` instances into plain objects, since some of each of their relevant\n // properties are non-enumerable and otherwise would get missed.\n const visitable = convertToPlainObject(value as ObjOrArray<unknown>);\n\n for (const visitKey in visitable) {\n // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.\n if (!Object.prototype.hasOwnProperty.call(visitable, visitKey)) {\n continue;\n }\n\n if (numAdded >= maxProperties) {\n normalized[visitKey] = '[MaxProperties ~]';\n break;\n }\n\n // Recursively visit all the child nodes\n const visitValue = visitable[visitKey];\n normalized[visitKey] = visit(visitKey, visitValue, remainingDepth - 1, maxProperties, memo);\n\n numAdded++;\n }\n\n // Once we've visited all the branches, remove the parent from memo storage\n unmemoize(value);\n\n // Return accumulated values\n return normalized;\n}\n\n/* eslint-disable complexity */\n/**\n * Stringify the given value. Handles various known special values and types.\n *\n * Not meant to be used on simple primitives which already have a string representation, as it will, for example, turn\n * the number 1231 into \"[Object Number]\", nor on `null`, as it will throw.\n *\n * @param value The value to stringify\n * @returns A stringified representation of the given value\n */\nfunction stringifyValue(\n key: unknown,\n // this type is a tiny bit of a cheat, since this function does handle NaN (which is technically a number), but for\n // our internal use, it'll do\n value: Exclude<unknown, string | number | boolean | null>,\n): string {\n try {\n if (key === 'domain' && value && typeof value === 'object' && (value as { _events: unknown })._events) {\n return '[Domain]';\n }\n\n if (key === 'domainEmitter') {\n return '[DomainEmitter]';\n }\n\n // It's safe to use `global`, `window`, and `document` here in this manner, as we are asserting using `typeof` first\n // which won't throw if they are not present.\n\n if (typeof global !== 'undefined' && value === global) {\n return '[Global]';\n }\n\n // eslint-disable-next-line no-restricted-globals\n if (typeof window !== 'undefined' && value === window) {\n return '[Window]';\n }\n\n // eslint-disable-next-line no-restricted-globals\n if (typeof document !== 'undefined' && value === document) {\n return '[Document]';\n }\n\n if (isVueViewModel(value)) {\n return getVueInternalName(value);\n }\n\n // React's SyntheticEvent thingy\n if (isSyntheticEvent(value)) {\n return '[SyntheticEvent]';\n }\n\n if (typeof value === 'number' && !Number.isFinite(value)) {\n return `[${value}]`;\n }\n\n if (typeof value === 'function') {\n return `[Function: ${getFunctionName(value)}]`;\n }\n\n if (typeof value === 'symbol') {\n return `[${String(value)}]`;\n }\n\n // stringified BigInts are indistinguishable from regular numbers, so we need to label them to avoid confusion\n if (typeof value === 'bigint') {\n return `[BigInt: ${String(value)}]`;\n }\n\n // Now that we've knocked out all the special cases and the primitives, all we have left are objects. Simply casting\n // them to strings means that instances of classes which haven't defined their `toStringTag` will just come out as\n // `\"[object Object]\"`. If we instead look at the constructor's name (which is the same as the name of the class),\n // we can make sure that only plain objects come out that way.\n const objName = getConstructorName(value);\n\n // Handle HTML Elements\n if (/^HTML(\\w*)Element$/.test(objName)) {\n return `[HTMLElement: ${objName}]`;\n }\n\n return `[object ${objName}]`;\n } catch (err) {\n return `**non-serializable** (${err})`;\n }\n}\n/* eslint-enable complexity */\n\nfunction getConstructorName(value: unknown): string {\n const prototype: Prototype | null = Object.getPrototypeOf(value);\n\n return prototype?.constructor ? prototype.constructor.name : 'null prototype';\n}\n\n/** Calculates bytes size of input string */\nfunction utf8Length(value: string): number {\n // eslint-disable-next-line no-bitwise\n return ~-encodeURI(value).split(/%..|./).length;\n}\n\n/** Calculates bytes size of input object */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction jsonSize(value: any): number {\n return utf8Length(JSON.stringify(value));\n}\n\n/**\n * Normalizes URLs in exceptions and stacktraces to a base path so Sentry can fingerprint\n * across platforms and working directory.\n *\n * @param url The URL to be normalized.\n * @param basePath The application base path.\n * @returns The normalized URL.\n */\nexport function normalizeUrlToBase(url: string, basePath: string): string {\n const escapedBase = basePath\n // Backslash to forward\n .replace(/\\\\/g, '/')\n // Escape RegExp special characters\n .replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&');\n\n let newUrl = url;\n try {\n newUrl = decodeURI(url);\n } catch {\n // Sometime this breaks\n }\n return (\n newUrl\n .replace(/\\\\/g, '/')\n .replace(/webpack:\\/?/g, '') // Remove intermediate base path\n // oxlint-disable-next-line sdk/no-regexp-constructor\n .replace(new RegExp(`(file://)?/*${escapedBase}/*`, 'ig'), 'app:///')\n );\n}\n\n/**\n * Helper to decycle json objects\n */\nfunction memoBuilder(): MemoFunc {\n const inner = new WeakSet<object>();\n function memoize(obj: object): boolean {\n if (inner.has(obj)) {\n return true;\n }\n inner.add(obj);\n return false;\n }\n\n function unmemoize(obj: object): void {\n inner.delete(obj);\n }\n return [memoize, unmemoize];\n}\n"],"names":["hasSkipNormalizationHint","getNormalizationDepthOverrideHint","convertToPlainObject","isVueViewModel","getVueInternalName","isSyntheticEvent","getFunctionName"],"mappings":";;;;;;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAC,KAAK,EAAW,KAAK,GAAW,GAAG,EAAE,aAAa,GAAW,CAAC,QAAQ,EAAO;AACvG,EAAE,IAAI;AACN;AACA,IAAI,OAAO,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC;AACjD,EAAE,CAAA,CAAE,OAAO,GAAG,EAAE;AAChB,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC,CAAA,EAAG;AACrD,EAAE;AACF;;AAEA;AACO,SAAS,eAAe;AAC/B;AACA,EAAE,MAAM;AACR;AACA,EAAE,KAAK,GAAW,CAAC;AACnB;AAC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erableProperty(obj, name, value) {
64
64
  configurable: true,
65
65
  });
66
66
  } catch {
67
- debugBuild.DEBUG_BUILD && debugLogger.debug.log(`Failed to add non-enumerable property "${name}" to object`, obj);
67
+ debugBuild.DEBUG_BUILD && debugLogger.debug.log(`Failed to add non-enumerable property "${String(name)}" to object`, obj);
68
68
  }
69
69
  }
70
70
 
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sources":["../../../src/utils/object.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { WrappedFunction } from '../types-hoist/wrappedfunction';\nimport { htmlTreeAsString } from './browser';\nimport { debug } from './debug-logger';\nimport { isElement, isError, isEvent, isInstanceOf, isPrimitive } from './is';\n\n/**\n * Replace a method in an object with a wrapped version of itself.\n *\n * If the method on the passed object is not a function, the wrapper will not be applied.\n *\n * @param source An object that contains a method to be wrapped.\n * @param name The name of the method to be wrapped.\n * @param replacementFactory A higher-order function that takes the original version of the given method and returns a\n * wrapped version. Note: The function returned by `replacementFactory` needs to be a non-arrow function, in order to\n * preserve the correct value of `this`, and the original method must be called using `origMethod.call(this, <other\n * args>)` or `origMethod.apply(this, [<other args>])` (rather than being called directly), again to preserve `this`.\n * @returns void\n */\n\nexport function fill(source: { [key: string]: any }, name: string, replacementFactory: (...args: any[]) => any): void {\n if (!(name in source)) {\n return;\n }\n\n // explicitly casting to unknown because we don't know the type of the method initially at all\n const original = source[name] as unknown;\n\n if (typeof original !== 'function') {\n return;\n }\n\n const wrapped = replacementFactory(original) as WrappedFunction;\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n markFunctionWrapped(wrapped, original);\n }\n\n try {\n source[name] = wrapped;\n } catch {\n DEBUG_BUILD && debug.log(`Failed to replace method \"${name}\" in object`, source);\n }\n}\n\n/**\n * Defines a non-enumerable property on the given object.\n *\n * @param obj The object on which to set the property\n * @param name The name of the property to be set\n * @param value The value to which to set the property\n */\nexport function addNonEnumerableProperty(obj: object, name: string, value: unknown): void {\n try {\n Object.defineProperty(obj, name, {\n // enumerable: false, // the default, so we can save on bundle size by not explicitly setting it\n value,\n writable: true,\n configurable: true,\n });\n } catch {\n DEBUG_BUILD && debug.log(`Failed to add non-enumerable property \"${name}\" to object`, obj);\n }\n}\n\n/**\n * Remembers the original function on the wrapped function and\n * patches up the prototype.\n *\n * @param wrapped the wrapper function\n * @param original the original function that gets wrapped\n */\nexport function markFunctionWrapped(wrapped: WrappedFunction, original: WrappedFunction): void {\n try {\n const proto = original.prototype || {};\n wrapped.prototype = original.prototype = proto;\n addNonEnumerableProperty(wrapped, '__sentry_original__', original);\n } catch {} // eslint-disable-line no-empty\n}\n\n/**\n * Wrap a method on an object by name, only if it is not already wrapped.\n *\n * Note: to set the wrapped method as a non-enumerable property, pass\n * false as the `enumerable` argument. This could be detected, but only\n * by either walking up the prototype chain, or iterating over all fields\n * in a `for(in)` loop. Neither are an acceptable performance impact for\n * the rare case where we might patch a non-enumerable method.\n */\nexport function wrapMethod<O extends {}, T extends string & keyof O>(\n obj: O,\n field: T,\n wrapped: WrappedFunction,\n enumerable: boolean = true,\n): void {\n const original = obj[field];\n if (typeof original !== 'function') {\n throw new Error(`Cannot wrap method: ${field} is not a function`);\n }\n if (getOriginalFunction(original)) {\n throw new Error(`Attempting to wrap method ${field} multiple times`);\n }\n markFunctionWrapped(wrapped, original);\n Object.defineProperty(obj, field, {\n writable: true,\n configurable: true,\n enumerable,\n value: wrapped,\n });\n}\n\n/**\n * This extracts the original function if available. See\n * `markFunctionWrapped` for more information.\n *\n * @param func the function to unwrap\n * @returns the unwrapped version of the function if available.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function getOriginalFunction<T extends Function>(func: WrappedFunction<T>): T | undefined {\n return func.__sentry_original__;\n}\n\n/**\n * Transforms any `Error` or `Event` into a plain object with all of their enumerable properties, and some of their\n * non-enumerable properties attached.\n *\n * @param value Initial source that we have to transform in order for it to be usable by the serializer\n * @returns An Event or Error turned into an object - or the value argument itself, when value is neither an Event nor\n * an Error.\n */\nexport function convertToPlainObject<V>(value: V):\n | {\n [ownProps: string]: unknown;\n type: string;\n target: string;\n currentTarget: string;\n detail?: unknown;\n }\n | {\n [ownProps: string]: unknown;\n message: string;\n name: string;\n stack?: string;\n }\n | V {\n if (isError(value)) {\n return {\n message: value.message,\n name: value.name,\n stack: value.stack,\n ...getOwnProperties(value),\n };\n } else if (isEvent(value)) {\n const newObj: {\n [ownProps: string]: unknown;\n type: string;\n target: string;\n currentTarget: string;\n detail?: unknown;\n } = {\n type: value.type,\n target: serializeEventTarget(value.target),\n currentTarget: serializeEventTarget(value.currentTarget),\n ...getOwnProperties(value),\n };\n\n if (typeof CustomEvent !== 'undefined' && isInstanceOf(value, CustomEvent)) {\n newObj.detail = value.detail;\n }\n\n return newObj;\n } else {\n return value;\n }\n}\n\n/** Creates a string representation of the target of an `Event` object */\nfunction serializeEventTarget(target: unknown): string {\n try {\n return isElement(target) ? htmlTreeAsString(target) : Object.prototype.toString.call(target);\n } catch {\n return '<unknown>';\n }\n}\n\n/** Filters out all but an object's own properties */\nfunction getOwnProperties(obj: unknown): { [key: string]: unknown } {\n if (typeof obj === 'object' && obj !== null) {\n return Object.fromEntries(Object.entries(obj));\n }\n return {};\n}\n\n/**\n * Given any captured exception, extract its keys and create a sorted\n * and truncated list that will be used inside the event message.\n * eg. `Non-error exception captured with keys: foo, bar, baz`\n */\nexport function extractExceptionKeysForMessage(exception: Record<string, unknown>): string {\n const keys = Object.keys(convertToPlainObject(exception));\n keys.sort();\n\n return !keys[0] ? '[object has no keys]' : keys.join(', ');\n}\n\n/**\n * Given any object, return a new object having removed all fields whose value was `undefined`.\n * Works recursively on objects and arrays.\n *\n * Attention: This function keeps circular references in the returned object.\n *\n * @deprecated This function is no longer used by the SDK and will be removed in a future major version.\n */\nexport function dropUndefinedKeys<T>(inputValue: T): T {\n // This map keeps track of what already visited nodes map to.\n // Our Set - based memoBuilder doesn't work here because we want to the output object to have the same circular\n // references as the input object.\n const memoizationMap = new Map<unknown, unknown>();\n\n // This function just proxies `_dropUndefinedKeys` to keep the `memoBuilder` out of this function's API\n return _dropUndefinedKeys(inputValue, memoizationMap);\n}\n\nfunction _dropUndefinedKeys<T>(inputValue: T, memoizationMap: Map<unknown, unknown>): T {\n // Early return for primitive values\n if (inputValue === null || typeof inputValue !== 'object') {\n return inputValue;\n }\n\n // Check memo map first for all object types\n const memoVal = memoizationMap.get(inputValue);\n if (memoVal !== undefined) {\n return memoVal as T;\n }\n\n // handle arrays\n if (Array.isArray(inputValue)) {\n const returnValue: unknown[] = [];\n // Store mapping to handle circular references\n memoizationMap.set(inputValue, returnValue);\n\n inputValue.forEach(value => {\n returnValue.push(_dropUndefinedKeys(value, memoizationMap));\n });\n\n return returnValue as unknown as T;\n }\n\n if (isPojo(inputValue)) {\n const returnValue: { [key: string]: unknown } = {};\n // Store mapping to handle circular references\n memoizationMap.set(inputValue, returnValue);\n\n const keys = Object.keys(inputValue);\n\n keys.forEach(key => {\n const val = inputValue[key];\n if (val !== undefined) {\n returnValue[key] = _dropUndefinedKeys(val, memoizationMap);\n }\n });\n\n return returnValue as T;\n }\n\n // For other object types, return as is\n return inputValue;\n}\n\nfunction isPojo(input: unknown): input is Record<string, unknown> {\n // Plain objects have Object as constructor or no constructor\n const constructor = (input as object).constructor;\n return constructor === Object || constructor === undefined;\n}\n\n/**\n * Ensure that something is an object.\n *\n * Turns `undefined` and `null` into `String`s and all other primitives into instances of their respective wrapper\n * classes (String, Boolean, Number, etc.). Acts as the identity function on non-primitives.\n *\n * @param wat The subject of the objectification\n * @returns A version of `wat` which can safely be used with `Object` class methods\n */\nexport function objectify(wat: unknown): typeof Object {\n let objectified;\n switch (true) {\n // this will catch both undefined and null\n case wat == undefined:\n objectified = new String(wat);\n break;\n\n // Though symbols and bigints do have wrapper classes (`Symbol` and `BigInt`, respectively), for whatever reason\n // those classes don't have constructors which can be used with the `new` keyword. We therefore need to cast each as\n // an object in order to wrap it.\n case typeof wat === 'symbol' || typeof wat === 'bigint':\n objectified = Object(wat);\n break;\n\n // this will catch the remaining primitives: `String`, `Number`, and `Boolean`\n case isPrimitive(wat):\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n objectified = new (wat as any).constructor(wat);\n break;\n\n // by process of elimination, at this point we know that `wat` must already be an object\n default:\n objectified = wat;\n break;\n }\n return objectified;\n}\n"],"names":["DEBUG_BUILD","debug","isError","isEvent","isInstanceOf","isElement","htmlTreeAsString","isPrimitive"],"mappings":";;;;;;;AAAA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,SAAS,IAAI,CAAC,MAAM,EAA0B,IAAI,EAAU,kBAAkB,EAAiC;AACtH,EAAE,IAAI,EAAE,QAAQ,MAAM,CAAC,EAAE;AACzB,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,MAAM,QAAA,GAAW,MAAM,CAAC,IAAI,CAAA;;AAE9B,EAAE,IAAI,OAAO,QAAA,KAAa,UAAU,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,OAAA,GAAU,kBAAkB,CAAC,QAAQ,CAAA;;AAE7C;AACA;AACA,EAAE,IAAI,OAAO,OAAA,KAAY,UAAU,EAAE;AACrC,IAAI,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC;AAC1C,EAAE;;AAEF,EAAE,IAAI;AACN,IAAI,MAAM,CAAC,IAAI,CAAA,GAAI,OAAO;AAC1B,EAAE,EAAE,MAAM;AACV,IAAIA,sBAAA,IAAeC,iBAAK,CAAC,GAAG,CAAC,CAAC,0BAA0B,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;AACpF,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,CAAC,GAAG,EAAU,IAAI,EAAU,K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AC,GAAG,EAA0B;AACvD,EAAE,IAAI,WAAW;AACjB,EAAE,QAAQ,IAAI;AACd;AACA,IAAI,KAAK,GAAA,IAAO,SAAS;AACzB,MAAM,cAAc,IAAI,MAAM,CAAC,GAAG,CAAC;AACnC,MAAM;;AAEN;AACA;AACA;AACA,IAAI,KAAK,OAAO,GAAA,KAAQ,YAAY,OAAO,GAAA,KAAQ,QAAQ;AAC3D,MAAM,WAAA,GAAc,MAAM,CAAC,GAAG,CAAC;AAC/B,MAAM;;AAEN;AACA,IAAI,KAAKC,cAAW,CAAC,GAAG,CAAC;AACzB;AACA,MAAM,WAAA,GAAc,IAAI,CAAC,GAAA,GAAY,WAAW,CAAC,GAAG,CAAC;AACrD,MAAM;;AAEN;AACA,IAAI;AACJ,MAAM,WAAA,GAAc,GAAG;AACvB,MAAM;AACN;AACA,EAAE,OAAO,WAAW;AACpB;;;;;;;;;;;;"}
1
+ {"version":3,"file":"object.js","sources":["../../../src/utils/object.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { WrappedFunction } from '../types-hoist/wrappedfunction';\nimport { htmlTreeAsString } from './browser';\nimport { debug } from './debug-logger';\nimport { isElement, isError, isEvent, isInstanceOf, isPrimitive } from './is';\n\n/**\n * Replace a method in an object with a wrapped version of itself.\n *\n * If the method on the passed object is not a function, the wrapper will not be applied.\n *\n * @param source An object that contains a method to be wrapped.\n * @param name The name of the method to be wrapped.\n * @param replacementFactory A higher-order function that takes the original version of the given method and returns a\n * wrapped version. Note: The function returned by `replacementFactory` needs to be a non-arrow function, in order to\n * preserve the correct value of `this`, and the original method must be called using `origMethod.call(this, <other\n * args>)` or `origMethod.apply(this, [<other args>])` (rather than being called directly), again to preserve `this`.\n * @returns void\n */\n\nexport function fill(source: { [key: string]: any }, name: string, replacementFactory: (...args: any[]) => any): void {\n if (!(name in source)) {\n return;\n }\n\n // explicitly casting to unknown because we don't know the type of the method initially at all\n const original = source[name] as unknown;\n\n if (typeof original !== 'function') {\n return;\n }\n\n const wrapped = replacementFactory(original) as WrappedFunction;\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n markFunctionWrapped(wrapped, original);\n }\n\n try {\n source[name] = wrapped;\n } catch {\n DEBUG_BUILD && debug.log(`Failed to replace method \"${name}\" in object`, source);\n }\n}\n\n/**\n * Defines a non-enumerable property on the given object.\n *\n * @param obj The object on which to set the property\n * @param name The name of the property to be set\n * @param value The value to which to set the property\n */\nexport function addNonEnumerableProperty(obj: object, name: string | symbol, value: unknown): void {\n try {\n Object.defineProperty(obj, name, {\n // enumerable: false, // the default, so we can save on bundle size by not explicitly setting it\n value,\n writable: true,\n configurable: true,\n });\n } catch {\n DEBUG_BUILD && debug.log(`Failed to add non-enumerable property \"${String(name)}\" to object`, obj);\n }\n}\n\n/**\n * Remembers the original function on the wrapped function and\n * patches up the prototype.\n *\n * @param wrapped the wrapper function\n * @param original the original function that gets wrapped\n */\nexport function markFunctionWrapped(wrapped: WrappedFunction, original: WrappedFunction): void {\n try {\n const proto = original.prototype || {};\n wrapped.prototype = original.prototype = proto;\n addNonEnumerableProperty(wrapped, '__sentry_original__', original);\n } catch {} // eslint-disable-line no-empty\n}\n\n/**\n * Wrap a method on an object by name, only if it is not already wrapped.\n *\n * Note: to set the wrapped method as a non-enumerable property, pass\n * false as the `enumerable` argument. This could be detected, but only\n * by either walking up the prototype chain, or iterating over all fields\n * in a `for(in)` loop. Neither are an acceptable performance impact for\n * the rare case where we might patch a non-enumerable method.\n */\nexport function wrapMethod<O extends {}, T extends string & keyof O>(\n obj: O,\n field: T,\n wrapped: WrappedFunction,\n enumerable: boolean = true,\n): void {\n const original = obj[field];\n if (typeof original !== 'function') {\n throw new Error(`Cannot wrap method: ${field} is not a function`);\n }\n if (getOriginalFunction(original)) {\n throw new Error(`Attempting to wrap method ${field} multiple times`);\n }\n markFunctionWrapped(wrapped, original);\n Object.defineProperty(obj, field, {\n writable: true,\n configurable: true,\n enumerable,\n value: wrapped,\n });\n}\n\n/**\n * This extracts the original function if available. See\n * `markFunctionWrapped` for more information.\n *\n * @param func the function to unwrap\n * @returns the unwrapped version of the function if available.\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function getOriginalFunction<T extends Function>(func: WrappedFunction<T>): T | undefined {\n return func.__sentry_original__;\n}\n\n/**\n * Transforms any `Error` or `Event` into a plain object with all of their enumerable properties, and some of their\n * non-enumerable properties attached.\n *\n * @param value Initial source that we have to transform in order for it to be usable by the serializer\n * @returns An Event or Error turned into an object - or the value argument itself, when value is neither an Event nor\n * an Error.\n */\nexport function convertToPlainObject<V>(value: V):\n | {\n [ownProps: string]: unknown;\n type: string;\n target: string;\n currentTarget: string;\n detail?: unknown;\n }\n | {\n [ownProps: string]: unknown;\n message: string;\n name: string;\n stack?: string;\n }\n | V {\n if (isError(value)) {\n return {\n message: value.message,\n name: value.name,\n stack: value.stack,\n ...getOwnProperties(value),\n };\n } else if (isEvent(value)) {\n const newObj: {\n [ownProps: string]: unknown;\n type: string;\n target: string;\n currentTarget: string;\n detail?: unknown;\n } = {\n type: value.type,\n target: serializeEventTarget(value.target),\n currentTarget: serializeEventTarget(value.currentTarget),\n ...getOwnProperties(value),\n };\n\n if (typeof CustomEvent !== 'undefined' && isInstanceOf(value, CustomEvent)) {\n newObj.detail = value.detail;\n }\n\n return newObj;\n } else {\n return value;\n }\n}\n\n/** Creates a string representation of the target of an `Event` object */\nfunction serializeEventTarget(target: unknown): string {\n try {\n return isElement(target) ? htmlTreeAsString(target) : Object.prototype.toString.call(target);\n } catch {\n return '<unknown>';\n }\n}\n\n/** Filters out all but an object's own properties */\nfunction getOwnProperties(obj: unknown): { [key: string]: unknown } {\n if (typeof obj === 'object' && obj !== null) {\n return Object.fromEntries(Object.entries(obj));\n }\n return {};\n}\n\n/**\n * Given any captured exception, extract its keys and create a sorted\n * and truncated list that will be used inside the event message.\n * eg. `Non-error exception captured with keys: foo, bar, baz`\n */\nexport function extractExceptionKeysForMessage(exception: Record<string, unknown>): string {\n const keys = Object.keys(convertToPlainObject(exception));\n keys.sort();\n\n return !keys[0] ? '[object has no keys]' : keys.join(', ');\n}\n\n/**\n * Given any object, return a new object having removed all fields whose value was `undefined`.\n * Works recursively on objects and arrays.\n *\n * Attention: This function keeps circular references in the returned object.\n *\n * @deprecated This function is no longer used by the SDK and will be removed in a future major version.\n */\nexport function dropUndefinedKeys<T>(inputValue: T): T {\n // This map keeps track of what already visited nodes map to.\n // Our Set - based memoBuilder doesn't work here because we want to the output object to have the same circular\n // references as the input object.\n const memoizationMap = new Map<unknown, unknown>();\n\n // This function just proxies `_dropUndefinedKeys` to keep the `memoBuilder` out of this function's API\n return _dropUndefinedKeys(inputValue, memoizationMap);\n}\n\nfunction _dropUndefinedKeys<T>(inputValue: T, memoizationMap: Map<unknown, unknown>): T {\n // Early return for primitive values\n if (inputValue === null || typeof inputValue !== 'object') {\n return inputValue;\n }\n\n // Check memo map first for all object types\n const memoVal = memoizationMap.get(inputValue);\n if (memoVal !== undefined) {\n return memoVal as T;\n }\n\n // handle arrays\n if (Array.isArray(inputValue)) {\n const returnValue: unknown[] = [];\n // Store mapping to handle circular references\n memoizationMap.set(inputValue, returnValue);\n\n inputValue.forEach(value => {\n returnValue.push(_dropUndefinedKeys(value, memoizationMap));\n });\n\n return returnValue as unknown as T;\n }\n\n if (isPojo(inputValue)) {\n const returnValue: { [key: string]: unknown } = {};\n // Store mapping to handle circular references\n memoizationMap.set(inputValue, returnValue);\n\n const keys = Object.keys(inputValue);\n\n keys.forEach(key => {\n const val = inputValue[key];\n if (val !== undefined) {\n returnValue[key] = _dropUndefinedKeys(val, memoizationMap);\n }\n });\n\n return returnValue as T;\n }\n\n // For other object types, return as is\n return inputValue;\n}\n\nfunction isPojo(input: unknown): input is Record<string, unknown> {\n // Plain objects have Object as constructor or no constructor\n const constructor = (input as object).constructor;\n return constructor === Object || constructor === undefined;\n}\n\n/**\n * Ensure that something is an object.\n *\n * Turns `undefined` and `null` into `String`s and all other primitives into instances of their respective wrapper\n * classes (String, Boolean, Number, etc.). Acts as the identity function on non-primitives.\n *\n * @param wat The subject of the objectification\n * @returns A version of `wat` which can safely be used with `Object` class methods\n */\nexport function objectify(wat: unknown): typeof Object {\n let objectified;\n switch (true) {\n // this will catch both undefined and null\n case wat == undefined:\n objectified = new String(wat);\n break;\n\n // Though symbols and bigints do have wrapper classes (`Symbol` and `BigInt`, respectively), for whatever reason\n // those classes don't have constructors which can be used with the `new` keyword. We therefore need to cast each as\n // an object in order to wrap it.\n case typeof wat === 'symbol' || typeof wat === 'bigint':\n objectified = Object(wat);\n break;\n\n // this will catch the remaining primitives: `String`, `Number`, and `Boolean`\n case isPrimitive(wat):\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n objectified = new (wat as any).constructor(wat);\n break;\n\n // by process of elimination, at this point we know that `wat` must already be an object\n default:\n objectified = wat;\n break;\n }\n return objectified;\n}\n"],"names":["DEBUG_BUILD","debug","isError","isEvent","isInstanceOf","isElement","htmlTreeAsString","isPrimitive"],"mappings":";;;;;;;AAAA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,SAAS,IAAI,CAAC,MAAM,EAA0B,IAAI,EAAU,kBAAkB,EAAiC;AACtH,EAAE,IAAI,EAAE,QAAQ,MAAM,CAAC,EAAE;AACzB,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,MAAM,QAAA,GAAW,MAAM,CAAC,IAAI,CAAA;;AAE9B,EAAE,IAAI,OAAO,QAAA,KAAa,UAAU,EAAE;AACtC,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,OAAA,GAAU,kBAAkB,CAAC,QAAQ,CAAA;;AAE7C;AACA;AACA,EAAE,IAAI,OAAO,OAAA,KAAY,UAAU,EAAE;AACrC,IAAI,mBAAmB,CAAC,OAAO,EA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