@sentry/core 10.47.0 → 10.49.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 (413) hide show
  1. package/build/cjs/attributes.js +43 -0
  2. package/build/cjs/attributes.js.map +1 -1
  3. package/build/cjs/client.js +13 -6
  4. package/build/cjs/client.js.map +1 -1
  5. package/build/cjs/envelope.js +4 -3
  6. package/build/cjs/envelope.js.map +1 -1
  7. package/build/cjs/fetch.js +36 -17
  8. package/build/cjs/fetch.js.map +1 -1
  9. package/build/cjs/index.js +53 -18
  10. package/build/cjs/index.js.map +1 -1
  11. package/build/cjs/integration.js +6 -0
  12. package/build/cjs/integration.js.map +1 -1
  13. package/build/cjs/integrations/conversationId.js +11 -0
  14. package/build/cjs/integrations/conversationId.js.map +1 -1
  15. package/build/cjs/integrations/express/index.js +243 -0
  16. package/build/cjs/integrations/express/index.js.map +1 -0
  17. package/build/cjs/integrations/express/patch-layer.js +257 -0
  18. package/build/cjs/integrations/express/patch-layer.js.map +1 -0
  19. package/build/cjs/integrations/express/request-layer-store.js +25 -0
  20. package/build/cjs/integrations/express/request-layer-store.js.map +1 -0
  21. package/build/cjs/integrations/express/set-sdk-processing-metadata.js +17 -0
  22. package/build/cjs/integrations/express/set-sdk-processing-metadata.js.map +1 -0
  23. package/build/cjs/integrations/express/types.js +17 -0
  24. package/build/cjs/integrations/express/types.js.map +1 -0
  25. package/build/cjs/integrations/express/utils.js +238 -0
  26. package/build/cjs/integrations/express/utils.js.map +1 -0
  27. package/build/cjs/integrations/mcp-server/correlation.js +5 -1
  28. package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
  29. package/build/cjs/integrations/mcp-server/handlers.js +18 -10
  30. package/build/cjs/integrations/mcp-server/handlers.js.map +1 -1
  31. package/build/cjs/integrations/mcp-server/index.js +2 -1
  32. package/build/cjs/integrations/mcp-server/index.js.map +1 -1
  33. package/build/cjs/integrations/mcp-server/transport.js +1 -1
  34. package/build/cjs/integrations/mcp-server/transport.js.map +1 -1
  35. package/build/cjs/integrations/mcp-server/validation.js +7 -5
  36. package/build/cjs/integrations/mcp-server/validation.js.map +1 -1
  37. package/build/cjs/integrations/requestdata.js.map +1 -1
  38. package/build/cjs/integrations/spanStreaming.js +48 -0
  39. package/build/cjs/integrations/spanStreaming.js.map +1 -0
  40. package/build/cjs/semanticAttributes.js +35 -3
  41. package/build/cjs/semanticAttributes.js.map +1 -1
  42. package/build/cjs/tracing/ai/gen-ai-attributes.js +3 -89
  43. package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
  44. package/build/cjs/tracing/ai/utils.js +74 -0
  45. package/build/cjs/tracing/ai/utils.js.map +1 -1
  46. package/build/cjs/tracing/anthropic-ai/index.js +6 -17
  47. package/build/cjs/tracing/anthropic-ai/index.js.map +1 -1
  48. package/build/cjs/tracing/anthropic-ai/streaming.js +2 -100
  49. package/build/cjs/tracing/anthropic-ai/streaming.js.map +1 -1
  50. package/build/cjs/tracing/anthropic-ai/utils.js +4 -2
  51. package/build/cjs/tracing/anthropic-ai/utils.js.map +1 -1
  52. package/build/cjs/tracing/dynamicSamplingContext.js +2 -1
  53. package/build/cjs/tracing/dynamicSamplingContext.js.map +1 -1
  54. package/build/cjs/tracing/google-genai/constants.js +1 -6
  55. package/build/cjs/tracing/google-genai/constants.js.map +1 -1
  56. package/build/cjs/tracing/google-genai/index.js +40 -35
  57. package/build/cjs/tracing/google-genai/index.js.map +1 -1
  58. package/build/cjs/tracing/google-genai/streaming.js +2 -23
  59. package/build/cjs/tracing/google-genai/streaming.js.map +1 -1
  60. package/build/cjs/tracing/langchain/embeddings.js +132 -0
  61. package/build/cjs/tracing/langchain/embeddings.js.map +1 -0
  62. package/build/cjs/tracing/langchain/index.js +3 -0
  63. package/build/cjs/tracing/langchain/index.js.map +1 -1
  64. package/build/cjs/tracing/langchain/utils.js +12 -4
  65. package/build/cjs/tracing/langchain/utils.js.map +1 -1
  66. package/build/cjs/tracing/langgraph/index.js +4 -3
  67. package/build/cjs/tracing/langgraph/index.js.map +1 -1
  68. package/build/cjs/tracing/openai/index.js +14 -34
  69. package/build/cjs/tracing/openai/index.js.map +1 -1
  70. package/build/cjs/tracing/openai/streaming.js +3 -34
  71. package/build/cjs/tracing/openai/streaming.js.map +1 -1
  72. package/build/cjs/tracing/openai/utils.js +78 -204
  73. package/build/cjs/tracing/openai/utils.js.map +1 -1
  74. package/build/cjs/tracing/sentryNonRecordingSpan.js +7 -0
  75. package/build/cjs/tracing/sentryNonRecordingSpan.js.map +1 -1
  76. package/build/cjs/tracing/sentrySpan.js +39 -0
  77. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  78. package/build/cjs/tracing/spans/beforeSendSpan.js +43 -0
  79. package/build/cjs/tracing/spans/beforeSendSpan.js.map +1 -0
  80. package/build/cjs/tracing/spans/captureSpan.js +126 -0
  81. package/build/cjs/tracing/spans/captureSpan.js.map +1 -0
  82. package/build/cjs/tracing/spans/envelope.js +38 -0
  83. package/build/cjs/tracing/spans/envelope.js.map +1 -0
  84. package/build/cjs/tracing/spans/estimateSize.js +41 -0
  85. package/build/cjs/tracing/spans/estimateSize.js.map +1 -0
  86. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js +11 -0
  87. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
  88. package/build/cjs/tracing/spans/spanBuffer.js +158 -0
  89. package/build/cjs/tracing/spans/spanBuffer.js.map +1 -0
  90. package/build/cjs/tracing/trace.js +83 -13
  91. package/build/cjs/tracing/trace.js.map +1 -1
  92. package/build/cjs/tracing/utils.js +3 -37
  93. package/build/cjs/tracing/utils.js.map +1 -1
  94. package/build/cjs/tracing/vercel-ai/constants.js +15 -23
  95. package/build/cjs/tracing/vercel-ai/constants.js.map +1 -1
  96. package/build/cjs/tracing/vercel-ai/index.js +32 -45
  97. package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
  98. package/build/cjs/tracing/vercel-ai/utils.js +11 -42
  99. package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
  100. package/build/cjs/tracing/vercel-ai/vercel-ai-attributes.js +4 -1
  101. package/build/cjs/tracing/vercel-ai/vercel-ai-attributes.js.map +1 -1
  102. package/build/cjs/utils/browser.js +2 -3
  103. package/build/cjs/utils/browser.js.map +1 -1
  104. package/build/cjs/utils/featureFlags.js +6 -0
  105. package/build/cjs/utils/featureFlags.js.map +1 -1
  106. package/build/cjs/utils/object.js +33 -0
  107. package/build/cjs/utils/object.js.map +1 -1
  108. package/build/cjs/utils/spanUtils.js +116 -13
  109. package/build/cjs/utils/spanUtils.js.map +1 -1
  110. package/build/cjs/utils/stacktrace.js +3 -1
  111. package/build/cjs/utils/stacktrace.js.map +1 -1
  112. package/build/cjs/utils/string.js +3 -0
  113. package/build/cjs/utils/string.js.map +1 -1
  114. package/build/cjs/utils/version.js +1 -1
  115. package/build/cjs/utils/weakRef.js +62 -0
  116. package/build/cjs/utils/weakRef.js.map +1 -0
  117. package/build/esm/attributes.js +43 -1
  118. package/build/esm/attributes.js.map +1 -1
  119. package/build/esm/client.js +8 -1
  120. package/build/esm/client.js.map +1 -1
  121. package/build/esm/envelope.js +2 -1
  122. package/build/esm/envelope.js.map +1 -1
  123. package/build/esm/fetch.js +36 -17
  124. package/build/esm/fetch.js.map +1 -1
  125. package/build/esm/index.js +12 -3
  126. package/build/esm/index.js.map +1 -1
  127. package/build/esm/integration.js +6 -0
  128. package/build/esm/integration.js.map +1 -1
  129. package/build/esm/integrations/conversationId.js +11 -0
  130. package/build/esm/integrations/conversationId.js.map +1 -1
  131. package/build/esm/integrations/express/index.js +239 -0
  132. package/build/esm/integrations/express/index.js.map +1 -0
  133. package/build/esm/integrations/express/patch-layer.js +255 -0
  134. package/build/esm/integrations/express/patch-layer.js.map +1 -0
  135. package/build/esm/integrations/express/request-layer-store.js +22 -0
  136. package/build/esm/integrations/express/request-layer-store.js.map +1 -0
  137. package/build/esm/integrations/express/set-sdk-processing-metadata.js +15 -0
  138. package/build/esm/integrations/express/set-sdk-processing-metadata.js.map +1 -0
  139. package/build/esm/integrations/express/types.js +10 -0
  140. package/build/esm/integrations/express/types.js.map +1 -0
  141. package/build/esm/integrations/express/utils.js +225 -0
  142. package/build/esm/integrations/express/utils.js.map +1 -0
  143. package/build/esm/integrations/mcp-server/correlation.js +5 -1
  144. package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
  145. package/build/esm/integrations/mcp-server/handlers.js +18 -10
  146. package/build/esm/integrations/mcp-server/handlers.js.map +1 -1
  147. package/build/esm/integrations/mcp-server/index.js +2 -1
  148. package/build/esm/integrations/mcp-server/index.js.map +1 -1
  149. package/build/esm/integrations/mcp-server/transport.js +1 -1
  150. package/build/esm/integrations/mcp-server/transport.js.map +1 -1
  151. package/build/esm/integrations/mcp-server/validation.js +7 -5
  152. package/build/esm/integrations/mcp-server/validation.js.map +1 -1
  153. package/build/esm/integrations/requestdata.js.map +1 -1
  154. package/build/esm/integrations/spanStreaming.js +46 -0
  155. package/build/esm/integrations/spanStreaming.js.map +1 -0
  156. package/build/esm/package.json +1 -1
  157. package/build/esm/semanticAttributes.js +26 -4
  158. package/build/esm/semanticAttributes.js.map +1 -1
  159. package/build/esm/tracing/ai/gen-ai-attributes.js +3 -76
  160. package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
  161. package/build/esm/tracing/ai/utils.js +73 -2
  162. package/build/esm/tracing/ai/utils.js.map +1 -1
  163. package/build/esm/tracing/anthropic-ai/index.js +8 -19
  164. package/build/esm/tracing/anthropic-ai/index.js.map +1 -1
  165. package/build/esm/tracing/anthropic-ai/streaming.js +3 -101
  166. package/build/esm/tracing/anthropic-ai/streaming.js.map +1 -1
  167. package/build/esm/tracing/anthropic-ai/utils.js +5 -3
  168. package/build/esm/tracing/anthropic-ai/utils.js.map +1 -1
  169. package/build/esm/tracing/dynamicSamplingContext.js +2 -1
  170. package/build/esm/tracing/dynamicSamplingContext.js.map +1 -1
  171. package/build/esm/tracing/google-genai/constants.js +2 -5
  172. package/build/esm/tracing/google-genai/constants.js.map +1 -1
  173. package/build/esm/tracing/google-genai/index.js +42 -37
  174. package/build/esm/tracing/google-genai/index.js.map +1 -1
  175. package/build/esm/tracing/google-genai/streaming.js +2 -23
  176. package/build/esm/tracing/google-genai/streaming.js.map +1 -1
  177. package/build/esm/tracing/langchain/embeddings.js +129 -0
  178. package/build/esm/tracing/langchain/embeddings.js.map +1 -0
  179. package/build/esm/tracing/langchain/index.js +4 -1
  180. package/build/esm/tracing/langchain/index.js.map +1 -1
  181. package/build/esm/tracing/langchain/utils.js +13 -5
  182. package/build/esm/tracing/langchain/utils.js.map +1 -1
  183. package/build/esm/tracing/langgraph/index.js +5 -4
  184. package/build/esm/tracing/langgraph/index.js.map +1 -1
  185. package/build/esm/tracing/openai/index.js +16 -36
  186. package/build/esm/tracing/openai/index.js.map +1 -1
  187. package/build/esm/tracing/openai/streaming.js +4 -35
  188. package/build/esm/tracing/openai/streaming.js.map +1 -1
  189. package/build/esm/tracing/openai/utils.js +79 -196
  190. package/build/esm/tracing/openai/utils.js.map +1 -1
  191. package/build/esm/tracing/sentryNonRecordingSpan.js +7 -0
  192. package/build/esm/tracing/sentryNonRecordingSpan.js.map +1 -1
  193. package/build/esm/tracing/sentrySpan.js +40 -1
  194. package/build/esm/tracing/sentrySpan.js.map +1 -1
  195. package/build/esm/tracing/spans/beforeSendSpan.js +40 -0
  196. package/build/esm/tracing/spans/beforeSendSpan.js.map +1 -0
  197. package/build/esm/tracing/spans/captureSpan.js +122 -0
  198. package/build/esm/tracing/spans/captureSpan.js.map +1 -0
  199. package/build/esm/tracing/spans/envelope.js +36 -0
  200. package/build/esm/tracing/spans/envelope.js.map +1 -0
  201. package/build/esm/tracing/spans/estimateSize.js +39 -0
  202. package/build/esm/tracing/spans/estimateSize.js.map +1 -0
  203. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js +9 -0
  204. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
  205. package/build/esm/tracing/spans/spanBuffer.js +156 -0
  206. package/build/esm/tracing/spans/spanBuffer.js.map +1 -0
  207. package/build/esm/tracing/trace.js +84 -14
  208. package/build/esm/tracing/trace.js.map +1 -1
  209. package/build/esm/tracing/utils.js +3 -37
  210. package/build/esm/tracing/utils.js.map +1 -1
  211. package/build/esm/tracing/vercel-ai/constants.js +15 -19
  212. package/build/esm/tracing/vercel-ai/constants.js.map +1 -1
  213. package/build/esm/tracing/vercel-ai/index.js +29 -42
  214. package/build/esm/tracing/vercel-ai/index.js.map +1 -1
  215. package/build/esm/tracing/vercel-ai/utils.js +14 -44
  216. package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
  217. package/build/esm/tracing/vercel-ai/vercel-ai-attributes.js +4 -1
  218. package/build/esm/tracing/vercel-ai/vercel-ai-attributes.js.map +1 -1
  219. package/build/esm/utils/browser.js +2 -3
  220. package/build/esm/utils/browser.js.map +1 -1
  221. package/build/esm/utils/featureFlags.js +6 -0
  222. package/build/esm/utils/featureFlags.js.map +1 -1
  223. package/build/esm/utils/object.js +33 -1
  224. package/build/esm/utils/object.js.map +1 -1
  225. package/build/esm/utils/spanUtils.js +112 -14
  226. package/build/esm/utils/spanUtils.js.map +1 -1
  227. package/build/esm/utils/stacktrace.js +3 -1
  228. package/build/esm/utils/stacktrace.js.map +1 -1
  229. package/build/esm/utils/string.js +3 -0
  230. package/build/esm/utils/string.js.map +1 -1
  231. package/build/esm/utils/version.js +1 -1
  232. package/build/esm/utils/weakRef.js +59 -0
  233. package/build/esm/utils/weakRef.js.map +1 -0
  234. package/build/types/attributes.d.ts +5 -0
  235. package/build/types/attributes.d.ts.map +1 -1
  236. package/build/types/build-time-plugins/buildTimeOptionsBase.d.ts +13 -0
  237. package/build/types/build-time-plugins/buildTimeOptionsBase.d.ts.map +1 -1
  238. package/build/types/client.d.ts +35 -1
  239. package/build/types/client.d.ts.map +1 -1
  240. package/build/types/envelope.d.ts.map +1 -1
  241. package/build/types/fetch.d.ts +12 -8
  242. package/build/types/fetch.d.ts.map +1 -1
  243. package/build/types/index.d.ts +16 -5
  244. package/build/types/index.d.ts.map +1 -1
  245. package/build/types/integration.d.ts.map +1 -1
  246. package/build/types/integrations/conversationId.d.ts.map +1 -1
  247. package/build/types/integrations/express/index.d.ts +82 -0
  248. package/build/types/integrations/express/index.d.ts.map +1 -0
  249. package/build/types/integrations/express/patch-layer.d.ts +32 -0
  250. package/build/types/integrations/express/patch-layer.d.ts.map +1 -0
  251. package/build/types/integrations/express/request-layer-store.d.ts +32 -0
  252. package/build/types/integrations/express/request-layer-store.d.ts.map +1 -0
  253. package/build/types/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
  254. package/build/types/integrations/express/set-sdk-processing-metadata.d.ts.map +1 -0
  255. package/build/types/integrations/express/types.d.ts +158 -0
  256. package/build/types/integrations/express/types.d.ts.map +1 -0
  257. package/build/types/integrations/express/utils.d.ts +93 -0
  258. package/build/types/integrations/express/utils.d.ts.map +1 -0
  259. package/build/types/integrations/mcp-server/correlation.d.ts +2 -1
  260. package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
  261. package/build/types/integrations/mcp-server/handlers.d.ts +9 -4
  262. package/build/types/integrations/mcp-server/handlers.d.ts.map +1 -1
  263. package/build/types/integrations/mcp-server/index.d.ts +2 -1
  264. package/build/types/integrations/mcp-server/index.d.ts.map +1 -1
  265. package/build/types/integrations/mcp-server/types.d.ts +40 -7
  266. package/build/types/integrations/mcp-server/types.d.ts.map +1 -1
  267. package/build/types/integrations/mcp-server/validation.d.ts +4 -1
  268. package/build/types/integrations/mcp-server/validation.d.ts.map +1 -1
  269. package/build/types/integrations/requestdata.d.ts.map +1 -1
  270. package/build/types/integrations/spanStreaming.d.ts +2 -0
  271. package/build/types/integrations/spanStreaming.d.ts.map +1 -0
  272. package/build/types/semanticAttributes.d.ts +23 -3
  273. package/build/types/semanticAttributes.d.ts.map +1 -1
  274. package/build/types/tracing/ai/gen-ai-attributes.d.ts +4 -44
  275. package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
  276. package/build/types/tracing/ai/utils.d.ts +32 -2
  277. package/build/types/tracing/ai/utils.d.ts.map +1 -1
  278. package/build/types/tracing/anthropic-ai/index.d.ts.map +1 -1
  279. package/build/types/tracing/anthropic-ai/streaming.d.ts.map +1 -1
  280. package/build/types/tracing/anthropic-ai/types.d.ts +5 -0
  281. package/build/types/tracing/anthropic-ai/types.d.ts.map +1 -1
  282. package/build/types/tracing/anthropic-ai/utils.d.ts +1 -1
  283. package/build/types/tracing/anthropic-ai/utils.d.ts.map +1 -1
  284. package/build/types/tracing/dynamicSamplingContext.d.ts.map +1 -1
  285. package/build/types/tracing/google-genai/constants.d.ts +1 -3
  286. package/build/types/tracing/google-genai/constants.d.ts.map +1 -1
  287. package/build/types/tracing/google-genai/index.d.ts.map +1 -1
  288. package/build/types/tracing/google-genai/streaming.d.ts.map +1 -1
  289. package/build/types/tracing/google-genai/types.d.ts +5 -0
  290. package/build/types/tracing/google-genai/types.d.ts.map +1 -1
  291. package/build/types/tracing/index.d.ts +1 -0
  292. package/build/types/tracing/index.d.ts.map +1 -1
  293. package/build/types/tracing/langchain/embeddings.d.ts +27 -0
  294. package/build/types/tracing/langchain/embeddings.d.ts.map +1 -0
  295. package/build/types/tracing/langchain/index.d.ts +1 -0
  296. package/build/types/tracing/langchain/index.d.ts.map +1 -1
  297. package/build/types/tracing/langchain/types.d.ts +5 -0
  298. package/build/types/tracing/langchain/types.d.ts.map +1 -1
  299. package/build/types/tracing/langchain/utils.d.ts +2 -2
  300. package/build/types/tracing/langchain/utils.d.ts.map +1 -1
  301. package/build/types/tracing/langgraph/index.d.ts.map +1 -1
  302. package/build/types/tracing/langgraph/types.d.ts +5 -0
  303. package/build/types/tracing/langgraph/types.d.ts.map +1 -1
  304. package/build/types/tracing/openai/index.d.ts.map +1 -1
  305. package/build/types/tracing/openai/streaming.d.ts.map +1 -1
  306. package/build/types/tracing/openai/types.d.ts +5 -0
  307. package/build/types/tracing/openai/types.d.ts.map +1 -1
  308. package/build/types/tracing/openai/utils.d.ts +4 -49
  309. package/build/types/tracing/openai/utils.d.ts.map +1 -1
  310. package/build/types/tracing/sentryNonRecordingSpan.d.ts +12 -1
  311. package/build/types/tracing/sentryNonRecordingSpan.d.ts.map +1 -1
  312. package/build/types/tracing/sentrySpan.d.ts +10 -1
  313. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  314. package/build/types/tracing/spans/beforeSendSpan.d.ts +35 -0
  315. package/build/types/tracing/spans/beforeSendSpan.d.ts.map +1 -0
  316. package/build/types/tracing/spans/captureSpan.d.ts +26 -0
  317. package/build/types/tracing/spans/captureSpan.d.ts.map +1 -0
  318. package/build/types/tracing/spans/envelope.d.ts +8 -0
  319. package/build/types/tracing/spans/envelope.d.ts.map +1 -0
  320. package/build/types/tracing/spans/estimateSize.d.ts +12 -0
  321. package/build/types/tracing/spans/estimateSize.d.ts.map +1 -0
  322. package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
  323. package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts.map +1 -0
  324. package/build/types/tracing/spans/spanBuffer.d.ts +60 -0
  325. package/build/types/tracing/spans/spanBuffer.d.ts.map +1 -0
  326. package/build/types/tracing/trace.d.ts.map +1 -1
  327. package/build/types/tracing/utils.d.ts.map +1 -1
  328. package/build/types/tracing/vercel-ai/constants.d.ts +2 -5
  329. package/build/types/tracing/vercel-ai/constants.d.ts.map +1 -1
  330. package/build/types/tracing/vercel-ai/index.d.ts.map +1 -1
  331. package/build/types/tracing/vercel-ai/utils.d.ts +1 -5
  332. package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
  333. package/build/types/tracing/vercel-ai/vercel-ai-attributes.d.ts +0 -480
  334. package/build/types/tracing/vercel-ai/vercel-ai-attributes.d.ts.map +1 -1
  335. package/build/types/types-hoist/envelope.d.ts +22 -2
  336. package/build/types/types-hoist/envelope.d.ts.map +1 -1
  337. package/build/types/types-hoist/integration.d.ts +8 -0
  338. package/build/types/types-hoist/integration.d.ts.map +1 -1
  339. package/build/types/types-hoist/link.d.ts +2 -2
  340. package/build/types/types-hoist/link.d.ts.map +1 -1
  341. package/build/types/types-hoist/options.d.ts +26 -2
  342. package/build/types/types-hoist/options.d.ts.map +1 -1
  343. package/build/types/types-hoist/span.d.ts +35 -0
  344. package/build/types/types-hoist/span.d.ts.map +1 -1
  345. package/build/types/types-hoist/view-hierarchy.d.ts +1 -0
  346. package/build/types/types-hoist/view-hierarchy.d.ts.map +1 -1
  347. package/build/types/utils/browser.d.ts +1 -1
  348. package/build/types/utils/browser.d.ts.map +1 -1
  349. package/build/types/utils/featureFlags.d.ts.map +1 -1
  350. package/build/types/utils/object.d.ts +10 -0
  351. package/build/types/utils/object.d.ts.map +1 -1
  352. package/build/types/utils/spanUtils.d.ts +27 -2
  353. package/build/types/utils/spanUtils.d.ts.map +1 -1
  354. package/build/types/utils/stacktrace.d.ts.map +1 -1
  355. package/build/types/utils/string.d.ts +2 -2
  356. package/build/types/utils/string.d.ts.map +1 -1
  357. package/build/types/utils/weakRef.d.ts +34 -0
  358. package/build/types/utils/weakRef.d.ts.map +1 -0
  359. package/build/types-ts3.8/attributes.d.ts +5 -0
  360. package/build/types-ts3.8/build-time-plugins/buildTimeOptionsBase.d.ts +13 -0
  361. package/build/types-ts3.8/client.d.ts +35 -1
  362. package/build/types-ts3.8/fetch.d.ts +14 -10
  363. package/build/types-ts3.8/index.d.ts +16 -5
  364. package/build/types-ts3.8/integrations/express/index.d.ts +82 -0
  365. package/build/types-ts3.8/integrations/express/patch-layer.d.ts +32 -0
  366. package/build/types-ts3.8/integrations/express/request-layer-store.d.ts +32 -0
  367. package/build/types-ts3.8/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
  368. package/build/types-ts3.8/integrations/express/types.d.ts +158 -0
  369. package/build/types-ts3.8/integrations/express/utils.d.ts +96 -0
  370. package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +2 -1
  371. package/build/types-ts3.8/integrations/mcp-server/handlers.d.ts +9 -4
  372. package/build/types-ts3.8/integrations/mcp-server/index.d.ts +2 -1
  373. package/build/types-ts3.8/integrations/mcp-server/types.d.ts +40 -7
  374. package/build/types-ts3.8/integrations/mcp-server/validation.d.ts +4 -1
  375. package/build/types-ts3.8/integrations/spanStreaming.d.ts +2 -0
  376. package/build/types-ts3.8/semanticAttributes.d.ts +23 -3
  377. package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +4 -44
  378. package/build/types-ts3.8/tracing/ai/utils.d.ts +32 -2
  379. package/build/types-ts3.8/tracing/anthropic-ai/types.d.ts +5 -0
  380. package/build/types-ts3.8/tracing/anthropic-ai/utils.d.ts +1 -1
  381. package/build/types-ts3.8/tracing/google-genai/constants.d.ts +1 -3
  382. package/build/types-ts3.8/tracing/google-genai/types.d.ts +5 -0
  383. package/build/types-ts3.8/tracing/index.d.ts +1 -0
  384. package/build/types-ts3.8/tracing/langchain/embeddings.d.ts +27 -0
  385. package/build/types-ts3.8/tracing/langchain/index.d.ts +1 -0
  386. package/build/types-ts3.8/tracing/langchain/types.d.ts +5 -0
  387. package/build/types-ts3.8/tracing/langchain/utils.d.ts +2 -2
  388. package/build/types-ts3.8/tracing/langgraph/types.d.ts +5 -0
  389. package/build/types-ts3.8/tracing/openai/types.d.ts +5 -0
  390. package/build/types-ts3.8/tracing/openai/utils.d.ts +4 -49
  391. package/build/types-ts3.8/tracing/sentryNonRecordingSpan.d.ts +12 -1
  392. package/build/types-ts3.8/tracing/sentrySpan.d.ts +10 -1
  393. package/build/types-ts3.8/tracing/spans/beforeSendSpan.d.ts +35 -0
  394. package/build/types-ts3.8/tracing/spans/captureSpan.d.ts +26 -0
  395. package/build/types-ts3.8/tracing/spans/envelope.d.ts +8 -0
  396. package/build/types-ts3.8/tracing/spans/estimateSize.d.ts +12 -0
  397. package/build/types-ts3.8/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
  398. package/build/types-ts3.8/tracing/spans/spanBuffer.d.ts +60 -0
  399. package/build/types-ts3.8/tracing/vercel-ai/constants.d.ts +2 -5
  400. package/build/types-ts3.8/tracing/vercel-ai/utils.d.ts +1 -5
  401. package/build/types-ts3.8/tracing/vercel-ai/vercel-ai-attributes.d.ts +0 -480
  402. package/build/types-ts3.8/types-hoist/envelope.d.ts +22 -2
  403. package/build/types-ts3.8/types-hoist/integration.d.ts +8 -0
  404. package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
  405. package/build/types-ts3.8/types-hoist/options.d.ts +26 -2
  406. package/build/types-ts3.8/types-hoist/span.d.ts +35 -0
  407. package/build/types-ts3.8/types-hoist/view-hierarchy.d.ts +1 -0
  408. package/build/types-ts3.8/utils/browser.d.ts +1 -1
  409. package/build/types-ts3.8/utils/object.d.ts +10 -0
  410. package/build/types-ts3.8/utils/spanUtils.d.ts +27 -2
  411. package/build/types-ts3.8/utils/string.d.ts +2 -2
  412. package/build/types-ts3.8/utils/weakRef.d.ts +34 -0
  413. package/package.json +1 -1
