@sentry/core 10.53.1 → 10.54.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 (1517) hide show
  1. package/build/cjs/api.js +10 -34
  2. package/build/cjs/api.js.map +1 -1
  3. package/build/cjs/asyncContext/index.js +0 -14
  4. package/build/cjs/asyncContext/index.js.map +1 -1
  5. package/build/cjs/asyncContext/stackStrategy.js +16 -47
  6. package/build/cjs/asyncContext/stackStrategy.js.map +1 -1
  7. package/build/cjs/attributes.js +17 -95
  8. package/build/cjs/attributes.js.map +1 -1
  9. package/build/cjs/breadcrumbs.js +2 -22
  10. package/build/cjs/breadcrumbs.js.map +1 -1
  11. package/build/cjs/browser.js +12 -3
  12. package/build/cjs/browser.js.map +1 -1
  13. package/build/cjs/carrier.js +5 -42
  14. package/build/cjs/carrier.js.map +1 -1
  15. package/build/cjs/checkin.js +5 -19
  16. package/build/cjs/checkin.js.map +1 -1
  17. package/build/cjs/client.js +216 -585
  18. package/build/cjs/client.js.map +1 -1
  19. package/build/cjs/constants.js +2 -2
  20. package/build/cjs/currentScopes.js +5 -86
  21. package/build/cjs/currentScopes.js.map +1 -1
  22. package/build/cjs/debug-build.js +0 -5
  23. package/build/cjs/debug-build.js.map +1 -1
  24. package/build/cjs/defaultScopes.js +2 -5
  25. package/build/cjs/defaultScopes.js.map +1 -1
  26. package/build/cjs/envelope.js +32 -103
  27. package/build/cjs/envelope.js.map +1 -1
  28. package/build/cjs/eventProcessors.js +4 -23
  29. package/build/cjs/eventProcessors.js.map +1 -1
  30. package/build/cjs/exports.js +21 -197
  31. package/build/cjs/exports.js.map +1 -1
  32. package/build/cjs/feedback.js +7 -19
  33. package/build/cjs/feedback.js.map +1 -1
  34. package/build/cjs/fetch.js +66 -201
  35. package/build/cjs/fetch.js.map +1 -1
  36. package/build/cjs/index.js +17 -3
  37. package/build/cjs/index.js.map +1 -1
  38. package/build/cjs/instrument/console.js +9 -41
  39. package/build/cjs/instrument/console.js.map +1 -1
  40. package/build/cjs/instrument/fetch.js +47 -156
  41. package/build/cjs/instrument/fetch.js.map +1 -1
  42. package/build/cjs/instrument/globalError.js +4 -25
  43. package/build/cjs/instrument/globalError.js.map +1 -1
  44. package/build/cjs/instrument/globalUnhandledRejection.js +4 -21
  45. package/build/cjs/instrument/globalUnhandledRejection.js.map +1 -1
  46. package/build/cjs/instrument/handlers.js +9 -21
  47. package/build/cjs/instrument/handlers.js.map +1 -1
  48. package/build/cjs/integration.js +13 -77
  49. package/build/cjs/integration.js.map +1 -1
  50. package/build/cjs/integrations/captureconsole.js +16 -40
  51. package/build/cjs/integrations/captureconsole.js.map +1 -1
  52. package/build/cjs/integrations/consola.js +57 -163
  53. package/build/cjs/integrations/consola.js.map +1 -1
  54. package/build/cjs/integrations/console.js +11 -43
  55. package/build/cjs/integrations/console.js.map +1 -1
  56. package/build/cjs/integrations/conversationId.js +5 -22
  57. package/build/cjs/integrations/conversationId.js.map +1 -1
  58. package/build/cjs/integrations/dedupe.js +16 -74
  59. package/build/cjs/integrations/dedupe.js.map +1 -1
  60. package/build/cjs/integrations/eventFilters.js +63 -114
  61. package/build/cjs/integrations/eventFilters.js.map +1 -1
  62. package/build/cjs/integrations/express/index.js +30 -145
  63. package/build/cjs/integrations/express/index.js.map +1 -1
  64. package/build/cjs/integrations/express/patch-layer.js +20 -130
  65. package/build/cjs/integrations/express/patch-layer.js.map +1 -1
  66. package/build/cjs/integrations/express/request-layer-store.js +1 -3
  67. package/build/cjs/integrations/express/request-layer-store.js.map +1 -1
  68. package/build/cjs/integrations/express/set-sdk-processing-metadata.js +0 -2
  69. package/build/cjs/integrations/express/set-sdk-processing-metadata.js.map +1 -1
  70. package/build/cjs/integrations/express/types.js +6 -7
  71. package/build/cjs/integrations/express/types.js.map +1 -1
  72. package/build/cjs/integrations/express/utils.js +37 -145
  73. package/build/cjs/integrations/express/utils.js.map +1 -1
  74. package/build/cjs/integrations/extraerrordata.js +24 -69
  75. package/build/cjs/integrations/extraerrordata.js.map +1 -1
  76. package/build/cjs/integrations/featureFlags/featureFlagsIntegration.js +3 -29
  77. package/build/cjs/integrations/featureFlags/featureFlagsIntegration.js.map +1 -1
  78. package/build/cjs/integrations/featureFlags/growthbook.js +11 -40
  79. package/build/cjs/integrations/featureFlags/growthbook.js.map +1 -1
  80. package/build/cjs/integrations/functiontostring.js +6 -27
  81. package/build/cjs/integrations/functiontostring.js.map +1 -1
  82. package/build/cjs/integrations/http/add-outgoing-request-breadcrumb.js +10 -18
  83. package/build/cjs/integrations/http/add-outgoing-request-breadcrumb.js.map +1 -1
  84. package/build/cjs/integrations/http/client-patch.js +8 -70
  85. package/build/cjs/integrations/http/client-patch.js.map +1 -1
  86. package/build/cjs/integrations/http/client-subscriptions.js +22 -59
  87. package/build/cjs/integrations/http/client-subscriptions.js.map +1 -1
  88. package/build/cjs/integrations/http/constants.js +3 -3
  89. package/build/cjs/integrations/http/double-wrap-warning.js +10 -18
  90. package/build/cjs/integrations/http/double-wrap-warning.js.map +1 -1
  91. package/build/cjs/integrations/http/get-outgoing-span-data.js +30 -47
  92. package/build/cjs/integrations/http/get-outgoing-span-data.js.map +1 -1
  93. package/build/cjs/integrations/http/get-request-url.js +7 -24
  94. package/build/cjs/integrations/http/get-request-url.js.map +1 -1
  95. package/build/cjs/integrations/http/inject-trace-propagation-headers.js +14 -38
  96. package/build/cjs/integrations/http/inject-trace-propagation-headers.js.map +1 -1
  97. package/build/cjs/integrations/http/patch-request-to-capture-body.js +80 -0
  98. package/build/cjs/integrations/http/patch-request-to-capture-body.js.map +1 -0
  99. package/build/cjs/integrations/http/record-request-session.js +61 -0
  100. package/build/cjs/integrations/http/record-request-session.js.map +1 -0
  101. package/build/cjs/integrations/http/server-subscription.js +289 -0
  102. package/build/cjs/integrations/http/server-subscription.js.map +1 -0
  103. package/build/cjs/integrations/linkederrors.js +6 -11
  104. package/build/cjs/integrations/linkederrors.js.map +1 -1
  105. package/build/cjs/integrations/mcp-server/attributeExtraction.js +26 -69
  106. package/build/cjs/integrations/mcp-server/attributeExtraction.js.map +1 -1
  107. package/build/cjs/integrations/mcp-server/attributes.js +30 -138
  108. package/build/cjs/integrations/mcp-server/attributes.js.map +1 -1
  109. package/build/cjs/integrations/mcp-server/correlation.js +20 -91
  110. package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
  111. package/build/cjs/integrations/mcp-server/errorCapture.js +6 -25
  112. package/build/cjs/integrations/mcp-server/errorCapture.js.map +1 -1
  113. package/build/cjs/integrations/mcp-server/handlers.js +55 -169
  114. package/build/cjs/integrations/mcp-server/handlers.js.map +1 -1
  115. package/build/cjs/integrations/mcp-server/index.js +7 -60
  116. package/build/cjs/integrations/mcp-server/index.js.map +1 -1
  117. package/build/cjs/integrations/mcp-server/methodConfig.js +21 -59
  118. package/build/cjs/integrations/mcp-server/methodConfig.js.map +1 -1
  119. package/build/cjs/integrations/mcp-server/piiFiltering.js +5 -33
  120. package/build/cjs/integrations/mcp-server/piiFiltering.js.map +1 -1
  121. package/build/cjs/integrations/mcp-server/resultExtraction.js +20 -76
  122. package/build/cjs/integrations/mcp-server/resultExtraction.js.map +1 -1
  123. package/build/cjs/integrations/mcp-server/sessionExtraction.js +30 -121
  124. package/build/cjs/integrations/mcp-server/sessionExtraction.js.map +1 -1
  125. package/build/cjs/integrations/mcp-server/sessionManagement.js +2 -60
  126. package/build/cjs/integrations/mcp-server/sessionManagement.js.map +1 -1
  127. package/build/cjs/integrations/mcp-server/spans.js +20 -107
  128. package/build/cjs/integrations/mcp-server/spans.js.map +1 -1
  129. package/build/cjs/integrations/mcp-server/transport.js +26 -94
  130. package/build/cjs/integrations/mcp-server/transport.js.map +1 -1
  131. package/build/cjs/integrations/mcp-server/validation.js +6 -72
  132. package/build/cjs/integrations/mcp-server/validation.js.map +1 -1
  133. package/build/cjs/integrations/moduleMetadata.js +6 -20
  134. package/build/cjs/integrations/moduleMetadata.js.map +1 -1
  135. package/build/cjs/integrations/postgresjs.js +78 -287
  136. package/build/cjs/integrations/postgresjs.js.map +1 -1
  137. package/build/cjs/integrations/requestdata.js +30 -93
  138. package/build/cjs/integrations/requestdata.js.map +1 -1
  139. package/build/cjs/integrations/rewriteframes.js +14 -45
  140. package/build/cjs/integrations/rewriteframes.js.map +1 -1
  141. package/build/cjs/integrations/spanStreaming.js +9 -15
  142. package/build/cjs/integrations/spanStreaming.js.map +1 -1
  143. package/build/cjs/integrations/supabase.js +224 -333
  144. package/build/cjs/integrations/supabase.js.map +1 -1
  145. package/build/cjs/integrations/third-party-errors-filter.js +60 -85
  146. package/build/cjs/integrations/third-party-errors-filter.js.map +1 -1
  147. package/build/cjs/integrations/zoderrors.js +35 -111
  148. package/build/cjs/integrations/zoderrors.js.map +1 -1
  149. package/build/cjs/logs/console-integration.js +15 -50
  150. package/build/cjs/logs/console-integration.js.map +1 -1
  151. package/build/cjs/logs/constants.js +1 -6
  152. package/build/cjs/logs/constants.js.map +1 -1
  153. package/build/cjs/logs/envelope.js +10 -40
  154. package/build/cjs/logs/envelope.js.map +1 -1
  155. package/build/cjs/logs/internal.js +53 -125
  156. package/build/cjs/logs/internal.js.map +1 -1
  157. package/build/cjs/logs/public-api.js +13 -228
  158. package/build/cjs/logs/public-api.js.map +1 -1
  159. package/build/cjs/logs/utils.js +6 -47
  160. package/build/cjs/logs/utils.js.map +1 -1
  161. package/build/cjs/metadata.js +6 -51
  162. package/build/cjs/metadata.js.map +1 -1
  163. package/build/cjs/metrics/envelope.js +12 -45
  164. package/build/cjs/metrics/envelope.js.map +1 -1
  165. package/build/cjs/metrics/internal.js +31 -144
  166. package/build/cjs/metrics/internal.js.map +1 -1
  167. package/build/cjs/metrics/public-api.js +4 -109
  168. package/build/cjs/metrics/public-api.js.map +1 -1
  169. package/build/cjs/profiling.js +11 -41
  170. package/build/cjs/profiling.js.map +1 -1
  171. package/build/cjs/scope.js +73 -224
  172. package/build/cjs/scope.js.map +1 -1
  173. package/build/cjs/sdk.js +2 -21
  174. package/build/cjs/sdk.js.map +1 -1
  175. package/build/cjs/semanticAttributes.js +30 -116
  176. package/build/cjs/semanticAttributes.js.map +1 -1
  177. package/build/cjs/server-runtime-client.js +32 -87
  178. package/build/cjs/server-runtime-client.js.map +1 -1
  179. package/build/cjs/server.js +17 -3
  180. package/build/cjs/server.js.map +1 -1
  181. package/build/cjs/session.js +14 -67
  182. package/build/cjs/session.js.map +1 -1
  183. package/build/cjs/tracing/ai/gen-ai-attributes.js +45 -249
  184. package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
  185. package/build/cjs/tracing/ai/mediaStripping.js +21 -116
  186. package/build/cjs/tracing/ai/mediaStripping.js.map +1 -1
  187. package/build/cjs/tracing/ai/messageTruncation.js +26 -212
  188. package/build/cjs/tracing/ai/messageTruncation.js.map +1 -1
  189. package/build/cjs/tracing/ai/utils.js +40 -180
  190. package/build/cjs/tracing/ai/utils.js.map +1 -1
  191. package/build/cjs/tracing/anthropic-ai/constants.js +9 -12
  192. package/build/cjs/tracing/anthropic-ai/constants.js.map +1 -1
  193. package/build/cjs/tracing/anthropic-ai/index.js +67 -172
  194. package/build/cjs/tracing/anthropic-ai/index.js.map +1 -1
  195. package/build/cjs/tracing/anthropic-ai/streaming.js +45 -149
  196. package/build/cjs/tracing/anthropic-ai/streaming.js.map +1 -1
  197. package/build/cjs/tracing/anthropic-ai/utils.js +17 -47
  198. package/build/cjs/tracing/anthropic-ai/utils.js.map +1 -1
  199. package/build/cjs/tracing/dynamicSamplingContext.js +18 -85
  200. package/build/cjs/tracing/dynamicSamplingContext.js.map +1 -1
  201. package/build/cjs/tracing/errors.js +2 -14
  202. package/build/cjs/tracing/errors.js.map +1 -1
  203. package/build/cjs/tracing/google-genai/constants.js +9 -16
  204. package/build/cjs/tracing/google-genai/constants.js.map +1 -1
  205. package/build/cjs/tracing/google-genai/index.js +79 -223
  206. package/build/cjs/tracing/google-genai/index.js.map +1 -1
  207. package/build/cjs/tracing/google-genai/streaming.js +11 -56
  208. package/build/cjs/tracing/google-genai/streaming.js.map +1 -1
  209. package/build/cjs/tracing/google-genai/utils.js +8 -13
  210. package/build/cjs/tracing/google-genai/utils.js.map +1 -1
  211. package/build/cjs/tracing/idleSpan.js +48 -174
  212. package/build/cjs/tracing/idleSpan.js.map +1 -1
  213. package/build/cjs/tracing/langchain/constants.js +8 -9
  214. package/build/cjs/tracing/langchain/constants.js.map +1 -1
  215. package/build/cjs/tracing/langchain/embeddings.js +31 -75
  216. package/build/cjs/tracing/langchain/embeddings.js.map +1 -1
  217. package/build/cjs/tracing/langchain/index.js +64 -161
  218. package/build/cjs/tracing/langchain/index.js.map +1 -1
  219. package/build/cjs/tracing/langchain/utils.js +101 -311
  220. package/build/cjs/tracing/langchain/utils.js.map +1 -1
  221. package/build/cjs/tracing/langgraph/constants.js +2 -2
  222. package/build/cjs/tracing/langgraph/index.js +57 -160
  223. package/build/cjs/tracing/langgraph/index.js.map +1 -1
  224. package/build/cjs/tracing/langgraph/utils.js +53 -170
  225. package/build/cjs/tracing/langgraph/utils.js.map +1 -1
  226. package/build/cjs/tracing/logSpans.js +10 -26
  227. package/build/cjs/tracing/logSpans.js.map +1 -1
  228. package/build/cjs/tracing/measurement.js +6 -18
  229. package/build/cjs/tracing/measurement.js.map +1 -1
  230. package/build/cjs/tracing/openai/constants.js +20 -24
  231. package/build/cjs/tracing/openai/constants.js.map +1 -1
  232. package/build/cjs/tracing/openai/index.js +52 -132
  233. package/build/cjs/tracing/openai/index.js.map +1 -1
  234. package/build/cjs/tracing/openai/streaming.js +24 -102
  235. package/build/cjs/tracing/openai/streaming.js.map +1 -1
  236. package/build/cjs/tracing/openai/utils.js +36 -107
  237. package/build/cjs/tracing/openai/utils.js.map +1 -1
  238. package/build/cjs/tracing/sampling.js +23 -63
  239. package/build/cjs/tracing/sampling.js.map +1 -1
  240. package/build/cjs/tracing/sentryNonRecordingSpan.js +15 -40
  241. package/build/cjs/tracing/sentryNonRecordingSpan.js.map +1 -1
  242. package/build/cjs/tracing/sentrySpan.js +66 -172
  243. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  244. package/build/cjs/tracing/spans/beforeSendSpan.js +4 -32
  245. package/build/cjs/tracing/spans/beforeSendSpan.js.map +1 -1
  246. package/build/cjs/tracing/spans/captureSpan.js +58 -156
  247. package/build/cjs/tracing/spans/captureSpan.js.map +1 -1
  248. package/build/cjs/tracing/spans/envelope.js +12 -24
  249. package/build/cjs/tracing/spans/envelope.js.map +1 -1
  250. package/build/cjs/tracing/spans/estimateSize.js +0 -22
  251. package/build/cjs/tracing/spans/estimateSize.js.map +1 -1
  252. package/build/cjs/tracing/spans/extractGenAiSpans.js +11 -33
  253. package/build/cjs/tracing/spans/extractGenAiSpans.js.map +1 -1
  254. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js +1 -4
  255. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js.map +1 -1
  256. package/build/cjs/tracing/spans/scopeContextAttributes.js +58 -0
  257. package/build/cjs/tracing/spans/scopeContextAttributes.js.map +1 -0
  258. package/build/cjs/tracing/spans/spanBuffer.js +21 -71
  259. package/build/cjs/tracing/spans/spanBuffer.js.map +1 -1
  260. package/build/cjs/tracing/spans/spanJsonToStreamedSpan.js +4 -8
  261. package/build/cjs/tracing/spans/spanJsonToStreamedSpan.js.map +1 -1
  262. package/build/cjs/tracing/spanstatus.js +15 -32
  263. package/build/cjs/tracing/spanstatus.js.map +1 -1
  264. package/build/cjs/tracing/trace.js +95 -311
  265. package/build/cjs/tracing/trace.js.map +1 -1
  266. package/build/cjs/tracing/utils.js +4 -14
  267. package/build/cjs/tracing/utils.js.map +1 -1
  268. package/build/cjs/tracing/vercel-ai/constants.js +15 -26
  269. package/build/cjs/tracing/vercel-ai/constants.js.map +1 -1
  270. package/build/cjs/tracing/vercel-ai/index.js +84 -288
  271. package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
  272. package/build/cjs/tracing/vercel-ai/utils.js +30 -128
  273. package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
  274. package/build/cjs/tracing/vercel-ai/vercel-ai-attributes.js +22 -229
  275. package/build/cjs/tracing/vercel-ai/vercel-ai-attributes.js.map +1 -1
  276. package/build/cjs/transports/base.js +32 -67
  277. package/build/cjs/transports/base.js.map +1 -1
  278. package/build/cjs/transports/multiplexed.js +38 -103
  279. package/build/cjs/transports/multiplexed.js.map +1 -1
  280. package/build/cjs/transports/offline.js +31 -72
  281. package/build/cjs/transports/offline.js.map +1 -1
  282. package/build/cjs/transports/userAgent.js +4 -13
  283. package/build/cjs/transports/userAgent.js.map +1 -1
  284. package/build/cjs/trpc.js +19 -39
  285. package/build/cjs/trpc.js.map +1 -1
  286. package/build/cjs/utils/aggregate-errors.js +18 -62
  287. package/build/cjs/utils/aggregate-errors.js.map +1 -1
  288. package/build/cjs/utils/ai/providerSkip.js +3 -50
  289. package/build/cjs/utils/ai/providerSkip.js.map +1 -1
  290. package/build/cjs/utils/anr.js +7 -36
  291. package/build/cjs/utils/anr.js.map +1 -1
  292. package/build/cjs/utils/baggage.js +37 -146
  293. package/build/cjs/utils/baggage.js.map +1 -1
  294. package/build/cjs/utils/breadcrumb-log-level.js +5 -9
  295. package/build/cjs/utils/breadcrumb-log-level.js.map +1 -1
  296. package/build/cjs/utils/browser.js +24 -86
  297. package/build/cjs/utils/browser.js.map +1 -1
  298. package/build/cjs/utils/chain-and-copy-promiselike.js +10 -27
  299. package/build/cjs/utils/chain-and-copy-promiselike.js.map +1 -1
  300. package/build/cjs/utils/clientreport.js +4 -13
  301. package/build/cjs/utils/clientreport.js.map +1 -1
  302. package/build/cjs/utils/cookie.js +6 -53
  303. package/build/cjs/utils/cookie.js.map +1 -1
  304. package/build/cjs/utils/data-collection/defaultPiiToCollectionOptions.js +28 -0
  305. package/build/cjs/utils/data-collection/defaultPiiToCollectionOptions.js.map +1 -0
  306. package/build/cjs/utils/data-collection/filterCookies.js +23 -0
  307. package/build/cjs/utils/data-collection/filterCookies.js.map +1 -0
  308. package/build/cjs/utils/data-collection/filterKeyValueData.js +43 -0
  309. package/build/cjs/utils/data-collection/filterKeyValueData.js.map +1 -0
  310. package/build/cjs/utils/data-collection/filterQueryParams.js +26 -0
  311. package/build/cjs/utils/data-collection/filterQueryParams.js.map +1 -0
  312. package/build/cjs/utils/data-collection/filtering-snippets.js +61 -0
  313. package/build/cjs/utils/data-collection/filtering-snippets.js.map +1 -0
  314. package/build/cjs/utils/data-collection/resolveDataCollectionOptions.js +37 -0
  315. package/build/cjs/utils/data-collection/resolveDataCollectionOptions.js.map +1 -0
  316. package/build/cjs/utils/debounce.js +5 -32
  317. package/build/cjs/utils/debounce.js.map +1 -1
  318. package/build/cjs/utils/debug-ids.js +4 -42
  319. package/build/cjs/utils/debug-ids.js.map +1 -1
  320. package/build/cjs/utils/debug-logger.js +23 -56
  321. package/build/cjs/utils/debug-logger.js.map +1 -1
  322. package/build/cjs/utils/dsn.js +18 -81
  323. package/build/cjs/utils/dsn.js.map +1 -1
  324. package/build/cjs/utils/env.js +3 -27
  325. package/build/cjs/utils/env.js.map +1 -1
  326. package/build/cjs/utils/envToBool.js +2 -15
  327. package/build/cjs/utils/envToBool.js.map +1 -1
  328. package/build/cjs/utils/envelope.js +39 -133
  329. package/build/cjs/utils/envelope.js.map +1 -1
  330. package/build/cjs/utils/error.js +3 -10
  331. package/build/cjs/utils/error.js.map +1 -1
  332. package/build/cjs/utils/eventUtils.js +0 -8
  333. package/build/cjs/utils/eventUtils.js.map +1 -1
  334. package/build/cjs/utils/eventbuilder.js +30 -114
  335. package/build/cjs/utils/eventbuilder.js.map +1 -1
  336. package/build/cjs/utils/exports.js +5 -24
  337. package/build/cjs/utils/exports.js.map +1 -1
  338. package/build/cjs/utils/featureFlags.js +10 -96
  339. package/build/cjs/utils/featureFlags.js.map +1 -1
  340. package/build/cjs/utils/flushIfServerless.js +14 -48
  341. package/build/cjs/utils/flushIfServerless.js.map +1 -1
  342. package/build/cjs/utils/get-default-export.js +1 -25
  343. package/build/cjs/utils/get-default-export.js.map +1 -1
  344. package/build/cjs/utils/handleCallbackErrors.js +10 -48
  345. package/build/cjs/utils/handleCallbackErrors.js.map +1 -1
  346. package/build/cjs/utils/hasSpansEnabled.js +4 -28
  347. package/build/cjs/utils/hasSpansEnabled.js.map +1 -1
  348. package/build/cjs/utils/ipAddress.js +7 -19
  349. package/build/cjs/utils/ipAddress.js.map +1 -1
  350. package/build/cjs/utils/is.js +18 -163
  351. package/build/cjs/utils/is.js.map +1 -1
  352. package/build/cjs/utils/isBrowser.js +3 -9
  353. package/build/cjs/utils/isBrowser.js.map +1 -1
  354. package/build/cjs/utils/isSentryRequestUrl.js +2 -19
  355. package/build/cjs/utils/isSentryRequestUrl.js.map +1 -1
  356. package/build/cjs/utils/lru.js +13 -24
  357. package/build/cjs/utils/lru.js.map +1 -1
  358. package/build/cjs/utils/merge.js +1 -17
  359. package/build/cjs/utils/merge.js.map +1 -1
  360. package/build/cjs/utils/meta.js +1 -24
  361. package/build/cjs/utils/meta.js.map +1 -1
  362. package/build/cjs/utils/misc.js +31 -134
  363. package/build/cjs/utils/misc.js.map +1 -1
  364. package/build/cjs/utils/node-stack-trace.js +22 -61
  365. package/build/cjs/utils/node-stack-trace.js.map +1 -1
  366. package/build/cjs/utils/node.js +3 -48
  367. package/build/cjs/utils/node.js.map +1 -1
  368. package/build/cjs/utils/normalizationHints.js +5 -18
  369. package/build/cjs/utils/normalizationHints.js.map +1 -1
  370. package/build/cjs/utils/normalize.js +39 -205
  371. package/build/cjs/utils/normalize.js.map +1 -1
  372. package/build/cjs/utils/object.js +33 -168
  373. package/build/cjs/utils/object.js.map +1 -1
  374. package/build/cjs/utils/parameterize.js +2 -21
  375. package/build/cjs/utils/parameterize.js.map +1 -1
  376. package/build/cjs/utils/parseSampleRate.js +4 -13
  377. package/build/cjs/utils/parseSampleRate.js.map +1 -1
  378. package/build/cjs/utils/path.js +28 -115
  379. package/build/cjs/utils/path.js.map +1 -1
  380. package/build/cjs/utils/prepareEvent.js +53 -191
  381. package/build/cjs/utils/prepareEvent.js.map +1 -1
  382. package/build/cjs/utils/promisebuffer.js +5 -47
  383. package/build/cjs/utils/promisebuffer.js.map +1 -1
  384. package/build/cjs/utils/propagationContext.js +0 -7
  385. package/build/cjs/utils/propagationContext.js.map +1 -1
  386. package/build/cjs/utils/randomSafeContext.js +3 -22
  387. package/build/cjs/utils/randomSafeContext.js.map +1 -1
  388. package/build/cjs/utils/ratelimit.js +13 -66
  389. package/build/cjs/utils/ratelimit.js.map +1 -1
  390. package/build/cjs/utils/request.js +62 -269
  391. package/build/cjs/utils/request.js.map +1 -1
  392. package/build/cjs/utils/scopeData.js +15 -79
  393. package/build/cjs/utils/scopeData.js.map +1 -1
  394. package/build/cjs/utils/sdkMetadata.js +5 -19
  395. package/build/cjs/utils/sdkMetadata.js.map +1 -1
  396. package/build/cjs/utils/severity.js +1 -9
  397. package/build/cjs/utils/severity.js.map +1 -1
  398. package/build/cjs/utils/should-ignore-span.js +6 -38
  399. package/build/cjs/utils/should-ignore-span.js.map +1 -1
  400. package/build/cjs/utils/spanOnScope.js +3 -14
  401. package/build/cjs/utils/spanOnScope.js.map +1 -1
  402. package/build/cjs/utils/spanUtils.js +42 -222
  403. package/build/cjs/utils/spanUtils.js.map +1 -1
  404. package/build/cjs/utils/stacktrace.js +19 -106
  405. package/build/cjs/utils/stacktrace.js.map +1 -1
  406. package/build/cjs/utils/string.js +7 -75
  407. package/build/cjs/utils/string.js.map +1 -1
  408. package/build/cjs/utils/supports.js +14 -99
  409. package/build/cjs/utils/supports.js.map +1 -1
  410. package/build/cjs/utils/syncpromise.js +19 -68
  411. package/build/cjs/utils/syncpromise.js.map +1 -1
  412. package/build/cjs/utils/time.js +7 -84
  413. package/build/cjs/utils/time.js.map +1 -1
  414. package/build/cjs/utils/timer.js +1 -10
  415. package/build/cjs/utils/timer.js.map +1 -1
  416. package/build/cjs/utils/timestampSequence.js +5 -21
  417. package/build/cjs/utils/timestampSequence.js.map +1 -1
  418. package/build/cjs/utils/trace-info.js +3 -10
  419. package/build/cjs/utils/trace-info.js.map +1 -1
  420. package/build/cjs/utils/traceData.js +4 -39
  421. package/build/cjs/utils/traceData.js.map +1 -1
  422. package/build/cjs/utils/tracePropagationTargets.js +4 -18
  423. package/build/cjs/utils/tracePropagationTargets.js.map +1 -1
  424. package/build/cjs/utils/tracing.js +32 -106
  425. package/build/cjs/utils/tracing.js.map +1 -1
  426. package/build/cjs/utils/transactionEvent.js +11 -19
  427. package/build/cjs/utils/transactionEvent.js.map +1 -1
  428. package/build/cjs/utils/tunnel.js +12 -33
  429. package/build/cjs/utils/tunnel.js.map +1 -1
  430. package/build/cjs/utils/url.js +42 -176
  431. package/build/cjs/utils/url.js.map +1 -1
  432. package/build/cjs/utils/vercelWaitUntil.js +4 -12
  433. package/build/cjs/utils/vercelWaitUntil.js.map +1 -1
  434. package/build/cjs/utils/version.js +1 -3
  435. package/build/cjs/utils/version.js.map +1 -1
  436. package/build/cjs/utils/weakRef.js +5 -36
  437. package/build/cjs/utils/weakRef.js.map +1 -1
  438. package/build/cjs/utils/worldwide.js +1 -4
  439. package/build/cjs/utils/worldwide.js.map +1 -1
  440. package/build/cjs/vendor/escapeStringForRegex.js +1 -32
  441. package/build/cjs/vendor/escapeStringForRegex.js.map +1 -1
  442. package/build/cjs/vendor/getIpAddress.js +19 -99
  443. package/build/cjs/vendor/getIpAddress.js.map +1 -1
  444. package/build/esm/api.js +10 -34
  445. package/build/esm/api.js.map +1 -1
  446. package/build/esm/asyncContext/index.js +0 -14
  447. package/build/esm/asyncContext/index.js.map +1 -1
  448. package/build/esm/asyncContext/stackStrategy.js +16 -47
  449. package/build/esm/asyncContext/stackStrategy.js.map +1 -1
  450. package/build/esm/attributes.js +17 -95
  451. package/build/esm/attributes.js.map +1 -1
  452. package/build/esm/breadcrumbs.js +2 -22
  453. package/build/esm/breadcrumbs.js.map +1 -1
  454. package/build/esm/browser.js +5 -1
  455. package/build/esm/browser.js.map +1 -1
  456. package/build/esm/carrier.js +5 -42
  457. package/build/esm/carrier.js.map +1 -1
  458. package/build/esm/checkin.js +5 -19
  459. package/build/esm/checkin.js.map +1 -1
  460. package/build/esm/client.js +216 -585
  461. package/build/esm/client.js.map +1 -1
  462. package/build/esm/constants.js +2 -2
  463. package/build/esm/currentScopes.js +5 -86
  464. package/build/esm/currentScopes.js.map +1 -1
  465. package/build/esm/debug-build.js +0 -5
  466. package/build/esm/debug-build.js.map +1 -1
  467. package/build/esm/defaultScopes.js +2 -5
  468. package/build/esm/defaultScopes.js.map +1 -1
  469. package/build/esm/envelope.js +32 -103
  470. package/build/esm/envelope.js.map +1 -1
  471. package/build/esm/eventProcessors.js +4 -23
  472. package/build/esm/eventProcessors.js.map +1 -1
  473. package/build/esm/exports.js +21 -197
  474. package/build/esm/exports.js.map +1 -1
  475. package/build/esm/feedback.js +7 -19
  476. package/build/esm/feedback.js.map +1 -1
  477. package/build/esm/fetch.js +66 -201
  478. package/build/esm/fetch.js.map +1 -1
  479. package/build/esm/index.js +7 -1
  480. package/build/esm/index.js.map +1 -1
  481. package/build/esm/instrument/console.js +9 -41
  482. package/build/esm/instrument/console.js.map +1 -1
  483. package/build/esm/instrument/fetch.js +47 -156
  484. package/build/esm/instrument/fetch.js.map +1 -1
  485. package/build/esm/instrument/globalError.js +4 -25
  486. package/build/esm/instrument/globalError.js.map +1 -1
  487. package/build/esm/instrument/globalUnhandledRejection.js +4 -21
  488. package/build/esm/instrument/globalUnhandledRejection.js.map +1 -1
  489. package/build/esm/instrument/handlers.js +9 -21
  490. package/build/esm/instrument/handlers.js.map +1 -1
  491. package/build/esm/integration.js +13 -77
  492. package/build/esm/integration.js.map +1 -1
  493. package/build/esm/integrations/captureconsole.js +16 -40
  494. package/build/esm/integrations/captureconsole.js.map +1 -1
  495. package/build/esm/integrations/consola.js +57 -163
  496. package/build/esm/integrations/consola.js.map +1 -1
  497. package/build/esm/integrations/console.js +11 -43
  498. package/build/esm/integrations/console.js.map +1 -1
  499. package/build/esm/integrations/conversationId.js +5 -22
  500. package/build/esm/integrations/conversationId.js.map +1 -1
  501. package/build/esm/integrations/dedupe.js +16 -74
  502. package/build/esm/integrations/dedupe.js.map +1 -1
  503. package/build/esm/integrations/eventFilters.js +63 -114
  504. package/build/esm/integrations/eventFilters.js.map +1 -1
  505. package/build/esm/integrations/express/index.js +30 -145
  506. package/build/esm/integrations/express/index.js.map +1 -1
  507. package/build/esm/integrations/express/patch-layer.js +20 -130
  508. package/build/esm/integrations/express/patch-layer.js.map +1 -1
  509. package/build/esm/integrations/express/request-layer-store.js +1 -3
  510. package/build/esm/integrations/express/request-layer-store.js.map +1 -1
  511. package/build/esm/integrations/express/set-sdk-processing-metadata.js +0 -2
  512. package/build/esm/integrations/express/set-sdk-processing-metadata.js.map +1 -1
  513. package/build/esm/integrations/express/types.js +6 -7
  514. package/build/esm/integrations/express/types.js.map +1 -1
  515. package/build/esm/integrations/express/utils.js +37 -145
  516. package/build/esm/integrations/express/utils.js.map +1 -1
  517. package/build/esm/integrations/extraerrordata.js +24 -69
  518. package/build/esm/integrations/extraerrordata.js.map +1 -1
  519. package/build/esm/integrations/featureFlags/featureFlagsIntegration.js +3 -29
  520. package/build/esm/integrations/featureFlags/featureFlagsIntegration.js.map +1 -1
  521. package/build/esm/integrations/featureFlags/growthbook.js +11 -40
  522. package/build/esm/integrations/featureFlags/growthbook.js.map +1 -1
  523. package/build/esm/integrations/functiontostring.js +6 -27
  524. package/build/esm/integrations/functiontostring.js.map +1 -1
  525. package/build/esm/integrations/http/add-outgoing-request-breadcrumb.js +10 -18
  526. package/build/esm/integrations/http/add-outgoing-request-breadcrumb.js.map +1 -1
  527. package/build/esm/integrations/http/client-patch.js +8 -70
  528. package/build/esm/integrations/http/client-patch.js.map +1 -1
  529. package/build/esm/integrations/http/client-subscriptions.js +22 -59
  530. package/build/esm/integrations/http/client-subscriptions.js.map +1 -1
  531. package/build/esm/integrations/http/constants.js +3 -3
  532. package/build/esm/integrations/http/double-wrap-warning.js +10 -18
  533. package/build/esm/integrations/http/double-wrap-warning.js.map +1 -1
  534. package/build/esm/integrations/http/get-outgoing-span-data.js +30 -47
  535. package/build/esm/integrations/http/get-outgoing-span-data.js.map +1 -1
  536. package/build/esm/integrations/http/get-request-url.js +7 -24
  537. package/build/esm/integrations/http/get-request-url.js.map +1 -1
  538. package/build/esm/integrations/http/inject-trace-propagation-headers.js +14 -38
  539. package/build/esm/integrations/http/inject-trace-propagation-headers.js.map +1 -1
  540. package/build/esm/integrations/http/patch-request-to-capture-body.js +78 -0
  541. package/build/esm/integrations/http/patch-request-to-capture-body.js.map +1 -0
  542. package/build/esm/integrations/http/record-request-session.js +59 -0
  543. package/build/esm/integrations/http/record-request-session.js.map +1 -0
  544. package/build/esm/integrations/http/server-subscription.js +285 -0
  545. package/build/esm/integrations/http/server-subscription.js.map +1 -0
  546. package/build/esm/integrations/linkederrors.js +6 -11
  547. package/build/esm/integrations/linkederrors.js.map +1 -1
  548. package/build/esm/integrations/mcp-server/attributeExtraction.js +26 -69
  549. package/build/esm/integrations/mcp-server/attributeExtraction.js.map +1 -1
  550. package/build/esm/integrations/mcp-server/attributes.js +30 -138
  551. package/build/esm/integrations/mcp-server/attributes.js.map +1 -1
  552. package/build/esm/integrations/mcp-server/correlation.js +20 -91
  553. package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
  554. package/build/esm/integrations/mcp-server/errorCapture.js +6 -25
  555. package/build/esm/integrations/mcp-server/errorCapture.js.map +1 -1
  556. package/build/esm/integrations/mcp-server/handlers.js +55 -169
  557. package/build/esm/integrations/mcp-server/handlers.js.map +1 -1
  558. package/build/esm/integrations/mcp-server/index.js +7 -60
  559. package/build/esm/integrations/mcp-server/index.js.map +1 -1
  560. package/build/esm/integrations/mcp-server/methodConfig.js +21 -59
  561. package/build/esm/integrations/mcp-server/methodConfig.js.map +1 -1
  562. package/build/esm/integrations/mcp-server/piiFiltering.js +5 -33
  563. package/build/esm/integrations/mcp-server/piiFiltering.js.map +1 -1
  564. package/build/esm/integrations/mcp-server/resultExtraction.js +20 -76
  565. package/build/esm/integrations/mcp-server/resultExtraction.js.map +1 -1
  566. package/build/esm/integrations/mcp-server/sessionExtraction.js +30 -121
  567. package/build/esm/integrations/mcp-server/sessionExtraction.js.map +1 -1
  568. package/build/esm/integrations/mcp-server/sessionManagement.js +2 -60
  569. package/build/esm/integrations/mcp-server/sessionManagement.js.map +1 -1
  570. package/build/esm/integrations/mcp-server/spans.js +20 -107
  571. package/build/esm/integrations/mcp-server/spans.js.map +1 -1
  572. package/build/esm/integrations/mcp-server/transport.js +26 -94
  573. package/build/esm/integrations/mcp-server/transport.js.map +1 -1
  574. package/build/esm/integrations/mcp-server/validation.js +6 -72
  575. package/build/esm/integrations/mcp-server/validation.js.map +1 -1
  576. package/build/esm/integrations/moduleMetadata.js +6 -20
  577. package/build/esm/integrations/moduleMetadata.js.map +1 -1
  578. package/build/esm/integrations/postgresjs.js +78 -287
  579. package/build/esm/integrations/postgresjs.js.map +1 -1
  580. package/build/esm/integrations/requestdata.js +30 -93
  581. package/build/esm/integrations/requestdata.js.map +1 -1
  582. package/build/esm/integrations/rewriteframes.js +14 -45
  583. package/build/esm/integrations/rewriteframes.js.map +1 -1
  584. package/build/esm/integrations/spanStreaming.js +9 -15
  585. package/build/esm/integrations/spanStreaming.js.map +1 -1
  586. package/build/esm/integrations/supabase.js +224 -333
  587. package/build/esm/integrations/supabase.js.map +1 -1
  588. package/build/esm/integrations/third-party-errors-filter.js +60 -85
  589. package/build/esm/integrations/third-party-errors-filter.js.map +1 -1
  590. package/build/esm/integrations/zoderrors.js +35 -111
  591. package/build/esm/integrations/zoderrors.js.map +1 -1
  592. package/build/esm/logs/console-integration.js +15 -50
  593. package/build/esm/logs/console-integration.js.map +1 -1
  594. package/build/esm/logs/constants.js +1 -6
  595. package/build/esm/logs/constants.js.map +1 -1
  596. package/build/esm/logs/envelope.js +10 -40
  597. package/build/esm/logs/envelope.js.map +1 -1
  598. package/build/esm/logs/internal.js +53 -126
  599. package/build/esm/logs/internal.js.map +1 -1
  600. package/build/esm/logs/public-api.js +13 -228
  601. package/build/esm/logs/public-api.js.map +1 -1
  602. package/build/esm/logs/utils.js +6 -47
  603. package/build/esm/logs/utils.js.map +1 -1
  604. package/build/esm/metadata.js +6 -51
  605. package/build/esm/metadata.js.map +1 -1
  606. package/build/esm/metrics/envelope.js +12 -45
  607. package/build/esm/metrics/envelope.js.map +1 -1
  608. package/build/esm/metrics/internal.js +31 -144
  609. package/build/esm/metrics/internal.js.map +1 -1
  610. package/build/esm/metrics/public-api.js +4 -109
  611. package/build/esm/metrics/public-api.js.map +1 -1
  612. package/build/esm/package.json +1 -1
  613. package/build/esm/profiling.js +11 -41
  614. package/build/esm/profiling.js.map +1 -1
  615. package/build/esm/scope.js +73 -224
  616. package/build/esm/scope.js.map +1 -1
  617. package/build/esm/sdk.js +2 -21
  618. package/build/esm/sdk.js.map +1 -1
  619. package/build/esm/semanticAttributes.js +31 -118
  620. package/build/esm/semanticAttributes.js.map +1 -1
  621. package/build/esm/server-runtime-client.js +32 -87
  622. package/build/esm/server-runtime-client.js.map +1 -1
  623. package/build/esm/server.js +7 -1
  624. package/build/esm/server.js.map +1 -1
  625. package/build/esm/session.js +14 -67
  626. package/build/esm/session.js.map +1 -1
  627. package/build/esm/tracing/ai/gen-ai-attributes.js +45 -249
  628. package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
  629. package/build/esm/tracing/ai/mediaStripping.js +21 -116
  630. package/build/esm/tracing/ai/mediaStripping.js.map +1 -1
  631. package/build/esm/tracing/ai/messageTruncation.js +26 -212
  632. package/build/esm/tracing/ai/messageTruncation.js.map +1 -1
  633. package/build/esm/tracing/ai/utils.js +40 -180
  634. package/build/esm/tracing/ai/utils.js.map +1 -1
  635. package/build/esm/tracing/anthropic-ai/constants.js +9 -12
  636. package/build/esm/tracing/anthropic-ai/constants.js.map +1 -1
  637. package/build/esm/tracing/anthropic-ai/index.js +67 -172
  638. package/build/esm/tracing/anthropic-ai/index.js.map +1 -1
  639. package/build/esm/tracing/anthropic-ai/streaming.js +45 -149
  640. package/build/esm/tracing/anthropic-ai/streaming.js.map +1 -1
  641. package/build/esm/tracing/anthropic-ai/utils.js +17 -47
  642. package/build/esm/tracing/anthropic-ai/utils.js.map +1 -1
  643. package/build/esm/tracing/dynamicSamplingContext.js +18 -85
  644. package/build/esm/tracing/dynamicSamplingContext.js.map +1 -1
  645. package/build/esm/tracing/errors.js +2 -14
  646. package/build/esm/tracing/errors.js.map +1 -1
  647. package/build/esm/tracing/google-genai/constants.js +9 -16
  648. package/build/esm/tracing/google-genai/constants.js.map +1 -1
  649. package/build/esm/tracing/google-genai/index.js +79 -223
  650. package/build/esm/tracing/google-genai/index.js.map +1 -1
  651. package/build/esm/tracing/google-genai/streaming.js +11 -56
  652. package/build/esm/tracing/google-genai/streaming.js.map +1 -1
  653. package/build/esm/tracing/google-genai/utils.js +8 -13
  654. package/build/esm/tracing/google-genai/utils.js.map +1 -1
  655. package/build/esm/tracing/idleSpan.js +48 -174
  656. package/build/esm/tracing/idleSpan.js.map +1 -1
  657. package/build/esm/tracing/langchain/constants.js +8 -9
  658. package/build/esm/tracing/langchain/constants.js.map +1 -1
  659. package/build/esm/tracing/langchain/embeddings.js +31 -75
  660. package/build/esm/tracing/langchain/embeddings.js.map +1 -1
  661. package/build/esm/tracing/langchain/index.js +64 -161
  662. package/build/esm/tracing/langchain/index.js.map +1 -1
  663. package/build/esm/tracing/langchain/utils.js +101 -312
  664. package/build/esm/tracing/langchain/utils.js.map +1 -1
  665. package/build/esm/tracing/langgraph/constants.js +2 -2
  666. package/build/esm/tracing/langgraph/index.js +59 -162
  667. package/build/esm/tracing/langgraph/index.js.map +1 -1
  668. package/build/esm/tracing/langgraph/utils.js +54 -170
  669. package/build/esm/tracing/langgraph/utils.js.map +1 -1
  670. package/build/esm/tracing/logSpans.js +10 -26
  671. package/build/esm/tracing/logSpans.js.map +1 -1
  672. package/build/esm/tracing/measurement.js +6 -18
  673. package/build/esm/tracing/measurement.js.map +1 -1
  674. package/build/esm/tracing/openai/constants.js +20 -24
  675. package/build/esm/tracing/openai/constants.js.map +1 -1
  676. package/build/esm/tracing/openai/index.js +52 -132
  677. package/build/esm/tracing/openai/index.js.map +1 -1
  678. package/build/esm/tracing/openai/streaming.js +24 -102
  679. package/build/esm/tracing/openai/streaming.js.map +1 -1
  680. package/build/esm/tracing/openai/utils.js +36 -107
  681. package/build/esm/tracing/openai/utils.js.map +1 -1
  682. package/build/esm/tracing/sampling.js +23 -63
  683. package/build/esm/tracing/sampling.js.map +1 -1
  684. package/build/esm/tracing/sentryNonRecordingSpan.js +15 -40
  685. package/build/esm/tracing/sentryNonRecordingSpan.js.map +1 -1
  686. package/build/esm/tracing/sentrySpan.js +66 -172
  687. package/build/esm/tracing/sentrySpan.js.map +1 -1
  688. package/build/esm/tracing/spans/beforeSendSpan.js +4 -32
  689. package/build/esm/tracing/spans/beforeSendSpan.js.map +1 -1
  690. package/build/esm/tracing/spans/captureSpan.js +59 -157
  691. package/build/esm/tracing/spans/captureSpan.js.map +1 -1
  692. package/build/esm/tracing/spans/envelope.js +12 -24
  693. package/build/esm/tracing/spans/envelope.js.map +1 -1
  694. package/build/esm/tracing/spans/estimateSize.js +0 -22
  695. package/build/esm/tracing/spans/estimateSize.js.map +1 -1
  696. package/build/esm/tracing/spans/extractGenAiSpans.js +11 -33
  697. package/build/esm/tracing/spans/extractGenAiSpans.js.map +1 -1
  698. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js +1 -4
  699. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js.map +1 -1
  700. package/build/esm/tracing/spans/scopeContextAttributes.js +56 -0
  701. package/build/esm/tracing/spans/scopeContextAttributes.js.map +1 -0
  702. package/build/esm/tracing/spans/spanBuffer.js +21 -71
  703. package/build/esm/tracing/spans/spanBuffer.js.map +1 -1
  704. package/build/esm/tracing/spans/spanJsonToStreamedSpan.js +4 -8
  705. package/build/esm/tracing/spans/spanJsonToStreamedSpan.js.map +1 -1
  706. package/build/esm/tracing/spanstatus.js +15 -32
  707. package/build/esm/tracing/spanstatus.js.map +1 -1
  708. package/build/esm/tracing/trace.js +95 -311
  709. package/build/esm/tracing/trace.js.map +1 -1
  710. package/build/esm/tracing/utils.js +4 -14
  711. package/build/esm/tracing/utils.js.map +1 -1
  712. package/build/esm/tracing/vercel-ai/constants.js +15 -26
  713. package/build/esm/tracing/vercel-ai/constants.js.map +1 -1
  714. package/build/esm/tracing/vercel-ai/index.js +84 -288
  715. package/build/esm/tracing/vercel-ai/index.js.map +1 -1
  716. package/build/esm/tracing/vercel-ai/utils.js +30 -128
  717. package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
  718. package/build/esm/tracing/vercel-ai/vercel-ai-attributes.js +22 -229
  719. package/build/esm/tracing/vercel-ai/vercel-ai-attributes.js.map +1 -1
  720. package/build/esm/transports/base.js +32 -67
  721. package/build/esm/transports/base.js.map +1 -1
  722. package/build/esm/transports/multiplexed.js +38 -103
  723. package/build/esm/transports/multiplexed.js.map +1 -1
  724. package/build/esm/transports/offline.js +31 -72
  725. package/build/esm/transports/offline.js.map +1 -1
  726. package/build/esm/transports/userAgent.js +4 -13
  727. package/build/esm/transports/userAgent.js.map +1 -1
  728. package/build/esm/trpc.js +19 -39
  729. package/build/esm/trpc.js.map +1 -1
  730. package/build/esm/utils/aggregate-errors.js +18 -62
  731. package/build/esm/utils/aggregate-errors.js.map +1 -1
  732. package/build/esm/utils/ai/providerSkip.js +3 -50
  733. package/build/esm/utils/ai/providerSkip.js.map +1 -1
  734. package/build/esm/utils/anr.js +7 -36
  735. package/build/esm/utils/anr.js.map +1 -1
  736. package/build/esm/utils/baggage.js +37 -146
  737. package/build/esm/utils/baggage.js.map +1 -1
  738. package/build/esm/utils/breadcrumb-log-level.js +5 -9
  739. package/build/esm/utils/breadcrumb-log-level.js.map +1 -1
  740. package/build/esm/utils/browser.js +24 -86
  741. package/build/esm/utils/browser.js.map +1 -1
  742. package/build/esm/utils/chain-and-copy-promiselike.js +10 -27
  743. package/build/esm/utils/chain-and-copy-promiselike.js.map +1 -1
  744. package/build/esm/utils/clientreport.js +4 -13
  745. package/build/esm/utils/clientreport.js.map +1 -1
  746. package/build/esm/utils/cookie.js +6 -53
  747. package/build/esm/utils/cookie.js.map +1 -1
  748. package/build/esm/utils/data-collection/defaultPiiToCollectionOptions.js +26 -0
  749. package/build/esm/utils/data-collection/defaultPiiToCollectionOptions.js.map +1 -0
  750. package/build/esm/utils/data-collection/filterCookies.js +21 -0
  751. package/build/esm/utils/data-collection/filterCookies.js.map +1 -0
  752. package/build/esm/utils/data-collection/filterKeyValueData.js +41 -0
  753. package/build/esm/utils/data-collection/filterKeyValueData.js.map +1 -0
  754. package/build/esm/utils/data-collection/filterQueryParams.js +24 -0
  755. package/build/esm/utils/data-collection/filterQueryParams.js.map +1 -0
  756. package/build/esm/utils/data-collection/filtering-snippets.js +56 -0
  757. package/build/esm/utils/data-collection/filtering-snippets.js.map +1 -0
  758. package/build/esm/utils/data-collection/resolveDataCollectionOptions.js +35 -0
  759. package/build/esm/utils/data-collection/resolveDataCollectionOptions.js.map +1 -0
  760. package/build/esm/utils/debounce.js +5 -32
  761. package/build/esm/utils/debounce.js.map +1 -1
  762. package/build/esm/utils/debug-ids.js +4 -42
  763. package/build/esm/utils/debug-ids.js.map +1 -1
  764. package/build/esm/utils/debug-logger.js +23 -56
  765. package/build/esm/utils/debug-logger.js.map +1 -1
  766. package/build/esm/utils/dsn.js +18 -81
  767. package/build/esm/utils/dsn.js.map +1 -1
  768. package/build/esm/utils/env.js +3 -27
  769. package/build/esm/utils/env.js.map +1 -1
  770. package/build/esm/utils/envToBool.js +2 -15
  771. package/build/esm/utils/envToBool.js.map +1 -1
  772. package/build/esm/utils/envelope.js +39 -133
  773. package/build/esm/utils/envelope.js.map +1 -1
  774. package/build/esm/utils/error.js +3 -10
  775. package/build/esm/utils/error.js.map +1 -1
  776. package/build/esm/utils/eventUtils.js +0 -8
  777. package/build/esm/utils/eventUtils.js.map +1 -1
  778. package/build/esm/utils/eventbuilder.js +30 -114
  779. package/build/esm/utils/eventbuilder.js.map +1 -1
  780. package/build/esm/utils/exports.js +5 -24
  781. package/build/esm/utils/exports.js.map +1 -1
  782. package/build/esm/utils/featureFlags.js +10 -96
  783. package/build/esm/utils/featureFlags.js.map +1 -1
  784. package/build/esm/utils/flushIfServerless.js +14 -48
  785. package/build/esm/utils/flushIfServerless.js.map +1 -1
  786. package/build/esm/utils/get-default-export.js +1 -25
  787. package/build/esm/utils/get-default-export.js.map +1 -1
  788. package/build/esm/utils/handleCallbackErrors.js +10 -48
  789. package/build/esm/utils/handleCallbackErrors.js.map +1 -1
  790. package/build/esm/utils/hasSpansEnabled.js +4 -28
  791. package/build/esm/utils/hasSpansEnabled.js.map +1 -1
  792. package/build/esm/utils/ipAddress.js +7 -19
  793. package/build/esm/utils/ipAddress.js.map +1 -1
  794. package/build/esm/utils/is.js +18 -163
  795. package/build/esm/utils/is.js.map +1 -1
  796. package/build/esm/utils/isBrowser.js +3 -9
  797. package/build/esm/utils/isBrowser.js.map +1 -1
  798. package/build/esm/utils/isSentryRequestUrl.js +2 -19
  799. package/build/esm/utils/isSentryRequestUrl.js.map +1 -1
  800. package/build/esm/utils/lru.js +13 -24
  801. package/build/esm/utils/lru.js.map +1 -1
  802. package/build/esm/utils/merge.js +1 -17
  803. package/build/esm/utils/merge.js.map +1 -1
  804. package/build/esm/utils/meta.js +1 -24
  805. package/build/esm/utils/meta.js.map +1 -1
  806. package/build/esm/utils/misc.js +31 -134
  807. package/build/esm/utils/misc.js.map +1 -1
  808. package/build/esm/utils/node-stack-trace.js +22 -61
  809. package/build/esm/utils/node-stack-trace.js.map +1 -1
  810. package/build/esm/utils/node.js +3 -48
  811. package/build/esm/utils/node.js.map +1 -1
  812. package/build/esm/utils/normalizationHints.js +5 -18
  813. package/build/esm/utils/normalizationHints.js.map +1 -1
  814. package/build/esm/utils/normalize.js +39 -205
  815. package/build/esm/utils/normalize.js.map +1 -1
  816. package/build/esm/utils/object.js +33 -168
  817. package/build/esm/utils/object.js.map +1 -1
  818. package/build/esm/utils/parameterize.js +2 -21
  819. package/build/esm/utils/parameterize.js.map +1 -1
  820. package/build/esm/utils/parseSampleRate.js +4 -13
  821. package/build/esm/utils/parseSampleRate.js.map +1 -1
  822. package/build/esm/utils/path.js +28 -115
  823. package/build/esm/utils/path.js.map +1 -1
  824. package/build/esm/utils/prepareEvent.js +53 -191
  825. package/build/esm/utils/prepareEvent.js.map +1 -1
  826. package/build/esm/utils/promisebuffer.js +5 -47
  827. package/build/esm/utils/promisebuffer.js.map +1 -1
  828. package/build/esm/utils/propagationContext.js +0 -7
  829. package/build/esm/utils/propagationContext.js.map +1 -1
  830. package/build/esm/utils/randomSafeContext.js +3 -22
  831. package/build/esm/utils/randomSafeContext.js.map +1 -1
  832. package/build/esm/utils/ratelimit.js +13 -66
  833. package/build/esm/utils/ratelimit.js.map +1 -1
  834. package/build/esm/utils/request.js +62 -269
  835. package/build/esm/utils/request.js.map +1 -1
  836. package/build/esm/utils/scopeData.js +15 -79
  837. package/build/esm/utils/scopeData.js.map +1 -1
  838. package/build/esm/utils/sdkMetadata.js +5 -19
  839. package/build/esm/utils/sdkMetadata.js.map +1 -1
  840. package/build/esm/utils/severity.js +1 -9
  841. package/build/esm/utils/severity.js.map +1 -1
  842. package/build/esm/utils/should-ignore-span.js +6 -38
  843. package/build/esm/utils/should-ignore-span.js.map +1 -1
  844. package/build/esm/utils/spanOnScope.js +3 -14
  845. package/build/esm/utils/spanOnScope.js.map +1 -1
  846. package/build/esm/utils/spanUtils.js +42 -222
  847. package/build/esm/utils/spanUtils.js.map +1 -1
  848. package/build/esm/utils/stacktrace.js +19 -106
  849. package/build/esm/utils/stacktrace.js.map +1 -1
  850. package/build/esm/utils/string.js +7 -75
  851. package/build/esm/utils/string.js.map +1 -1
  852. package/build/esm/utils/supports.js +14 -99
  853. package/build/esm/utils/supports.js.map +1 -1
  854. package/build/esm/utils/syncpromise.js +19 -68
  855. package/build/esm/utils/syncpromise.js.map +1 -1
  856. package/build/esm/utils/time.js +7 -84
  857. package/build/esm/utils/time.js.map +1 -1
  858. package/build/esm/utils/timer.js +1 -10
  859. package/build/esm/utils/timer.js.map +1 -1
  860. package/build/esm/utils/timestampSequence.js +5 -21
  861. package/build/esm/utils/timestampSequence.js.map +1 -1
  862. package/build/esm/utils/trace-info.js +3 -10
  863. package/build/esm/utils/trace-info.js.map +1 -1
  864. package/build/esm/utils/traceData.js +4 -39
  865. package/build/esm/utils/traceData.js.map +1 -1
  866. package/build/esm/utils/tracePropagationTargets.js +4 -18
  867. package/build/esm/utils/tracePropagationTargets.js.map +1 -1
  868. package/build/esm/utils/tracing.js +32 -106
  869. package/build/esm/utils/tracing.js.map +1 -1
  870. package/build/esm/utils/transactionEvent.js +11 -19
  871. package/build/esm/utils/transactionEvent.js.map +1 -1
  872. package/build/esm/utils/tunnel.js +12 -33
  873. package/build/esm/utils/tunnel.js.map +1 -1
  874. package/build/esm/utils/url.js +42 -176
  875. package/build/esm/utils/url.js.map +1 -1
  876. package/build/esm/utils/vercelWaitUntil.js +4 -12
  877. package/build/esm/utils/vercelWaitUntil.js.map +1 -1
  878. package/build/esm/utils/version.js +1 -3
  879. package/build/esm/utils/version.js.map +1 -1
  880. package/build/esm/utils/weakRef.js +5 -36
  881. package/build/esm/utils/weakRef.js.map +1 -1
  882. package/build/esm/utils/worldwide.js +1 -4
  883. package/build/esm/utils/worldwide.js.map +1 -1
  884. package/build/esm/vendor/escapeStringForRegex.js +1 -32
  885. package/build/esm/vendor/escapeStringForRegex.js.map +1 -1
  886. package/build/esm/vendor/getIpAddress.js +19 -99
  887. package/build/esm/vendor/getIpAddress.js.map +1 -1
  888. package/build/types/api.d.ts +2 -2
  889. package/build/types/api.d.ts.map +1 -1
  890. package/build/types/attributes.d.ts +5 -8
  891. package/build/types/attributes.d.ts.map +1 -1
  892. package/build/types/breadcrumbs.d.ts +1 -1
  893. package/build/types/breadcrumbs.d.ts.map +1 -1
  894. package/build/types/browser-exports.d.ts +3 -3
  895. package/build/types/browser-exports.d.ts.map +1 -1
  896. package/build/types/carrier.d.ts +2 -2
  897. package/build/types/carrier.d.ts.map +1 -1
  898. package/build/types/checkin.d.ts +4 -4
  899. package/build/types/checkin.d.ts.map +1 -1
  900. package/build/types/client.d.ts +32 -22
  901. package/build/types/client.d.ts.map +1 -1
  902. package/build/types/currentScopes.d.ts +1 -1
  903. package/build/types/currentScopes.d.ts.map +1 -1
  904. package/build/types/envelope.d.ts +7 -7
  905. package/build/types/envelope.d.ts.map +1 -1
  906. package/build/types/eventProcessors.d.ts +2 -2
  907. package/build/types/eventProcessors.d.ts.map +1 -1
  908. package/build/types/exports.d.ts +8 -8
  909. package/build/types/exports.d.ts.map +1 -1
  910. package/build/types/feedback.d.ts +2 -2
  911. package/build/types/feedback.d.ts.map +1 -1
  912. package/build/types/fetch.d.ts +3 -3
  913. package/build/types/fetch.d.ts.map +1 -1
  914. package/build/types/instrument/console.d.ts +1 -1
  915. package/build/types/instrument/console.d.ts.map +1 -1
  916. package/build/types/instrument/fetch.d.ts +1 -1
  917. package/build/types/instrument/fetch.d.ts.map +1 -1
  918. package/build/types/instrument/globalError.d.ts +1 -1
  919. package/build/types/instrument/globalError.d.ts.map +1 -1
  920. package/build/types/instrument/globalUnhandledRejection.d.ts +1 -1
  921. package/build/types/instrument/globalUnhandledRejection.d.ts.map +1 -1
  922. package/build/types/integration.d.ts +2 -2
  923. package/build/types/integration.d.ts.map +1 -1
  924. package/build/types/integrations/consola.d.ts +1 -1
  925. package/build/types/integrations/consola.d.ts.map +1 -1
  926. package/build/types/integrations/console.d.ts +1 -1
  927. package/build/types/integrations/console.d.ts.map +1 -1
  928. package/build/types/integrations/dedupe.d.ts +1 -1
  929. package/build/types/integrations/dedupe.d.ts.map +1 -1
  930. package/build/types/integrations/express/types.d.ts +2 -2
  931. package/build/types/integrations/express/types.d.ts.map +1 -1
  932. package/build/types/integrations/express/utils.d.ts +1 -1
  933. package/build/types/integrations/express/utils.d.ts.map +1 -1
  934. package/build/types/integrations/featureFlags/featureFlagsIntegration.d.ts +1 -1
  935. package/build/types/integrations/featureFlags/featureFlagsIntegration.d.ts.map +1 -1
  936. package/build/types/integrations/featureFlags/growthbook.d.ts +1 -1
  937. package/build/types/integrations/featureFlags/growthbook.d.ts.map +1 -1
  938. package/build/types/integrations/http/double-wrap-warning.d.ts +1 -1
  939. package/build/types/integrations/http/double-wrap-warning.d.ts.map +1 -1
  940. package/build/types/integrations/http/get-outgoing-span-data.d.ts +2 -2
  941. package/build/types/integrations/http/get-outgoing-span-data.d.ts.map +1 -1
  942. package/build/types/integrations/http/patch-request-to-capture-body.d.ts +12 -0
  943. package/build/types/integrations/http/patch-request-to-capture-body.d.ts.map +1 -0
  944. package/build/types/integrations/http/record-request-session.d.ts +18 -0
  945. package/build/types/integrations/http/record-request-session.d.ts.map +1 -0
  946. package/build/types/integrations/http/server-subscription.d.ts +26 -0
  947. package/build/types/integrations/http/server-subscription.d.ts.map +1 -0
  948. package/build/types/integrations/http/types.d.ts +12 -6
  949. package/build/types/integrations/http/types.d.ts.map +1 -1
  950. package/build/types/integrations/mcp-server/correlation.d.ts +1 -1
  951. package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
  952. package/build/types/integrations/mcp-server/piiFiltering.d.ts +1 -1
  953. package/build/types/integrations/mcp-server/piiFiltering.d.ts.map +1 -1
  954. package/build/types/integrations/mcp-server/types.d.ts +1 -1
  955. package/build/types/integrations/mcp-server/types.d.ts.map +1 -1
  956. package/build/types/integrations/postgresjs.d.ts +1 -1
  957. package/build/types/integrations/postgresjs.d.ts.map +1 -1
  958. package/build/types/integrations/rewriteframes.d.ts +1 -1
  959. package/build/types/integrations/rewriteframes.d.ts.map +1 -1
  960. package/build/types/integrations/supabase.d.ts +14 -3
  961. package/build/types/integrations/supabase.d.ts.map +1 -1
  962. package/build/types/integrations/third-party-errors-filter.d.ts.map +1 -1
  963. package/build/types/integrations/zoderrors.d.ts +1 -1
  964. package/build/types/integrations/zoderrors.d.ts.map +1 -1
  965. package/build/types/logs/console-integration.d.ts +1 -1
  966. package/build/types/logs/console-integration.d.ts.map +1 -1
  967. package/build/types/logs/constants.d.ts +1 -1
  968. package/build/types/logs/constants.d.ts.map +1 -1
  969. package/build/types/logs/envelope.d.ts +4 -4
  970. package/build/types/logs/envelope.d.ts.map +1 -1
  971. package/build/types/logs/internal.d.ts +16 -1
  972. package/build/types/logs/internal.d.ts.map +1 -1
  973. package/build/types/logs/public-api.d.ts +2 -2
  974. package/build/types/logs/public-api.d.ts.map +1 -1
  975. package/build/types/metadata.d.ts +2 -2
  976. package/build/types/metadata.d.ts.map +1 -1
  977. package/build/types/metrics/envelope.d.ts +4 -4
  978. package/build/types/metrics/envelope.d.ts.map +1 -1
  979. package/build/types/metrics/internal.d.ts +1 -1
  980. package/build/types/metrics/internal.d.ts.map +1 -1
  981. package/build/types/metrics/public-api.d.ts +1 -1
  982. package/build/types/metrics/public-api.d.ts.map +1 -1
  983. package/build/types/profiling.d.ts +1 -1
  984. package/build/types/profiling.d.ts.map +1 -1
  985. package/build/types/report-dialog.d.ts +1 -1
  986. package/build/types/report-dialog.d.ts.map +1 -1
  987. package/build/types/scope.d.ts +14 -14
  988. package/build/types/scope.d.ts.map +1 -1
  989. package/build/types/sdk.d.ts +1 -1
  990. package/build/types/sdk.d.ts.map +1 -1
  991. package/build/types/semanticAttributes.d.ts +2 -0
  992. package/build/types/semanticAttributes.d.ts.map +1 -1
  993. package/build/types/server-exports.d.ts +3 -1
  994. package/build/types/server-exports.d.ts.map +1 -1
  995. package/build/types/server-runtime-client.d.ts +6 -6
  996. package/build/types/server-runtime-client.d.ts.map +1 -1
  997. package/build/types/session.d.ts +1 -1
  998. package/build/types/session.d.ts.map +1 -1
  999. package/build/types/shared-exports.d.ts +58 -53
  1000. package/build/types/shared-exports.d.ts.map +1 -1
  1001. package/build/types/tracing/ai/utils.d.ts +1 -1
  1002. package/build/types/tracing/ai/utils.d.ts.map +1 -1
  1003. package/build/types/tracing/anthropic-ai/streaming.d.ts +1 -1
  1004. package/build/types/tracing/anthropic-ai/streaming.d.ts.map +1 -1
  1005. package/build/types/tracing/anthropic-ai/utils.d.ts +2 -2
  1006. package/build/types/tracing/anthropic-ai/utils.d.ts.map +1 -1
  1007. package/build/types/tracing/dynamicSamplingContext.d.ts +2 -2
  1008. package/build/types/tracing/dynamicSamplingContext.d.ts.map +1 -1
  1009. package/build/types/tracing/google-genai/streaming.d.ts +1 -1
  1010. package/build/types/tracing/google-genai/streaming.d.ts.map +1 -1
  1011. package/build/types/tracing/idleSpan.d.ts +2 -2
  1012. package/build/types/tracing/idleSpan.d.ts.map +1 -1
  1013. package/build/types/tracing/langchain/utils.d.ts +6 -1
  1014. package/build/types/tracing/langchain/utils.d.ts.map +1 -1
  1015. package/build/types/tracing/langgraph/index.d.ts.map +1 -1
  1016. package/build/types/tracing/langgraph/utils.d.ts +1 -3
  1017. package/build/types/tracing/langgraph/utils.d.ts.map +1 -1
  1018. package/build/types/tracing/logSpans.d.ts +1 -1
  1019. package/build/types/tracing/logSpans.d.ts.map +1 -1
  1020. package/build/types/tracing/measurement.d.ts +2 -2
  1021. package/build/types/tracing/measurement.d.ts.map +1 -1
  1022. package/build/types/tracing/openai/streaming.d.ts +1 -1
  1023. package/build/types/tracing/openai/streaming.d.ts.map +1 -1
  1024. package/build/types/tracing/openai/utils.d.ts +1 -1
  1025. package/build/types/tracing/openai/utils.d.ts.map +1 -1
  1026. package/build/types/tracing/sampling.d.ts +2 -2
  1027. package/build/types/tracing/sampling.d.ts.map +1 -1
  1028. package/build/types/tracing/sentryNonRecordingSpan.d.ts +3 -3
  1029. package/build/types/tracing/sentryNonRecordingSpan.d.ts.map +1 -1
  1030. package/build/types/tracing/sentrySpan.d.ts +4 -4
  1031. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  1032. package/build/types/tracing/spans/beforeSendSpan.d.ts +3 -3
  1033. package/build/types/tracing/spans/beforeSendSpan.d.ts.map +1 -1
  1034. package/build/types/tracing/spans/captureSpan.d.ts +1 -1
  1035. package/build/types/tracing/spans/captureSpan.d.ts.map +1 -1
  1036. package/build/types/tracing/spans/envelope.d.ts +2 -2
  1037. package/build/types/tracing/spans/envelope.d.ts.map +1 -1
  1038. package/build/types/tracing/spans/estimateSize.d.ts +1 -1
  1039. package/build/types/tracing/spans/estimateSize.d.ts.map +1 -1
  1040. package/build/types/tracing/spans/extractGenAiSpans.d.ts +2 -2
  1041. package/build/types/tracing/spans/extractGenAiSpans.d.ts.map +1 -1
  1042. package/build/types/tracing/spans/scopeContextAttributes.d.ts +9 -0
  1043. package/build/types/tracing/spans/scopeContextAttributes.d.ts.map +1 -0
  1044. package/build/types/tracing/spans/spanJsonToStreamedSpan.d.ts +1 -1
  1045. package/build/types/tracing/spans/spanJsonToStreamedSpan.d.ts.map +1 -1
  1046. package/build/types/tracing/spanstatus.d.ts +2 -2
  1047. package/build/types/tracing/spanstatus.d.ts.map +1 -1
  1048. package/build/types/tracing/trace.d.ts +2 -2
  1049. package/build/types/tracing/trace.d.ts.map +1 -1
  1050. package/build/types/tracing/utils.d.ts +1 -1
  1051. package/build/types/tracing/utils.d.ts.map +1 -1
  1052. package/build/types/tracing/vercel-ai/utils.d.ts +2 -2
  1053. package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
  1054. package/build/types/transports/base.d.ts +1 -1
  1055. package/build/types/transports/base.d.ts.map +1 -1
  1056. package/build/types/transports/multiplexed.d.ts +3 -3
  1057. package/build/types/transports/multiplexed.d.ts.map +1 -1
  1058. package/build/types/transports/offline.d.ts +2 -2
  1059. package/build/types/transports/offline.d.ts.map +1 -1
  1060. package/build/types/transports/userAgent.d.ts +1 -1
  1061. package/build/types/transports/userAgent.d.ts.map +1 -1
  1062. package/build/types/trpc.d.ts.map +1 -1
  1063. package/build/types/types/attachment.d.ts.map +1 -0
  1064. package/build/types/types/breadcrumb.d.ts.map +1 -0
  1065. package/build/types/types/browseroptions.d.ts.map +1 -0
  1066. package/build/types/types/checkin.d.ts.map +1 -0
  1067. package/build/types/types/clientreport.d.ts.map +1 -0
  1068. package/build/types/types/context.d.ts.map +1 -0
  1069. package/build/types/types/csp.d.ts.map +1 -0
  1070. package/build/types/types/datacategory.d.ts.map +1 -0
  1071. package/build/types/types/datacollection.d.ts +75 -0
  1072. package/build/types/types/datacollection.d.ts.map +1 -0
  1073. package/build/types/types/debugMeta.d.ts.map +1 -0
  1074. package/build/types/types/dsn.d.ts.map +1 -0
  1075. package/build/types/types/envelope.d.ts.map +1 -0
  1076. package/build/types/types/error.d.ts.map +1 -0
  1077. package/build/types/types/event.d.ts.map +1 -0
  1078. package/build/types/types/eventprocessor.d.ts.map +1 -0
  1079. package/build/types/types/exception.d.ts.map +1 -0
  1080. package/build/types/types/extra.d.ts.map +1 -0
  1081. package/build/types/types/feedback/config.d.ts.map +1 -0
  1082. package/build/types/types/feedback/form.d.ts.map +1 -0
  1083. package/build/types/types/feedback/index.d.ts.map +1 -0
  1084. package/build/types/types/feedback/sendFeedback.d.ts.map +1 -0
  1085. package/build/types/types/feedback/theme.d.ts.map +1 -0
  1086. package/build/types/types/instrument.d.ts.map +1 -0
  1087. package/build/types/types/integration.d.ts.map +1 -0
  1088. package/build/types/types/link.d.ts.map +1 -0
  1089. package/build/types/types/log.d.ts.map +1 -0
  1090. package/build/types/types/measurement.d.ts.map +1 -0
  1091. package/build/types/types/mechanism.d.ts.map +1 -0
  1092. package/build/types/types/metric.d.ts.map +1 -0
  1093. package/build/types/types/misc.d.ts.map +1 -0
  1094. package/build/types/types/opentelemetry.d.ts.map +1 -0
  1095. package/build/types/{types-hoist → types}/options.d.ts +17 -0
  1096. package/build/types/types/options.d.ts.map +1 -0
  1097. package/build/types/types/package.d.ts.map +1 -0
  1098. package/build/types/types/parameterize.d.ts.map +1 -0
  1099. package/build/types/types/polymorphics.d.ts.map +1 -0
  1100. package/build/types/types/profiling.d.ts.map +1 -0
  1101. package/build/types/types/replay.d.ts.map +1 -0
  1102. package/build/types/types/request.d.ts.map +1 -0
  1103. package/build/types/types/runtime.d.ts.map +1 -0
  1104. package/build/types/{types-hoist → types}/samplingcontext.d.ts +1 -1
  1105. package/build/types/types/samplingcontext.d.ts.map +1 -0
  1106. package/build/types/types/sdkinfo.d.ts.map +1 -0
  1107. package/build/types/types/sdkmetadata.d.ts.map +1 -0
  1108. package/build/types/types/session.d.ts.map +1 -0
  1109. package/build/types/types/severity.d.ts.map +1 -0
  1110. package/build/types/types/span.d.ts.map +1 -0
  1111. package/build/types/types/spanStatus.d.ts.map +1 -0
  1112. package/build/types/types/stackframe.d.ts.map +1 -0
  1113. package/build/types/types/stacktrace.d.ts.map +1 -0
  1114. package/build/types/{types-hoist → types}/startSpanOptions.d.ts +13 -0
  1115. package/build/types/types/startSpanOptions.d.ts.map +1 -0
  1116. package/build/types/types/thread.d.ts.map +1 -0
  1117. package/build/types/types/timedEvent.d.ts.map +1 -0
  1118. package/build/types/types/tracing.d.ts.map +1 -0
  1119. package/build/types/types/transaction.d.ts.map +1 -0
  1120. package/build/types/types/transport.d.ts.map +1 -0
  1121. package/build/types/types/user.d.ts.map +1 -0
  1122. package/build/types/types/view-hierarchy.d.ts.map +1 -0
  1123. package/build/types/types/vue.d.ts.map +1 -0
  1124. package/build/types/types/webfetchapi.d.ts.map +1 -0
  1125. package/build/types/types/wrappedfunction.d.ts.map +1 -0
  1126. package/build/types/utils/aggregate-errors.d.ts +3 -3
  1127. package/build/types/utils/aggregate-errors.d.ts.map +1 -1
  1128. package/build/types/utils/anr.d.ts +1 -1
  1129. package/build/types/utils/anr.d.ts.map +1 -1
  1130. package/build/types/utils/baggage.d.ts +1 -1
  1131. package/build/types/utils/baggage.d.ts.map +1 -1
  1132. package/build/types/utils/breadcrumb-log-level.d.ts +1 -1
  1133. package/build/types/utils/breadcrumb-log-level.d.ts.map +1 -1
  1134. package/build/types/utils/clientreport.d.ts +2 -2
  1135. package/build/types/utils/clientreport.d.ts.map +1 -1
  1136. package/build/types/utils/data-collection/defaultPiiToCollectionOptions.d.ts +6 -0
  1137. package/build/types/utils/data-collection/defaultPiiToCollectionOptions.d.ts.map +1 -0
  1138. package/build/types/utils/data-collection/filterCookies.d.ts +9 -0
  1139. package/build/types/utils/data-collection/filterCookies.d.ts.map +1 -0
  1140. package/build/types/utils/data-collection/filterKeyValueData.d.ts +11 -0
  1141. package/build/types/utils/data-collection/filterKeyValueData.d.ts.map +1 -0
  1142. package/build/types/utils/data-collection/filterQueryParams.d.ts +9 -0
  1143. package/build/types/utils/data-collection/filterQueryParams.d.ts.map +1 -0
  1144. package/build/types/utils/data-collection/filtering-snippets.d.ts +14 -0
  1145. package/build/types/utils/data-collection/filtering-snippets.d.ts.map +1 -0
  1146. package/build/types/utils/data-collection/resolveDataCollectionOptions.d.ts +14 -0
  1147. package/build/types/utils/data-collection/resolveDataCollectionOptions.d.ts.map +1 -0
  1148. package/build/types/utils/debug-ids.d.ts +2 -2
  1149. package/build/types/utils/debug-ids.d.ts.map +1 -1
  1150. package/build/types/utils/debug-logger.d.ts +1 -1
  1151. package/build/types/utils/debug-logger.d.ts.map +1 -1
  1152. package/build/types/utils/dsn.d.ts +1 -1
  1153. package/build/types/utils/dsn.d.ts.map +1 -1
  1154. package/build/types/utils/env.d.ts.map +1 -1
  1155. package/build/types/utils/envelope.d.ts +8 -8
  1156. package/build/types/utils/envelope.d.ts.map +1 -1
  1157. package/build/types/utils/error.d.ts +1 -1
  1158. package/build/types/utils/error.d.ts.map +1 -1
  1159. package/build/types/utils/eventUtils.d.ts +1 -1
  1160. package/build/types/utils/eventUtils.d.ts.map +1 -1
  1161. package/build/types/utils/eventbuilder.d.ts +6 -6
  1162. package/build/types/utils/eventbuilder.d.ts.map +1 -1
  1163. package/build/types/utils/featureFlags.d.ts +1 -1
  1164. package/build/types/utils/featureFlags.d.ts.map +1 -1
  1165. package/build/types/utils/hasSpansEnabled.d.ts +1 -1
  1166. package/build/types/utils/hasSpansEnabled.d.ts.map +1 -1
  1167. package/build/types/utils/ipAddress.d.ts +2 -2
  1168. package/build/types/utils/ipAddress.d.ts.map +1 -1
  1169. package/build/types/utils/is.d.ts +4 -4
  1170. package/build/types/utils/is.d.ts.map +1 -1
  1171. package/build/types/utils/meta.d.ts +1 -1
  1172. package/build/types/utils/meta.d.ts.map +1 -1
  1173. package/build/types/utils/misc.d.ts +3 -3
  1174. package/build/types/utils/misc.d.ts.map +1 -1
  1175. package/build/types/utils/node-stack-trace.d.ts +1 -1
  1176. package/build/types/utils/node-stack-trace.d.ts.map +1 -1
  1177. package/build/types/utils/object.d.ts +1 -1
  1178. package/build/types/utils/object.d.ts.map +1 -1
  1179. package/build/types/utils/parameterize.d.ts +1 -1
  1180. package/build/types/utils/parameterize.d.ts.map +1 -1
  1181. package/build/types/utils/prepareEvent.d.ts +3 -3
  1182. package/build/types/utils/prepareEvent.d.ts.map +1 -1
  1183. package/build/types/utils/ratelimit.d.ts +2 -2
  1184. package/build/types/utils/ratelimit.d.ts.map +1 -1
  1185. package/build/types/utils/request.d.ts +3 -3
  1186. package/build/types/utils/request.d.ts.map +1 -1
  1187. package/build/types/utils/scopeData.d.ts +1 -1
  1188. package/build/types/utils/scopeData.d.ts.map +1 -1
  1189. package/build/types/utils/sdkMetadata.d.ts +1 -1
  1190. package/build/types/utils/sdkMetadata.d.ts.map +1 -1
  1191. package/build/types/utils/severity.d.ts +1 -1
  1192. package/build/types/utils/severity.d.ts.map +1 -1
  1193. package/build/types/utils/should-ignore-span.d.ts +2 -2
  1194. package/build/types/utils/should-ignore-span.d.ts.map +1 -1
  1195. package/build/types/utils/spanOnScope.d.ts +1 -1
  1196. package/build/types/utils/spanOnScope.d.ts.map +1 -1
  1197. package/build/types/utils/spanUtils.d.ts +4 -4
  1198. package/build/types/utils/spanUtils.d.ts.map +1 -1
  1199. package/build/types/utils/stacktrace.d.ts +4 -4
  1200. package/build/types/utils/stacktrace.d.ts.map +1 -1
  1201. package/build/types/utils/trace-info.d.ts +2 -2
  1202. package/build/types/utils/trace-info.d.ts.map +1 -1
  1203. package/build/types/utils/traceData.d.ts +2 -2
  1204. package/build/types/utils/traceData.d.ts.map +1 -1
  1205. package/build/types/utils/tracePropagationTargets.d.ts +1 -1
  1206. package/build/types/utils/tracePropagationTargets.d.ts.map +1 -1
  1207. package/build/types/utils/tracing.d.ts +2 -2
  1208. package/build/types/utils/tracing.d.ts.map +1 -1
  1209. package/build/types/utils/transactionEvent.d.ts +2 -2
  1210. package/build/types/utils/transactionEvent.d.ts.map +1 -1
  1211. package/build/types/utils/url.d.ts +1 -1
  1212. package/build/types/utils/url.d.ts.map +1 -1
  1213. package/build/types/utils/worldwide.d.ts +1 -0
  1214. package/build/types/utils/worldwide.d.ts.map +1 -1
  1215. package/build/types-ts3.8/api.d.ts +2 -2
  1216. package/build/types-ts3.8/attributes.d.ts +5 -8
  1217. package/build/types-ts3.8/breadcrumbs.d.ts +1 -1
  1218. package/build/types-ts3.8/browser-exports.d.ts +3 -3
  1219. package/build/types-ts3.8/carrier.d.ts +2 -2
  1220. package/build/types-ts3.8/checkin.d.ts +4 -4
  1221. package/build/types-ts3.8/client.d.ts +32 -22
  1222. package/build/types-ts3.8/currentScopes.d.ts +1 -1
  1223. package/build/types-ts3.8/envelope.d.ts +7 -7
  1224. package/build/types-ts3.8/eventProcessors.d.ts +2 -2
  1225. package/build/types-ts3.8/exports.d.ts +8 -8
  1226. package/build/types-ts3.8/feedback.d.ts +2 -2
  1227. package/build/types-ts3.8/fetch.d.ts +3 -3
  1228. package/build/types-ts3.8/instrument/console.d.ts +1 -1
  1229. package/build/types-ts3.8/instrument/fetch.d.ts +1 -1
  1230. package/build/types-ts3.8/instrument/globalError.d.ts +1 -1
  1231. package/build/types-ts3.8/instrument/globalUnhandledRejection.d.ts +1 -1
  1232. package/build/types-ts3.8/integration.d.ts +2 -2
  1233. package/build/types-ts3.8/integrations/consola.d.ts +1 -1
  1234. package/build/types-ts3.8/integrations/console.d.ts +1 -1
  1235. package/build/types-ts3.8/integrations/dedupe.d.ts +1 -1
  1236. package/build/types-ts3.8/integrations/express/types.d.ts +2 -2
  1237. package/build/types-ts3.8/integrations/express/utils.d.ts +1 -1
  1238. package/build/types-ts3.8/integrations/featureFlags/featureFlagsIntegration.d.ts +1 -1
  1239. package/build/types-ts3.8/integrations/featureFlags/growthbook.d.ts +1 -1
  1240. package/build/types-ts3.8/integrations/http/double-wrap-warning.d.ts +1 -1
  1241. package/build/types-ts3.8/integrations/http/get-outgoing-span-data.d.ts +2 -2
  1242. package/build/types-ts3.8/integrations/http/patch-request-to-capture-body.d.ts +12 -0
  1243. package/build/types-ts3.8/integrations/http/record-request-session.d.ts +18 -0
  1244. package/build/types-ts3.8/integrations/http/server-subscription.d.ts +26 -0
  1245. package/build/types-ts3.8/integrations/http/types.d.ts +12 -6
  1246. package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +1 -1
  1247. package/build/types-ts3.8/integrations/mcp-server/piiFiltering.d.ts +1 -1
  1248. package/build/types-ts3.8/integrations/mcp-server/types.d.ts +1 -1
  1249. package/build/types-ts3.8/integrations/postgresjs.d.ts +1 -1
  1250. package/build/types-ts3.8/integrations/rewriteframes.d.ts +1 -1
  1251. package/build/types-ts3.8/integrations/supabase.d.ts +14 -3
  1252. package/build/types-ts3.8/integrations/zoderrors.d.ts +1 -1
  1253. package/build/types-ts3.8/logs/console-integration.d.ts +1 -1
  1254. package/build/types-ts3.8/logs/constants.d.ts +1 -1
  1255. package/build/types-ts3.8/logs/envelope.d.ts +4 -4
  1256. package/build/types-ts3.8/logs/internal.d.ts +16 -1
  1257. package/build/types-ts3.8/logs/public-api.d.ts +2 -2
  1258. package/build/types-ts3.8/metadata.d.ts +2 -2
  1259. package/build/types-ts3.8/metrics/envelope.d.ts +4 -4
  1260. package/build/types-ts3.8/metrics/internal.d.ts +1 -1
  1261. package/build/types-ts3.8/metrics/public-api.d.ts +1 -1
  1262. package/build/types-ts3.8/profiling.d.ts +1 -1
  1263. package/build/types-ts3.8/report-dialog.d.ts +1 -1
  1264. package/build/types-ts3.8/scope.d.ts +14 -14
  1265. package/build/types-ts3.8/sdk.d.ts +1 -1
  1266. package/build/types-ts3.8/semanticAttributes.d.ts +2 -0
  1267. package/build/types-ts3.8/server-exports.d.ts +3 -1
  1268. package/build/types-ts3.8/server-runtime-client.d.ts +6 -6
  1269. package/build/types-ts3.8/session.d.ts +1 -1
  1270. package/build/types-ts3.8/shared-exports.d.ts +58 -53
  1271. package/build/types-ts3.8/tracing/ai/utils.d.ts +1 -1
  1272. package/build/types-ts3.8/tracing/anthropic-ai/streaming.d.ts +1 -1
  1273. package/build/types-ts3.8/tracing/anthropic-ai/utils.d.ts +2 -2
  1274. package/build/types-ts3.8/tracing/dynamicSamplingContext.d.ts +2 -2
  1275. package/build/types-ts3.8/tracing/google-genai/streaming.d.ts +1 -1
  1276. package/build/types-ts3.8/tracing/idleSpan.d.ts +2 -2
  1277. package/build/types-ts3.8/tracing/langchain/utils.d.ts +6 -1
  1278. package/build/types-ts3.8/tracing/langgraph/utils.d.ts +1 -3
  1279. package/build/types-ts3.8/tracing/logSpans.d.ts +1 -1
  1280. package/build/types-ts3.8/tracing/measurement.d.ts +2 -2
  1281. package/build/types-ts3.8/tracing/openai/streaming.d.ts +1 -1
  1282. package/build/types-ts3.8/tracing/openai/utils.d.ts +1 -1
  1283. package/build/types-ts3.8/tracing/sampling.d.ts +2 -2
  1284. package/build/types-ts3.8/tracing/sentryNonRecordingSpan.d.ts +3 -3
  1285. package/build/types-ts3.8/tracing/sentrySpan.d.ts +4 -4
  1286. package/build/types-ts3.8/tracing/spans/beforeSendSpan.d.ts +3 -3
  1287. package/build/types-ts3.8/tracing/spans/captureSpan.d.ts +1 -1
  1288. package/build/types-ts3.8/tracing/spans/envelope.d.ts +2 -2
  1289. package/build/types-ts3.8/tracing/spans/estimateSize.d.ts +1 -1
  1290. package/build/types-ts3.8/tracing/spans/extractGenAiSpans.d.ts +2 -2
  1291. package/build/types-ts3.8/tracing/spans/scopeContextAttributes.d.ts +9 -0
  1292. package/build/types-ts3.8/tracing/spans/spanJsonToStreamedSpan.d.ts +1 -1
  1293. package/build/types-ts3.8/tracing/spanstatus.d.ts +2 -2
  1294. package/build/types-ts3.8/tracing/trace.d.ts +2 -2
  1295. package/build/types-ts3.8/tracing/utils.d.ts +1 -1
  1296. package/build/types-ts3.8/tracing/vercel-ai/utils.d.ts +2 -2
  1297. package/build/types-ts3.8/transports/base.d.ts +1 -1
  1298. package/build/types-ts3.8/transports/multiplexed.d.ts +3 -3
  1299. package/build/types-ts3.8/transports/offline.d.ts +2 -2
  1300. package/build/types-ts3.8/transports/userAgent.d.ts +1 -1
  1301. package/build/types-ts3.8/types/datacollection.d.ts +75 -0
  1302. package/build/types-ts3.8/{types-hoist → types}/options.d.ts +17 -0
  1303. package/build/types-ts3.8/{types-hoist → types}/samplingcontext.d.ts +1 -1
  1304. package/build/types-ts3.8/{types-hoist → types}/startSpanOptions.d.ts +13 -0
  1305. package/build/types-ts3.8/utils/aggregate-errors.d.ts +3 -3
  1306. package/build/types-ts3.8/utils/anr.d.ts +1 -1
  1307. package/build/types-ts3.8/utils/baggage.d.ts +1 -1
  1308. package/build/types-ts3.8/utils/breadcrumb-log-level.d.ts +1 -1
  1309. package/build/types-ts3.8/utils/clientreport.d.ts +2 -2
  1310. package/build/types-ts3.8/utils/data-collection/defaultPiiToCollectionOptions.d.ts +6 -0
  1311. package/build/types-ts3.8/utils/data-collection/filterCookies.d.ts +9 -0
  1312. package/build/types-ts3.8/utils/data-collection/filterKeyValueData.d.ts +11 -0
  1313. package/build/types-ts3.8/utils/data-collection/filterQueryParams.d.ts +9 -0
  1314. package/build/types-ts3.8/utils/data-collection/filtering-snippets.d.ts +14 -0
  1315. package/build/types-ts3.8/utils/data-collection/resolveDataCollectionOptions.d.ts +14 -0
  1316. package/build/types-ts3.8/utils/debug-ids.d.ts +2 -2
  1317. package/build/types-ts3.8/utils/debug-logger.d.ts +1 -1
  1318. package/build/types-ts3.8/utils/dsn.d.ts +1 -1
  1319. package/build/types-ts3.8/utils/envelope.d.ts +8 -8
  1320. package/build/types-ts3.8/utils/error.d.ts +1 -1
  1321. package/build/types-ts3.8/utils/eventUtils.d.ts +1 -1
  1322. package/build/types-ts3.8/utils/eventbuilder.d.ts +6 -6
  1323. package/build/types-ts3.8/utils/featureFlags.d.ts +1 -1
  1324. package/build/types-ts3.8/utils/hasSpansEnabled.d.ts +1 -1
  1325. package/build/types-ts3.8/utils/ipAddress.d.ts +2 -2
  1326. package/build/types-ts3.8/utils/is.d.ts +4 -4
  1327. package/build/types-ts3.8/utils/meta.d.ts +1 -1
  1328. package/build/types-ts3.8/utils/misc.d.ts +3 -3
  1329. package/build/types-ts3.8/utils/node-stack-trace.d.ts +1 -1
  1330. package/build/types-ts3.8/utils/object.d.ts +1 -1
  1331. package/build/types-ts3.8/utils/parameterize.d.ts +1 -1
  1332. package/build/types-ts3.8/utils/prepareEvent.d.ts +3 -3
  1333. package/build/types-ts3.8/utils/ratelimit.d.ts +2 -2
  1334. package/build/types-ts3.8/utils/request.d.ts +3 -3
  1335. package/build/types-ts3.8/utils/scopeData.d.ts +1 -1
  1336. package/build/types-ts3.8/utils/sdkMetadata.d.ts +1 -1
  1337. package/build/types-ts3.8/utils/severity.d.ts +1 -1
  1338. package/build/types-ts3.8/utils/should-ignore-span.d.ts +2 -2
  1339. package/build/types-ts3.8/utils/spanOnScope.d.ts +1 -1
  1340. package/build/types-ts3.8/utils/spanUtils.d.ts +4 -4
  1341. package/build/types-ts3.8/utils/stacktrace.d.ts +4 -4
  1342. package/build/types-ts3.8/utils/trace-info.d.ts +2 -2
  1343. package/build/types-ts3.8/utils/traceData.d.ts +2 -2
  1344. package/build/types-ts3.8/utils/tracePropagationTargets.d.ts +1 -1
  1345. package/build/types-ts3.8/utils/tracing.d.ts +2 -2
  1346. package/build/types-ts3.8/utils/transactionEvent.d.ts +2 -2
  1347. package/build/types-ts3.8/utils/url.d.ts +1 -1
  1348. package/build/types-ts3.8/utils/worldwide.d.ts +1 -0
  1349. package/package.json +1 -1
  1350. package/build/types/types-hoist/attachment.d.ts.map +0 -1
  1351. package/build/types/types-hoist/breadcrumb.d.ts.map +0 -1
  1352. package/build/types/types-hoist/browseroptions.d.ts.map +0 -1
  1353. package/build/types/types-hoist/checkin.d.ts.map +0 -1
  1354. package/build/types/types-hoist/clientreport.d.ts.map +0 -1
  1355. package/build/types/types-hoist/context.d.ts.map +0 -1
  1356. package/build/types/types-hoist/csp.d.ts.map +0 -1
  1357. package/build/types/types-hoist/datacategory.d.ts.map +0 -1
  1358. package/build/types/types-hoist/debugMeta.d.ts.map +0 -1
  1359. package/build/types/types-hoist/dsn.d.ts.map +0 -1
  1360. package/build/types/types-hoist/envelope.d.ts.map +0 -1
  1361. package/build/types/types-hoist/error.d.ts.map +0 -1
  1362. package/build/types/types-hoist/event.d.ts.map +0 -1
  1363. package/build/types/types-hoist/eventprocessor.d.ts.map +0 -1
  1364. package/build/types/types-hoist/exception.d.ts.map +0 -1
  1365. package/build/types/types-hoist/extra.d.ts.map +0 -1
  1366. package/build/types/types-hoist/feedback/config.d.ts.map +0 -1
  1367. package/build/types/types-hoist/feedback/form.d.ts.map +0 -1
  1368. package/build/types/types-hoist/feedback/index.d.ts.map +0 -1
  1369. package/build/types/types-hoist/feedback/sendFeedback.d.ts.map +0 -1
  1370. package/build/types/types-hoist/feedback/theme.d.ts.map +0 -1
  1371. package/build/types/types-hoist/instrument.d.ts.map +0 -1
  1372. package/build/types/types-hoist/integration.d.ts.map +0 -1
  1373. package/build/types/types-hoist/link.d.ts.map +0 -1
  1374. package/build/types/types-hoist/log.d.ts.map +0 -1
  1375. package/build/types/types-hoist/measurement.d.ts.map +0 -1
  1376. package/build/types/types-hoist/mechanism.d.ts.map +0 -1
  1377. package/build/types/types-hoist/metric.d.ts.map +0 -1
  1378. package/build/types/types-hoist/misc.d.ts.map +0 -1
  1379. package/build/types/types-hoist/opentelemetry.d.ts.map +0 -1
  1380. package/build/types/types-hoist/options.d.ts.map +0 -1
  1381. package/build/types/types-hoist/package.d.ts.map +0 -1
  1382. package/build/types/types-hoist/parameterize.d.ts.map +0 -1
  1383. package/build/types/types-hoist/polymorphics.d.ts.map +0 -1
  1384. package/build/types/types-hoist/profiling.d.ts.map +0 -1
  1385. package/build/types/types-hoist/replay.d.ts.map +0 -1
  1386. package/build/types/types-hoist/request.d.ts.map +0 -1
  1387. package/build/types/types-hoist/runtime.d.ts.map +0 -1
  1388. package/build/types/types-hoist/samplingcontext.d.ts.map +0 -1
  1389. package/build/types/types-hoist/sdkinfo.d.ts.map +0 -1
  1390. package/build/types/types-hoist/sdkmetadata.d.ts.map +0 -1
  1391. package/build/types/types-hoist/session.d.ts.map +0 -1
  1392. package/build/types/types-hoist/severity.d.ts.map +0 -1
  1393. package/build/types/types-hoist/span.d.ts.map +0 -1
  1394. package/build/types/types-hoist/spanStatus.d.ts.map +0 -1
  1395. package/build/types/types-hoist/stackframe.d.ts.map +0 -1
  1396. package/build/types/types-hoist/stacktrace.d.ts.map +0 -1
  1397. package/build/types/types-hoist/startSpanOptions.d.ts.map +0 -1
  1398. package/build/types/types-hoist/thread.d.ts.map +0 -1
  1399. package/build/types/types-hoist/timedEvent.d.ts.map +0 -1
  1400. package/build/types/types-hoist/tracing.d.ts.map +0 -1
  1401. package/build/types/types-hoist/transaction.d.ts.map +0 -1
  1402. package/build/types/types-hoist/transport.d.ts.map +0 -1
  1403. package/build/types/types-hoist/user.d.ts.map +0 -1
  1404. package/build/types/types-hoist/view-hierarchy.d.ts.map +0 -1
  1405. package/build/types/types-hoist/vue.d.ts.map +0 -1
  1406. package/build/types/types-hoist/webfetchapi.d.ts.map +0 -1
  1407. package/build/types/types-hoist/wrappedfunction.d.ts.map +0 -1
  1408. /package/build/types/{types-hoist → types}/attachment.d.ts +0 -0
  1409. /package/build/types/{types-hoist → types}/breadcrumb.d.ts +0 -0
  1410. /package/build/types/{types-hoist → types}/browseroptions.d.ts +0 -0
  1411. /package/build/types/{types-hoist → types}/checkin.d.ts +0 -0
  1412. /package/build/types/{types-hoist → types}/clientreport.d.ts +0 -0
  1413. /package/build/types/{types-hoist → types}/context.d.ts +0 -0
  1414. /package/build/types/{types-hoist → types}/csp.d.ts +0 -0
  1415. /package/build/types/{types-hoist → types}/datacategory.d.ts +0 -0
  1416. /package/build/types/{types-hoist → types}/debugMeta.d.ts +0 -0
  1417. /package/build/types/{types-hoist → types}/dsn.d.ts +0 -0
  1418. /package/build/types/{types-hoist → types}/envelope.d.ts +0 -0
  1419. /package/build/types/{types-hoist → types}/error.d.ts +0 -0
  1420. /package/build/types/{types-hoist → types}/event.d.ts +0 -0
  1421. /package/build/types/{types-hoist → types}/eventprocessor.d.ts +0 -0
  1422. /package/build/types/{types-hoist → types}/exception.d.ts +0 -0
  1423. /package/build/types/{types-hoist → types}/extra.d.ts +0 -0
  1424. /package/build/types/{types-hoist → types}/feedback/config.d.ts +0 -0
  1425. /package/build/types/{types-hoist → types}/feedback/form.d.ts +0 -0
  1426. /package/build/types/{types-hoist → types}/feedback/index.d.ts +0 -0
  1427. /package/build/types/{types-hoist → types}/feedback/sendFeedback.d.ts +0 -0
  1428. /package/build/types/{types-hoist → types}/feedback/theme.d.ts +0 -0
  1429. /package/build/types/{types-hoist → types}/instrument.d.ts +0 -0
  1430. /package/build/types/{types-hoist → types}/integration.d.ts +0 -0
  1431. /package/build/types/{types-hoist → types}/link.d.ts +0 -0
  1432. /package/build/types/{types-hoist → types}/log.d.ts +0 -0
  1433. /package/build/types/{types-hoist → types}/measurement.d.ts +0 -0
  1434. /package/build/types/{types-hoist → types}/mechanism.d.ts +0 -0
  1435. /package/build/types/{types-hoist → types}/metric.d.ts +0 -0
  1436. /package/build/types/{types-hoist → types}/misc.d.ts +0 -0
  1437. /package/build/types/{types-hoist → types}/opentelemetry.d.ts +0 -0
  1438. /package/build/types/{types-hoist → types}/package.d.ts +0 -0
  1439. /package/build/types/{types-hoist → types}/parameterize.d.ts +0 -0
  1440. /package/build/types/{types-hoist → types}/polymorphics.d.ts +0 -0
  1441. /package/build/types/{types-hoist → types}/profiling.d.ts +0 -0
  1442. /package/build/types/{types-hoist → types}/replay.d.ts +0 -0
  1443. /package/build/types/{types-hoist → types}/request.d.ts +0 -0
  1444. /package/build/types/{types-hoist → types}/runtime.d.ts +0 -0
  1445. /package/build/types/{types-hoist → types}/sdkinfo.d.ts +0 -0
  1446. /package/build/types/{types-hoist → types}/sdkmetadata.d.ts +0 -0
  1447. /package/build/types/{types-hoist → types}/session.d.ts +0 -0
  1448. /package/build/types/{types-hoist → types}/severity.d.ts +0 -0
  1449. /package/build/types/{types-hoist → types}/span.d.ts +0 -0
  1450. /package/build/types/{types-hoist → types}/spanStatus.d.ts +0 -0
  1451. /package/build/types/{types-hoist → types}/stackframe.d.ts +0 -0
  1452. /package/build/types/{types-hoist → types}/stacktrace.d.ts +0 -0
  1453. /package/build/types/{types-hoist → types}/thread.d.ts +0 -0
  1454. /package/build/types/{types-hoist → types}/timedEvent.d.ts +0 -0
  1455. /package/build/types/{types-hoist → types}/tracing.d.ts +0 -0
  1456. /package/build/types/{types-hoist → types}/transaction.d.ts +0 -0
  1457. /package/build/types/{types-hoist → types}/transport.d.ts +0 -0
  1458. /package/build/types/{types-hoist → types}/user.d.ts +0 -0
  1459. /package/build/types/{types-hoist → types}/view-hierarchy.d.ts +0 -0
  1460. /package/build/types/{types-hoist → types}/vue.d.ts +0 -0
  1461. /package/build/types/{types-hoist → types}/webfetchapi.d.ts +0 -0
  1462. /package/build/types/{types-hoist → types}/wrappedfunction.d.ts +0 -0
  1463. /package/build/types-ts3.8/{types-hoist → types}/attachment.d.ts +0 -0
  1464. /package/build/types-ts3.8/{types-hoist → types}/breadcrumb.d.ts +0 -0
  1465. /package/build/types-ts3.8/{types-hoist → types}/browseroptions.d.ts +0 -0
  1466. /package/build/types-ts3.8/{types-hoist → types}/checkin.d.ts +0 -0
  1467. /package/build/types-ts3.8/{types-hoist → types}/clientreport.d.ts +0 -0
  1468. /package/build/types-ts3.8/{types-hoist → types}/context.d.ts +0 -0
  1469. /package/build/types-ts3.8/{types-hoist → types}/csp.d.ts +0 -0
  1470. /package/build/types-ts3.8/{types-hoist → types}/datacategory.d.ts +0 -0
  1471. /package/build/types-ts3.8/{types-hoist → types}/debugMeta.d.ts +0 -0
  1472. /package/build/types-ts3.8/{types-hoist → types}/dsn.d.ts +0 -0
  1473. /package/build/types-ts3.8/{types-hoist → types}/envelope.d.ts +0 -0
  1474. /package/build/types-ts3.8/{types-hoist → types}/error.d.ts +0 -0
  1475. /package/build/types-ts3.8/{types-hoist → types}/event.d.ts +0 -0
  1476. /package/build/types-ts3.8/{types-hoist → types}/eventprocessor.d.ts +0 -0
  1477. /package/build/types-ts3.8/{types-hoist → types}/exception.d.ts +0 -0
  1478. /package/build/types-ts3.8/{types-hoist → types}/extra.d.ts +0 -0
  1479. /package/build/types-ts3.8/{types-hoist → types}/feedback/config.d.ts +0 -0
  1480. /package/build/types-ts3.8/{types-hoist → types}/feedback/form.d.ts +0 -0
  1481. /package/build/types-ts3.8/{types-hoist → types}/feedback/index.d.ts +0 -0
  1482. /package/build/types-ts3.8/{types-hoist → types}/feedback/sendFeedback.d.ts +0 -0
  1483. /package/build/types-ts3.8/{types-hoist → types}/feedback/theme.d.ts +0 -0
  1484. /package/build/types-ts3.8/{types-hoist → types}/instrument.d.ts +0 -0
  1485. /package/build/types-ts3.8/{types-hoist → types}/integration.d.ts +0 -0
  1486. /package/build/types-ts3.8/{types-hoist → types}/link.d.ts +0 -0
  1487. /package/build/types-ts3.8/{types-hoist → types}/log.d.ts +0 -0
  1488. /package/build/types-ts3.8/{types-hoist → types}/measurement.d.ts +0 -0
  1489. /package/build/types-ts3.8/{types-hoist → types}/mechanism.d.ts +0 -0
  1490. /package/build/types-ts3.8/{types-hoist → types}/metric.d.ts +0 -0
  1491. /package/build/types-ts3.8/{types-hoist → types}/misc.d.ts +0 -0
  1492. /package/build/types-ts3.8/{types-hoist → types}/opentelemetry.d.ts +0 -0
  1493. /package/build/types-ts3.8/{types-hoist → types}/package.d.ts +0 -0
  1494. /package/build/types-ts3.8/{types-hoist → types}/parameterize.d.ts +0 -0
  1495. /package/build/types-ts3.8/{types-hoist → types}/polymorphics.d.ts +0 -0
  1496. /package/build/types-ts3.8/{types-hoist → types}/profiling.d.ts +0 -0
  1497. /package/build/types-ts3.8/{types-hoist → types}/replay.d.ts +0 -0
  1498. /package/build/types-ts3.8/{types-hoist → types}/request.d.ts +0 -0
  1499. /package/build/types-ts3.8/{types-hoist → types}/runtime.d.ts +0 -0
  1500. /package/build/types-ts3.8/{types-hoist → types}/sdkinfo.d.ts +0 -0
  1501. /package/build/types-ts3.8/{types-hoist → types}/sdkmetadata.d.ts +0 -0
  1502. /package/build/types-ts3.8/{types-hoist → types}/session.d.ts +0 -0
  1503. /package/build/types-ts3.8/{types-hoist → types}/severity.d.ts +0 -0
  1504. /package/build/types-ts3.8/{types-hoist → types}/span.d.ts +0 -0
  1505. /package/build/types-ts3.8/{types-hoist → types}/spanStatus.d.ts +0 -0
  1506. /package/build/types-ts3.8/{types-hoist → types}/stackframe.d.ts +0 -0
  1507. /package/build/types-ts3.8/{types-hoist → types}/stacktrace.d.ts +0 -0
  1508. /package/build/types-ts3.8/{types-hoist → types}/thread.d.ts +0 -0
  1509. /package/build/types-ts3.8/{types-hoist → types}/timedEvent.d.ts +0 -0
  1510. /package/build/types-ts3.8/{types-hoist → types}/tracing.d.ts +0 -0
  1511. /package/build/types-ts3.8/{types-hoist → types}/transaction.d.ts +0 -0
  1512. /package/build/types-ts3.8/{types-hoist → types}/transport.d.ts +0 -0
  1513. /package/build/types-ts3.8/{types-hoist → types}/user.d.ts +0 -0
  1514. /package/build/types-ts3.8/{types-hoist → types}/view-hierarchy.d.ts +0 -0
  1515. /package/build/types-ts3.8/{types-hoist → types}/vue.d.ts +0 -0
  1516. /package/build/types-ts3.8/{types-hoist → types}/webfetchapi.d.ts +0 -0
  1517. /package/build/types-ts3.8/{types-hoist → types}/wrappedfunction.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/tracing/langchain/utils.ts"],"sourcesContent":["import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport type { SpanAttributeValue } from '../../types-hoist/span';\nimport {\n GEN_AI_AGENT_NAME_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_STREAM_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { isContentMedia, stripInlineMediaFromSingleMessage } from '../ai/mediaStripping';\nimport { extractSystemInstructions, getJsonString, getTruncatedJsonString } from '../ai/utils';\nimport { LANGCHAIN_ORIGIN, ROLE_MAP } from './constants';\nimport type { LangChainLLMResult, LangChainMessage, LangChainSerialized } from './types';\n\n/**\n * Assigns an attribute only when the value is neither `undefined` nor `null`.\n *\n * We keep this tiny helper because call sites are repetitive and easy to miswrite.\n * It also preserves falsy-but-valid values like `0` and `\"\"`.\n */\nconst setIfDefined = (target: Record<string, SpanAttributeValue>, key: string, value: unknown): void => {\n if (value != null) target[key] = value as SpanAttributeValue;\n};\n\n/**\n * Like `setIfDefined`, but converts the value with `Number()` and skips only when the\n * result is `NaN`. This ensures numeric 0 makes it through (unlike truthy checks).\n */\nconst setNumberIfDefined = (target: Record<string, SpanAttributeValue>, key: string, value: unknown): void => {\n const n = Number(value);\n if (!Number.isNaN(n)) target[key] = n;\n};\n\n/**\n * Converts a value to a string. Avoids double-quoted JSON strings where a plain\n * string is desired, but still handles objects/arrays safely.\n */\nfunction asString(v: unknown): string {\n if (typeof v === 'string') return v;\n try {\n return JSON.stringify(v);\n } catch {\n return String(v);\n }\n}\n\n/**\n * Converts message content to a string, stripping inline media (base64 images, audio, etc.)\n * from multimodal content before stringification so downstream media stripping can't miss it.\n *\n * @example\n * // String content passes through unchanged:\n * normalizeContent(\"Hello\") // => \"Hello\"\n *\n * // Multimodal array content — media is replaced with \"[Blob substitute]\" before JSON.stringify:\n * normalizeContent([\n * { type: \"text\", text: \"What color?\" },\n * { type: \"image_url\", image_url: { url: \"data:image/png;base64,iVBOR...\" } }\n * ])\n * // => '[{\"type\":\"text\",\"text\":\"What color?\"},{\"type\":\"image_url\",\"image_url\":{\"url\":\"[Blob substitute]\"}}]'\n *\n * // Without this, asString() would JSON.stringify the raw array and the base64 blob\n * // would end up in span attributes, since downstream stripping only works on objects.\n */\nfunction normalizeContent(v: unknown): string {\n if (Array.isArray(v)) {\n try {\n const stripped = v.map(part =>\n part && typeof part === 'object' && isContentMedia(part) ? stripInlineMediaFromSingleMessage(part) : part,\n );\n return JSON.stringify(stripped);\n } catch {\n return String(v);\n }\n }\n return asString(v);\n}\n\n/**\n * Normalizes a single role token to our canonical set.\n *\n * @param role Incoming role value (free-form, any casing)\n * @returns Canonical role: 'user' | 'assistant' | 'system' | 'function' | 'tool' | <passthrough>\n */\nfunction normalizeMessageRole(role: string): string {\n const normalized = role.toLowerCase();\n return ROLE_MAP[normalized] ?? normalized;\n}\n\n/**\n * Infers a role from a LangChain message constructor name.\n *\n * Checks for substrings like \"System\", \"Human\", \"AI\", etc.\n */\nfunction normalizeRoleNameFromCtor(name: string): string {\n if (name.includes('System')) return 'system';\n if (name.includes('Human')) return 'user';\n if (name.includes('AI') || name.includes('Assistant')) return 'assistant';\n if (name.includes('Function')) return 'function';\n if (name.includes('Tool')) return 'tool';\n return 'user';\n}\n\n/**\n * Returns invocation params from a LangChain `tags` object.\n *\n * LangChain often passes runtime parameters (model, temperature, etc.) via the\n * `tags.invocation_params` bag. If `tags` is an array (LangChain sometimes uses\n * string tags), we return `undefined`.\n *\n * @param tags LangChain tags (string[] or record)\n * @returns The `invocation_params` object, if present\n */\nexport function getInvocationParams(tags?: string[] | Record<string, unknown>): Record<string, unknown> | undefined {\n if (!tags || Array.isArray(tags)) return undefined;\n return tags.invocation_params as Record<string, unknown> | undefined;\n}\n\n/**\n * Normalizes a heterogeneous set of LangChain messages to `{ role, content }`.\n *\n * Why so many branches? LangChain messages can arrive in several shapes:\n * - Message classes with `_getType()` (most reliable)\n * - Classes with meaningful constructor names (e.g. `SystemMessage`)\n * - Plain objects with `type`, or `{ role, content }`\n * - Serialized format with `{ lc: 1, id: [...], kwargs: { content } }`\n * We preserve the prioritization to minimize behavioral drift.\n *\n * @param messages Mixed LangChain messages\n * @returns Array of normalized `{ role, content }`\n */\nexport function normalizeLangChainMessages(messages: LangChainMessage[]): Array<{ role: string; content: string }> {\n return messages.map(message => {\n // 1) Prefer _getType() when present\n const maybeGetType = (message as { _getType?: () => string })._getType;\n if (typeof maybeGetType === 'function') {\n const messageType = maybeGetType.call(message);\n return {\n role: normalizeMessageRole(messageType),\n content: normalizeContent(message.content),\n };\n }\n\n // 2) Serialized LangChain format (lc: 1) - check before constructor name\n // This is more reliable than constructor.name which can be lost during serialization\n if (message.lc === 1 && message.kwargs) {\n const id = message.id;\n const messageType = Array.isArray(id) && id.length > 0 ? id[id.length - 1] : '';\n const role = typeof messageType === 'string' ? normalizeRoleNameFromCtor(messageType) : 'user';\n\n return {\n role: normalizeMessageRole(role),\n content: normalizeContent(message.kwargs?.content),\n };\n }\n\n // 3) Then objects with `type`\n if (message.type) {\n const role = String(message.type).toLowerCase();\n return {\n role: normalizeMessageRole(role),\n content: normalizeContent(message.content),\n };\n }\n\n // 4) Then objects with `{ role, content }` - check before constructor name\n // Plain objects have constructor.name=\"Object\" which would incorrectly default to \"user\"\n if (message.role) {\n return {\n role: normalizeMessageRole(String(message.role)),\n content: normalizeContent(message.content),\n };\n }\n\n // 5) Then try constructor name (SystemMessage / HumanMessage / ...)\n // Only use this if we haven't matched a more specific case\n const ctor = (message as { constructor?: { name?: string } }).constructor?.name;\n if (ctor && ctor !== 'Object') {\n return {\n role: normalizeMessageRole(normalizeRoleNameFromCtor(ctor)),\n content: normalizeContent(message.content),\n };\n }\n\n // 6) Fallback: treat as user text\n return {\n role: 'user',\n content: normalizeContent(message.content),\n };\n });\n}\n\n/**\n * Extracts request attributes common to both LLM and ChatModel invocations.\n *\n * Source precedence:\n * 1) `invocationParams` (highest)\n * 2) `langSmithMetadata`\n *\n * Numeric values are set even when 0 (e.g. `temperature: 0`), but skipped if `NaN`.\n */\nfunction extractCommonRequestAttributes(\n serialized: LangChainSerialized,\n invocationParams?: Record<string, unknown>,\n langSmithMetadata?: Record<string, unknown>,\n): Record<string, SpanAttributeValue> {\n const attrs: Record<string, SpanAttributeValue> = {};\n\n // Get kwargs if available (from constructor type)\n const kwargs = 'kwargs' in serialized ? serialized.kwargs : undefined;\n\n const temperature = invocationParams?.temperature ?? langSmithMetadata?.ls_temperature ?? kwargs?.temperature;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE, temperature);\n\n const maxTokens = invocationParams?.max_tokens ?? langSmithMetadata?.ls_max_tokens ?? kwargs?.max_tokens;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE, maxTokens);\n\n const topP = invocationParams?.top_p ?? kwargs?.top_p;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_TOP_P_ATTRIBUTE, topP);\n\n const frequencyPenalty = invocationParams?.frequency_penalty;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE, frequencyPenalty);\n\n const presencePenalty = invocationParams?.presence_penalty;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE, presencePenalty);\n\n // LangChain uses `stream`. We only set the attribute if the key actually exists\n // (some callbacks report `false` even on streamed requests, this stems from LangChain's callback handler).\n if (invocationParams && 'stream' in invocationParams) {\n setIfDefined(attrs, GEN_AI_REQUEST_STREAM_ATTRIBUTE, Boolean(invocationParams.stream));\n }\n\n return attrs;\n}\n\n/**\n * Small helper to assemble boilerplate attributes shared by both request extractors.\n * Always uses 'chat' as the operation type for all LLM and chat model operations.\n */\nfunction baseRequestAttributes(\n system: unknown,\n modelName: unknown,\n serialized: LangChainSerialized,\n invocationParams?: Record<string, unknown>,\n langSmithMetadata?: Record<string, unknown>,\n): Record<string, SpanAttributeValue> {\n return {\n [GEN_AI_SYSTEM_ATTRIBUTE]: asString(system ?? 'langchain'),\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'chat',\n [GEN_AI_REQUEST_MODEL_ATTRIBUTE]: asString(modelName),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGCHAIN_ORIGIN,\n ...extractCommonRequestAttributes(serialized, invocationParams, langSmithMetadata),\n };\n}\n\n/**\n * Extracts attributes for plain LLM invocations (string prompts).\n *\n * - Operation is tagged as `chat` following OpenTelemetry semantic conventions.\n * LangChain LLM operations are treated as chat operations.\n * - When `recordInputs` is true, string prompts are wrapped into `{role:\"user\"}`\n * messages to align with the chat schema used elsewhere.\n */\nexport function extractLLMRequestAttributes(\n llm: LangChainSerialized,\n prompts: string[],\n recordInputs: boolean,\n enableTruncation: boolean,\n invocationParams?: Record<string, unknown>,\n langSmithMetadata?: Record<string, unknown>,\n): Record<string, SpanAttributeValue> {\n const system = langSmithMetadata?.ls_provider;\n const modelName = invocationParams?.model ?? langSmithMetadata?.ls_model_name ?? 'unknown';\n\n const attrs = baseRequestAttributes(system, modelName, llm, invocationParams, langSmithMetadata);\n\n if (recordInputs && Array.isArray(prompts) && prompts.length > 0) {\n setIfDefined(attrs, GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, prompts.length);\n const messages = prompts.map(p => ({ role: 'user', content: p }));\n setIfDefined(\n attrs,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(messages) : getJsonString(messages),\n );\n }\n\n return attrs;\n}\n\n/**\n * Extracts attributes for ChatModel invocations (array-of-arrays of messages).\n *\n * - Operation is tagged as `chat` following OpenTelemetry semantic conventions.\n * LangChain chat model operations are chat operations.\n * - We flatten LangChain's `LangChainMessage[][]` and normalize shapes into a\n * consistent `{ role, content }` array when `recordInputs` is true.\n * - Provider system value falls back to `serialized.id?.[2]`.\n */\nexport function extractChatModelRequestAttributes(\n llm: LangChainSerialized,\n langChainMessages: LangChainMessage[][],\n recordInputs: boolean,\n enableTruncation: boolean,\n invocationParams?: Record<string, unknown>,\n langSmithMetadata?: Record<string, unknown>,\n): Record<string, SpanAttributeValue> {\n const system = langSmithMetadata?.ls_provider ?? llm.id?.[2];\n const modelName = invocationParams?.model ?? langSmithMetadata?.ls_model_name ?? 'unknown';\n\n const attrs = baseRequestAttributes(system, modelName, llm, invocationParams, langSmithMetadata);\n\n if (recordInputs && Array.isArray(langChainMessages) && langChainMessages.length > 0) {\n const normalized = normalizeLangChainMessages(langChainMessages.flat());\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(normalized);\n\n if (systemInstructions) {\n setIfDefined(attrs, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n setIfDefined(attrs, GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, filteredLength);\n\n setIfDefined(\n attrs,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(filteredMessages) : getJsonString(filteredMessages),\n );\n }\n\n return attrs;\n}\n\n/**\n * Extracts tool calls from generations and records them on the span attributes.\n * Prefers message.tool_calls (LangChain's normalized format). Falls back to\n * scanning message.content for Anthropic-style tool_use items in older versions\n * where tool_calls may not be populated.\n */\nfunction addToolCallsAttributes(generations: LangChainMessage[][], attrs: Record<string, SpanAttributeValue>): void {\n const toolCalls: unknown[] = [];\n const flatGenerations = generations.flat();\n\n for (const gen of flatGenerations) {\n const msg = gen.message as Record<string, unknown> | undefined;\n const msgToolCalls = msg?.tool_calls as unknown[] | undefined;\n if (Array.isArray(msgToolCalls) && msgToolCalls.length > 0) {\n toolCalls.push(...msgToolCalls);\n } else {\n // Fallback for older LangChain versions: scan message.content for Anthropic-style tool_use\n const content = gen.message?.content;\n if (Array.isArray(content)) {\n for (const item of content) {\n const t = item as Record<string, unknown>;\n if (t.type === 'tool_use') toolCalls.push(t);\n }\n }\n }\n }\n\n if (toolCalls.length > 0) {\n setIfDefined(attrs, GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, asString(toolCalls));\n }\n}\n\n/**\n * Adds token usage attributes, supporting both OpenAI (`tokenUsage`) and Anthropic (`usage`) formats.\n * - Preserve zero values (0 tokens) by avoiding truthy checks.\n * - Compute a total for Anthropic when not explicitly provided.\n * - Include cache token metrics when present.\n */\nfunction addTokenUsageAttributes(\n llmOutput: LangChainLLMResult['llmOutput'],\n attrs: Record<string, SpanAttributeValue>,\n): void {\n if (!llmOutput) return;\n\n const tokenUsage = llmOutput.tokenUsage as\n | { promptTokens?: number; completionTokens?: number; totalTokens?: number }\n | undefined;\n const anthropicUsage = llmOutput.usage as\n | {\n input_tokens?: number;\n output_tokens?: number;\n cache_creation_input_tokens?: number;\n cache_read_input_tokens?: number;\n }\n | undefined;\n\n if (tokenUsage) {\n setNumberIfDefined(attrs, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, tokenUsage.promptTokens);\n setNumberIfDefined(attrs, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, tokenUsage.completionTokens);\n setNumberIfDefined(attrs, GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE, tokenUsage.totalTokens);\n } else if (anthropicUsage) {\n setNumberIfDefined(attrs, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, anthropicUsage.input_tokens);\n setNumberIfDefined(attrs, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, anthropicUsage.output_tokens);\n\n // Compute total when not provided by the provider.\n const input = Number(anthropicUsage.input_tokens);\n const output = Number(anthropicUsage.output_tokens);\n const total = (Number.isNaN(input) ? 0 : input) + (Number.isNaN(output) ? 0 : output);\n if (total > 0) setNumberIfDefined(attrs, GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE, total);\n\n // Extra Anthropic cache metrics (present only when caching is enabled)\n if (anthropicUsage.cache_creation_input_tokens !== undefined)\n setNumberIfDefined(\n attrs,\n GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS_ATTRIBUTE,\n anthropicUsage.cache_creation_input_tokens,\n );\n if (anthropicUsage.cache_read_input_tokens !== undefined)\n setNumberIfDefined(attrs, GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS_ATTRIBUTE, anthropicUsage.cache_read_input_tokens);\n }\n}\n\n/**\n * Extracts response-related attributes based on a `LangChainLLMResult`.\n *\n * - Records finish reasons when present on generations (e.g., OpenAI)\n * - When `recordOutputs` is true, captures textual response content and any\n * tool calls.\n * - Also propagates model name (`model_name` or `model`), response `id`, and\n * `stop_reason` (for providers that use it).\n */\nexport function extractLlmResponseAttributes(\n llmResult: LangChainLLMResult,\n recordOutputs: boolean,\n): Record<string, SpanAttributeValue> | undefined {\n if (!llmResult) return;\n\n const attrs: Record<string, SpanAttributeValue> = {};\n\n if (Array.isArray(llmResult.generations)) {\n const finishReasons = llmResult.generations\n .flat()\n .map(g => {\n // v1 uses generationInfo.finish_reason\n if (g.generationInfo?.finish_reason) {\n return g.generationInfo.finish_reason;\n }\n // v0.3+ uses generation_info.finish_reason\n if (g.generation_info?.finish_reason) {\n return g.generation_info.finish_reason;\n }\n return null;\n })\n .filter((r): r is string => typeof r === 'string');\n\n if (finishReasons.length > 0) {\n setIfDefined(attrs, GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE, asString(finishReasons));\n }\n\n // Tool calls metadata (names, IDs) are not PII, so capture them regardless of recordOutputs\n addToolCallsAttributes(llmResult.generations as LangChainMessage[][], attrs);\n\n if (recordOutputs) {\n const texts = llmResult.generations\n .flat()\n .map(gen => gen.text ?? gen.message?.content)\n .filter(t => typeof t === 'string');\n\n if (texts.length > 0) {\n setIfDefined(attrs, GEN_AI_RESPONSE_TEXT_ATTRIBUTE, asString(texts));\n }\n }\n }\n\n addTokenUsageAttributes(llmResult.llmOutput, attrs);\n\n const llmOutput = llmResult.llmOutput;\n\n // Extract from v1 generations structure if available\n const firstGeneration = llmResult.generations?.[0]?.[0];\n const v1Message = firstGeneration?.message;\n\n // Provider model identifier: `model_name` (OpenAI-style) or `model` (others)\n // v1 stores this in message.response_metadata.model_name\n const modelName = llmOutput?.model_name ?? llmOutput?.model ?? v1Message?.response_metadata?.model_name;\n if (modelName) setIfDefined(attrs, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, modelName);\n\n // Response ID: v1 stores this in message.id\n const responseId = llmOutput?.id ?? v1Message?.id;\n if (responseId) {\n setIfDefined(attrs, GEN_AI_RESPONSE_ID_ATTRIBUTE, responseId);\n }\n\n // Stop reason: v1 stores this in message.response_metadata.finish_reason\n const stopReason = llmOutput?.stop_reason ?? v1Message?.response_metadata?.finish_reason;\n if (stopReason) {\n setIfDefined(attrs, GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE, asString(stopReason));\n }\n\n return attrs;\n}\n\nexport function getAgentNameFromMetadata(metadata?: Record<string, unknown>): Record<string, SpanAttributeValue> {\n const attrs: Record<string, SpanAttributeValue> = {};\n // lc_agent_name is injected by instrumentCompiledGraphInvoke (langgraph integration)\n const agentName = metadata?.lc_agent_name;\n if (typeof agentName === 'string') {\n attrs[GEN_AI_AGENT_NAME_ATTRIBUTE] = agentName;\n }\n return attrs;\n}\n\nexport function extractToolDefinitions(extraParams?: Record<string, unknown>): string | undefined {\n const tools =\n (extraParams?.invocation_params as Record<string, unknown>)?.tools ??\n (extraParams?.options as Record<string, unknown>)?.tools;\n if (!Array.isArray(tools) || tools.length === 0) return undefined;\n const toolDefs = tools.map((tool: Record<string, unknown>) => {\n const fn = tool.function as Record<string, unknown> | undefined;\n return {\n type: 'function',\n name: tool.name ?? fn?.name ?? '',\n description: tool.description ?? fn?.description,\n };\n });\n return JSON.stringify(toolDefs);\n}\n"],"names":[],"mappings":";;;;;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,YAAA,GAAe,CAAC,MAAM,EAAsC,GAAG,EAAU,KAAK,KAAoB;AACxG,EAAE,IAAI,KAAA,IAAS,IAAI,EAAE,MAAM,CAAC,GAAG,CAAA,GAAI,KAAA;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAM,kBAAA,GAAqB,CAAC,MAAM,EAAsC,GAAG,EAAU,KAAK,KAAoB;AAC9G,EAAE,MAAM,CAAA,GAAI,MAAM,CAAC,KAAK,CAAC;AACzB,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE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pF,EAAE;;AAEF,EAAE,OAAO,KAAK;AACd;;AAEO,SAAS,wBAAwB,CAAC,QAAQ,EAAgE;AACjH,EAAE,MAAM,KAAK,GAAuC,EAAE;AACtD;AACA,EAAE,MAAM,SAAA,GAAY,QAAQ,EAAE,aAAa;AAC3C,EAAE,IAAI,OAAO,SAAA,KAAc,QAAQ,EAAE;AACrC,IAAI,KAAK,CAAC,2BAA2B,CAAA,GAAI,SAAS;AAClD,EAAE;AACF,EAAE,OAAO,KAAK;AACd;;AAEO,SAAS,sBAAsB,CAAC,WAAW,EAAgD;AAClG,EAAE,MAAM,KAAA;AACR,IAAI,CAAC,WAAW,EAAE,iBAAA,IAA+C,KAAA;AACjE,IAAI,CAAC,WAAW,EAAE,OAAA,IAAqC,KAAK;AAC5D,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAA,IAAK,KAAK,CAAC,MAAA,KAAW,CAAC,EAAE,OAAO,SAAS;AACnE,EAAE,MAAM,QAAA,GAAW,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAA8B;AAChE,IAAI,MAAM,EAAA,GAAK,IAAI,CAAC,QAAA;AACpB,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,UAAU;AACtB,MAAM,IAAI,EAAE,IAAI,CAAC,IAAA,IAAQ,EAAE,EAAE,IAAA,IAAQ,EAAE;AACvC,MAAM,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,WAAW;AACtD,KAAK;AACL,EAAE,CAAC,CAAC;AACJ,EAAE,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;AACjC;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/tracing/langchain/utils.ts"],"sourcesContent":["import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport type { SpanAttributeValue } from '../../types/span';\nimport {\n GEN_AI_AGENT_NAME_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_STREAM_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport { isContentMedia, stripInlineMediaFromSingleMessage } from '../ai/mediaStripping';\nimport { extractSystemInstructions, getJsonString, getTruncatedJsonString } from '../ai/utils';\nimport { LANGCHAIN_ORIGIN, ROLE_MAP } from './constants';\nimport type { LangChainLLMResult, LangChainMessage, LangChainSerialized } from './types';\n\n/**\n * Assigns an attribute only when the value is neither `undefined` nor `null`.\n *\n * We keep this tiny helper because call sites are repetitive and easy to miswrite.\n * It also preserves falsy-but-valid values like `0` and `\"\"`.\n */\nconst setIfDefined = (target: Record<string, SpanAttributeValue>, key: string, value: unknown): void => {\n if (value != null) target[key] = value as SpanAttributeValue;\n};\n\n/**\n * Like `setIfDefined`, but converts the value with `Number()` and skips only when the\n * result is `NaN`. This ensures numeric 0 makes it through (unlike truthy checks).\n */\nconst setNumberIfDefined = (target: Record<string, SpanAttributeValue>, key: string, value: unknown): void => {\n const n = Number(value);\n if (!Number.isNaN(n)) target[key] = n;\n};\n\n/**\n * Converts a value to a string. Avoids double-quoted JSON strings where a plain\n * string is desired, but still handles objects/arrays safely.\n */\nfunction asString(v: unknown): string {\n if (typeof v === 'string') return v;\n try {\n return JSON.stringify(v);\n } catch {\n return String(v);\n }\n}\n\n/**\n * Converts message content to a string, stripping inline media (base64 images, audio, etc.)\n * from multimodal content before stringification so downstream media stripping can't miss it.\n *\n * @example\n * // String content passes through unchanged:\n * normalizeContent(\"Hello\") // => \"Hello\"\n *\n * // Multimodal array content — media is replaced with \"[Blob substitute]\" before JSON.stringify:\n * normalizeContent([\n * { type: \"text\", text: \"What color?\" },\n * { type: \"image_url\", image_url: { url: \"data:image/png;base64,iVBOR...\" } }\n * ])\n * // => '[{\"type\":\"text\",\"text\":\"What color?\"},{\"type\":\"image_url\",\"image_url\":{\"url\":\"[Blob substitute]\"}}]'\n *\n * // Without this, asString() would JSON.stringify the raw array and the base64 blob\n * // would end up in span attributes, since downstream stripping only works on objects.\n */\nfunction normalizeContent(v: unknown): string {\n if (Array.isArray(v)) {\n try {\n const stripped = v.map(part =>\n part && typeof part === 'object' && isContentMedia(part) ? stripInlineMediaFromSingleMessage(part) : part,\n );\n return JSON.stringify(stripped);\n } catch {\n return String(v);\n }\n }\n return asString(v);\n}\n\n/**\n * Normalizes a single role token to our canonical set.\n *\n * @param role Incoming role value (free-form, any casing)\n * @returns Canonical role: 'user' | 'assistant' | 'system' | 'function' | 'tool' | <passthrough>\n */\nfunction normalizeMessageRole(role: string): string {\n const normalized = role.toLowerCase();\n return ROLE_MAP[normalized] ?? normalized;\n}\n\n/**\n * Infers a role from a LangChain message constructor name.\n *\n * Checks for substrings like \"System\", \"Human\", \"AI\", etc.\n */\nfunction normalizeRoleNameFromCtor(name: string): string {\n if (name.includes('System')) return 'system';\n if (name.includes('Human')) return 'user';\n if (name.includes('AI') || name.includes('Assistant')) return 'assistant';\n if (name.includes('Function')) return 'function';\n if (name.includes('Tool')) return 'tool';\n return 'user';\n}\n\n/**\n * Returns invocation params from a LangChain `tags` object.\n *\n * LangChain often passes runtime parameters (model, temperature, etc.) via the\n * `tags.invocation_params` bag. If `tags` is an array (LangChain sometimes uses\n * string tags), we return `undefined`.\n *\n * @param tags LangChain tags (string[] or record)\n * @returns The `invocation_params` object, if present\n */\nexport function getInvocationParams(tags?: string[] | Record<string, unknown>): Record<string, unknown> | undefined {\n if (!tags || Array.isArray(tags)) return undefined;\n return tags.invocation_params as Record<string, unknown> | undefined;\n}\n\n/**\n * Normalizes a heterogeneous set of LangChain messages to `{ role, content }`.\n *\n * Why so many branches? LangChain messages can arrive in several shapes:\n * - Message classes with `_getType()` (most reliable)\n * - Classes with meaningful constructor names (e.g. `SystemMessage`)\n * - Plain objects with `type`, or `{ role, content }`\n * - Serialized format with `{ lc: 1, id: [...], kwargs: { content } }`\n * We preserve the prioritization to minimize behavioral drift.\n *\n * @param messages Mixed LangChain messages\n * @returns Array of normalized `{ role, content }`\n */\nexport function normalizeLangChainMessages(messages: LangChainMessage[]): Array<{ role: string; content: string }> {\n return messages.map(message => {\n // 1) Prefer _getType() when present\n const maybeGetType = (message as { _getType?: () => string })._getType;\n if (typeof maybeGetType === 'function') {\n const messageType = maybeGetType.call(message);\n return {\n role: normalizeMessageRole(messageType),\n content: normalizeContent(message.content),\n };\n }\n\n // 2) Serialized LangChain format (lc: 1) - check before constructor name\n // This is more reliable than constructor.name which can be lost during serialization\n if (message.lc === 1 && message.kwargs) {\n const id = message.id;\n const messageType = Array.isArray(id) && id.length > 0 ? id[id.length - 1] : '';\n const role = typeof messageType === 'string' ? normalizeRoleNameFromCtor(messageType) : 'user';\n\n return {\n role: normalizeMessageRole(role),\n content: normalizeContent(message.kwargs?.content),\n };\n }\n\n // 3) Then objects with `type`\n if (message.type) {\n const role = String(message.type).toLowerCase();\n return {\n role: normalizeMessageRole(role),\n content: normalizeContent(message.content),\n };\n }\n\n // 4) Then objects with `{ role, content }` - check before constructor name\n // Plain objects have constructor.name=\"Object\" which would incorrectly default to \"user\"\n if (message.role) {\n return {\n role: normalizeMessageRole(String(message.role)),\n content: normalizeContent(message.content),\n };\n }\n\n // 5) Then try constructor name (SystemMessage / HumanMessage / ...)\n // Only use this if we haven't matched a more specific case\n const ctor = (message as { constructor?: { name?: string } }).constructor?.name;\n if (ctor && ctor !== 'Object') {\n return {\n role: normalizeMessageRole(normalizeRoleNameFromCtor(ctor)),\n content: normalizeContent(message.content),\n };\n }\n\n // 6) Fallback: treat as user text\n return {\n role: 'user',\n content: normalizeContent(message.content),\n };\n });\n}\n\n/**\n * Extracts request attributes common to both LLM and ChatModel invocations.\n *\n * Source precedence:\n * 1) `invocationParams` (highest)\n * 2) `langSmithMetadata`\n *\n * Numeric values are set even when 0 (e.g. `temperature: 0`), but skipped if `NaN`.\n */\nfunction extractCommonRequestAttributes(\n serialized: LangChainSerialized,\n invocationParams?: Record<string, unknown>,\n langSmithMetadata?: Record<string, unknown>,\n): Record<string, SpanAttributeValue> {\n const attrs: Record<string, SpanAttributeValue> = {};\n\n // Get kwargs if available (from constructor type)\n const kwargs = 'kwargs' in serialized ? serialized.kwargs : undefined;\n\n const temperature = invocationParams?.temperature ?? langSmithMetadata?.ls_temperature ?? kwargs?.temperature;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE, temperature);\n\n const maxTokens = invocationParams?.max_tokens ?? langSmithMetadata?.ls_max_tokens ?? kwargs?.max_tokens;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE, maxTokens);\n\n const topP = invocationParams?.top_p ?? kwargs?.top_p;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_TOP_P_ATTRIBUTE, topP);\n\n const frequencyPenalty = invocationParams?.frequency_penalty;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE, frequencyPenalty);\n\n const presencePenalty = invocationParams?.presence_penalty;\n setNumberIfDefined(attrs, GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE, presencePenalty);\n\n // LangChain uses `stream`. We only set the attribute if the key actually exists\n // (some callbacks report `false` even on streamed requests, this stems from LangChain's callback handler).\n if (invocationParams && 'stream' in invocationParams) {\n setIfDefined(attrs, GEN_AI_REQUEST_STREAM_ATTRIBUTE, Boolean(invocationParams.stream));\n }\n\n return attrs;\n}\n\n/**\n * Small helper to assemble boilerplate attributes shared by both request extractors.\n * Always uses 'chat' as the operation type for all LLM and chat model operations.\n */\nfunction baseRequestAttributes(\n system: unknown,\n modelName: unknown,\n serialized: LangChainSerialized,\n invocationParams?: Record<string, unknown>,\n langSmithMetadata?: Record<string, unknown>,\n): Record<string, SpanAttributeValue> {\n return {\n [GEN_AI_SYSTEM_ATTRIBUTE]: asString(system ?? 'langchain'),\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'chat',\n [GEN_AI_REQUEST_MODEL_ATTRIBUTE]: asString(modelName),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGCHAIN_ORIGIN,\n ...extractCommonRequestAttributes(serialized, invocationParams, langSmithMetadata),\n };\n}\n\n/**\n * Extracts attributes for plain LLM invocations (string prompts).\n *\n * - Operation is tagged as `chat` following OpenTelemetry semantic conventions.\n * LangChain LLM operations are treated as chat operations.\n * - When `recordInputs` is true, string prompts are wrapped into `{role:\"user\"}`\n * messages to align with the chat schema used elsewhere.\n */\nexport function extractLLMRequestAttributes(\n llm: LangChainSerialized,\n prompts: string[],\n recordInputs: boolean,\n enableTruncation: boolean,\n invocationParams?: Record<string, unknown>,\n langSmithMetadata?: Record<string, unknown>,\n): Record<string, SpanAttributeValue> {\n const system = langSmithMetadata?.ls_provider;\n const modelName = invocationParams?.model ?? langSmithMetadata?.ls_model_name ?? 'unknown';\n\n const attrs = baseRequestAttributes(system, modelName, llm, invocationParams, langSmithMetadata);\n\n if (recordInputs && Array.isArray(prompts) && prompts.length > 0) {\n setIfDefined(attrs, GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, prompts.length);\n const messages = prompts.map(p => ({ role: 'user', content: p }));\n setIfDefined(\n attrs,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(messages) : getJsonString(messages),\n );\n }\n\n return attrs;\n}\n\n/**\n * Extracts attributes for ChatModel invocations (array-of-arrays of messages).\n *\n * - Operation is tagged as `chat` following OpenTelemetry semantic conventions.\n * LangChain chat model operations are chat operations.\n * - We flatten LangChain's `LangChainMessage[][]` and normalize shapes into a\n * consistent `{ role, content }` array when `recordInputs` is true.\n * - Provider system value falls back to `serialized.id?.[2]`.\n */\nexport function extractChatModelRequestAttributes(\n llm: LangChainSerialized,\n langChainMessages: LangChainMessage[][],\n recordInputs: boolean,\n enableTruncation: boolean,\n invocationParams?: Record<string, unknown>,\n langSmithMetadata?: Record<string, unknown>,\n): Record<string, SpanAttributeValue> {\n const system = langSmithMetadata?.ls_provider ?? llm.id?.[2];\n const modelName = invocationParams?.model ?? langSmithMetadata?.ls_model_name ?? 'unknown';\n\n const attrs = baseRequestAttributes(system, modelName, llm, invocationParams, langSmithMetadata);\n\n if (recordInputs && Array.isArray(langChainMessages) && langChainMessages.length > 0) {\n const normalized = normalizeLangChainMessages(langChainMessages.flat());\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(normalized);\n\n if (systemInstructions) {\n setIfDefined(attrs, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n setIfDefined(attrs, GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, filteredLength);\n\n setIfDefined(\n attrs,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(filteredMessages) : getJsonString(filteredMessages),\n );\n }\n\n return attrs;\n}\n\n/**\n * Extracts tool calls from generations and records them on the span attributes.\n * Prefers message.tool_calls (LangChain's normalized format). Falls back to\n * scanning message.content for Anthropic-style tool_use items in older versions\n * where tool_calls may not be populated.\n */\nfunction addToolCallsAttributes(generations: LangChainMessage[][], attrs: Record<string, SpanAttributeValue>): void {\n const toolCalls: unknown[] = [];\n const flatGenerations = generations.flat();\n\n for (const gen of flatGenerations) {\n const msg = gen.message as Record<string, unknown> | undefined;\n const msgToolCalls = msg?.tool_calls as unknown[] | undefined;\n if (Array.isArray(msgToolCalls) && msgToolCalls.length > 0) {\n toolCalls.push(...msgToolCalls);\n } else {\n // Fallback for older LangChain versions: scan message.content for Anthropic-style tool_use\n const content = gen.message?.content;\n if (Array.isArray(content)) {\n for (const item of content) {\n const t = item as Record<string, unknown>;\n if (t.type === 'tool_use') toolCalls.push(t);\n }\n }\n }\n }\n\n if (toolCalls.length > 0) {\n setIfDefined(attrs, GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, asString(toolCalls));\n }\n}\n\n/**\n * Adds token usage attributes, supporting both OpenAI (`tokenUsage`) and Anthropic (`usage`) formats.\n * - Preserve zero values (0 tokens) by avoiding truthy checks.\n * - Compute a total for Anthropic when not explicitly provided.\n * - Include cache token metrics when present.\n */\nfunction addTokenUsageAttributes(\n llmOutput: LangChainLLMResult['llmOutput'],\n attrs: Record<string, SpanAttributeValue>,\n): void {\n if (!llmOutput) return;\n\n const tokenUsage = llmOutput.tokenUsage as\n | { promptTokens?: number; completionTokens?: number; totalTokens?: number }\n | undefined;\n const anthropicUsage = llmOutput.usage as\n | {\n input_tokens?: number;\n output_tokens?: number;\n cache_creation_input_tokens?: number;\n cache_read_input_tokens?: number;\n }\n | undefined;\n\n if (tokenUsage) {\n setNumberIfDefined(attrs, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, tokenUsage.promptTokens);\n setNumberIfDefined(attrs, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, tokenUsage.completionTokens);\n setNumberIfDefined(attrs, GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE, tokenUsage.totalTokens);\n } else if (anthropicUsage) {\n setNumberIfDefined(attrs, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, anthropicUsage.input_tokens);\n setNumberIfDefined(attrs, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, anthropicUsage.output_tokens);\n\n // Compute total when not provided by the provider.\n const input = Number(anthropicUsage.input_tokens);\n const output = Number(anthropicUsage.output_tokens);\n const total = (Number.isNaN(input) ? 0 : input) + (Number.isNaN(output) ? 0 : output);\n if (total > 0) setNumberIfDefined(attrs, GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE, total);\n\n // Extra Anthropic cache metrics (present only when caching is enabled)\n if (anthropicUsage.cache_creation_input_tokens !== undefined)\n setNumberIfDefined(\n attrs,\n GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS_ATTRIBUTE,\n anthropicUsage.cache_creation_input_tokens,\n );\n if (anthropicUsage.cache_read_input_tokens !== undefined)\n setNumberIfDefined(attrs, GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS_ATTRIBUTE, anthropicUsage.cache_read_input_tokens);\n }\n}\n\n/**\n * Extracts response-related attributes based on a `LangChainLLMResult`.\n *\n * - Records finish reasons when present on generations (e.g., OpenAI)\n * - When `recordOutputs` is true, captures textual response content and any\n * tool calls.\n * - Also propagates model name (`model_name` or `model`), response `id`, and\n * `stop_reason` (for providers that use it).\n */\nexport function extractLlmResponseAttributes(\n llmResult: LangChainLLMResult,\n recordOutputs: boolean,\n): Record<string, SpanAttributeValue> | undefined {\n if (!llmResult) return;\n\n const attrs: Record<string, SpanAttributeValue> = {};\n\n if (Array.isArray(llmResult.generations)) {\n const finishReasons = llmResult.generations\n .flat()\n .map(g => {\n // v1 uses generationInfo.finish_reason\n if (g.generationInfo?.finish_reason) {\n return g.generationInfo.finish_reason;\n }\n // v0.3+ uses generation_info.finish_reason\n if (g.generation_info?.finish_reason) {\n return g.generation_info.finish_reason;\n }\n return null;\n })\n .filter((r): r is string => typeof r === 'string');\n\n if (finishReasons.length > 0) {\n setIfDefined(attrs, GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE, asString(finishReasons));\n }\n\n // Tool calls metadata (names, IDs) are not PII, so capture them regardless of recordOutputs\n addToolCallsAttributes(llmResult.generations as LangChainMessage[][], attrs);\n\n if (recordOutputs) {\n const texts = llmResult.generations\n .flat()\n .map(gen => gen.text ?? gen.message?.content)\n .filter(t => typeof t === 'string');\n\n if (texts.length > 0) {\n setIfDefined(attrs, GEN_AI_RESPONSE_TEXT_ATTRIBUTE, asString(texts));\n }\n }\n }\n\n addTokenUsageAttributes(llmResult.llmOutput, attrs);\n\n const llmOutput = llmResult.llmOutput;\n\n // Extract from v1 generations structure if available\n const firstGeneration = llmResult.generations?.[0]?.[0];\n const v1Message = firstGeneration?.message;\n\n // Provider model identifier: `model_name` (OpenAI-style) or `model` (others)\n // v1 stores this in message.response_metadata.model_name\n const modelName = llmOutput?.model_name ?? llmOutput?.model ?? v1Message?.response_metadata?.model_name;\n if (modelName) setIfDefined(attrs, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, modelName);\n\n // Response ID: v1 stores this in message.id\n const responseId = llmOutput?.id ?? v1Message?.id;\n if (responseId) {\n setIfDefined(attrs, GEN_AI_RESPONSE_ID_ATTRIBUTE, responseId);\n }\n\n // Stop reason: v1 stores this in message.response_metadata.finish_reason\n const stopReason = llmOutput?.stop_reason ?? v1Message?.response_metadata?.finish_reason;\n if (stopReason) {\n setIfDefined(attrs, GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE, asString(stopReason));\n }\n\n return attrs;\n}\n\nexport function getAgentNameFromMetadata(metadata?: Record<string, unknown>): Record<string, SpanAttributeValue> {\n const attrs: Record<string, SpanAttributeValue> = {};\n // lc_agent_name is injected by instrumentCompiledGraphInvoke (langgraph integration)\n const agentName = metadata?.lc_agent_name;\n if (typeof agentName === 'string') {\n attrs[GEN_AI_AGENT_NAME_ATTRIBUTE] = agentName;\n }\n return attrs;\n}\n\nexport function extractToolDefinitions(extraParams?: Record<string, unknown>): string | undefined {\n const tools =\n (extraParams?.invocation_params as Record<string, unknown>)?.tools ??\n (extraParams?.options as Record<string, unknown>)?.tools;\n if (!Array.isArray(tools) || tools.length === 0) return undefined;\n const toolDefs = tools.map((tool: Record<string, unknown>) => {\n const fn = tool.function as Record<string, unknown> | undefined;\n return {\n type: 'function',\n name: tool.name ?? fn?.name ?? '',\n description: tool.description ?? fn?.description,\n };\n });\n return JSON.stringify(toolDefs);\n}\n\n/** Duck-types a LangChain `CallbackManager` (avoids coupling to a specific `@langchain/core` resolution). */\nfunction isCallbackManager(value: unknown): value is {\n addHandler: (handler: unknown, inherit?: boolean) => void;\n copy: () => unknown;\n handlers?: unknown[];\n} {\n if (!value || typeof value !== 'object') {\n return false;\n }\n const candidate = value as { addHandler?: unknown; copy?: unknown };\n return typeof candidate.addHandler === 'function' && typeof candidate.copy === 'function';\n}\n\nfunction isSentryHandler(handler: unknown): boolean {\n return typeof handler === 'object' && (handler as Record<string, unknown>)?.name === 'SentryCallbackHandler';\n}\n\nfunction containsSentryHandler(handlers: unknown[]): boolean {\n return handlers.some(isSentryHandler);\n}\n\n/**\n * Merge `sentryHandler` into a given set of LangChain callbacks or callback manager.\n * @internal Exported for cross-package instrumentation.\n */\nexport function _INTERNAL_mergeLangChainCallbackHandler(existing: unknown, sentryHandler: unknown): unknown {\n if (!existing) {\n return [sentryHandler];\n }\n\n if (isCallbackManager(existing)) {\n if (containsSentryHandler(existing.handlers ?? [])) {\n return existing;\n }\n\n const copied = existing.copy() as { addHandler: (handler: unknown, inherit?: boolean) => void };\n copied.addHandler(sentryHandler, true);\n return copied;\n }\n\n const handlers = Array.isArray(existing) ? existing : [existing];\n if (containsSentryHandler(handlers)) {\n return existing;\n }\n\n return [...handlers, sentryHandler];\n}\n"],"names":[],"mappings":";;;;;;AAuCA,MAAM,YAAA,GAAe,CAAC,MAAA,EAA4C,GAAA,EAAa,KAAA,KAAyB;AACtG,EAAA,IAAI,KAAA,IAAS,IAAA,EAAM,MAAA,CAAO,GAAG,CAAA,GAAI,KAAA;AACnC,CAAA;AAMA,MAAM,kBAAA,GAAqB,CAAC,MAAA,EAA4C,GAAA,EAAa,KAAA,KAAyB;AAC5G,EAAA,MAAM,CAAA,GAAI,OAAO,KAAK,CAAA;AACtB,EAAA,IAAI,CAAC,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA,EAAG,MAAA,CAAO,GAAG,CAAA,GAAI,CAAA;AACtC,CAAA;AAMA,SAAS,SAAS,CAAA,EAAoB;AACpC,EAAA,IAAI,OAAO,CAAA,KAAM,QAAA,EAAU,OAAO,CAAA;AAClC,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,CAAK,UAAU,CAAC,CAAA;AAAA,EACzB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,OAAO,CAAC,CAAA;AAAA,EACjB;AACF;AAoBA,SAAS,iBAAiB,CAAA,EAAoB;AAC5C,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,EAAG;AACpB,IAAA,IAAI;AACF,MAAA,MAAM,WAAW,CAAA,CAAE,GAAA;AAAA,QAAI,CAAA,IAAA,KACrB,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,IAAY,eAAe,IAAI,CAAA,GAAI,iCAAA,CAAkC,IAAI,CAAA,GAAI;AAAA,OACvG;AACA,MAAA,OAAO,IAAA,CAAK,UAAU,QAAQ,CAAA;AAAA,IAChC,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,OAAO,CAAC,CAAA;AAAA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IGIN = "auto.ai.langgraph";
3
3
 
4
4
  export { LANGGRAPH_INTEGRATION_NAME, LANGGRAPH_ORIGIN };
5
5
  //# sourceMappingURL=constants.js.map
@@ -5,237 +5,168 @@ import { startSpan } from '../trace.js';
5
5
  import { GEN_AI_PIPELINE_NAME_ATTRIBUTE, GEN_AI_AGENT_NAME_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_CONVERSATION_ID_ATTRIBUTE, GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ATTRIBUTE, GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE, GEN_AI_OPERATION_NAME_ATTRIBUTE } from '../ai/gen-ai-attributes.js';
6
6
  import { resolveAIRecordingOptions, extractSystemInstructions, shouldEnableTruncation, getTruncatedJsonString, getJsonString } from '../ai/utils.js';
7
7
  import { createLangChainCallbackHandler } from '../langchain/index.js';
8
- import { normalizeLangChainMessages } from '../langchain/utils.js';
8
+ import { _INTERNAL_mergeLangChainCallbackHandler, normalizeLangChainMessages } from '../langchain/utils.js';
9
9
  import { LANGGRAPH_ORIGIN } from './constants.js';
10
- import { extractLLMFromParams, extractAgentNameFromParams, wrapToolsWithSpans, mergeSentryCallback, extractToolsFromCompiledGraph, setResponseAttributes } from './utils.js';
10
+ import { extractLLMFromParams, extractAgentNameFromParams, wrapToolsWithSpans, extractToolsFromCompiledGraph, setResponseAttributes } from './utils.js';
11
11
 
12
12
  let _insideCreateReactAgent = false;
13
-
14
- const SENTRY_PATCHED = '__sentry_patched__';
15
-
16
- /**
17
- * Instruments StateGraph's compile method to create spans for agent creation and invocation
18
- *
19
- * Wraps the compile() method to:
20
- * - Create a `gen_ai.create_agent` span when compile() is called
21
- * - Automatically wrap the invoke() method on the returned compiled graph with a `gen_ai.invoke_agent` span
22
- *
23
- */
24
- function instrumentStateGraphCompile(
25
- originalCompile,
26
- options,
27
- ) {
13
+ const SENTRY_PATCHED = "__sentry_patched__";
14
+ function instrumentStateGraphCompile(originalCompile, options) {
28
15
  if (Object.prototype.hasOwnProperty.call(originalCompile, SENTRY_PATCHED)) {
29
16
  return originalCompile;
30
17
  }
31
-
32
18
  const sentryHandler = createLangChainCallbackHandler(options);
33
-
34
19
  const wrapped = new Proxy(originalCompile, {
35
20
  apply(target, thisArg, args) {
36
- // Skip when called from within createReactAgent to avoid duplicate instrumentation
37
21
  if (_insideCreateReactAgent) {
38
22
  return Reflect.apply(target, thisArg, args);
39
23
  }
40
-
41
24
  return startSpan(
42
25
  {
43
- op: 'gen_ai.create_agent',
44
- name: 'create_agent',
26
+ op: "gen_ai.create_agent",
27
+ name: "create_agent",
45
28
  attributes: {
46
29
  [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,
47
- [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.create_agent',
48
- [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'create_agent',
49
- },
30
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "gen_ai.create_agent",
31
+ [GEN_AI_OPERATION_NAME_ATTRIBUTE]: "create_agent"
32
+ }
50
33
  },
51
- span => {
34
+ (span) => {
52
35
  try {
53
36
  const compiledGraph = Reflect.apply(target, thisArg, args);
54
- const compileOptions = args.length > 0 ? (args[0] ) : {};
55
-
56
- // Extract graph name
57
- if (compileOptions?.name && typeof compileOptions.name === 'string') {
37
+ const compileOptions = args.length > 0 ? args[0] : {};
38
+ if (compileOptions?.name && typeof compileOptions.name === "string") {
58
39
  span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, compileOptions.name);
59
40
  span.updateName(`create_agent ${compileOptions.name}`);
60
41
  }
61
-
62
- // Instrument agent invoke method on the compiled graph
63
42
  const originalInvoke = compiledGraph.invoke;
64
- if (originalInvoke && typeof originalInvoke === 'function') {
43
+ if (originalInvoke && typeof originalInvoke === "function") {
65
44
  compiledGraph.invoke = instrumentCompiledGraphInvoke(
66
- originalInvoke.bind(compiledGraph) ,
45
+ originalInvoke.bind(compiledGraph),
67
46
  compiledGraph,
68
47
  compileOptions,
69
48
  options,
70
- undefined,
71
- sentryHandler,
72
- ) ;
49
+ void 0,
50
+ sentryHandler
51
+ );
73
52
  }
74
-
75
53
  return compiledGraph;
76
54
  } catch (error) {
77
- span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
55
+ span.setStatus({ code: SPAN_STATUS_ERROR, message: "internal_error" });
78
56
  captureException(error, {
79
57
  mechanism: {
80
58
  handled: false,
81
- type: 'auto.ai.langgraph.error',
82
- },
59
+ type: "auto.ai.langgraph.error"
60
+ }
83
61
  });
84
62
  throw error;
85
63
  }
86
- },
64
+ }
87
65
  );
88
- },
89
- }) ;
90
-
66
+ }
67
+ });
91
68
  Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });
92
69
  return wrapped;
93
70
  }
94
-
95
- /**
96
- * Instruments CompiledGraph's invoke method to create spans for agent invocation
97
- *
98
- * Creates a `gen_ai.invoke_agent` span when invoke() is called
99
- */
100
- function instrumentCompiledGraphInvoke(
101
- originalInvoke,
102
- graphInstance,
103
- compileOptions,
104
- options,
105
- llm,
106
- sentryCallbackHandler,
107
- ) {
71
+ function instrumentCompiledGraphInvoke(originalInvoke, graphInstance, compileOptions, options, llm, sentryCallbackHandler) {
108
72
  return new Proxy(originalInvoke, {
109
73
  apply(target, thisArg, args) {
110
74
  const modelName = llm?.modelName ?? llm?.model;
111
75
  return startSpan(
112
76
  {
113
- op: 'gen_ai.invoke_agent',
114
- name: 'invoke_agent',
77
+ op: "gen_ai.invoke_agent",
78
+ name: "invoke_agent",
115
79
  attributes: {
116
80
  [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,
117
81
  [SEMANTIC_ATTRIBUTE_SENTRY_OP]: GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE,
118
- [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'invoke_agent',
119
- },
82
+ [GEN_AI_OPERATION_NAME_ATTRIBUTE]: "invoke_agent"
83
+ }
120
84
  },
121
- async span => {
85
+ async (span) => {
122
86
  try {
123
87
  const graphName = compileOptions?.name;
124
-
125
- if (graphName && typeof graphName === 'string') {
88
+ if (graphName && typeof graphName === "string") {
126
89
  span.setAttribute(GEN_AI_PIPELINE_NAME_ATTRIBUTE, graphName);
127
90
  span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, graphName);
128
91
  span.updateName(`invoke_agent ${graphName}`);
129
92
  }
130
-
131
93
  if (modelName) {
132
94
  span.setAttribute(GEN_AI_REQUEST_MODEL_ATTRIBUTE, modelName);
133
95
  }
134
-
135
- // Extract thread_id from the config (second argument)
136
- // LangGraph uses config.configurable.thread_id for conversation/session linking
137
- const config = args.length > 1 ? (args[1] ) : undefined;
138
- const configurable = config?.configurable ;
96
+ const config = args.length > 1 ? args[1] : void 0;
97
+ const configurable = config?.configurable;
139
98
  const threadId = configurable?.thread_id;
140
- if (threadId && typeof threadId === 'string') {
99
+ if (threadId && typeof threadId === "string") {
141
100
  span.setAttribute(GEN_AI_CONVERSATION_ID_ATTRIBUTE, threadId);
142
101
  }
143
-
144
- // Inject callback handler and agent name into invoke config
145
102
  if (sentryCallbackHandler) {
146
- const invokeConfig = (args[1] ?? {}) ;
103
+ const invokeConfig = args[1] ?? {};
147
104
  args[1] = invokeConfig;
148
-
149
- const existingMetadata = (invokeConfig.metadata ?? {}) ;
105
+ const existingMetadata = invokeConfig.metadata ?? {};
150
106
  invokeConfig.metadata = {
151
107
  ...existingMetadata,
152
108
  __sentry_langgraph__: true,
153
- ...(typeof graphName === 'string' ? { lc_agent_name: graphName } : {}),
109
+ ...typeof graphName === "string" ? { lc_agent_name: graphName } : {}
154
110
  };
155
-
156
- invokeConfig.callbacks = mergeSentryCallback(invokeConfig.callbacks, sentryCallbackHandler);
111
+ invokeConfig.callbacks = _INTERNAL_mergeLangChainCallbackHandler(
112
+ invokeConfig.callbacks,
113
+ sentryCallbackHandler
114
+ );
157
115
  }
158
-
159
- // Extract available tools from the graph instance
160
116
  const tools = extractToolsFromCompiledGraph(graphInstance);
161
117
  if (tools) {
162
118
  span.setAttribute(GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, JSON.stringify(tools));
163
119
  }
164
-
165
- // Parse input messages
166
120
  const recordInputs = options.recordInputs;
167
121
  const recordOutputs = options.recordOutputs;
168
- const inputMessages =
169
- args.length > 0 ? ((args[0] )?.messages ?? []) : [];
170
-
122
+ const inputMessages = args.length > 0 ? args[0]?.messages ?? [] : [];
171
123
  if (inputMessages && recordInputs) {
172
124
  const normalizedMessages = normalizeLangChainMessages(inputMessages);
173
125
  const { systemInstructions, filteredMessages } = extractSystemInstructions(normalizedMessages);
174
-
175
126
  if (systemInstructions) {
176
127
  span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);
177
128
  }
178
-
179
129
  const enableTruncation = shouldEnableTruncation(options.enableTruncation);
180
130
  const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;
181
131
  span.setAttributes({
182
- [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation
183
- ? getTruncatedJsonString(filteredMessages)
184
- : getJsonString(filteredMessages),
185
- [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,
132
+ [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation ? getTruncatedJsonString(filteredMessages) : getJsonString(filteredMessages),
133
+ [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength
186
134
  });
187
135
  }
188
-
189
- // Call original invoke
190
136
  const result = await Reflect.apply(target, thisArg, args);
191
-
192
137
  if (recordOutputs) {
193
138
  setResponseAttributes(span, inputMessages ?? null, result);
194
139
  }
195
-
196
140
  return result;
197
141
  } catch (error) {
198
- span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
142
+ span.setStatus({ code: SPAN_STATUS_ERROR, message: "internal_error" });
199
143
  captureException(error, {
200
144
  mechanism: {
201
145
  handled: false,
202
- type: 'auto.ai.langgraph.error',
203
- },
146
+ type: "auto.ai.langgraph.error"
147
+ }
204
148
  });
205
149
  throw error;
206
150
  }
207
- },
151
+ }
208
152
  );
209
- },
210
- }) ;
153
+ }
154
+ });
211
155
  }
212
-
213
- /**
214
- * Instruments createReactAgent to create invoke_agent and execute_tool spans.
215
- */
216
- function instrumentCreateReactAgent(
217
- originalCreateReactAgent,
218
- options,
219
- ) {
156
+ function instrumentCreateReactAgent(originalCreateReactAgent, options) {
220
157
  if (Object.prototype.hasOwnProperty.call(originalCreateReactAgent, SENTRY_PATCHED)) {
221
158
  return originalCreateReactAgent;
222
159
  }
223
-
224
160
  const resolvedOptions = resolveAIRecordingOptions(options);
225
161
  const sentryHandler = createLangChainCallbackHandler(resolvedOptions);
226
-
227
162
  const wrapped = new Proxy(originalCreateReactAgent, {
228
163
  apply(target, thisArg, args) {
229
164
  const llm = extractLLMFromParams(args);
230
165
  const agentName = extractAgentNameFromParams(args);
231
-
232
- // Wrap tools with execute_tool spans (direct access gives us name, type, description)
233
- const params = args[0] ;
166
+ const params = args[0];
234
167
  if (params && Array.isArray(params.tools) && params.tools.length > 0) {
235
- wrapToolsWithSpans(params.tools, resolvedOptions, agentName ?? undefined);
168
+ wrapToolsWithSpans(params.tools, resolvedOptions, agentName ?? void 0);
236
169
  }
237
-
238
- // Suppress StateGraph.compile instrumentation inside createReactAgent
239
170
  _insideCreateReactAgent = true;
240
171
  let compiledGraph;
241
172
  try {
@@ -243,63 +174,29 @@ function instrumentCreateReactAgent(
243
174
  } finally {
244
175
  _insideCreateReactAgent = false;
245
176
  }
246
-
247
- // Wrap invoke() on the returned compiled graph
248
177
  const originalInvoke = compiledGraph.invoke;
249
- if (originalInvoke && typeof originalInvoke === 'function') {
178
+ if (originalInvoke && typeof originalInvoke === "function") {
250
179
  const compileOptions = {};
251
180
  if (agentName) {
252
181
  compileOptions.name = agentName;
253
182
  }
254
-
255
183
  compiledGraph.invoke = instrumentCompiledGraphInvoke(
256
- originalInvoke.bind(compiledGraph) ,
184
+ originalInvoke.bind(compiledGraph),
257
185
  compiledGraph,
258
186
  compileOptions,
259
187
  resolvedOptions,
260
188
  llm,
261
- sentryHandler,
262
- ) ;
189
+ sentryHandler
190
+ );
263
191
  }
264
-
265
192
  return compiledGraph;
266
- },
267
- }) ;
268
-
193
+ }
194
+ });
269
195
  Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });
270
196
  return wrapped;
271
197
  }
