@sentry/core 10.47.0 → 10.48.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 (316) 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/index.js +44 -13
  8. package/build/cjs/index.js.map +1 -1
  9. package/build/cjs/integration.js +6 -0
  10. package/build/cjs/integration.js.map +1 -1
  11. package/build/cjs/integrations/express/index.js +206 -0
  12. package/build/cjs/integrations/express/index.js.map +1 -0
  13. package/build/cjs/integrations/express/patch-layer.js +251 -0
  14. package/build/cjs/integrations/express/patch-layer.js.map +1 -0
  15. package/build/cjs/integrations/express/request-layer-store.js +25 -0
  16. package/build/cjs/integrations/express/request-layer-store.js.map +1 -0
  17. package/build/cjs/integrations/express/set-sdk-processing-metadata.js +17 -0
  18. package/build/cjs/integrations/express/set-sdk-processing-metadata.js.map +1 -0
  19. package/build/cjs/integrations/express/types.js +17 -0
  20. package/build/cjs/integrations/express/types.js.map +1 -0
  21. package/build/cjs/integrations/express/utils.js +238 -0
  22. package/build/cjs/integrations/express/utils.js.map +1 -0
  23. package/build/cjs/integrations/mcp-server/correlation.js +5 -1
  24. package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
  25. package/build/cjs/integrations/mcp-server/handlers.js +18 -10
  26. package/build/cjs/integrations/mcp-server/handlers.js.map +1 -1
  27. package/build/cjs/integrations/mcp-server/index.js +2 -1
  28. package/build/cjs/integrations/mcp-server/index.js.map +1 -1
  29. package/build/cjs/integrations/mcp-server/transport.js +1 -1
  30. package/build/cjs/integrations/mcp-server/transport.js.map +1 -1
  31. package/build/cjs/integrations/mcp-server/validation.js +7 -5
  32. package/build/cjs/integrations/mcp-server/validation.js.map +1 -1
  33. package/build/cjs/integrations/spanStreaming.js +48 -0
  34. package/build/cjs/integrations/spanStreaming.js.map +1 -0
  35. package/build/cjs/semanticAttributes.js +35 -3
  36. package/build/cjs/semanticAttributes.js.map +1 -1
  37. package/build/cjs/tracing/ai/gen-ai-attributes.js +9 -65
  38. package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
  39. package/build/cjs/tracing/ai/utils.js +50 -0
  40. package/build/cjs/tracing/ai/utils.js.map +1 -1
  41. package/build/cjs/tracing/anthropic-ai/index.js +1 -12
  42. package/build/cjs/tracing/anthropic-ai/index.js.map +1 -1
  43. package/build/cjs/tracing/anthropic-ai/streaming.js +2 -100
  44. package/build/cjs/tracing/anthropic-ai/streaming.js.map +1 -1
  45. package/build/cjs/tracing/dynamicSamplingContext.js +2 -1
  46. package/build/cjs/tracing/dynamicSamplingContext.js.map +1 -1
  47. package/build/cjs/tracing/google-genai/constants.js +1 -6
  48. package/build/cjs/tracing/google-genai/constants.js.map +1 -1
  49. package/build/cjs/tracing/google-genai/index.js +24 -30
  50. package/build/cjs/tracing/google-genai/index.js.map +1 -1
  51. package/build/cjs/tracing/google-genai/streaming.js +2 -23
  52. package/build/cjs/tracing/google-genai/streaming.js.map +1 -1
  53. package/build/cjs/tracing/langchain/embeddings.js +132 -0
  54. package/build/cjs/tracing/langchain/embeddings.js.map +1 -0
  55. package/build/cjs/tracing/langchain/index.js.map +1 -1
  56. package/build/cjs/tracing/openai/index.js +2 -29
  57. package/build/cjs/tracing/openai/index.js.map +1 -1
  58. package/build/cjs/tracing/openai/streaming.js +3 -34
  59. package/build/cjs/tracing/openai/streaming.js.map +1 -1
  60. package/build/cjs/tracing/openai/utils.js +78 -204
  61. package/build/cjs/tracing/openai/utils.js.map +1 -1
  62. package/build/cjs/tracing/sentryNonRecordingSpan.js +7 -0
  63. package/build/cjs/tracing/sentryNonRecordingSpan.js.map +1 -1
  64. package/build/cjs/tracing/sentrySpan.js +39 -0
  65. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  66. package/build/cjs/tracing/spans/beforeSendSpan.js +43 -0
  67. package/build/cjs/tracing/spans/beforeSendSpan.js.map +1 -0
  68. package/build/cjs/tracing/spans/captureSpan.js +126 -0
  69. package/build/cjs/tracing/spans/captureSpan.js.map +1 -0
  70. package/build/cjs/tracing/spans/envelope.js +38 -0
  71. package/build/cjs/tracing/spans/envelope.js.map +1 -0
  72. package/build/cjs/tracing/spans/estimateSize.js +41 -0
  73. package/build/cjs/tracing/spans/estimateSize.js.map +1 -0
  74. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js +11 -0
  75. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
  76. package/build/cjs/tracing/spans/spanBuffer.js +158 -0
  77. package/build/cjs/tracing/spans/spanBuffer.js.map +1 -0
  78. package/build/cjs/tracing/trace.js +83 -13
  79. package/build/cjs/tracing/trace.js.map +1 -1
  80. package/build/cjs/tracing/vercel-ai/utils.js +1 -4
  81. package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
  82. package/build/cjs/utils/featureFlags.js +6 -0
  83. package/build/cjs/utils/featureFlags.js.map +1 -1
  84. package/build/cjs/utils/object.js +33 -0
  85. package/build/cjs/utils/object.js.map +1 -1
  86. package/build/cjs/utils/spanUtils.js +116 -13
  87. package/build/cjs/utils/spanUtils.js.map +1 -1
  88. package/build/cjs/utils/stacktrace.js +3 -1
  89. package/build/cjs/utils/stacktrace.js.map +1 -1
  90. package/build/cjs/utils/string.js +3 -0
  91. package/build/cjs/utils/string.js.map +1 -1
  92. package/build/cjs/utils/version.js +1 -1
  93. package/build/esm/attributes.js +43 -1
  94. package/build/esm/attributes.js.map +1 -1
  95. package/build/esm/client.js +8 -1
  96. package/build/esm/client.js.map +1 -1
  97. package/build/esm/envelope.js +2 -1
  98. package/build/esm/envelope.js.map +1 -1
  99. package/build/esm/index.js +10 -2
  100. package/build/esm/index.js.map +1 -1
  101. package/build/esm/integration.js +6 -0
  102. package/build/esm/integration.js.map +1 -1
  103. package/build/esm/integrations/express/index.js +202 -0
  104. package/build/esm/integrations/express/index.js.map +1 -0
  105. package/build/esm/integrations/express/patch-layer.js +249 -0
  106. package/build/esm/integrations/express/patch-layer.js.map +1 -0
  107. package/build/esm/integrations/express/request-layer-store.js +22 -0
  108. package/build/esm/integrations/express/request-layer-store.js.map +1 -0
  109. package/build/esm/integrations/express/set-sdk-processing-metadata.js +15 -0
  110. package/build/esm/integrations/express/set-sdk-processing-metadata.js.map +1 -0
  111. package/build/esm/integrations/express/types.js +10 -0
  112. package/build/esm/integrations/express/types.js.map +1 -0
  113. package/build/esm/integrations/express/utils.js +225 -0
  114. package/build/esm/integrations/express/utils.js.map +1 -0
  115. package/build/esm/integrations/mcp-server/correlation.js +5 -1
  116. package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
  117. package/build/esm/integrations/mcp-server/handlers.js +18 -10
  118. package/build/esm/integrations/mcp-server/handlers.js.map +1 -1
  119. package/build/esm/integrations/mcp-server/index.js +2 -1
  120. package/build/esm/integrations/mcp-server/index.js.map +1 -1
  121. package/build/esm/integrations/mcp-server/transport.js +1 -1
  122. package/build/esm/integrations/mcp-server/transport.js.map +1 -1
  123. package/build/esm/integrations/mcp-server/validation.js +7 -5
  124. package/build/esm/integrations/mcp-server/validation.js.map +1 -1
  125. package/build/esm/integrations/spanStreaming.js +46 -0
  126. package/build/esm/integrations/spanStreaming.js.map +1 -0
  127. package/build/esm/package.json +1 -1
  128. package/build/esm/semanticAttributes.js +26 -4
  129. package/build/esm/semanticAttributes.js.map +1 -1
  130. package/build/esm/tracing/ai/gen-ai-attributes.js +8 -56
  131. package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
  132. package/build/esm/tracing/ai/utils.js +51 -2
  133. package/build/esm/tracing/ai/utils.js.map +1 -1
  134. package/build/esm/tracing/anthropic-ai/index.js +2 -13
  135. package/build/esm/tracing/anthropic-ai/index.js.map +1 -1
  136. package/build/esm/tracing/anthropic-ai/streaming.js +3 -101
  137. package/build/esm/tracing/anthropic-ai/streaming.js.map +1 -1
  138. package/build/esm/tracing/dynamicSamplingContext.js +2 -1
  139. package/build/esm/tracing/dynamicSamplingContext.js.map +1 -1
  140. package/build/esm/tracing/google-genai/constants.js +2 -5
  141. package/build/esm/tracing/google-genai/constants.js.map +1 -1
  142. package/build/esm/tracing/google-genai/index.js +25 -31
  143. package/build/esm/tracing/google-genai/index.js.map +1 -1
  144. package/build/esm/tracing/google-genai/streaming.js +2 -23
  145. package/build/esm/tracing/google-genai/streaming.js.map +1 -1
  146. package/build/esm/tracing/langchain/embeddings.js +129 -0
  147. package/build/esm/tracing/langchain/embeddings.js.map +1 -0
  148. package/build/esm/tracing/langchain/index.js.map +1 -1
  149. package/build/esm/tracing/openai/index.js +3 -30
  150. package/build/esm/tracing/openai/index.js.map +1 -1
  151. package/build/esm/tracing/openai/streaming.js +4 -35
  152. package/build/esm/tracing/openai/streaming.js.map +1 -1
  153. package/build/esm/tracing/openai/utils.js +79 -196
  154. package/build/esm/tracing/openai/utils.js.map +1 -1
  155. package/build/esm/tracing/sentryNonRecordingSpan.js +7 -0
  156. package/build/esm/tracing/sentryNonRecordingSpan.js.map +1 -1
  157. package/build/esm/tracing/sentrySpan.js +40 -1
  158. package/build/esm/tracing/sentrySpan.js.map +1 -1
  159. package/build/esm/tracing/spans/beforeSendSpan.js +40 -0
  160. package/build/esm/tracing/spans/beforeSendSpan.js.map +1 -0
  161. package/build/esm/tracing/spans/captureSpan.js +122 -0
  162. package/build/esm/tracing/spans/captureSpan.js.map +1 -0
  163. package/build/esm/tracing/spans/envelope.js +36 -0
  164. package/build/esm/tracing/spans/envelope.js.map +1 -0
  165. package/build/esm/tracing/spans/estimateSize.js +39 -0
  166. package/build/esm/tracing/spans/estimateSize.js.map +1 -0
  167. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js +9 -0
  168. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
  169. package/build/esm/tracing/spans/spanBuffer.js +156 -0
  170. package/build/esm/tracing/spans/spanBuffer.js.map +1 -0
  171. package/build/esm/tracing/trace.js +84 -14
  172. package/build/esm/tracing/trace.js.map +1 -1
  173. package/build/esm/tracing/vercel-ai/utils.js +2 -5
  174. package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
  175. package/build/esm/utils/featureFlags.js +6 -0
  176. package/build/esm/utils/featureFlags.js.map +1 -1
  177. package/build/esm/utils/object.js +33 -1
  178. package/build/esm/utils/object.js.map +1 -1
  179. package/build/esm/utils/spanUtils.js +112 -14
  180. package/build/esm/utils/spanUtils.js.map +1 -1
  181. package/build/esm/utils/stacktrace.js +3 -1
  182. package/build/esm/utils/stacktrace.js.map +1 -1
  183. package/build/esm/utils/string.js +3 -0
  184. package/build/esm/utils/string.js.map +1 -1
  185. package/build/esm/utils/version.js +1 -1
  186. package/build/types/attributes.d.ts +5 -0
  187. package/build/types/attributes.d.ts.map +1 -1
  188. package/build/types/client.d.ts +35 -1
  189. package/build/types/client.d.ts.map +1 -1
  190. package/build/types/envelope.d.ts.map +1 -1
  191. package/build/types/index.d.ts +12 -4
  192. package/build/types/index.d.ts.map +1 -1
  193. package/build/types/integration.d.ts.map +1 -1
  194. package/build/types/integrations/express/index.d.ts +75 -0
  195. package/build/types/integrations/express/index.d.ts.map +1 -0
  196. package/build/types/integrations/express/patch-layer.d.ts +32 -0
  197. package/build/types/integrations/express/patch-layer.d.ts.map +1 -0
  198. package/build/types/integrations/express/request-layer-store.d.ts +32 -0
  199. package/build/types/integrations/express/request-layer-store.d.ts.map +1 -0
  200. package/build/types/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
  201. package/build/types/integrations/express/set-sdk-processing-metadata.d.ts.map +1 -0
  202. package/build/types/integrations/express/types.d.ts +154 -0
  203. package/build/types/integrations/express/types.d.ts.map +1 -0
  204. package/build/types/integrations/express/utils.d.ts +93 -0
  205. package/build/types/integrations/express/utils.d.ts.map +1 -0
  206. package/build/types/integrations/mcp-server/correlation.d.ts +2 -1
  207. package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
  208. package/build/types/integrations/mcp-server/handlers.d.ts +9 -4
  209. package/build/types/integrations/mcp-server/handlers.d.ts.map +1 -1
  210. package/build/types/integrations/mcp-server/index.d.ts +2 -1
  211. package/build/types/integrations/mcp-server/index.d.ts.map +1 -1
  212. package/build/types/integrations/mcp-server/types.d.ts +40 -7
  213. package/build/types/integrations/mcp-server/types.d.ts.map +1 -1
  214. package/build/types/integrations/mcp-server/validation.d.ts +4 -1
  215. package/build/types/integrations/mcp-server/validation.d.ts.map +1 -1
  216. package/build/types/integrations/spanStreaming.d.ts +2 -0
  217. package/build/types/integrations/spanStreaming.d.ts.map +1 -0
  218. package/build/types/semanticAttributes.d.ts +23 -3
  219. package/build/types/semanticAttributes.d.ts.map +1 -1
  220. package/build/types/tracing/ai/gen-ai-attributes.d.ts +6 -38
  221. package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
  222. package/build/types/tracing/ai/utils.d.ts +21 -2
  223. package/build/types/tracing/ai/utils.d.ts.map +1 -1
  224. package/build/types/tracing/anthropic-ai/index.d.ts.map +1 -1
  225. package/build/types/tracing/anthropic-ai/streaming.d.ts.map +1 -1
  226. package/build/types/tracing/dynamicSamplingContext.d.ts.map +1 -1
  227. package/build/types/tracing/google-genai/constants.d.ts +1 -3
  228. package/build/types/tracing/google-genai/constants.d.ts.map +1 -1
  229. package/build/types/tracing/google-genai/index.d.ts.map +1 -1
  230. package/build/types/tracing/google-genai/streaming.d.ts.map +1 -1
  231. package/build/types/tracing/index.d.ts +1 -0
  232. package/build/types/tracing/index.d.ts.map +1 -1
  233. package/build/types/tracing/langchain/embeddings.d.ts +27 -0
  234. package/build/types/tracing/langchain/embeddings.d.ts.map +1 -0
  235. package/build/types/tracing/langchain/index.d.ts +1 -0
  236. package/build/types/tracing/langchain/index.d.ts.map +1 -1
  237. package/build/types/tracing/openai/index.d.ts.map +1 -1
  238. package/build/types/tracing/openai/streaming.d.ts.map +1 -1
  239. package/build/types/tracing/openai/utils.d.ts +4 -49
  240. package/build/types/tracing/openai/utils.d.ts.map +1 -1
  241. package/build/types/tracing/sentryNonRecordingSpan.d.ts +12 -1
  242. package/build/types/tracing/sentryNonRecordingSpan.d.ts.map +1 -1
  243. package/build/types/tracing/sentrySpan.d.ts +10 -1
  244. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  245. package/build/types/tracing/spans/beforeSendSpan.d.ts +35 -0
  246. package/build/types/tracing/spans/beforeSendSpan.d.ts.map +1 -0
  247. package/build/types/tracing/spans/captureSpan.d.ts +26 -0
  248. package/build/types/tracing/spans/captureSpan.d.ts.map +1 -0
  249. package/build/types/tracing/spans/envelope.d.ts +8 -0
  250. package/build/types/tracing/spans/envelope.d.ts.map +1 -0
  251. package/build/types/tracing/spans/estimateSize.d.ts +12 -0
  252. package/build/types/tracing/spans/estimateSize.d.ts.map +1 -0
  253. package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
  254. package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts.map +1 -0
  255. package/build/types/tracing/spans/spanBuffer.d.ts +60 -0
  256. package/build/types/tracing/spans/spanBuffer.d.ts.map +1 -0
  257. package/build/types/tracing/trace.d.ts.map +1 -1
  258. package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
  259. package/build/types/types-hoist/envelope.d.ts +22 -2
  260. package/build/types/types-hoist/envelope.d.ts.map +1 -1
  261. package/build/types/types-hoist/integration.d.ts +8 -0
  262. package/build/types/types-hoist/integration.d.ts.map +1 -1
  263. package/build/types/types-hoist/link.d.ts +2 -2
  264. package/build/types/types-hoist/link.d.ts.map +1 -1
  265. package/build/types/types-hoist/options.d.ts +26 -2
  266. package/build/types/types-hoist/options.d.ts.map +1 -1
  267. package/build/types/types-hoist/span.d.ts +35 -0
  268. package/build/types/types-hoist/span.d.ts.map +1 -1
  269. package/build/types/utils/featureFlags.d.ts.map +1 -1
  270. package/build/types/utils/object.d.ts +10 -0
  271. package/build/types/utils/object.d.ts.map +1 -1
  272. package/build/types/utils/spanUtils.d.ts +27 -2
  273. package/build/types/utils/spanUtils.d.ts.map +1 -1
  274. package/build/types/utils/stacktrace.d.ts.map +1 -1
  275. package/build/types/utils/string.d.ts +2 -2
  276. package/build/types/utils/string.d.ts.map +1 -1
  277. package/build/types-ts3.8/attributes.d.ts +5 -0
  278. package/build/types-ts3.8/client.d.ts +35 -1
  279. package/build/types-ts3.8/index.d.ts +12 -4
  280. package/build/types-ts3.8/integrations/express/index.d.ts +75 -0
  281. package/build/types-ts3.8/integrations/express/patch-layer.d.ts +32 -0
  282. package/build/types-ts3.8/integrations/express/request-layer-store.d.ts +32 -0
  283. package/build/types-ts3.8/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
  284. package/build/types-ts3.8/integrations/express/types.d.ts +154 -0
  285. package/build/types-ts3.8/integrations/express/utils.d.ts +96 -0
  286. package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +2 -1
  287. package/build/types-ts3.8/integrations/mcp-server/handlers.d.ts +9 -4
  288. package/build/types-ts3.8/integrations/mcp-server/index.d.ts +2 -1
  289. package/build/types-ts3.8/integrations/mcp-server/types.d.ts +40 -7
  290. package/build/types-ts3.8/integrations/mcp-server/validation.d.ts +4 -1
  291. package/build/types-ts3.8/integrations/spanStreaming.d.ts +2 -0
  292. package/build/types-ts3.8/semanticAttributes.d.ts +23 -3
  293. package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +6 -38
  294. package/build/types-ts3.8/tracing/ai/utils.d.ts +21 -2
  295. package/build/types-ts3.8/tracing/google-genai/constants.d.ts +1 -3
  296. package/build/types-ts3.8/tracing/index.d.ts +1 -0
  297. package/build/types-ts3.8/tracing/langchain/embeddings.d.ts +27 -0
  298. package/build/types-ts3.8/tracing/langchain/index.d.ts +1 -0
  299. package/build/types-ts3.8/tracing/openai/utils.d.ts +4 -49
  300. package/build/types-ts3.8/tracing/sentryNonRecordingSpan.d.ts +12 -1
  301. package/build/types-ts3.8/tracing/sentrySpan.d.ts +10 -1
  302. package/build/types-ts3.8/tracing/spans/beforeSendSpan.d.ts +35 -0
  303. package/build/types-ts3.8/tracing/spans/captureSpan.d.ts +26 -0
  304. package/build/types-ts3.8/tracing/spans/envelope.d.ts +8 -0
  305. package/build/types-ts3.8/tracing/spans/estimateSize.d.ts +12 -0
  306. package/build/types-ts3.8/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
  307. package/build/types-ts3.8/tracing/spans/spanBuffer.d.ts +60 -0
  308. package/build/types-ts3.8/types-hoist/envelope.d.ts +22 -2
  309. package/build/types-ts3.8/types-hoist/integration.d.ts +8 -0
  310. package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
  311. package/build/types-ts3.8/types-hoist/options.d.ts +26 -2
  312. package/build/types-ts3.8/types-hoist/span.d.ts +35 -0
  313. package/build/types-ts3.8/utils/object.d.ts +10 -0
  314. package/build/types-ts3.8/utils/spanUtils.d.ts +27 -2
  315. package/build/types-ts3.8/utils/string.d.ts +2 -2
  316. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"trace.js","sources":["../../../src/tracing/trace.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types-hoist/envelope';\nimport type { ClientOptions } from '../types-hoist/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types-hoist/span';\nimport type { StartSpanOptions } from '../types-hoist/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\n\nconst SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n _setSpanForScope(scope, activeSpan);\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n _setSpanForScope(scope, activeSpan);\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n\n if (shouldSkipSpan) {\n return new SentryNonRecordingSpan();\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n if (!hasSpansEnabled()) {\n const span = new SentryNonRecordingSpan();\n\n // If this is a root span, we ensure to freeze a DSC\n // So we can have at least partial data here\n if (forceTransaction || !parentSpan) {\n const dsc = {\n sampled: 'false',\n sample_rate: '0',\n transaction: spanArguments.name,\n ...getDynamicSamplingContextFromSpan(span),\n } satisfies Partial<DynamicSamplingContext>;\n freezeDscOnSpan(span, dsc);\n }\n\n return span;\n }\n\n const isolationScope = getIsolationScope();\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(spanArguments: SentrySpanArguments, scope: Scope, parentSampled?: boolean): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const [sampled, sampleRate, localSampleRateWasApplied] = scope.getScopeData().sdkProcessingMetadata[\n SUPPRESS_TRACING_KEY\n ]\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', 'transaction');\n }\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(parentSpan: Span, scope: Scope, spanArguments: SentrySpanArguments): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const sampled = scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n const client = getClient();\n if (client) {\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n }\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n"],"names":["withScope","getCurrentScope","SentryNonRecordingSpan","_setSpanForScope","handleCallbackErrors","spanToJSON","SPAN_STATUS_ERROR","carrier","getMainCarrier","getAsyncContextStrategy","baggage","getClient","baggageHeaderToDynamicSamplingContext","shouldContinueTrace","propagationContextFromHeaders","generateTraceId","safeMathRandom","DEBUG_BUILD","debug","hasSpansEnabled","getDynamicSamplingContextFromSpan","freezeDscOnSpan","getIsolationScope","addChildSpanToSpan","spanIsSampled","logSpanStart","setCapturedScopesOnSpan","spanTimeInputToSeconds","sampleSpan","parseSampleRate","SentrySpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","_getSpanForScope","getRootSpan"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AA+BA,MAAM,oBAAA,GAAuB,6BAA6B;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAI,OAAO,EAAoB,QAAQ,EAAwB;AACxF,EAAE,MAAM,GAAA,GAAM,MAAM,EAAE;AACtB,EAAE,IAAI,GAAG,CAAC,SAAS,EAAE;AACrB,IAAI,OAAO,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC;AAC3C,EAAE;;AAEF,EAAE,MAAM,aAAA,GAAgB,wBAAwB,CAAC,OAAO,CAAC;AACzD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qB,4BAAA,CAAA,UAAA,EAAA,SAAA,CAAA;;AAEA,EAAA,MAAA,MAAA,GAAAZ,uBAAA,EAAA;AACA,EAAA,IAAA,MAAA,EAAA;AACA,IAAA,MAAA,CAAA,IAAA,CAAA,WAAA,EAAA,SAAA,CAAA;AACA;AACA,IAAA,IAAA,aAAA,CAAA,YAAA,EAAA;AACA,MAAA,MAAA,CAAA,IAAA,CAAA,SAAA,EAAA,SAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,OAAA,SAAA;AACA;;AAEA,SAAA,aAAA,CAAA,KAAA,EAAA,gBAAA,EAAA;AACA;AACA,EAAA,IAAA,gBAAA,EAAA;AACA,IAAA,OAAA,gBAAA;AACA,EAAA;;AAEA;AACA,EAAA,IAAA,gBAAA,KAAA,IAAA,EAAA;AACA,IAAA,OAAA,SAAA;AACA,EAAA;;AAEA,EAAA,MAAA,IAAA,GAAAsB,4BAAA,CAAA,KAAA,CAAA;;AAEA,EAAA,IAAA,CAAA,IAAA,EAAA;AACA,IAAA,OAAA,SAAA;AACA,EAAA;;AAEA,EAAA,MAAA,MAAA,GAAAtB,uBAAA,EAAA;AACA,EAAA,MAAA,OAAA,GAAA,MAAA,GAAA,MAAA,CAAA,UAAA,EAAA,GAAA,EAAA;AACA,EAAA,IAAA,OAAA,CAAA,0BAAA,EAAA;AACA,IAAA,OAAAuB,qBAAA,CAAA,IAAA,CAAA;AACA,EAAA;;AAEA,EAAA,OAAA,IAAA;AACA;;AAEA,SAAA,oBAAA,CAAA,UAAA,EAAA;AACA,EAAA,OAAA,UAAA,KAAA;AACA,MAAA,CAAA,QAAA,KAAA;AACA,QAAA,OAAA,cAAA,CAAA,UAAA,EAAA,QAAA,CAAA;AACA,MAAA;AACA,MAAA,CAAA,QAAA,KAAA,QAAA,EAAA;AACA;;;;;;;;;;"}
1
+ {"version":3,"file":"trace.js","sources":["../../../src/tracing/trace.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types-hoist/envelope';\nimport type { ClientOptions } from '../types-hoist/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types-hoist/span';\nimport type { StartSpanOptions } from '../types-hoist/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { shouldIgnoreSpan } from '../utils/should-ignore-span';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\nimport type { Client } from '../client';\n\nconst SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them\n // and descendants are also non-recording. Ignored child spans don't need this because\n // the parent span is already on scope.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // We don't set ignored child spans onto the scope because there likely is an active,\n // unignored span on the scope already.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n\n if (shouldSkipSpan) {\n return new SentryNonRecordingSpan();\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n if (!hasSpansEnabled()) {\n const span = new SentryNonRecordingSpan();\n\n // If this is a root span, we ensure to freeze a DSC\n // So we can have at least partial data here\n if (forceTransaction || !parentSpan) {\n const dsc = {\n sampled: 'false',\n sample_rate: '0',\n transaction: spanArguments.name,\n ...getDynamicSamplingContextFromSpan(span),\n } satisfies Partial<DynamicSamplingContext>;\n freezeDscOnSpan(span, dsc);\n }\n\n return span;\n }\n\n const client = getClient();\n if (_shouldIgnoreStreamedSpan(client, spanArguments)) {\n if (!_isTracingSuppressed(scope)) {\n // if tracing is actively suppressed (Sentry.suppressTracing(...)),\n // we don't want to record a client outcome for the ignored span\n client?.recordDroppedEvent('ignored', 'span');\n }\n\n return new SentryNonRecordingSpan({\n dropReason: 'ignored',\n traceId: parentSpan?.spanContext().traceId ?? scope.getPropagationContext().traceId,\n });\n }\n\n const isolationScope = getIsolationScope();\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(spanArguments: SentrySpanArguments, scope: Scope, parentSampled?: boolean): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const isTracingSuppressed = _isTracingSuppressed(scope);\n\n const [sampled, sampleRate, localSampleRateWasApplied] = isTracingSuppressed\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client && !isTracingSuppressed) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', hasSpanStreamingEnabled(client) ? 'span' : 'transaction');\n }\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(parentSpan: Span, scope: Scope, spanArguments: SentrySpanArguments): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const isTracingSuppressed = _isTracingSuppressed(scope);\n const sampled = isTracingSuppressed ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n const client = getClient();\n\n if (!client) {\n return childSpan;\n }\n\n if (hasSpanStreamingEnabled(client) && childSpan instanceof SentryNonRecordingSpan) {\n if (parentSpan instanceof SentryNonRecordingSpan && parentSpan.dropReason) {\n // We land here if the parent span was a segment span that was ignored (`ignoreSpans`).\n // In this case, the child was also ignored (see `sampled` above) but we need to\n // record a client outcome for the child.\n childSpan.dropReason = parentSpan.dropReason;\n client.recordDroppedEvent(parentSpan.dropReason, 'span');\n } else if (!isTracingSuppressed) {\n // Otherwise, the child is not sampled due to sampling of the parent span,\n // hence we record a sample_rate client outcome for the child.\n childSpan.dropReason = 'sample_rate';\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n client.emit('afterSpanEnd', childSpan);\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n\n/* Checks if `ignoreSpans` applies (extracted for bundle size)*/\nfunction _shouldIgnoreStreamedSpan(client: Client | undefined, spanArguments: SentrySpanArguments): boolean {\n const ignoreSpans = client?.getOptions().ignoreSpans;\n\n if (!client || !hasSpanStreamingEnabled(client) || !ignoreSpans?.length) {\n return false;\n }\n\n return shouldIgnoreSpan(\n {\n description: spanArguments.name || '',\n op: spanArguments.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] || spanArguments.op,\n },\n ignoreSpans,\n );\n}\n\nfunction _isIgnoredSpan(span: Span): span is SentryNonRecordingSpan {\n return span instanceof SentryNonRecordingSpan && span.dropReason === 'ignored';\n}\n\nfunction _isTracingSuppressed(scope: Scope): boolean {\n return scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] === true;\n}\n"],"names":["withScope","getCurrentScope","SentryNonRecordingSpan","_setSpanForScope","handleCallbackErrors","spanToJSON","SPAN_STATUS_ERROR","carrier","getMainCarrier","getAsyncContextStrategy","baggage","getClient","baggageHeaderToDynamicSamplingContext","shouldContinueTrace","propagationContextFromHeaders","generateTraceId","safeMathRandom","DEBUG_BUILD","debug","hasSpansEnabled","getDynamicSamplingContextFromSpan","freezeDscOnSpan","getIsolationScope","addChildSpanToSpan","spanIsSampled","logSpanStart","setCapturedScopesOnSpan","spanTimeInputToSeconds","sampleSpan","parseSampleRate","SentrySpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","hasSpanStreamingEnabled","_getSpanForScope","getRootSpan","shouldIgnoreSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AAsCA,MAAM,oBAAA,GAAuB,6BAA6B;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAI,OAAO,EAAoB,QAAQ,EAAwB;AACxF,EAAE,MAAM,GAAA,GAAM,MAAM,EAAE;AACtB,EAAE,IAAI,GAAG,CAAC,SAAS,EAAE;AACrB,IAAI,OAAO,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC;AAC3C,EAAE;;AAEF,EAAE,MAAM,aAAA,GAAgB,wBAAwB,CAAC,OAAO,CAAC;AACzD,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAA,EAAY,GAAI,OAAO;;AAExF;AACA;AACA,EAAE,MAAM,iBAAA,GAAoB,WAAW,EAAE,KAAK,EAAE;;AAEhD,EAAE,OAAOA,uBAAS,CAAC,iBAAiB,EAAE,MAAM;AAC5C;AACA,IAAI,MAAM,OAAA,GAAU,oBAAoB,CAAI,gBAAgB,CAAC;;AAE7D,IAAI,OAAO,OAAO,CAAC,MAAM;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AC,+CAAA,CAAA,IAAA,aAAA,CAAA,EAAA;AACA,KAAA;AACA,IAAA,WAAA;AACA,GAAA;AACA;;AAEA,SAAA,cAAA,CAAA,IAAA,EAAA;AACA,EAAA,OAAA,IAAA,YAAAnC,6CAAA,IAAA,IAAA,CAAA,UAAA,KAAA,SAAA;AACA;;AAEA,SAAA,oBAAA,CAAA,KAAA,EAAA;AACA,EAAA,OAAA,KAAA,CAAA,YAAA,EAAA,CAAA,qBAAA,CAAA,oBAAA,CAAA,KAAA,IAAA;AACA;;;;;;;;;;"}
@@ -276,13 +276,10 @@ function getSpanOpFromName(name) {
276
276
  case 'ai.streamObject':
277
277
  return genAiAttributes.GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE;
278
278
  case 'ai.generateText.doGenerate':
279
- return genAiAttributes.GEN_AI_GENERATE_TEXT_DO_GENERATE_OPERATION_ATTRIBUTE;
280
279
  case 'ai.streamText.doStream':
281
- return genAiAttributes.GEN_AI_STREAM_TEXT_DO_STREAM_OPERATION_ATTRIBUTE;
282
280
  case 'ai.generateObject.doGenerate':
283
- return genAiAttributes.GEN_AI_GENERATE_OBJECT_DO_GENERATE_OPERATION_ATTRIBUTE;
284
281
  case 'ai.streamObject.doStream':
285
- return genAiAttributes.GEN_AI_STREAM_OBJECT_DO_STREAM_OPERATION_ATTRIBUTE;
282
+ return genAiAttributes.GEN_AI_GENERATE_CONTENT_OPERATION_ATTRIBUTE;
286
283
  case 'ai.embed.doEmbed':
287
284
  return genAiAttributes.GEN_AI_EMBED_DO_EMBED_OPERATION_ATTRIBUTE;
288
285
  case 'ai.embedMany.doEmbed':
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/tracing/vercel-ai/utils.ts"],"sourcesContent":["import type { TraceContext } from '../../types-hoist/context';\nimport type { Span, SpanAttributes, SpanJSON } from '../../types-hoist/span';\nimport {\n GEN_AI_EMBED_DO_EMBED_OPERATION_ATTRIBUTE,\n GEN_AI_EMBED_MANY_DO_EMBED_OPERATION_ATTRIBUTE,\n GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE,\n GEN_AI_GENERATE_OBJECT_DO_GENERATE_OPERATION_ATTRIBUTE,\n GEN_AI_GENERATE_TEXT_DO_GENERATE_OPERATION_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE,\n GEN_AI_RERANK_DO_RERANK_OPERATION_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_STREAM_OBJECT_DO_STREAM_OPERATION_ATTRIBUTE,\n GEN_AI_STREAM_TEXT_DO_STREAM_OPERATION_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { extractSystemInstructions, getTruncatedJsonString } from '../ai/utils';\nimport { toolCallSpanContextMap } from './constants';\nimport type { TokenSummary, ToolCallSpanContext } from './types';\nimport { AI_PROMPT_ATTRIBUTE, AI_PROMPT_MESSAGES_ATTRIBUTE } from './vercel-ai-attributes';\n\n/**\n * Accumulates token data from a span to its parent in the token accumulator map.\n * This function extracts token usage from the current span and adds it to the\n * accumulated totals for its parent span.\n */\nexport function accumulateTokensForParent(span: SpanJSON, tokenAccumulator: Map<string, TokenSummary>): void {\n const parentSpanId = span.parent_span_id;\n if (!parentSpanId) {\n return;\n }\n\n const inputTokens = span.data[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE];\n const outputTokens = span.data[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE];\n\n if (typeof inputTokens === 'number' || typeof outputTokens === 'number') {\n const existing = tokenAccumulator.get(parentSpanId) || { inputTokens: 0, outputTokens: 0 };\n\n if (typeof inputTokens === 'number') {\n existing.inputTokens += inputTokens;\n }\n if (typeof outputTokens === 'number') {\n existing.outputTokens += outputTokens;\n }\n\n tokenAccumulator.set(parentSpanId, existing);\n }\n}\n\n/**\n * Applies accumulated token data to the `gen_ai.invoke_agent` span.\n * Only immediate children of the `gen_ai.invoke_agent` span are considered,\n * since aggregation will automatically occur for each parent span.\n */\nexport function applyAccumulatedTokens(\n spanOrTrace: SpanJSON | TraceContext,\n tokenAccumulator: Map<string, TokenSummary>,\n): void {\n const accumulated = tokenAccumulator.get(spanOrTrace.span_id);\n if (!accumulated || !spanOrTrace.data) {\n return;\n }\n\n if (accumulated.inputTokens > 0) {\n spanOrTrace.data[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] = accumulated.inputTokens;\n }\n if (accumulated.outputTokens > 0) {\n spanOrTrace.data[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] = accumulated.outputTokens;\n }\n if (accumulated.inputTokens > 0 || accumulated.outputTokens > 0) {\n spanOrTrace.data['gen_ai.usage.total_tokens'] = accumulated.inputTokens + accumulated.outputTokens;\n }\n}\n\n/**\n * Builds a map of tool name -> description from all spans with available_tools.\n * This avoids O(n²) iteration and repeated JSON parsing.\n */\nfunction buildToolDescriptionMap(spans: SpanJSON[]): Map<string, string> {\n const toolDescriptions = new Map<string, string>();\n\n for (const span of spans) {\n const availableTools = span.data[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE];\n if (typeof availableTools !== 'string') {\n continue;\n }\n try {\n const tools = JSON.parse(availableTools) as Array<{ name?: string; description?: string }>;\n for (const tool of tools) {\n if (tool.name && tool.description && !toolDescriptions.has(tool.name)) {\n toolDescriptions.set(tool.name, tool.description);\n }\n }\n } catch {\n // ignore parse errors\n }\n }\n\n return toolDescriptions;\n}\n\n/**\n * Applies tool descriptions and accumulated tokens to spans in a single pass.\n *\n * - For `gen_ai.execute_tool` spans: looks up tool description from\n * `gen_ai.request.available_tools` on sibling spans\n * - For `gen_ai.invoke_agent` spans: applies accumulated token data from children\n */\nexport function applyToolDescriptionsAndTokens(spans: SpanJSON[], tokenAccumulator: Map<string, TokenSummary>): void {\n // Build lookup map once to avoid O(n²) iteration and repeated JSON parsing\n const toolDescriptions = buildToolDescriptionMap(spans);\n\n for (const span of spans) {\n if (span.op === 'gen_ai.execute_tool') {\n const toolName = span.data[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (typeof toolName === 'string') {\n const description = toolDescriptions.get(toolName);\n if (description) {\n span.data[GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE] = description;\n }\n }\n }\n\n if (span.op === 'gen_ai.invoke_agent') {\n applyAccumulatedTokens(span, tokenAccumulator);\n }\n }\n}\n\n/**\n * Get the span context associated with a tool call ID.\n */\nexport function _INTERNAL_getSpanContextForToolCallId(toolCallId: string): ToolCallSpanContext | undefined {\n return toolCallSpanContextMap.get(toolCallId);\n}\n\n/**\n * Clean up the span mapping for a tool call ID\n */\nexport function _INTERNAL_cleanupToolCallSpanContext(toolCallId: string): void {\n toolCallSpanContextMap.delete(toolCallId);\n}\n\n/**\n * Convert an array of tool strings to a JSON string\n */\nexport function convertAvailableToolsToJsonString(tools: unknown[]): string {\n const toolObjects = tools.map(tool => {\n if (typeof tool === 'string') {\n try {\n return JSON.parse(tool);\n } catch {\n return tool;\n }\n }\n return tool;\n });\n return JSON.stringify(toolObjects);\n}\n\n/**\n * Filter out invalid entries in messages array\n * @param input - The input array to filter\n * @returns The filtered array\n */\nfunction filterMessagesArray(input: unknown[]): { role: string; content: string }[] {\n return input.filter(\n (m: unknown): m is { role: string; content: string } =>\n !!m && typeof m === 'object' && 'role' in m && 'content' in m,\n );\n}\n\n/**\n * Normalize the user input (stringified object with prompt, system, messages) to messages array\n */\nexport function convertUserInputToMessagesFormat(userInput: string): { role: string; content: string }[] {\n try {\n const p = JSON.parse(userInput);\n if (!!p && typeof p === 'object') {\n let { messages } = p;\n const { prompt, system } = p;\n const result: { role: string; content: string }[] = [];\n\n // prepend top-level system instruction if present\n if (typeof system === 'string') {\n result.push({ role: 'system', content: system });\n }\n\n // stringified messages array\n if (typeof messages === 'string') {\n try {\n messages = JSON.parse(messages);\n } catch {\n // ignore parse errors\n }\n }\n\n // messages array format: { messages: [...] }\n if (Array.isArray(messages)) {\n result.push(...filterMessagesArray(messages));\n return result;\n }\n\n // prompt array format: { prompt: [...] }\n if (Array.isArray(prompt)) {\n result.push(...filterMessagesArray(prompt));\n return result;\n }\n\n // prompt string format: { prompt: \"...\" }\n if (typeof prompt === 'string') {\n result.push({ role: 'user', content: prompt });\n }\n\n if (result.length > 0) {\n return result;\n }\n }\n // eslint-disable-next-line no-empty\n } catch {}\n return [];\n}\n\n/**\n * Generate a request.messages JSON array from the prompt field in the\n * invoke_agent op\n */\nexport function requestMessagesFromPrompt(span: Span, attributes: SpanAttributes): void {\n if (\n typeof attributes[AI_PROMPT_ATTRIBUTE] === 'string' &&\n !attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE] &&\n !attributes[AI_PROMPT_MESSAGES_ATTRIBUTE]\n ) {\n // No messages array is present, so we need to convert the prompt to the proper messages format\n // This is the case for ai.generateText spans\n // The ai.prompt attribute is a stringified object with prompt, system, messages attributes\n // The format of these is described in the vercel docs, for instance: https://ai-sdk.dev/docs/reference/ai-sdk-core/stream-object#parameters\n const userInput = attributes[AI_PROMPT_ATTRIBUTE];\n const messages = convertUserInputToMessagesFormat(userInput);\n if (messages.length) {\n const { systemInstructions, filteredMessages } = extractSystemInstructions(messages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n const truncatedMessages = getTruncatedJsonString(filteredMessages);\n\n span.setAttributes({\n [AI_PROMPT_ATTRIBUTE]: truncatedMessages,\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: truncatedMessages,\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n }\n } else if (typeof attributes[AI_PROMPT_MESSAGES_ATTRIBUTE] === 'string') {\n // In this case we already get a properly formatted messages array, this is the preferred way to get the messages\n // This is the case for ai.generateText.doGenerate spans\n try {\n const messages = JSON.parse(attributes[AI_PROMPT_MESSAGES_ATTRIBUTE]);\n if (Array.isArray(messages)) {\n const { systemInstructions, filteredMessages } = extractSystemInstructions(messages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n const truncatedMessages = getTruncatedJsonString(filteredMessages);\n\n span.setAttributes({\n [AI_PROMPT_MESSAGES_ATTRIBUTE]: truncatedMessages,\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: truncatedMessages,\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n }\n // eslint-disable-next-line no-empty\n } catch {}\n }\n}\n\n/**\n * Maps a Vercel AI span name to the corresponding Sentry op.\n */\nexport function getSpanOpFromName(name: string): string | undefined {\n switch (name) {\n case 'ai.generateText':\n case 'ai.streamText':\n case 'ai.generateObject':\n case 'ai.streamObject':\n return GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE;\n case 'ai.generateText.doGenerate':\n return GEN_AI_GENERATE_TEXT_DO_GENERATE_OPERATION_ATTRIBUTE;\n case 'ai.streamText.doStream':\n return GEN_AI_STREAM_TEXT_DO_STREAM_OPERATION_ATTRIBUTE;\n case 'ai.generateObject.doGenerate':\n return GEN_AI_GENERATE_OBJECT_DO_GENERATE_OPERATION_ATTRIBUTE;\n case 'ai.streamObject.doStream':\n return GEN_AI_STREAM_OBJECT_DO_STREAM_OPERATION_ATTRIBUTE;\n case 'ai.embed.doEmbed':\n return GEN_AI_EMBED_DO_EMBED_OPERATION_ATTRIBUTE;\n case 'ai.embedMany.doEmbed':\n return GEN_AI_EMBED_MANY_DO_EMBED_OPERATION_ATTRIBUTE;\n case 'ai.rerank.doRerank':\n return GEN_AI_RERANK_DO_RERANK_OPERATION_ATTRIBUTE;\n case 'ai.toolCall':\n return GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE;\n default:\n if (name.startsWith('ai.stream')) {\n return 'ai.run';\n }\n return undefined;\n }\n}\n"],"names":["GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","GEN_AI_TOOL_NAME_ATTRIBUTE","GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE","toolCallSpanContextMap","AI_PROMPT_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","AI_PROMPT_MESSAGES_ATTRIBUTE","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","getTruncatedJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE","GEN_AI_GENERATE_TEXT_DO_GENERATE_OPERATION_ATTRIBUTE","GEN_AI_STREAM_TEXT_DO_STREAM_OPERATION_ATTRIBUTE","GEN_AI_GENERATE_OBJECT_DO_GENERATE_OPERATION_ATTRIBUTE","GEN_AI_STREAM_OBJECT_DO_STREAM_OPERATION_ATTRIBUTE","GEN_AI_EMBED_DO_EMBED_OPERATION_ATTRIBUTE","GEN_AI_EMBED_MANY_DO_EMBED_OPERATION_ATTRIBUTE","GEN_AI_RERANK_DO_RERANK_OPERATION_ATTRIBUTE","GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE"],"mappings":";;;;;;;AA0BA;AACA;AACA;AACA;AACA;AAC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uC;AACpD,IAAI,KAAK,4BAA4B;AACrC,MAAM,OAAOC,oEAAoD;AACjE,IAAI,KAAK,wBAAwB;AACjC,MAAM,OAAOC,gEAAgD;AAC7D,IAAI,KAAK,8BAA8B;AACvC,MAAM,OAAOC,sEAAsD;AACnE,IAAI,KAAK,0BAA0B;AACnC,MAAM,OAAOC,kEAAkD;AAC/D,IAAI,KAAK,kBAAkB;AAC3B,MAAM,OAAOC,yDAAyC;AACtD,IAAI,KAAK,sBAAsB;AAC/B,MAAM,OAAOC,8DAA8C;AAC3D,IAAI,KAAK,oBAAoB;AAC7B,MAAM,OAAOC,2DAA2C;AACxD,IAAI,KAAK,aAAa;AACtB,MAAM,OAAOC,uDAAuC;AACpD,IAAI;AACJ,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;AACxC,QAAQ,OAAO,QAAQ;AACvB,MAAM;AACN,MAAM,OAAO,SAAS;AACtB;AACA;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/tracing/vercel-ai/utils.ts"],"sourcesContent":["import type { TraceContext } from '../../types-hoist/context';\nimport type { Span, SpanAttributes, SpanJSON } from '../../types-hoist/span';\nimport {\n GEN_AI_EMBED_DO_EMBED_OPERATION_ATTRIBUTE,\n GEN_AI_EMBED_MANY_DO_EMBED_OPERATION_ATTRIBUTE,\n GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE,\n GEN_AI_GENERATE_CONTENT_OPERATION_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE,\n GEN_AI_RERANK_DO_RERANK_OPERATION_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE,\n GEN_AI_TOOL_NAME_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { extractSystemInstructions, getTruncatedJsonString } from '../ai/utils';\nimport { toolCallSpanContextMap } from './constants';\nimport type { TokenSummary, ToolCallSpanContext } from './types';\nimport { AI_PROMPT_ATTRIBUTE, AI_PROMPT_MESSAGES_ATTRIBUTE } from './vercel-ai-attributes';\n\n/**\n * Accumulates token data from a span to its parent in the token accumulator map.\n * This function extracts token usage from the current span and adds it to the\n * accumulated totals for its parent span.\n */\nexport function accumulateTokensForParent(span: SpanJSON, tokenAccumulator: Map<string, TokenSummary>): void {\n const parentSpanId = span.parent_span_id;\n if (!parentSpanId) {\n return;\n }\n\n const inputTokens = span.data[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE];\n const outputTokens = span.data[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE];\n\n if (typeof inputTokens === 'number' || typeof outputTokens === 'number') {\n const existing = tokenAccumulator.get(parentSpanId) || { inputTokens: 0, outputTokens: 0 };\n\n if (typeof inputTokens === 'number') {\n existing.inputTokens += inputTokens;\n }\n if (typeof outputTokens === 'number') {\n existing.outputTokens += outputTokens;\n }\n\n tokenAccumulator.set(parentSpanId, existing);\n }\n}\n\n/**\n * Applies accumulated token data to the `gen_ai.invoke_agent` span.\n * Only immediate children of the `gen_ai.invoke_agent` span are considered,\n * since aggregation will automatically occur for each parent span.\n */\nexport function applyAccumulatedTokens(\n spanOrTrace: SpanJSON | TraceContext,\n tokenAccumulator: Map<string, TokenSummary>,\n): void {\n const accumulated = tokenAccumulator.get(spanOrTrace.span_id);\n if (!accumulated || !spanOrTrace.data) {\n return;\n }\n\n if (accumulated.inputTokens > 0) {\n spanOrTrace.data[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] = accumulated.inputTokens;\n }\n if (accumulated.outputTokens > 0) {\n spanOrTrace.data[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] = accumulated.outputTokens;\n }\n if (accumulated.inputTokens > 0 || accumulated.outputTokens > 0) {\n spanOrTrace.data['gen_ai.usage.total_tokens'] = accumulated.inputTokens + accumulated.outputTokens;\n }\n}\n\n/**\n * Builds a map of tool name -> description from all spans with available_tools.\n * This avoids O(n²) iteration and repeated JSON parsing.\n */\nfunction buildToolDescriptionMap(spans: SpanJSON[]): Map<string, string> {\n const toolDescriptions = new Map<string, string>();\n\n for (const span of spans) {\n const availableTools = span.data[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE];\n if (typeof availableTools !== 'string') {\n continue;\n }\n try {\n const tools = JSON.parse(availableTools) as Array<{ name?: string; description?: string }>;\n for (const tool of tools) {\n if (tool.name && tool.description && !toolDescriptions.has(tool.name)) {\n toolDescriptions.set(tool.name, tool.description);\n }\n }\n } catch {\n // ignore parse errors\n }\n }\n\n return toolDescriptions;\n}\n\n/**\n * Applies tool descriptions and accumulated tokens to spans in a single pass.\n *\n * - For `gen_ai.execute_tool` spans: looks up tool description from\n * `gen_ai.request.available_tools` on sibling spans\n * - For `gen_ai.invoke_agent` spans: applies accumulated token data from children\n */\nexport function applyToolDescriptionsAndTokens(spans: SpanJSON[], tokenAccumulator: Map<string, TokenSummary>): void {\n // Build lookup map once to avoid O(n²) iteration and repeated JSON parsing\n const toolDescriptions = buildToolDescriptionMap(spans);\n\n for (const span of spans) {\n if (span.op === 'gen_ai.execute_tool') {\n const toolName = span.data[GEN_AI_TOOL_NAME_ATTRIBUTE];\n if (typeof toolName === 'string') {\n const description = toolDescriptions.get(toolName);\n if (description) {\n span.data[GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE] = description;\n }\n }\n }\n\n if (span.op === 'gen_ai.invoke_agent') {\n applyAccumulatedTokens(span, tokenAccumulator);\n }\n }\n}\n\n/**\n * Get the span context associated with a tool call ID.\n */\nexport function _INTERNAL_getSpanContextForToolCallId(toolCallId: string): ToolCallSpanContext | undefined {\n return toolCallSpanContextMap.get(toolCallId);\n}\n\n/**\n * Clean up the span mapping for a tool call ID\n */\nexport function _INTERNAL_cleanupToolCallSpanContext(toolCallId: string): void {\n toolCallSpanContextMap.delete(toolCallId);\n}\n\n/**\n * Convert an array of tool strings to a JSON string\n */\nexport function convertAvailableToolsToJsonString(tools: unknown[]): string {\n const toolObjects = tools.map(tool => {\n if (typeof tool === 'string') {\n try {\n return JSON.parse(tool);\n } catch {\n return tool;\n }\n }\n return tool;\n });\n return JSON.stringify(toolObjects);\n}\n\n/**\n * Filter out invalid entries in messages array\n * @param input - The input array to filter\n * @returns The filtered array\n */\nfunction filterMessagesArray(input: unknown[]): { role: string; content: string }[] {\n return input.filter(\n (m: unknown): m is { role: string; content: string } =>\n !!m && typeof m === 'object' && 'role' in m && 'content' in m,\n );\n}\n\n/**\n * Normalize the user input (stringified object with prompt, system, messages) to messages array\n */\nexport function convertUserInputToMessagesFormat(userInput: string): { role: string; content: string }[] {\n try {\n const p = JSON.parse(userInput);\n if (!!p && typeof p === 'object') {\n let { messages } = p;\n const { prompt, system } = p;\n const result: { role: string; content: string }[] = [];\n\n // prepend top-level system instruction if present\n if (typeof system === 'string') {\n result.push({ role: 'system', content: system });\n }\n\n // stringified messages array\n if (typeof messages === 'string') {\n try {\n messages = JSON.parse(messages);\n } catch {\n // ignore parse errors\n }\n }\n\n // messages array format: { messages: [...] }\n if (Array.isArray(messages)) {\n result.push(...filterMessagesArray(messages));\n return result;\n }\n\n // prompt array format: { prompt: [...] }\n if (Array.isArray(prompt)) {\n result.push(...filterMessagesArray(prompt));\n return result;\n }\n\n // prompt string format: { prompt: \"...\" }\n if (typeof prompt === 'string') {\n result.push({ role: 'user', content: prompt });\n }\n\n if (result.length > 0) {\n return result;\n }\n }\n // eslint-disable-next-line no-empty\n } catch {}\n return [];\n}\n\n/**\n * Generate a request.messages JSON array from the prompt field in the\n * invoke_agent op\n */\nexport function requestMessagesFromPrompt(span: Span, attributes: SpanAttributes): void {\n if (\n typeof attributes[AI_PROMPT_ATTRIBUTE] === 'string' &&\n !attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE] &&\n !attributes[AI_PROMPT_MESSAGES_ATTRIBUTE]\n ) {\n // No messages array is present, so we need to convert the prompt to the proper messages format\n // This is the case for ai.generateText spans\n // The ai.prompt attribute is a stringified object with prompt, system, messages attributes\n // The format of these is described in the vercel docs, for instance: https://ai-sdk.dev/docs/reference/ai-sdk-core/stream-object#parameters\n const userInput = attributes[AI_PROMPT_ATTRIBUTE];\n const messages = convertUserInputToMessagesFormat(userInput);\n if (messages.length) {\n const { systemInstructions, filteredMessages } = extractSystemInstructions(messages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n const truncatedMessages = getTruncatedJsonString(filteredMessages);\n\n span.setAttributes({\n [AI_PROMPT_ATTRIBUTE]: truncatedMessages,\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: truncatedMessages,\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n }\n } else if (typeof attributes[AI_PROMPT_MESSAGES_ATTRIBUTE] === 'string') {\n // In this case we already get a properly formatted messages array, this is the preferred way to get the messages\n // This is the case for ai.generateText.doGenerate spans\n try {\n const messages = JSON.parse(attributes[AI_PROMPT_MESSAGES_ATTRIBUTE]);\n if (Array.isArray(messages)) {\n const { systemInstructions, filteredMessages } = extractSystemInstructions(messages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n const truncatedMessages = getTruncatedJsonString(filteredMessages);\n\n span.setAttributes({\n [AI_PROMPT_MESSAGES_ATTRIBUTE]: truncatedMessages,\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: truncatedMessages,\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n }\n // eslint-disable-next-line no-empty\n } catch {}\n }\n}\n\n/**\n * Maps a Vercel AI span name to the corresponding Sentry op.\n */\nexport function getSpanOpFromName(name: string): string | undefined {\n switch (name) {\n case 'ai.generateText':\n case 'ai.streamText':\n case 'ai.generateObject':\n case 'ai.streamObject':\n return GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE;\n case 'ai.generateText.doGenerate':\n case 'ai.streamText.doStream':\n case 'ai.generateObject.doGenerate':\n case 'ai.streamObject.doStream':\n return GEN_AI_GENERATE_CONTENT_OPERATION_ATTRIBUTE;\n case 'ai.embed.doEmbed':\n return GEN_AI_EMBED_DO_EMBED_OPERATION_ATTRIBUTE;\n case 'ai.embedMany.doEmbed':\n return GEN_AI_EMBED_MANY_DO_EMBED_OPERATION_ATTRIBUTE;\n case 'ai.rerank.doRerank':\n return GEN_AI_RERANK_DO_RERANK_OPERATION_ATTRIBUTE;\n case 'ai.toolCall':\n return GEN_AI_EXECUTE_TOOL_OPERATION_ATTRIBUTE;\n default:\n if (name.startsWith('ai.stream')) {\n return 'ai.run';\n }\n return undefined;\n }\n}\n"],"names":["GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE","GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","GEN_AI_TOOL_NAME_ATTRIBUTE","GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE","toolCallSpanContextMap","AI_PROMPT_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","AI_PROMPT_MESSAGES_ATTRIBUTE","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","getTruncatedJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTR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+C,GAAG,cAAc;AAC3E,SAAS,CAAC;AACV,MAAM;AACN;AACA,IAAI,CAAA,CAAE,MAAM,CAAC;AACb,EAAE;AACF;;AAEA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,IAAI,EAA8B;AACpE,EAAE,QAAQ,IAAI;AACd,IAAI,KAAK,iBAAiB;AAC1B,IAAI,KAAK,eAAe;AACxB,IAAI,KAAK,mBAAmB;AAC5B,IAAI,KAAK,iBAAiB;AAC1B,MAAM,OAAOC,uDAAuC;AACpD,IAAI,KAAK,4BAA4B;AACrC,IAAI,KAAK,wBAAwB;AACjC,IAAI,KAAK,8BAA8B;AACvC,IAAI,KAAK,0BAA0B;AACnC,MAAM,OAAOC,2DAA2C;AACxD,IAAI,KAAK,kBAAkB;AAC3B,MAAM,OAAOC,yDAAyC;AACtD,IAAI,KAAK,sBAAsB;AAC/B,MAAM,OAAOC,8DAA8C;AAC3D,IAAI,KAAK,oBAAoB;AAC7B,MAAM,OAAOC,2DAA2C;AACxD,IAAI,KAAK,aAAa;AACtB,MAAM,OAAOC,uDAAuC;AACpD,IAAI;AACJ,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;AACxC,QAAQ,OAAO,QAAQ;AACvB,MAAM;AACN,MAAM,OAAO,SAAS;AACtB;AACA;;;;;;;;;;;;"}
@@ -27,6 +27,12 @@ const SPAN_FLAG_ATTRIBUTE_PREFIX = 'flag.evaluation.';
27
27
  * Copies feature flags that are in current scope context to the event context
28
28
  */
29
29
  function _INTERNAL_copyFlagsFromScopeToEvent(event) {
30
+ if (event.type) {
31
+ // No need to add the flags context to transaction events.
32
+ // Spans already get the flag.evaluation attributes.
33
+ return event;
34
+ }
35
+
30
36
  const scope = currentScopes.getCurrentScope();
31
37
  const flagContext = scope.getScopeData().contexts.flags;
32
38
  const flagBuffer = flagContext ? flagContext.values : [];
@@ -1 +1 @@
1
- {"version":3,"file":"featureFlags.js","sources":["../../../src/utils/featureFlags.ts"],"sourcesContent":["import { getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { type Event } from '../types-hoist/event';\nimport { debug } from './debug-logger';\nimport { getActiveSpan, spanToJSON } from './spanUtils';\n\n/**\n * Ordered LRU cache for storing feature flags in the scope context. The name\n * of each flag in the buffer is unique, and the output of getAll() is ordered\n * from oldest to newest.\n */\n\nexport type FeatureFlag = { readonly flag: string; readonly result: boolean };\n\n/**\n * Max size of the LRU flag buffer stored in Sentry scope and event contexts.\n */\nexport const _INTERNAL_FLAG_BUFFER_SIZE = 100;\n\n/**\n * Max number of flag evaluations to record per span.\n */\nexport const _INTERNAL_MAX_FLAGS_PER_SPAN = 10;\n\nconst SPAN_FLAG_ATTRIBUTE_PREFIX = 'flag.evaluation.';\n\n/**\n * Copies feature flags that are in current scope context to the event context\n */\nexport function _INTERNAL_copyFlagsFromScopeToEvent(event: Event): Event {\n const scope = getCurrentScope();\n const flagContext = scope.getScopeData().contexts.flags;\n const flagBuffer = flagContext ? flagContext.values : [];\n\n if (!flagBuffer.length) {\n return event;\n }\n\n if (event.contexts === undefined) {\n event.contexts = {};\n }\n event.contexts.flags = { values: [...flagBuffer] };\n return event;\n}\n\n/**\n * Inserts a flag into the current scope's context while maintaining ordered LRU properties.\n * Not thread-safe. After inserting:\n * - The flag buffer is sorted in order of recency, with the newest evaluation at the end.\n * - The names in the buffer are always unique.\n * - The length of the buffer never exceeds `maxSize`.\n *\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_insertFlagToScope(\n name: string,\n value: unknown,\n maxSize: number = _INTERNAL_FLAG_BUFFER_SIZE,\n): void {\n const scopeContexts = getCurrentScope().getScopeData().contexts;\n if (!scopeContexts.flags) {\n scopeContexts.flags = { values: [] };\n }\n const flags = scopeContexts.flags.values;\n _INTERNAL_insertToFlagBuffer(flags, name, value, maxSize);\n}\n\n/**\n * Exported for tests only. Currently only accepts boolean values (otherwise no-op).\n * Inserts a flag into a FeatureFlag array while maintaining the following properties:\n * - Flags are sorted in order of recency, with the newest evaluation at the end.\n * - The flag names are always unique.\n * - The length of the array never exceeds `maxSize`.\n *\n * @param flags The buffer to insert the flag into.\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_insertToFlagBuffer(\n flags: FeatureFlag[],\n name: string,\n value: unknown,\n maxSize: number,\n): void {\n if (typeof value !== 'boolean') {\n return;\n }\n\n if (flags.length > maxSize) {\n DEBUG_BUILD && debug.error(`[Feature Flags] insertToFlagBuffer called on a buffer larger than maxSize=${maxSize}`);\n return;\n }\n\n // Check if the flag is already in the buffer - O(n)\n const index = flags.findIndex(f => f.flag === name);\n\n if (index !== -1) {\n // The flag was found, remove it from its current position - O(n)\n flags.splice(index, 1);\n }\n\n if (flags.length === maxSize) {\n // If at capacity, pop the earliest flag - O(n)\n flags.shift();\n }\n\n // Push the flag to the end - O(1)\n flags.push({\n flag: name,\n result: value,\n });\n}\n\n/**\n * Records a feature flag evaluation for the active span. This is a no-op for non-boolean values.\n * The flag and its value is stored in span attributes with the `flag.evaluation` prefix. Once the\n * unique flags for a span reaches maxFlagsPerSpan, subsequent flags are dropped.\n *\n * @param name Name of the feature flag.\n * @param value Value of the feature flag. Non-boolean values are ignored.\n * @param maxFlagsPerSpan Max number of flags a buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_addFeatureFlagToActiveSpan(\n name: string,\n value: unknown,\n maxFlagsPerSpan: number = _INTERNAL_MAX_FLAGS_PER_SPAN,\n): void {\n if (typeof value !== 'boolean') {\n return;\n }\n\n const span = getActiveSpan();\n if (!span) {\n return;\n }\n\n const attributes = spanToJSON(span).data;\n\n // If the flag already exists, always update it\n if (`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}` in attributes) {\n span.setAttribute(`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}`, value);\n return;\n }\n\n // Else, add the flag to the span if we have not reached the max number of flags\n const numOfAddedFlags = Object.keys(attributes).filter(key => key.startsWith(SPAN_FLAG_ATTRIBUTE_PREFIX)).length;\n if (numOfAddedFlags < maxFlagsPerSpan) {\n span.setAttribute(`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}`, value);\n }\n}\n"],"names":["getCurrentScope","DEBUG_BUILD","debug","getActiveSpan","spanToJSON"],"mappings":";;;;;;;AAMA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACO,MAAM,0BAAA,GAA6B;;AAE1C;AACA;AACA;AACO,MAAM,4BAAA,GAA+B;;AAE5C,MAAM,0BAAA,GAA6B,kBAAkB;;AAErD;AACA;AACA;AACO,SAAS,mCAAmC,CAAC,KAAK,EAAgB;AACzE,EAAE,MAAM,KAAA,GAAQA,6BAAe,EAAE;AACjC,EAAE,MAAM,WAAA,GAAc,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,KAAK;AACzD,EAAE,MAAM,UAAA,GAAa,WAAA,GAAc,WAAW,CAAC,MAAA,GAAS,EAAE;;AAE1D,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;AAC1B,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,IAAI,KAAK,CAAC,QAAA,KAAa,SAAS,EAAE;AACpC,IAAI,KAAK,CAAC,QAAA,GAAW,EAAE;AACvB,EAAE;AACF,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAA,GAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,GAAG;AACpD,EAAE,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,2BAA2B;AAC3C,EAAE,IAAI;AACN,EAAE,KAAK;AACP,EAAE,OAAO,GAAW,0BAA0B;AAC9C,EAAQ;AACR,EAAE,MAAM,aAAA,GAAgBA,6BAAe,EAAE,CAAC,YAAY,EAAE,CAAC,QAAQ;AACj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EAAA,eAAA,GAAA,4BAAA;AACA,EAAA;AACA,EAAA,IAAA,OAAA,KAAA,KAAA,SAAA,EAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,IAAA,GAAAC,uBAAA,EAAA;AACA,EAAA,IAAA,CAAA,IAAA,EAAA;AACA,IAAA;AACA,EAAA;;AAEA,EAAA,MAAA,UAAA,GAAAC,oBAAA,CAAA,IAAA,CAAA,CAAA,IAAA;;AAEA;AACA,EAAA,IAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,IAAA,UAAA,EAAA;AACA,IAAA,IAAA,CAAA,YAAA,CAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,EAAA,KAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA;AACA,EAAA,MAAA,eAAA,GAAA,MAAA,CAAA,IAAA,CAAA,UAAA,CAAA,CAAA,MAAA,CAAA,GAAA,IAAA,GAAA,CAAA,UAAA,CAAA,0BAAA,CAAA,CAAA,CAAA,MAAA;AACA,EAAA,IAAA,eAAA,GAAA,eAAA,EAAA;AACA,IAAA,IAAA,CAAA,YAAA,CAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,EAAA,KAAA,CAAA;AACA,EAAA;AACA;;;;;;;;;"}
1
+ {"version":3,"file":"featureFlags.js","sources":["../../../src/utils/featureFlags.ts"],"sourcesContent":["import { getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { type Event } from '../types-hoist/event';\nimport { debug } from './debug-logger';\nimport { getActiveSpan, spanToJSON } from './spanUtils';\n\n/**\n * Ordered LRU cache for storing feature flags in the scope context. The name\n * of each flag in the buffer is unique, and the output of getAll() is ordered\n * from oldest to newest.\n */\n\nexport type FeatureFlag = { readonly flag: string; readonly result: boolean };\n\n/**\n * Max size of the LRU flag buffer stored in Sentry scope and event contexts.\n */\nexport const _INTERNAL_FLAG_BUFFER_SIZE = 100;\n\n/**\n * Max number of flag evaluations to record per span.\n */\nexport const _INTERNAL_MAX_FLAGS_PER_SPAN = 10;\n\nconst SPAN_FLAG_ATTRIBUTE_PREFIX = 'flag.evaluation.';\n\n/**\n * Copies feature flags that are in current scope context to the event context\n */\nexport function _INTERNAL_copyFlagsFromScopeToEvent(event: Event): Event {\n if (event.type) {\n // No need to add the flags context to transaction events.\n // Spans already get the flag.evaluation attributes.\n return event;\n }\n\n const scope = getCurrentScope();\n const flagContext = scope.getScopeData().contexts.flags;\n const flagBuffer = flagContext ? flagContext.values : [];\n\n if (!flagBuffer.length) {\n return event;\n }\n\n if (event.contexts === undefined) {\n event.contexts = {};\n }\n event.contexts.flags = { values: [...flagBuffer] };\n return event;\n}\n\n/**\n * Inserts a flag into the current scope's context while maintaining ordered LRU properties.\n * Not thread-safe. After inserting:\n * - The flag buffer is sorted in order of recency, with the newest evaluation at the end.\n * - The names in the buffer are always unique.\n * - The length of the buffer never exceeds `maxSize`.\n *\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_insertFlagToScope(\n name: string,\n value: unknown,\n maxSize: number = _INTERNAL_FLAG_BUFFER_SIZE,\n): void {\n const scopeContexts = getCurrentScope().getScopeData().contexts;\n if (!scopeContexts.flags) {\n scopeContexts.flags = { values: [] };\n }\n const flags = scopeContexts.flags.values;\n _INTERNAL_insertToFlagBuffer(flags, name, value, maxSize);\n}\n\n/**\n * Exported for tests only. Currently only accepts boolean values (otherwise no-op).\n * Inserts a flag into a FeatureFlag array while maintaining the following properties:\n * - Flags are sorted in order of recency, with the newest evaluation at the end.\n * - The flag names are always unique.\n * - The length of the array never exceeds `maxSize`.\n *\n * @param flags The buffer to insert the flag into.\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_insertToFlagBuffer(\n flags: FeatureFlag[],\n name: string,\n value: unknown,\n maxSize: number,\n): void {\n if (typeof value !== 'boolean') {\n return;\n }\n\n if (flags.length > maxSize) {\n DEBUG_BUILD && debug.error(`[Feature Flags] insertToFlagBuffer called on a buffer larger than maxSize=${maxSize}`);\n return;\n }\n\n // Check if the flag is already in the buffer - O(n)\n const index = flags.findIndex(f => f.flag === name);\n\n if (index !== -1) {\n // The flag was found, remove it from its current position - O(n)\n flags.splice(index, 1);\n }\n\n if (flags.length === maxSize) {\n // If at capacity, pop the earliest flag - O(n)\n flags.shift();\n }\n\n // Push the flag to the end - O(1)\n flags.push({\n flag: name,\n result: value,\n });\n}\n\n/**\n * Records a feature flag evaluation for the active span. This is a no-op for non-boolean values.\n * The flag and its value is stored in span attributes with the `flag.evaluation` prefix. Once the\n * unique flags for a span reaches maxFlagsPerSpan, subsequent flags are dropped.\n *\n * @param name Name of the feature flag.\n * @param value Value of the feature flag. Non-boolean values are ignored.\n * @param maxFlagsPerSpan Max number of flags a buffer should store. Default value should always be used in production.\n */\nexport function _INTERNAL_addFeatureFlagToActiveSpan(\n name: string,\n value: unknown,\n maxFlagsPerSpan: number = _INTERNAL_MAX_FLAGS_PER_SPAN,\n): void {\n if (typeof value !== 'boolean') {\n return;\n }\n\n const span = getActiveSpan();\n if (!span) {\n return;\n }\n\n const attributes = spanToJSON(span).data;\n\n // If the flag already exists, always update it\n if (`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}` in attributes) {\n span.setAttribute(`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}`, value);\n return;\n }\n\n // Else, add the flag to the span if we have not reached the max number of flags\n const numOfAddedFlags = Object.keys(attributes).filter(key => key.startsWith(SPAN_FLAG_ATTRIBUTE_PREFIX)).length;\n if (numOfAddedFlags < maxFlagsPerSpan) {\n span.setAttribute(`${SPAN_FLAG_ATTRIBUTE_PREFIX}${name}`, value);\n }\n}\n"],"names":["getCurrentScope","DEBUG_BUILD","debug","getActiveSpan","spanToJSON"],"mappings":";;;;;;;AAMA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;AACA,EAAA;;AAEA,EAAA,MAAA,UAAA,GAAAC,oBAAA,CAAA,IAAA,CAAA,CAAA,IAAA;;AAEA;AACA,EAAA,IAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,IAAA,UAAA,EAAA;AACA,IAAA,IAAA,CAAA,YAAA,CAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,EAAA,KAAA,CAAA;AACA,IAAA;AACA,EAAA;;AAEA;AACA,EAAA,MAAA,eAAA,GAAA,MAAA,CAAA,IAAA,CAAA,UAAA,CAAA,CAAA,MAAA,CAAA,GAAA,IAAA,GAAA,CAAA,UAAA,CAAA,0BAAA,CAAA,CAAA,CAAA,MAAA;AACA,EAAA,IAAA,eAAA,GAAA,eAAA,EAAA;AACA,IAAA,IAAA,CAAA,YAAA,CAAA,CAAA,EAAA,0BAAA,CAAA,EAAA,IAAA,CAAA,CAAA,EAAA,KAAA,CAAA;AACA,EAAA;AACA;;;;;;;;;"}
@@ -20,6 +20,7 @@ const is = require('./is.js');
20
20
  * args>)` or `origMethod.apply(this, [<other args>])` (rather than being called directly), again to preserve `this`.
21
21
  * @returns void
22
22
  */
23
+
23
24
  function fill(source, name, replacementFactory) {
24
25
  if (!(name in source)) {
25
26
  return;
@@ -82,6 +83,37 @@ function markFunctionWrapped(wrapped, original) {
82
83
  } catch {} // eslint-disable-line no-empty
83
84
  }
84
85
 
86
+ /**
87
+ * Wrap a method on an object by name, only if it is not already wrapped.
88
+ *
89
+ * Note: to set the wrapped method as a non-enumerable property, pass
90
+ * false as the `enumerable` argument. This could be detected, but only
91
+ * by either walking up the prototype chain, or iterating over all fields
92
+ * in a `for(in)` loop. Neither are an acceptable performance impact for
93
+ * the rare case where we might patch a non-enumerable method.
94
+ */
95
+ function wrapMethod(
96
+ obj,
97
+ field,
98
+ wrapped,
99
+ enumerable = true,
100
+ ) {
101
+ const original = obj[field];
102
+ if (typeof original !== 'function') {
103
+ throw new Error(`Cannot wrap method: ${field} is not a function`);
104
+ }
105
+ if (getOriginalFunction(original)) {
106
+ throw new Error(`Attempting to wrap method ${field} multiple times`);
107
+ }
108
+ markFunctionWrapped(wrapped, original);
109
+ Object.defineProperty(obj, field, {
110
+ writable: true,
111
+ configurable: true,
112
+ enumerable,
113
+ value: wrapped,
114
+ });
115
+ }
116
+
85
117
  /**
86
118
  * This extracts the original function if available. See
87
119
  * `markFunctionWrapped` for more information.
@@ -277,4 +309,5 @@ exports.fill = fill;
277
309
  exports.getOriginalFunction = getOriginalFunction;
278
310
  exports.markFunctionWrapped = markFunctionWrapped;
279
311
  exports.objectify = objectify;
312
+ exports.wrapMethod = wrapMethod;
280
313
  //# sourceMappingURL=object.js.map
@@ -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 */\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 * 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;AACO,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,KAAK,EAAiB;AAC1F,EAAE,IAAI;AACN,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE;AACrC;AACA,MAAM,KAAK;AACX,MAAM,QAAQ,EAAE,IAAI;AACpB,MAAM,YAAY,EAAE,IAAI;AACxB,KAAK,CAAC;AACN,EAAE,EAAE,MAAM;AACV,IAAID,sBAAA,IAAeC,iBAAK,CAAC,GAAG,CAAC,CAAC,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AAC,KAAK,EAA6C;AAClE;AACA,EAAE,MAAM,WAAA,GAAc,CAAC,KAAA,GAAiB,WAAW;AACnD,EAAE,OAAO,WAAA,KAAgB,UAAU,WAAA,KAAgB,SAAS;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAC,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, 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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