@@ -0,0 +1,62 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const worldwide = require('./worldwide.js');
4
+
5
+ /**
6
+ * Interface representing a weak reference to an object.
7
+ * This matches the standard WeakRef interface but is defined here
8
+ * because WeakRef is not available in ES2020 type definitions.
9
+ */
10
+
11
+ /**
12
+ * Creates a weak reference to an object if WeakRef is available,
13
+ * otherwise returns the object directly.
14
+ *
15
+ * This is useful for breaking circular references while maintaining
16
+ * compatibility with environments that don't support WeakRef (e.g., older browsers).
17
+ *
18
+ * @param value - The object to create a weak reference to
19
+ * @returns A WeakRef wrapper if available, or the original object as fallback
20
+ */
21
+ function makeWeakRef(value) {
22
+ try {
23
+ // @ts-expect-error - WeakRef may not be in the type definitions for older TS targets
24
+ const WeakRefImpl = worldwide.GLOBAL_OBJ.WeakRef;
25
+ if (typeof WeakRefImpl === 'function') {
26
+ return new WeakRefImpl(value);
27
+ }
28
+ } catch {
29
+ // WeakRef not available or construction failed
30
+ }
31
+ return value;
32
+ }
33
+
34
+ /**
35
+ * Resolves a potentially weak reference, returning the underlying object
36
+ * or undefined if the reference has been garbage collected.
37
+ *
38
+ * @param ref - A MaybeWeakRef or undefined
39
+ * @returns The referenced object, or undefined if GC'd or ref was undefined
40
+ */
41
+ function derefWeakRef(ref) {
42
+ if (!ref) {
43
+ return undefined;
44
+ }
45
+
46
+ // Check if this is a WeakRef (has deref method)
47
+ if (typeof ref === 'object' && 'deref' in ref && typeof ref.deref === 'function') {
48
+ try {
49
+ return ref.deref();
50
+ } catch {
51
+ // deref() failed - treat as GC'd
52
+ return undefined;
53
+ }
54
+ }
55
+
56
+ // Direct reference fallback
57
+ return ref ;
58
+ }
59
+
60
+ exports.derefWeakRef = derefWeakRef;
61
+ exports.makeWeakRef = makeWeakRef;
62
+ //# sourceMappingURL=weakRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weakRef.js","sources":["../../../src/utils/weakRef.ts"],"sourcesContent":["import { GLOBAL_OBJ } from './worldwide';\n\n/**\n * Interface representing a weak reference to an object.\n * This matches the standard WeakRef interface but is defined here\n * because WeakRef is not available in ES2020 type definitions.\n */\ninterface WeakRefLike<T extends object> {\n deref(): T | undefined;\n}\n\n/**\n * A wrapper type that represents either a WeakRef-like object or a direct reference.\n * Used for optional weak referencing in environments where WeakRef may not be available.\n */\nexport type MaybeWeakRef<T extends object> = WeakRefLike<T> | T;\n\n/**\n * Creates a weak reference to an object if WeakRef is available,\n * otherwise returns the object directly.\n *\n * This is useful for breaking circular references while maintaining\n * compatibility with environments that don't support WeakRef (e.g., older browsers).\n *\n * @param value - The object to create a weak reference to\n * @returns A WeakRef wrapper if available, or the original object as fallback\n */\nexport function makeWeakRef<T extends object>(value: T): MaybeWeakRef<T> {\n try {\n // @ts-expect-error - WeakRef may not be in the type definitions for older TS targets\n const WeakRefImpl = GLOBAL_OBJ.WeakRef;\n if (typeof WeakRefImpl === 'function') {\n return new WeakRefImpl(value);\n }\n } catch {\n // WeakRef not available or construction failed\n }\n return value;\n}\n\n/**\n * Resolves a potentially weak reference, returning the underlying object\n * or undefined if the reference has been garbage collected.\n *\n * @param ref - A MaybeWeakRef or undefined\n * @returns The referenced object, or undefined if GC'd or ref was undefined\n */\nexport function derefWeakRef<T extends object>(ref: MaybeWeakRef<T> | undefined): T | undefined {\n if (!ref) {\n return undefined;\n }\n\n // Check if this is a WeakRef (has deref method)\n if (typeof ref === 'object' && 'deref' in ref && typeof ref.deref === 'function') {\n try {\n return ref.deref();\n } catch {\n // deref() failed - treat as GC'd\n return undefined;\n }\n }\n\n // Direct reference fallback\n return ref as T;\n}\n"],"names":["GLOBAL_OBJ"],"mappings":";;;;AAEA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAmB,KAAK,EAAsB;AACzE,EAAE,IAAI;AACN;AACA,IAAI,MAAM,WAAA,GAAcA,oBAAU,CAAC,OAAO;AAC1C,IAAI,IAAI,OAAO,WAAA,KAAgB,UAAU,EAAE;AAC3C,MAAM,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC;AACnC,IAAI;AACJ,EAAE,EAAE,MAAM;AACV;AACA,EAAE;AACF,EAAE,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAmB,GAAG,EAA8C;AAChG,EAAE,IAAI,CAAC,GAAG,EAAE;AACZ,IAAI,OAAO,SAAS;AACpB,EAAE;;AAEF;AACA,EAAE,IAAI,OAAO,GAAA,KAAQ,YAAY,OAAA,IAAW,GAAA,IAAO,OAAO,GAAG,CAAC,KAAA,KAAU,UAAU,EAAE;AACpF,IAAI,IAAI;AACR,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE;AACxB,IAAI,EAAE,MAAM;AACZ;AACA,MAAM,OAAO,SAAS;AACtB,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,OAAO,GAAA;AACT;;;;;"}
@@ -1,3 +1,5 @@
1
+ import { isPrimitive } from './utils/is.js';
2
+
1
3
  /**
2
4
  * Type-guard: The attribute object has the shape the official attribute object (value, type, unit).
3
5
  * https://develop.sentry.dev/sdk/telemetry/scopes/#setting-attributes
@@ -77,6 +79,46 @@ function serializeAttributes(
77
79
  return serializedAttributes;
78
80
  }
79
81
 
82
+ /**
83
+ * Estimates the serialized byte size of {@link Attributes},
84
+ * with a couple of heuristics for performance.
85
+ */
86
+ function estimateTypedAttributesSizeInBytes(attributes) {
87
+ if (!attributes) {
88
+ return 0;
89
+ }
90
+ let weight = 0;
91
+ for (const [key, attr] of Object.entries(attributes)) {
92
+ weight += key.length * 2;
93
+ weight += attr.type.length * 2;
94
+ weight += (attr.unit?.length ?? 0) * 2;
95
+ const val = attr.value;
96
+
97
+ if (Array.isArray(val)) {
98
+ // Assumption: Individual array items have the same type and roughly the same size
99
+ // probably not always true but allows us to cut down on runtime
100
+ weight += estimatePrimitiveSizeInBytes(val[0]) * val.length;
101
+ } else if (isPrimitive(val)) {
102
+ weight += estimatePrimitiveSizeInBytes(val);
103
+ } else {
104
+ // default fallback for anything else (objects)
105
+ weight += 100;
106
+ }
107
+ }
108
+ return weight;
109
+ }
110
+
111
+ function estimatePrimitiveSizeInBytes(value) {
112
+ if (typeof value === 'string') {
113
+ return value.length * 2;
114
+ } else if (typeof value === 'boolean') {
115
+ return 4;
116
+ } else if (typeof value === 'number') {
117
+ return 8;
118
+ }
119
+ return 0;
120
+ }
121
+
80
122
  /**
81
123
  * NOTE: We intentionally do not return anything for non-primitive values:
82
124
  * - array support will come in the future but if we stringify arrays now,
@@ -110,5 +152,5 @@ function getTypedAttributeValue(value) {
110
152
  }
111
153
  }
112
154
 
113
- export { attributeValueToTypedAttributeValue, isAttributeObject, serializeAttributes };
155
+ export { attributeValueToTypedAttributeValue, estimateTypedAttributesSizeInBytes, isAttributeObject, serializeAttributes };
114
156
  //# sourceMappingURL=attributes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.js","sources":["../../src/attributes.ts"],"sourcesContent":["import type { DurationUnit, FractionUnit, InformationUnit } from './types-hoist/measurement';\n\nexport type RawAttributes<T> = T & ValidatedAttributes<T>;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RawAttribute<T> = T extends { value: any } | { unit: any } ? AttributeObject : T;\n\nexport type Attributes = Record<string, TypedAttributeValue>;\n\nexport type AttributeValueType = string | number | boolean | Array<string> | Array<number> | Array<boolean>;\n\ntype AttributeTypeMap = {\n string: string;\n integer: number;\n double: number;\n boolean: boolean;\n 'string[]': Array<string>;\n 'integer[]': Array<number>;\n 'double[]': Array<number>;\n 'boolean[]': Array<boolean>;\n};\n\n/* Generates a type from the AttributeTypeMap like:\n | { value: string; type: 'string' }\n | { value: number; type: 'integer' }\n | { value: number; type: 'double' }\n */\ntype AttributeUnion = {\n [K in keyof AttributeTypeMap]: {\n value: AttributeTypeMap[K];\n type: K;\n };\n}[keyof AttributeTypeMap];\n\nexport type TypedAttributeValue = AttributeUnion & { unit?: AttributeUnit };\n\nexport type AttributeObject = {\n value: unknown;\n unit?: AttributeUnit;\n};\n\n// Unfortunately, we loose type safety if we did something like Exclude<MeasurementUnit, string>\n// so therefore we unionize between the three supported unit categories.\ntype AttributeUnit = DurationUnit | InformationUnit | FractionUnit;\n\n/* If an attribute has either a 'value' or 'unit' property, we use the ValidAttributeObject type. */\nexport type ValidatedAttributes<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends { value: any } | { unit: any } ? AttributeObject : unknown;\n};\n\n/**\n * Type-guard: The attribute object has the shape the official attribute object (value, type, unit).\n * https://develop.sentry.dev/sdk/telemetry/scopes/#setting-attributes\n */\nexport function isAttributeObject(maybeObj: unknown): maybeObj is AttributeObject {\n return (\n typeof maybeObj === 'object' &&\n maybeObj != null &&\n !Array.isArray(maybeObj) &&\n Object.keys(maybeObj).includes('value')\n );\n}\n\n/**\n * Converts an attribute value to a typed attribute value.\n *\n * For now, we intentionally only support primitive values and attribute objects with primitive values.\n * If @param useFallback is true, we stringify non-primitive values to a string attribute value. Otherwise\n * we return `undefined` for unsupported values.\n *\n * @param value - The value of the passed attribute.\n * @param useFallback - If true, unsupported values will be stringified to a string attribute value.\n * Defaults to false. In this case, `undefined` is returned for unsupported values.\n * @returns The typed attribute.\n */\nexport function attributeValueToTypedAttributeValue(\n rawValue: unknown,\n useFallback?: boolean | 'skip-undefined',\n): TypedAttributeValue | void {\n const { value, unit } = isAttributeObject(rawValue) ? rawValue : { value: rawValue, unit: undefined };\n const attributeValue = getTypedAttributeValue(value);\n const checkedUnit = unit && typeof unit === 'string' ? { unit } : {};\n if (attributeValue) {\n return { ...attributeValue, ...checkedUnit };\n }\n\n if (!useFallback || (useFallback === 'skip-undefined' && value === undefined)) {\n return;\n }\n\n // Fallback: stringify the value\n // TODO(v11): be smarter here and use String constructor if stringify fails\n // (this is a breaking change for already existing attribute values)\n let stringValue = '';\n try {\n stringValue = JSON.stringify(value) ?? '';\n } catch {\n // Do nothing\n }\n return {\n value: stringValue,\n type: 'string',\n ...checkedUnit,\n };\n}\n\n/**\n * Serializes raw attributes to typed attributes as expected in our envelopes.\n *\n * @param attributes The raw attributes to serialize.\n * @param fallback If true, unsupported values will be stringified to a string attribute value.\n * Defaults to false. In this case, `undefined` is returned for unsupported values.\n *\n * @returns The serialized attributes.\n */\nexport function serializeAttributes<T>(\n attributes: RawAttributes<T> | undefined,\n fallback: boolean | 'skip-undefined' = false,\n): Attributes {\n const serializedAttributes: Attributes = {};\n for (const [key, value] of Object.entries(attributes ?? {})) {\n const typedValue = attributeValueToTypedAttributeValue(value, fallback);\n if (typedValue) {\n serializedAttributes[key] = typedValue;\n }\n }\n return serializedAttributes;\n}\n\n/**\n * NOTE: We intentionally do not return anything for non-primitive values:\n * - array support will come in the future but if we stringify arrays now,\n * sending arrays (unstringified) later will be a subtle breaking change.\n * - Objects are not supported yet and product support is still TBD.\n * - We still keep the type signature for TypedAttributeValue wider to avoid a\n * breaking change once we add support for non-primitive values.\n * - Once we go back to supporting arrays and stringifying all other values,\n * we already implemented the serialization logic here:\n * https://github.com/getsentry/sentry-javascript/pull/18165\n */\nfunction getTypedAttributeValue(value: unknown): TypedAttributeValue | void {\n const primitiveType =\n typeof value === 'string'\n ? 'string'\n : typeof value === 'boolean'\n ? 'boolean'\n : typeof value === 'number' && !Number.isNaN(value)\n ? Number.isInteger(value)\n ? 'integer'\n : 'double'\n : null;\n if (primitiveType) {\n // @ts-expect-error - TS complains because {@link TypedAttributeValue} is strictly typed to\n // avoid setting the wrong `type` on the attribute value.\n // In this case, getPrimitiveType already does the check but TS doesn't know that.\n // The \"clean\" alternative is to return an object per `typeof value` case\n // but that would require more bundle size\n // Therefore, we ignore it.\n return { value, type: primitiveType };\n }\n}\n"],"names":[],"mappings":"AAkDA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,QAAQ,EAAwC;AAClF,EAAE;AACF,IAAI,OAAO,QAAA,KAAa,QAAA;AACxB,IAAI,QAAA,IAAY,IAAA;AAChB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAA;AAC3B,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO;AAC1C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mCAAmC;AACnD,EAAE,QAAQ;AACV,EAAE,WAAW;AACb,EAA8B;AAC9B,EAAE,MAAM,EAAE,KAAK,EAAE,MAAK,GAAI,iBAAiB,CAAC,QAAQ,CAAA,GAAI,QAAA,GAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAA,EAAW;AACvG,EAAE,MAAM,cAAA,GAAiB,sBAAsB,CAAC,KAAK,CAAC;AACtD,EAAE,MAAM,WAAA,GAAc,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,GAAW,EAAE,IAAA,EAAK,GAAI,EAAE;AACtE,EAAE,IAAI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AM,CAAC,KAAK,CAAC,KAAK;AAC1D,YAAY,MAAM,CAAC,SAAS,CAAC,KAAK;AAClC,cAAc;AACd,cAAc;AACd,YAAY,IAAI;AAChB,EAAE,IAAI,aAAa,EAAE;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe;AACzC,EAAE;AACF;;;;"}