272
-
273
- /**
274
- * Directly instruments a StateGraph instance to add tracing spans
275
- *
276
- * This function can be used to manually instrument LangGraph StateGraph instances
277
- * in environments where automatic instrumentation is not available or desired.
278
- *
279
- * @param stateGraph - The StateGraph instance to instrument
280
- * @param options - Optional configuration for recording inputs/outputs
281
- *
282
- * @example
283
- * ```typescript
284
- * import { instrumentLangGraph } from '@sentry/cloudflare';
285
- * import { StateGraph } from '@langchain/langgraph';
286
- *
287
- * const graph = new StateGraph(MessagesAnnotation)
288
- * .addNode('agent', mockLlm)
289
- * .addEdge(START, 'agent')
290
- * .addEdge('agent', END);
291
- *
292
- * instrumentLangGraph(graph, { recordInputs: true, recordOutputs: true });
293
- * const compiled = graph.compile({ name: 'my_agent' });
294
- * ```
295
- */
296
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
297
- function instrumentLangGraph(
298
- stateGraph,
299
- options,
300
- ) {
198
+ function instrumentLangGraph(stateGraph, options) {
301
199
  stateGraph.compile = instrumentStateGraphCompile(stateGraph.compile, resolveAIRecordingOptions(options));
302
-
303
200
  return stateGraph;
304
201
  }
305
202
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/tracing/langgraph/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport {\n GEN_AI_AGENT_NAME_ATTRIBUTE,\n GEN_AI_CONVERSATION_ID_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_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PIPELINE_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport {\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n} from '../ai/utils';\nimport { createLangChainCallbackHandler } from '../langchain';\nimport type { BaseChatModel, LangChainMessage } from '../langchain/types';\nimport { normalizeLangChainMessages } from '../langchain/utils';\nimport { startSpan } from '../trace';\nimport { LANGGRAPH_ORIGIN } from './constants';\nimport type { CompiledGraph, LangGraphOptions } from './types';\nimport {\n extractAgentNameFromParams,\n extractLLMFromParams,\n extractToolsFromCompiledGraph,\n mergeSentryCallback,\n setResponseAttributes,\n wrapToolsWithSpans,\n} from './utils';\n\nlet _insideCreateReactAgent = false;\n\nconst SENTRY_PATCHED = '__sentry_patched__';\n\n/**\n * Instruments StateGraph's compile method to create spans for agent creation and invocation\n *\n * Wraps the compile() method to:\n * - Create a `gen_ai.create_agent` span when compile() is called\n * - Automatically wrap the invoke() method on the returned compiled graph with a `gen_ai.invoke_agent` span\n *\n */\nexport function instrumentStateGraphCompile(\n originalCompile: (...args: unknown[]) => CompiledGraph,\n options: LangGraphOptions,\n): (...args: unknown[]) => CompiledGraph {\n if (Object.prototype.hasOwnProperty.call(originalCompile, SENTRY_PATCHED)) {\n return originalCompile;\n }\n\n const sentryHandler = createLangChainCallbackHandler(options);\n\n const wrapped = new Proxy(originalCompile, {\n apply(target, thisArg, args: unknown[]): CompiledGraph {\n // Skip when called from within createReactAgent to avoid duplicate instrumentation\n if (_insideCreateReactAgent) {\n return Reflect.apply(target, thisArg, args);\n }\n\n return startSpan(\n {\n op: 'gen_ai.create_agent',\n name: 'create_agent',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.create_agent',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'create_agent',\n },\n },\n span => {\n try {\n const compiledGraph = Reflect.apply(target, thisArg, args);\n const compileOptions = args.length > 0 ? (args[0] as Record<string, unknown>) : {};\n\n // Extract graph name\n if (compileOptions?.name && typeof compileOptions.name === 'string') {\n span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, compileOptions.name);\n span.updateName(`create_agent ${compileOptions.name}`);\n }\n\n // Instrument agent invoke method on the compiled graph\n const originalInvoke = compiledGraph.invoke;\n if (originalInvoke && typeof originalInvoke === 'function') {\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph) as (...args: unknown[]) => Promise<unknown>,\n compiledGraph,\n compileOptions,\n options,\n undefined,\n sentryHandler,\n ) as typeof originalInvoke;\n }\n\n return compiledGraph;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n }) as (...args: unknown[]) => CompiledGraph;\n\n Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });\n return wrapped;\n}\n\n/**\n * Instruments CompiledGraph's invoke method to create spans for agent invocation\n *\n * Creates a `gen_ai.invoke_agent` span when invoke() is called\n */\nfunction instrumentCompiledGraphInvoke(\n originalInvoke: (...args: unknown[]) => Promise<unknown>,\n graphInstance: CompiledGraph,\n compileOptions: Record<string, unknown>,\n options: LangGraphOptions,\n llm?: BaseChatModel | null,\n sentryCallbackHandler?: unknown,\n): (...args: unknown[]) => Promise<unknown> {\n return new Proxy(originalInvoke, {\n apply(target, thisArg, args: unknown[]): Promise<unknown> {\n const modelName = llm?.modelName ?? llm?.model;\n return startSpan(\n {\n op: 'gen_ai.invoke_agent',\n name: 'invoke_agent',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'invoke_agent',\n },\n },\n async span => {\n try {\n const graphName = compileOptions?.name;\n\n if (graphName && typeof graphName === 'string') {\n span.setAttribute(GEN_AI_PIPELINE_NAME_ATTRIBUTE, graphName);\n span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, graphName);\n span.updateName(`invoke_agent ${graphName}`);\n }\n\n if (modelName) {\n span.setAttribute(GEN_AI_REQUEST_MODEL_ATTRIBUTE, modelName);\n }\n\n // Extract thread_id from the config (second argument)\n // LangGraph uses config.configurable.thread_id for conversation/session linking\n const config = args.length > 1 ? (args[1] as Record<string, unknown> | undefined) : undefined;\n const configurable = config?.configurable as Record<string, unknown> | undefined;\n const threadId = configurable?.thread_id;\n if (threadId && typeof threadId === 'string') {\n span.setAttribute(GEN_AI_CONVERSATION_ID_ATTRIBUTE, threadId);\n }\n\n // Inject callback handler and agent name into invoke config\n if (sentryCallbackHandler) {\n const invokeConfig = (args[1] ?? {}) as Record<string, unknown>;\n args[1] = invokeConfig;\n\n const existingMetadata = (invokeConfig.metadata ?? {}) as Record<string, unknown>;\n invokeConfig.metadata = {\n ...existingMetadata,\n __sentry_langgraph__: true,\n ...(typeof graphName === 'string' ? { lc_agent_name: graphName } : {}),\n };\n\n invokeConfig.callbacks = mergeSentryCallback(invokeConfig.callbacks, sentryCallbackHandler);\n }\n\n // Extract available tools from the graph instance\n const tools = extractToolsFromCompiledGraph(graphInstance);\n if (tools) {\n span.setAttribute(GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, JSON.stringify(tools));\n }\n\n // Parse input messages\n const recordInputs = options.recordInputs;\n const recordOutputs = options.recordOutputs;\n const inputMessages =\n args.length > 0 ? ((args[0] as { messages?: LangChainMessage[] } | null)?.messages ?? []) : [];\n\n if (inputMessages && recordInputs) {\n const normalizedMessages = normalizeLangChainMessages(inputMessages);\n const { systemInstructions, filteredMessages } = extractSystemInstructions(normalizedMessages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const enableTruncation = shouldEnableTruncation(options.enableTruncation);\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n span.setAttributes({\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation\n ? getTruncatedJsonString(filteredMessages)\n : getJsonString(filteredMessages),\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n }\n\n // Call original invoke\n const result = await Reflect.apply(target, thisArg, args);\n\n if (recordOutputs) {\n setResponseAttributes(span, inputMessages ?? null, result);\n }\n\n return result;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n }) as (...args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Instruments createReactAgent to create invoke_agent and execute_tool spans.\n */\nexport function instrumentCreateReactAgent(\n originalCreateReactAgent: (...args: unknown[]) => CompiledGraph,\n options?: LangGraphOptions,\n): (...args: unknown[]) => CompiledGraph {\n if (Object.prototype.hasOwnProperty.call(originalCreateReactAgent, SENTRY_PATCHED)) {\n return originalCreateReactAgent;\n }\n\n const resolvedOptions = resolveAIRecordingOptions(options);\n const sentryHandler = createLangChainCallbackHandler(resolvedOptions);\n\n const wrapped = new Proxy(originalCreateReactAgent, {\n apply(target, thisArg, args: unknown[]): CompiledGraph {\n const llm = extractLLMFromParams(args);\n const agentName = extractAgentNameFromParams(args);\n\n // Wrap tools with execute_tool spans (direct access gives us name, type, description)\n const params = args[0] as Record<string, unknown> | undefined;\n if (params && Array.isArray(params.tools) && params.tools.length > 0) {\n wrapToolsWithSpans(params.tools, resolvedOptions, agentName ?? undefined);\n }\n\n // Suppress StateGraph.compile instrumentation inside createReactAgent\n _insideCreateReactAgent = true;\n let compiledGraph: CompiledGraph;\n try {\n compiledGraph = Reflect.apply(target, thisArg, args);\n } finally {\n _insideCreateReactAgent = false;\n }\n\n // Wrap invoke() on the returned compiled graph\n const originalInvoke = compiledGraph.invoke;\n if (originalInvoke && typeof originalInvoke === 'function') {\n const compileOptions: Record<string, unknown> = {};\n if (agentName) {\n compileOptions.name = agentName;\n }\n\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph) as (...args: unknown[]) => Promise<unknown>,\n compiledGraph,\n compileOptions,\n resolvedOptions,\n llm,\n sentryHandler,\n ) as typeof originalInvoke;\n }\n\n return compiledGraph;\n },\n }) as (...args: unknown[]) => CompiledGraph;\n\n Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });\n return wrapped;\n}\n\n/**\n * Directly instruments a StateGraph instance to add tracing spans\n *\n * This function can be used to manually instrument LangGraph StateGraph instances\n * in environments where automatic instrumentation is not available or desired.\n *\n * @param stateGraph - The StateGraph instance to instrument\n * @param options - Optional configuration for recording inputs/outputs\n *\n * @example\n * ```typescript\n * import { instrumentLangGraph } from '@sentry/cloudflare';\n * import { StateGraph } from '@langchain/langgraph';\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode('agent', mockLlm)\n * .addEdge(START, 'agent')\n * .addEdge('agent', END);\n *\n * instrumentLangGraph(graph, { recordInputs: true, recordOutputs: true });\n * const compiled = graph.compile({ name: 'my_agent' });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function instrumentLangGraph<T extends { compile: (...args: any[]) => any }>(\n stateGraph: T,\n options?: LangGraphOptions,\n): T {\n stateGraph.compile = instrumentStateGraphCompile(stateGraph.compile, resolveAIRecordingOptions(options));\n\n return stateGraph;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqCA,IAAI,uBAAA,GAA0B,KAAK;;AAEnC,MAAM,cAAA,GAAiB,oBAAoB;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,2BAA2B;AAC3C,EAAE,eAAe;AACjB,EAAE,OAAO;AACT,EAAyC;AACzC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,EAAE;AAC7E,IAAI,OAAO,eAAe;AAC1B,EAAE;;AAEF,EAAE,MAAM,aAAA,GAAgB,8BAA8B,CAAC,OAAO,CAAC;;AAE/D,EAAE,MAAM,OAAA,GAAU,IAAI,KAAK,CAAC,eAAe,EAAE;AAC7C,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAA4B;AAC3D;AACA,MAAM,IAAI,uBAAuB,EAAE;AACnC,QAAQ,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AACnD,MAAM;;AAEN,MAAM,OAAO,SAAS;AACtB,QAAQ;AACR,UAAU,EAAE,EAAE,qBAAqB;AACnC,UAAU,IAAI,EAAE,cAAc;AAC9B,UAAU,UAAU,EAAE;AACtB,YAAY,CAAC,gCAAgC,GAAG,gBAAgB;AAChE,YAAY,CAAC,4BAA4B,GAAG,qBAAqB;AACjE,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,MAAA,IAAA,cAAA,IAAA,OAAA,cAAA,KAAA,UAAA,EAAA;AACA,QAAA,MAAA,cAAA,GAAA,EAAA;AACA,QAAA,IAAA,SAAA,EAAA;AACA,UAAA,cAAA,CAAA,IAAA,GAAA,SAAA;AACA,QAAA;;AAEA,QAAA,aAAA,CAAA,MAAA,GAAA,6BAAA;AACA,UAAA,cAAA,CAAA,IAAA,CAAA,aAAA,CAAA;AACA,UAAA,aAAA;AACA,UAAA,cAAA;AACA,UAAA,eAAA;AACA,UAAA,GAAA;AACA,UAAA,aAAA;AACA,SAAA;AACA,MAAA;;AAEA,MAAA,OAAA,aAAA;AACA,IAAA,CAAA;AACA,GAAA,CAAA;;AAEA,EAAA,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,cAAA,EAAA,EAAA,KAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,CAAA;AACA,EAAA,OAAA,OAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,mBAAA;AACA,EAAA,UAAA;AACA,EAAA,OAAA;AACA,EAAA;AACA,EAAA,UAAA,CAAA,OAAA,GAAA,2BAAA,CAAA,UAAA,CAAA,OAAA,EAAA,yBAAA,CAAA,OAAA,CAAA,CAAA;;AAEA,EAAA,OAAA,UAAA;AACA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/tracing/langgraph/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport {\n GEN_AI_AGENT_NAME_ATTRIBUTE,\n GEN_AI_CONVERSATION_ID_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_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PIPELINE_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport {\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n} from '../ai/utils';\nimport { createLangChainCallbackHandler } from '../langchain';\nimport type { BaseChatModel, LangChainMessage } from '../langchain/types';\nimport { normalizeLangChainMessages } from '../langchain/utils';\nimport { startSpan } from '../trace';\nimport { LANGGRAPH_ORIGIN } from './constants';\nimport type { CompiledGraph, LangGraphOptions } from './types';\nimport {\n extractAgentNameFromParams,\n extractLLMFromParams,\n extractToolsFromCompiledGraph,\n setResponseAttributes,\n wrapToolsWithSpans,\n} from './utils';\nimport { _INTERNAL_mergeLangChainCallbackHandler } from '../langchain/utils';\n\nlet _insideCreateReactAgent = false;\n\nconst SENTRY_PATCHED = '__sentry_patched__';\n\n/**\n * Instruments StateGraph's compile method to create spans for agent creation and invocation\n *\n * Wraps the compile() method to:\n * - Create a `gen_ai.create_agent` span when compile() is called\n * - Automatically wrap the invoke() method on the returned compiled graph with a `gen_ai.invoke_agent` span\n *\n */\nexport function instrumentStateGraphCompile(\n originalCompile: (...args: unknown[]) => CompiledGraph,\n options: LangGraphOptions,\n): (...args: unknown[]) => CompiledGraph {\n if (Object.prototype.hasOwnProperty.call(originalCompile, SENTRY_PATCHED)) {\n return originalCompile;\n }\n\n const sentryHandler = createLangChainCallbackHandler(options);\n\n const wrapped = new Proxy(originalCompile, {\n apply(target, thisArg, args: unknown[]): CompiledGraph {\n // Skip when called from within createReactAgent to avoid duplicate instrumentation\n if (_insideCreateReactAgent) {\n return Reflect.apply(target, thisArg, args);\n }\n\n return startSpan(\n {\n op: 'gen_ai.create_agent',\n name: 'create_agent',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'gen_ai.create_agent',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'create_agent',\n },\n },\n span => {\n try {\n const compiledGraph = Reflect.apply(target, thisArg, args);\n const compileOptions = args.length > 0 ? (args[0] as Record<string, unknown>) : {};\n\n // Extract graph name\n if (compileOptions?.name && typeof compileOptions.name === 'string') {\n span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, compileOptions.name);\n span.updateName(`create_agent ${compileOptions.name}`);\n }\n\n // Instrument agent invoke method on the compiled graph\n const originalInvoke = compiledGraph.invoke;\n if (originalInvoke && typeof originalInvoke === 'function') {\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph) as (...args: unknown[]) => Promise<unknown>,\n compiledGraph,\n compileOptions,\n options,\n undefined,\n sentryHandler,\n ) as typeof originalInvoke;\n }\n\n return compiledGraph;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n }) as (...args: unknown[]) => CompiledGraph;\n\n Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });\n return wrapped;\n}\n\n/**\n * Instruments CompiledGraph's invoke method to create spans for agent invocation\n *\n * Creates a `gen_ai.invoke_agent` span when invoke() is called\n */\nfunction instrumentCompiledGraphInvoke(\n originalInvoke: (...args: unknown[]) => Promise<unknown>,\n graphInstance: CompiledGraph,\n compileOptions: Record<string, unknown>,\n options: LangGraphOptions,\n llm?: BaseChatModel | null,\n sentryCallbackHandler?: unknown,\n): (...args: unknown[]) => Promise<unknown> {\n return new Proxy(originalInvoke, {\n apply(target, thisArg, args: unknown[]): Promise<unknown> {\n const modelName = llm?.modelName ?? llm?.model;\n return startSpan(\n {\n op: 'gen_ai.invoke_agent',\n name: 'invoke_agent',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: LANGGRAPH_ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE,\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: 'invoke_agent',\n },\n },\n async span => {\n try {\n const graphName = compileOptions?.name;\n\n if (graphName && typeof graphName === 'string') {\n span.setAttribute(GEN_AI_PIPELINE_NAME_ATTRIBUTE, graphName);\n span.setAttribute(GEN_AI_AGENT_NAME_ATTRIBUTE, graphName);\n span.updateName(`invoke_agent ${graphName}`);\n }\n\n if (modelName) {\n span.setAttribute(GEN_AI_REQUEST_MODEL_ATTRIBUTE, modelName);\n }\n\n // Extract thread_id from the config (second argument)\n // LangGraph uses config.configurable.thread_id for conversation/session linking\n const config = args.length > 1 ? (args[1] as Record<string, unknown> | undefined) : undefined;\n const configurable = config?.configurable as Record<string, unknown> | undefined;\n const threadId = configurable?.thread_id;\n if (threadId && typeof threadId === 'string') {\n span.setAttribute(GEN_AI_CONVERSATION_ID_ATTRIBUTE, threadId);\n }\n\n // Inject callback handler and agent name into invoke config\n if (sentryCallbackHandler) {\n const invokeConfig = (args[1] ?? {}) as Record<string, unknown>;\n args[1] = invokeConfig;\n\n const existingMetadata = (invokeConfig.metadata ?? {}) as Record<string, unknown>;\n invokeConfig.metadata = {\n ...existingMetadata,\n __sentry_langgraph__: true,\n ...(typeof graphName === 'string' ? { lc_agent_name: graphName } : {}),\n };\n\n invokeConfig.callbacks = _INTERNAL_mergeLangChainCallbackHandler(\n invokeConfig.callbacks,\n sentryCallbackHandler,\n );\n }\n\n // Extract available tools from the graph instance\n const tools = extractToolsFromCompiledGraph(graphInstance);\n if (tools) {\n span.setAttribute(GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, JSON.stringify(tools));\n }\n\n // Parse input messages\n const recordInputs = options.recordInputs;\n const recordOutputs = options.recordOutputs;\n const inputMessages =\n args.length > 0 ? ((args[0] as { messages?: LangChainMessage[] } | null)?.messages ?? []) : [];\n\n if (inputMessages && recordInputs) {\n const normalizedMessages = normalizeLangChainMessages(inputMessages);\n const { systemInstructions, filteredMessages } = extractSystemInstructions(normalizedMessages);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n const enableTruncation = shouldEnableTruncation(options.enableTruncation);\n const filteredLength = Array.isArray(filteredMessages) ? filteredMessages.length : 0;\n span.setAttributes({\n [GEN_AI_INPUT_MESSAGES_ATTRIBUTE]: enableTruncation\n ? getTruncatedJsonString(filteredMessages)\n : getJsonString(filteredMessages),\n [GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: filteredLength,\n });\n }\n\n // Call original invoke\n const result = await Reflect.apply(target, thisArg, args);\n\n if (recordOutputs) {\n setResponseAttributes(span, inputMessages ?? null, result);\n }\n\n return result;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.langgraph.error',\n },\n });\n throw error;\n }\n },\n );\n },\n }) as (...args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Instruments createReactAgent to create invoke_agent and execute_tool spans.\n */\nexport function instrumentCreateReactAgent(\n originalCreateReactAgent: (...args: unknown[]) => CompiledGraph,\n options?: LangGraphOptions,\n): (...args: unknown[]) => CompiledGraph {\n if (Object.prototype.hasOwnProperty.call(originalCreateReactAgent, SENTRY_PATCHED)) {\n return originalCreateReactAgent;\n }\n\n const resolvedOptions = resolveAIRecordingOptions(options);\n const sentryHandler = createLangChainCallbackHandler(resolvedOptions);\n\n const wrapped = new Proxy(originalCreateReactAgent, {\n apply(target, thisArg, args: unknown[]): CompiledGraph {\n const llm = extractLLMFromParams(args);\n const agentName = extractAgentNameFromParams(args);\n\n // Wrap tools with execute_tool spans (direct access gives us name, type, description)\n const params = args[0] as Record<string, unknown> | undefined;\n if (params && Array.isArray(params.tools) && params.tools.length > 0) {\n wrapToolsWithSpans(params.tools, resolvedOptions, agentName ?? undefined);\n }\n\n // Suppress StateGraph.compile instrumentation inside createReactAgent\n _insideCreateReactAgent = true;\n let compiledGraph: CompiledGraph;\n try {\n compiledGraph = Reflect.apply(target, thisArg, args);\n } finally {\n _insideCreateReactAgent = false;\n }\n\n // Wrap invoke() on the returned compiled graph\n const originalInvoke = compiledGraph.invoke;\n if (originalInvoke && typeof originalInvoke === 'function') {\n const compileOptions: Record<string, unknown> = {};\n if (agentName) {\n compileOptions.name = agentName;\n }\n\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph) as (...args: unknown[]) => Promise<unknown>,\n compiledGraph,\n compileOptions,\n resolvedOptions,\n llm,\n sentryHandler,\n ) as typeof originalInvoke;\n }\n\n return compiledGraph;\n },\n }) as (...args: unknown[]) => CompiledGraph;\n\n Object.defineProperty(wrapped, SENTRY_PATCHED, { value: true, enumerable: false });\n return wrapped;\n}\n\n/**\n * Directly instruments a StateGraph instance to add tracing spans\n *\n * This function can be used to manually instrument LangGraph StateGraph instances\n * in environments where automatic instrumentation is not available or desired.\n *\n * @param stateGraph - The StateGraph instance to instrument\n * @param options - Optional configuration for recording inputs/outputs\n *\n * @example\n * ```typescript\n * import { instrumentLangGraph } from '@sentry/cloudflare';\n * import { StateGraph } from '@langchain/langgraph';\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode('agent', mockLlm)\n * .addEdge(START, 'agent')\n * .addEdge('agent', END);\n *\n * instrumentLangGraph(graph, { recordInputs: true, recordOutputs: true });\n * const compiled = graph.compile({ name: 'my_agent' });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function instrumentLangGraph<T extends { compile: (...args: any[]) => any }>(\n stateGraph: T,\n options?: LangGraphOptions,\n): T {\n stateGraph.compile = instrumentStateGraphCompile(stateGraph.compile, resolveAIRecordingOptions(options));\n\n return stateGraph;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqCA,IAAI,uBAAA,GAA0B,KAAA;AAE9B,MAAM,cAAA,GAAiB,oBAAA;AAUhB,SAAS,2BAAA,CACd,iBACA,OAAA,EACuC;AACvC,EAAA,IAAI,OAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,eAAA,EAAiB,cAAc,CAAA,EAAG;AACzE,IAAA,OAAO,eAAA;AAAA,EACT;AAEA,EAAA,MAAM,aAAA,GAAgB,+BAA+B,OAAO,CAAA;AAE5D,EAAA,MAAM,OAAA,GAAU,IAAI,KAAA,CAAM,eAAA,EAAiB;AAAA,IACzC,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAA,EAAgC;AAErD,MAAA,IAAI,uBAAA,EAAyB;AAC3B,QAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,MAC5C;AAEA,MAAA,OAAO,SAAA;AAAA,QACL;AAAA,UACE,EAAA,EAAI,qBAAA;AAAA,UACJ,IAAA,EAAM,cAAA;AAAA,UACN,UAAA,EAAY;AAAA,YACV,CAAC,gCAAgC,GAAG,gBAAA;AAAA,YACpC,CAAC,4BAA4B,GAAG,qBAAA;AAAA,YAChC,CAAC,+BAA+B,GAAG;AAAA;AACrC,SACF;AAAA,QACA,CAAA,IAAA,KAAQ;AACN,UAAA,IAAI;AACF,YAAA,MAAM,aAAA,GAAgB,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,SAAS,IAAI,CAAA;AACzD,YAAA,MAAM,iBAAiB,IAAA,CAAK,MAAA,GAAS,IAAK,IAAA,CAAK,CAAC,IAAgC,EAAC;AAGjF,YAAA,IAAI,cAAA,EAAgB,IAAA,IAAQ,OAAO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