1
+ {"version":3,"file":"attributes.js","sources":["../../src/attributes.ts"],"sourcesContent":["import type { DurationUnit, FractionUnit, InformationUnit } from './types-hoist/measurement';\nimport type { Primitive } from './types-hoist/misc';\nimport { isPrimitive } from './utils/is';\n\nexport type RawAttributes<T> = T & ValidatedAttributes<T>;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RawAttribute<T> = T extends { value: any } | { unit: any } ? AttributeObject : T;\n\nexport type Attributes = Record<string, TypedAttributeValue>;\n\nexport type AttributeValueType = string | number | boolean | Array<string> | Array<number> | Array<boolean>;\n\ntype AttributeTypeMap = {\n string: string;\n integer: number;\n double: number;\n boolean: boolean;\n 'string[]': Array<string>;\n 'integer[]': Array<number>;\n 'double[]': Array<number>;\n 'boolean[]': Array<boolean>;\n};\n\n/* Generates a type from the AttributeTypeMap like:\n | { value: string; type: 'string' }\n | { value: number; type: 'integer' }\n | { value: number; type: 'double' }\n */\ntype AttributeUnion = {\n [K in keyof AttributeTypeMap]: {\n value: AttributeTypeMap[K];\n type: K;\n };\n}[keyof AttributeTypeMap];\n\nexport type TypedAttributeValue = AttributeUnion & { unit?: AttributeUnit };\n\nexport type AttributeObject = {\n value: unknown;\n unit?: AttributeUnit;\n};\n\n// Unfortunately, we loose type safety if we did something like Exclude<MeasurementUnit, string>\n// so therefore we unionize between the three supported unit categories.\ntype AttributeUnit = DurationUnit | InformationUnit | FractionUnit;\n\n/* If an attribute has either a 'value' or 'unit' property, we use the ValidAttributeObject type. */\nexport type ValidatedAttributes<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends { value: any } | { unit: any } ? AttributeObject : unknown;\n};\n\n/**\n * Type-guard: The attribute object has the shape the official attribute object (value, type, unit).\n * https://develop.sentry.dev/sdk/telemetry/scopes/#setting-attributes\n */\nexport function isAttributeObject(maybeObj: unknown): maybeObj is AttributeObject {\n return (\n typeof maybeObj === 'object' &&\n maybeObj != null &&\n !Array.isArray(maybeObj) &&\n Object.keys(maybeObj).includes('value')\n );\n}\n\n/**\n * Converts an attribute value to a typed attribute value.\n *\n * For now, we intentionally only support primitive values and attribute objects with primitive values.\n * If @param useFallback is true, we stringify non-primitive values to a string attribute value. Otherwise\n * we return `undefined` for unsupported values.\n *\n * @param value - The value of the passed attribute.\n * @param useFallback - If true, unsupported values will be stringified to a string attribute value.\n * Defaults to false. In this case, `undefined` is returned for unsupported values.\n * @returns The typed attribute.\n */\nexport function attributeValueToTypedAttributeValue(\n rawValue: unknown,\n useFallback?: boolean | 'skip-undefined',\n): TypedAttributeValue | void {\n const { value, unit } = isAttributeObject(rawValue) ? rawValue : { value: rawValue, unit: undefined };\n const attributeValue = getTypedAttributeValue(value);\n const checkedUnit = unit && typeof unit === 'string' ? { unit } : {};\n if (attributeValue) {\n return { ...attributeValue, ...checkedUnit };\n }\n\n if (!useFallback || (useFallback === 'skip-undefined' && value === undefined)) {\n return;\n }\n\n // Fallback: stringify the value\n // TODO(v11): be smarter here and use String constructor if stringify fails\n // (this is a breaking change for already existing attribute values)\n let stringValue = '';\n try {\n stringValue = JSON.stringify(value) ?? '';\n } catch {\n // Do nothing\n }\n return {\n value: stringValue,\n type: 'string',\n ...checkedUnit,\n };\n}\n\n/**\n * Serializes raw attributes to typed attributes as expected in our envelopes.\n *\n * @param attributes The raw attributes to serialize.\n * @param fallback If true, unsupported values will be stringified to a string attribute value.\n * Defaults to false. In this case, `undefined` is returned for unsupported values.\n *\n * @returns The serialized attributes.\n */\nexport function serializeAttributes<T>(\n attributes: RawAttributes<T> | undefined,\n fallback: boolean | 'skip-undefined' = false,\n): Attributes {\n const serializedAttributes: Attributes = {};\n for (const [key, value] of Object.entries(attributes ?? {})) {\n const typedValue = attributeValueToTypedAttributeValue(value, fallback);\n if (typedValue) {\n serializedAttributes[key] = typedValue;\n }\n }\n return serializedAttributes;\n}\n\n/**\n * Estimates the serialized byte size of {@link Attributes},\n * with a couple of heuristics for performance.\n */\nexport function estimateTypedAttributesSizeInBytes(attributes: Attributes | undefined): number {\n if (!attributes) {\n return 0;\n }\n let weight = 0;\n for (const [key, attr] of Object.entries(attributes)) {\n weight += key.length * 2;\n weight += attr.type.length * 2;\n weight += (attr.unit?.length ?? 0) * 2;\n const val = attr.value;\n\n if (Array.isArray(val)) {\n // Assumption: Individual array items have the same type and roughly the same size\n // probably not always true but allows us to cut down on runtime\n weight += estimatePrimitiveSizeInBytes(val[0]) * val.length;\n } else if (isPrimitive(val)) {\n weight += estimatePrimitiveSizeInBytes(val);\n } else {\n // default fallback for anything else (objects)\n weight += 100;\n }\n }\n return weight;\n}\n\nfunction estimatePrimitiveSizeInBytes(value: Primitive): number {\n if (typeof value === 'string') {\n return value.length * 2;\n } else if (typeof value === 'boolean') {\n return 4;\n } else if (typeof value === 'number') {\n return 8;\n }\n return 0;\n}\n\n/**\n * NOTE: We intentionally do not return anything for non-primitive values:\n * - array support will come in the future but if we stringify arrays now,\n * sending arrays (unstringified) later will be a subtle breaking change.\n * - Objects are not supported yet and product support is still TBD.\n * - We still keep the type signature for TypedAttributeValue wider to avoid a\n * breaking change once we add support for non-primitive values.\n * - Once we go back to supporting arrays and stringifying all other values,\n * we already implemented the serialization logic here:\n * https://github.com/getsentry/sentry-javascript/pull/18165\n */\nfunction getTypedAttributeValue(value: unknown): TypedAttributeValue | void {\n const primitiveType =\n typeof value === 'string'\n ? 'string'\n : typeof value === 'boolean'\n ? 'boolean'\n : typeof value === 'number' && !Number.isNaN(value)\n ? Number.isInteger(value)\n ? 'integer'\n : 'double'\n : null;\n if (primitiveType) {\n // @ts-expect-error - TS complains because {@link TypedAttributeValue} is strictly typed to\n // avoid setting the wrong `type` on the attribute value.\n // In this case, getPrimitiveType already does the check but TS doesn't know that.\n // The \"clean\" alternative is to return an object per `typeof value` case\n // but that would require more bundle size\n // Therefore, we ignore it.\n return { value, type: primitiveType };\n }\n}\n"],"names":[],"mappings":";;AAoDA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,QAAQ,EAAwC;AAClF,EAAE;AACF,IAAI,OAAO,QAAA,KAAa,QAAA;AACxB,IAAI,QAAA,IAAY,IAAA;AAChB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAA;AAC3B,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO;AAC1C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mCAAmC;AACnD,EAAE,QAAQ;AACV,EAAE,WAAW;AACb,EAA8B;AAC9B,EAAE,MAAM,EAAE,KAAK,EAAE,MAAK,GAAI,iBAAiB,CAAC,QAAQ,CAAA,GAAI,QAAA,GAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAA,EAAW;AACvG,EAAE,MAAM,cAAA,GAAiB,sBAAsB,CAAC,KAAK,CAAC;AACtD,EAAE,MAAM,WAAA,GAAc,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,GAAW,EAAE,IAAA,EAAK,GAAI,EAAE;AACtE,EAAE,IAAI,cAAc,EAAE;AACtB,IAAI,OAAO,EAAE,GAAG,cAAc,EAAE,GAAG,aAAa;AAChD,EAAE;;AAEF,EAAE,IAAI,CAAC,WAAA,KAAgB,WAAA,KAAgB,gBAAA,IAAoB,KAAA,KAAU,SAAS,CAAC,EAAE;AACjF,IAAI;AACJ,EAAE;;AAEF;AACA;AACA;AACA,EAAE,IAAI,WAAA,GAAc,EAAE;AACtB,EAAE,IAAI;AACN,IAAI,WAAA,GAAc,IAAI,CAAC,SAAS,CA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/internal.js';
8
8
  import { _INTERNAL_flushMetricsBuffer } from './metrics/internal.js';
9
9
  import { updateSession } from './session.js';
10
10
  import { getDynamicSamplingContextFromScope } from './tracing/dynamicSamplingContext.js';
11
+ import { isStreamedBeforeSendSpanCallback } from './tracing/spans/beforeSendSpan.js';
11
12
  import { DEFAULT_TRANSPORT_BUFFER_SIZE } from './transports/base.js';
12
13
  import { createClientReportEnvelope } from './utils/clientreport.js';
13
14
  import { debug } from './utils/debug-logger.js';
@@ -455,6 +456,10 @@ class Client {
455
456
  addIntegration(integration) {
456
457
  const isAlreadyInstalled = this._integrations[integration.name];
457
458
 
459
+ if (!isAlreadyInstalled && integration.beforeSetup) {
460
+ integration.beforeSetup(this);
461
+ }
462
+
458
463
  // This hook takes care of only installing if not already installed
459
464
  setupIntegration(this, integration, this._integrations);
460
465
  // Here we need to check manually to make sure to not run this multiple times
@@ -999,7 +1004,9 @@ function processBeforeSend(
999
1004
  event,
1000
1005
  hint,
1001
1006
  ) {
1002
- const { beforeSend, beforeSendTransaction, beforeSendSpan, ignoreSpans } = options;
1007
+ const { beforeSend, beforeSendTransaction, ignoreSpans } = options;
1008
+ const beforeSendSpan = !isStreamedBeforeSendSpanCallback(options.beforeSendSpan) && options.beforeSendSpan;
1009
+
1003
1010
  let processedEvent = event;
1004
1011
 
1005
1012
  if (isErrorEvent(processedEvent) && beforeSend) {