@sentry/core 10.38.0 → 10.39.0-alpha.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 (255) hide show
  1. package/build/cjs/attributes.js.map +1 -1
  2. package/build/cjs/client.js +22 -12
  3. package/build/cjs/client.js.map +1 -1
  4. package/build/cjs/envelope.js +41 -7
  5. package/build/cjs/envelope.js.map +1 -1
  6. package/build/cjs/index.js +52 -0
  7. package/build/cjs/index.js.map +1 -1
  8. package/build/cjs/integration.js +12 -0
  9. package/build/cjs/integration.js.map +1 -1
  10. package/build/cjs/integrations/eventFilters.js +1 -1
  11. package/build/cjs/integrations/eventFilters.js.map +1 -1
  12. package/build/cjs/integrations/mcp-server/correlation.js +54 -10
  13. package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
  14. package/build/cjs/integrations/mcp-server/sessionManagement.js +50 -16
  15. package/build/cjs/integrations/mcp-server/sessionManagement.js.map +1 -1
  16. package/build/cjs/integrations/requestdata.js +72 -6
  17. package/build/cjs/integrations/requestdata.js.map +1 -1
  18. package/build/cjs/integrations/spanStreaming.js +54 -0
  19. package/build/cjs/integrations/spanStreaming.js.map +1 -0
  20. package/build/cjs/metrics/public-api.js +3 -3
  21. package/build/cjs/metrics/public-api.js.map +1 -1
  22. package/build/cjs/scope.js +1 -1
  23. package/build/cjs/scope.js.map +1 -1
  24. package/build/cjs/semanticAttributes.js +84 -0
  25. package/build/cjs/semanticAttributes.js.map +1 -1
  26. package/build/cjs/spans/captureSpan.js +104 -0
  27. package/build/cjs/spans/captureSpan.js.map +1 -0
  28. package/build/cjs/spans/spanBuffer.js +121 -0
  29. package/build/cjs/spans/spanBuffer.js.map +1 -0
  30. package/build/cjs/spans/spanFirstUtils.js +186 -0
  31. package/build/cjs/spans/spanFirstUtils.js.map +1 -0
  32. package/build/cjs/tracing/ai/gen-ai-attributes.js +6 -0
  33. package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
  34. package/build/cjs/tracing/openai/index.js +134 -51
  35. package/build/cjs/tracing/openai/index.js.map +1 -1
  36. package/build/cjs/tracing/sentrySpan.js +32 -0
  37. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  38. package/build/cjs/tracing/trace.js +1 -0
  39. package/build/cjs/tracing/trace.js.map +1 -1
  40. package/build/cjs/tracing/vercel-ai/constants.js +4 -0
  41. package/build/cjs/tracing/vercel-ai/constants.js.map +1 -1
  42. package/build/cjs/tracing/vercel-ai/index.js +14 -0
  43. package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
  44. package/build/cjs/tracing/vercel-ai/utils.js +71 -22
  45. package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
  46. package/build/cjs/transports/base.js +18 -2
  47. package/build/cjs/transports/base.js.map +1 -1
  48. package/build/cjs/transports/offline.js +16 -17
  49. package/build/cjs/transports/offline.js.map +1 -1
  50. package/build/cjs/utils/beforeSendSpan.js +36 -0
  51. package/build/cjs/utils/beforeSendSpan.js.map +1 -0
  52. package/build/cjs/utils/envToBool.js +32 -0
  53. package/build/cjs/utils/envToBool.js.map +1 -0
  54. package/build/cjs/utils/featureFlags.js +1 -0
  55. package/build/cjs/utils/featureFlags.js.map +1 -1
  56. package/build/cjs/utils/flushIfServerless.js.map +1 -1
  57. package/build/cjs/utils/hasSpanStreamingEnabled.js +21 -0
  58. package/build/cjs/utils/hasSpanStreamingEnabled.js.map +1 -0
  59. package/build/cjs/utils/prepareEvent.js +6 -1
  60. package/build/cjs/utils/prepareEvent.js.map +1 -1
  61. package/build/cjs/utils/promisebuffer.js +5 -3
  62. package/build/cjs/utils/promisebuffer.js.map +1 -1
  63. package/build/cjs/utils/scopeData.js +4 -0
  64. package/build/cjs/utils/scopeData.js.map +1 -1
  65. package/build/cjs/utils/sdkMetadata.js +7 -11
  66. package/build/cjs/utils/sdkMetadata.js.map +1 -1
  67. package/build/cjs/utils/should-ignore-span.js +31 -9
  68. package/build/cjs/utils/should-ignore-span.js.map +1 -1
  69. package/build/cjs/utils/spanUtils.js +90 -2
  70. package/build/cjs/utils/spanUtils.js.map +1 -1
  71. package/build/cjs/utils/timer.js +20 -0
  72. package/build/cjs/utils/timer.js.map +1 -0
  73. package/build/cjs/utils/tracePropagationTargets.js +38 -0
  74. package/build/cjs/utils/tracePropagationTargets.js.map +1 -0
  75. package/build/cjs/utils/version.js +1 -1
  76. package/build/cjs/utils/version.js.map +1 -1
  77. package/build/esm/attributes.js.map +1 -1
  78. package/build/esm/client.js +18 -8
  79. package/build/esm/client.js.map +1 -1
  80. package/build/esm/envelope.js +41 -8
  81. package/build/esm/envelope.js.map +1 -1
  82. package/build/esm/index.js +12 -3
  83. package/build/esm/index.js.map +1 -1
  84. package/build/esm/integration.js +12 -1
  85. package/build/esm/integration.js.map +1 -1
  86. package/build/esm/integrations/eventFilters.js +1 -1
  87. package/build/esm/integrations/eventFilters.js.map +1 -1
  88. package/build/esm/integrations/mcp-server/correlation.js +54 -10
  89. package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
  90. package/build/esm/integrations/mcp-server/sessionManagement.js +50 -16
  91. package/build/esm/integrations/mcp-server/sessionManagement.js.map +1 -1
  92. package/build/esm/integrations/requestdata.js +72 -6
  93. package/build/esm/integrations/requestdata.js.map +1 -1
  94. package/build/esm/integrations/spanStreaming.js +52 -0
  95. package/build/esm/integrations/spanStreaming.js.map +1 -0
  96. package/build/esm/metrics/public-api.js +3 -3
  97. package/build/esm/metrics/public-api.js.map +1 -1
  98. package/build/esm/package.json +1 -1
  99. package/build/esm/scope.js +1 -1
  100. package/build/esm/scope.js.map +1 -1
  101. package/build/esm/semanticAttributes.js +57 -1
  102. package/build/esm/semanticAttributes.js.map +1 -1
  103. package/build/esm/spans/captureSpan.js +102 -0
  104. package/build/esm/spans/captureSpan.js.map +1 -0
  105. package/build/esm/spans/spanBuffer.js +119 -0
  106. package/build/esm/spans/spanBuffer.js.map +1 -0
  107. package/build/esm/spans/spanFirstUtils.js +182 -0
  108. package/build/esm/spans/spanFirstUtils.js.map +1 -0
  109. package/build/esm/tracing/ai/gen-ai-attributes.js +6 -1
  110. package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
  111. package/build/esm/tracing/openai/index.js +134 -51
  112. package/build/esm/tracing/openai/index.js.map +1 -1
  113. package/build/esm/tracing/sentrySpan.js +33 -1
  114. package/build/esm/tracing/sentrySpan.js.map +1 -1
  115. package/build/esm/tracing/trace.js +1 -0
  116. package/build/esm/tracing/trace.js.map +1 -1
  117. package/build/esm/tracing/vercel-ai/constants.js +4 -1
  118. package/build/esm/tracing/vercel-ai/constants.js.map +1 -1
  119. package/build/esm/tracing/vercel-ai/index.js +15 -1
  120. package/build/esm/tracing/vercel-ai/index.js.map +1 -1
  121. package/build/esm/tracing/vercel-ai/utils.js +73 -24
  122. package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
  123. package/build/esm/transports/base.js +18 -2
  124. package/build/esm/transports/base.js.map +1 -1
  125. package/build/esm/transports/offline.js +16 -17
  126. package/build/esm/transports/offline.js.map +1 -1
  127. package/build/esm/utils/beforeSendSpan.js +33 -0
  128. package/build/esm/utils/beforeSendSpan.js.map +1 -0
  129. package/build/esm/utils/envToBool.js +28 -0
  130. package/build/esm/utils/envToBool.js.map +1 -0
  131. package/build/esm/utils/featureFlags.js +1 -0
  132. package/build/esm/utils/featureFlags.js.map +1 -1
  133. package/build/esm/utils/flushIfServerless.js.map +1 -1
  134. package/build/esm/utils/hasSpanStreamingEnabled.js +19 -0
  135. package/build/esm/utils/hasSpanStreamingEnabled.js.map +1 -0
  136. package/build/esm/utils/prepareEvent.js +6 -1
  137. package/build/esm/utils/prepareEvent.js.map +1 -1
  138. package/build/esm/utils/promisebuffer.js +5 -3
  139. package/build/esm/utils/promisebuffer.js.map +1 -1
  140. package/build/esm/utils/scopeData.js +4 -0
  141. package/build/esm/utils/scopeData.js.map +1 -1
  142. package/build/esm/utils/sdkMetadata.js +7 -11
  143. package/build/esm/utils/sdkMetadata.js.map +1 -1
  144. package/build/esm/utils/should-ignore-span.js +31 -9
  145. package/build/esm/utils/should-ignore-span.js.map +1 -1
  146. package/build/esm/utils/spanUtils.js +87 -3
  147. package/build/esm/utils/spanUtils.js.map +1 -1
  148. package/build/esm/utils/timer.js +18 -0
  149. package/build/esm/utils/timer.js.map +1 -0
  150. package/build/esm/utils/tracePropagationTargets.js +36 -0
  151. package/build/esm/utils/tracePropagationTargets.js.map +1 -0
  152. package/build/esm/utils/version.js +1 -1
  153. package/build/esm/utils/version.js.map +1 -1
  154. package/build/types/attributes.d.ts +1 -1
  155. package/build/types/attributes.d.ts.map +1 -1
  156. package/build/types/client.d.ts +40 -2
  157. package/build/types/client.d.ts.map +1 -1
  158. package/build/types/envelope.d.ts +6 -1
  159. package/build/types/envelope.d.ts.map +1 -1
  160. package/build/types/index.d.ts +13 -4
  161. package/build/types/index.d.ts.map +1 -1
  162. package/build/types/integration.d.ts +4 -0
  163. package/build/types/integration.d.ts.map +1 -1
  164. package/build/types/integrations/mcp-server/correlation.d.ts +6 -2
  165. package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
  166. package/build/types/integrations/mcp-server/sessionManagement.d.ts +8 -2
  167. package/build/types/integrations/mcp-server/sessionManagement.d.ts.map +1 -1
  168. package/build/types/integrations/requestdata.d.ts.map +1 -1
  169. package/build/types/integrations/spanStreaming.d.ts +11 -0
  170. package/build/types/integrations/spanStreaming.d.ts.map +1 -0
  171. package/build/types/metrics/public-api.d.ts +3 -3
  172. package/build/types/semanticAttributes.d.ts +38 -0
  173. package/build/types/semanticAttributes.d.ts.map +1 -1
  174. package/build/types/spans/captureSpan.d.ts +10 -0
  175. package/build/types/spans/captureSpan.d.ts.map +1 -0
  176. package/build/types/spans/spanBuffer.d.ts +35 -0
  177. package/build/types/spans/spanBuffer.d.ts.map +1 -0
  178. package/build/types/spans/spanFirstUtils.d.ts +20 -0
  179. package/build/types/spans/spanFirstUtils.d.ts.map +1 -0
  180. package/build/types/tracing/ai/gen-ai-attributes.d.ts +4 -0
  181. package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
  182. package/build/types/tracing/openai/index.d.ts.map +1 -1
  183. package/build/types/tracing/sentrySpan.d.ts +10 -1
  184. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  185. package/build/types/tracing/vercel-ai/constants.d.ts +1 -0
  186. package/build/types/tracing/vercel-ai/constants.d.ts.map +1 -1
  187. package/build/types/tracing/vercel-ai/index.d.ts.map +1 -1
  188. package/build/types/tracing/vercel-ai/utils.d.ts +2 -2
  189. package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
  190. package/build/types/transports/base.d.ts.map +1 -1
  191. package/build/types/transports/offline.d.ts.map +1 -1
  192. package/build/types/types-hoist/attributes.d.ts +19 -0
  193. package/build/types/types-hoist/attributes.d.ts.map +1 -0
  194. package/build/types/types-hoist/envelope.d.ts +22 -2
  195. package/build/types/types-hoist/envelope.d.ts.map +1 -1
  196. package/build/types/types-hoist/feedback/index.d.ts.map +1 -1
  197. package/build/types/types-hoist/integration.d.ts +7 -0
  198. package/build/types/types-hoist/integration.d.ts.map +1 -1
  199. package/build/types/types-hoist/link.d.ts +2 -2
  200. package/build/types/types-hoist/link.d.ts.map +1 -1
  201. package/build/types/types-hoist/options.d.ts +18 -2
  202. package/build/types/types-hoist/options.d.ts.map +1 -1
  203. package/build/types/types-hoist/span.d.ts +27 -0
  204. package/build/types/types-hoist/span.d.ts.map +1 -1
  205. package/build/types/utils/beforeSendSpan.d.ts +22 -0
  206. package/build/types/utils/beforeSendSpan.d.ts.map +1 -0
  207. package/build/types/utils/envToBool.d.ts +13 -0
  208. package/build/types/utils/envToBool.d.ts.map +1 -0
  209. package/build/types/utils/featureFlags.d.ts.map +1 -1
  210. package/build/types/utils/flushIfServerless.d.ts.map +1 -1
  211. package/build/types/utils/hasSpanStreamingEnabled.d.ts +9 -0
  212. package/build/types/utils/hasSpanStreamingEnabled.d.ts.map +1 -0
  213. package/build/types/utils/prepareEvent.d.ts.map +1 -1
  214. package/build/types/utils/promisebuffer.d.ts.map +1 -1
  215. package/build/types/utils/scopeData.d.ts.map +1 -1
  216. package/build/types/utils/sdkMetadata.d.ts.map +1 -1
  217. package/build/types/utils/should-ignore-span.d.ts +3 -3
  218. package/build/types/utils/should-ignore-span.d.ts.map +1 -1
  219. package/build/types/utils/spanUtils.d.ts +22 -2
  220. package/build/types/utils/spanUtils.d.ts.map +1 -1
  221. package/build/types/utils/timer.d.ts +11 -0
  222. package/build/types/utils/timer.d.ts.map +1 -0
  223. package/build/types/utils/tracePropagationTargets.d.ts +9 -0
  224. package/build/types/utils/tracePropagationTargets.d.ts.map +1 -0
  225. package/build/types-ts3.8/attributes.d.ts +1 -1
  226. package/build/types-ts3.8/client.d.ts +40 -2
  227. package/build/types-ts3.8/envelope.d.ts +6 -1
  228. package/build/types-ts3.8/index.d.ts +13 -4
  229. package/build/types-ts3.8/integration.d.ts +4 -0
  230. package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +6 -2
  231. package/build/types-ts3.8/integrations/mcp-server/sessionManagement.d.ts +8 -2
  232. package/build/types-ts3.8/integrations/spanStreaming.d.ts +11 -0
  233. package/build/types-ts3.8/metrics/public-api.d.ts +3 -3
  234. package/build/types-ts3.8/semanticAttributes.d.ts +38 -0
  235. package/build/types-ts3.8/spans/captureSpan.d.ts +10 -0
  236. package/build/types-ts3.8/spans/spanBuffer.d.ts +35 -0
  237. package/build/types-ts3.8/spans/spanFirstUtils.d.ts +20 -0
  238. package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +4 -0
  239. package/build/types-ts3.8/tracing/sentrySpan.d.ts +10 -1
  240. package/build/types-ts3.8/tracing/vercel-ai/constants.d.ts +1 -0
  241. package/build/types-ts3.8/tracing/vercel-ai/utils.d.ts +2 -2
  242. package/build/types-ts3.8/types-hoist/attributes.d.ts +19 -0
  243. package/build/types-ts3.8/types-hoist/envelope.d.ts +22 -2
  244. package/build/types-ts3.8/types-hoist/integration.d.ts +7 -0
  245. package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
  246. package/build/types-ts3.8/types-hoist/options.d.ts +18 -2
  247. package/build/types-ts3.8/types-hoist/span.d.ts +27 -0
  248. package/build/types-ts3.8/utils/beforeSendSpan.d.ts +22 -0
  249. package/build/types-ts3.8/utils/envToBool.d.ts +13 -0
  250. package/build/types-ts3.8/utils/hasSpanStreamingEnabled.d.ts +9 -0
  251. package/build/types-ts3.8/utils/should-ignore-span.d.ts +3 -3
  252. package/build/types-ts3.8/utils/spanUtils.d.ts +22 -2
  253. package/build/types-ts3.8/utils/timer.d.ts +11 -0
  254. package/build/types-ts3.8/utils/tracePropagationTargets.d.ts +9 -0
  255. package/package.json +1 -1
@@ -2,11 +2,12 @@ import { Client } from './client';
2
2
  import { SentrySpan } from './tracing/sentrySpan';
3
3
  import { LegacyCSPReport } from './types-hoist/csp';
4
4
  import { DsnComponents } from './types-hoist/dsn';
5
- import { EventEnvelope, RawSecurityEnvelope, SessionEnvelope, SpanEnvelope } from './types-hoist/envelope';
5
+ import { DynamicSamplingContext, EventEnvelope, RawSecurityEnvelope, SessionEnvelope, SpanEnvelope, SpanV2Envelope } from './types-hoist/envelope';
6
6
  import { Event } from './types-hoist/event';
7
7
  import { SdkInfo } from './types-hoist/sdkinfo';
8
8
  import { SdkMetadata } from './types-hoist/sdkmetadata';
9
9
  import { Session, SessionAggregates } from './types-hoist/session';
10
+ import { SpanV2JSON } from './types-hoist/span';
10
11
  /**
11
12
  * Apply SdkInfo (name, version, packages, integrations) to the corresponding event key.
12
13
  * Merge with existing data if any.
@@ -29,6 +30,10 @@ export declare function createSpanEnvelope(spans: [
29
30
  SentrySpan,
30
31
  ...SentrySpan[]
31
32
  ], client?: Client): SpanEnvelope;
33
+ /**
34
+ * Creates a span v2 envelope
35
+ */
36
+ export declare function createSpanV2Envelope(serializedSpans: SpanV2JSON[], dsc: Partial<DynamicSamplingContext>, client: Client): SpanV2Envelope;
32
37
  /**
33
38
  * Create an Envelope from a CSP report.
34
39
  */
@@ -6,7 +6,7 @@ export { ServerRuntimeClientOptions } from './server-runtime-client';
6
6
  export { IntegrationIndex } from './integration';
7
7
  export * from './tracing';
8
8
  export * from './semanticAttributes';
9
- export { createEventEnvelope, createSessionEnvelope, createSpanEnvelope } from './envelope';
9
+ export { createEventEnvelope, createSessionEnvelope, createSpanEnvelope, createSpanV2Envelope } from './envelope';
10
10
  export { captureCheckIn, withMonitor, captureException, captureEvent, captureMessage, lastEventId, close, flush, setContext, setExtra, setExtras, setTag, setTags, setUser, setConversationId, isInitialized, isEnabled, startSession, endSession, captureSession, addEventProcessor, } from './exports';
11
11
  export { getCurrentScope, getIsolationScope, getGlobalScope, withScope, withIsolationScope, getClient, getTraceContextFromScope, } from './currentScopes';
12
12
  export { getDefaultCurrentScope, getDefaultIsolationScope } from './defaultScopes';
@@ -25,21 +25,27 @@ export { makeOfflineTransport } from './transports/offline';
25
25
  export { makeMultiplexedTransport, MULTIPLEXED_TRANSPORT_EXTRA_KEY } from './transports/multiplexed';
26
26
  export { getIntegrationsToSetup, addIntegration, defineIntegration, installedIntegrations } from './integration';
27
27
  export { _INTERNAL_skipAiProviderWrapping, _INTERNAL_shouldSkipAiProviderWrapping, _INTERNAL_clearAiProviderSkips, } from './utils/ai/providerSkip';
28
+ export { envToBool } from './utils/envToBool';
28
29
  export { applyScopeDataToEvent, mergeScopeData, getCombinedScopeData } from './utils/scopeData';
29
30
  export { prepareEvent } from './utils/prepareEvent';
30
31
  export { ExclusiveEventHintOrCaptureContext } from './utils/prepareEvent';
31
32
  export { createCheckInEnvelope } from './checkin';
32
33
  export { hasSpansEnabled } from './utils/hasSpansEnabled';
34
+ export { hasSpanStreamingEnabled } from './utils/hasSpanStreamingEnabled';
33
35
  export { isSentryRequestUrl } from './utils/isSentryRequestUrl';
34
36
  export { handleCallbackErrors } from './utils/handleCallbackErrors';
35
37
  export { parameterize, fmt } from './utils/parameterize';
36
38
  export { addAutoIpAddressToSession } from './utils/ipAddress';
37
39
  export { addAutoIpAddressToUser } from './utils/ipAddress';
38
- export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils';
40
+ export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, INTERNAL_getSegmentSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, spanToV2JSON, showSpanDropWarning, } from './utils/spanUtils';
41
+ export { captureSpan } from './spans/captureSpan';
42
+ export { safeSetSpanJSONAttributes } from './spans/spanFirstUtils';
43
+ export { SpanBuffer, SpanBufferOptions } from './spans/spanBuffer';
39
44
  export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope';
40
45
  export { parseSampleRate } from './utils/parseSampleRate';
41
46
  export { applySdkMetadata } from './utils/sdkMetadata';
42
47
  export { getTraceData } from './utils/traceData';
48
+ export { shouldPropagateTraceForUrl } from './utils/tracePropagationTargets';
43
49
  export { getTraceMetaTags } from './utils/meta';
44
50
  export { debounce } from './utils/debounce';
45
51
  export { winterCGHeadersToDict, winterCGRequestToRequestData, httpRequestToRequestData, extractQueryParamsFromUrl, headersToDict, httpHeadersToSpanAttributes, } from './utils/request';
@@ -62,6 +68,7 @@ export { consoleIntegration } from './integrations/console';
62
68
  export { featureFlagsIntegration, FeatureFlagsIntegration } from './integrations/featureFlags';
63
69
  export { growthbookIntegration } from './integrations/featureFlags';
64
70
  export { conversationIdIntegration } from './integrations/conversationId';
71
+ export { spanStreamingIntegration } from './integrations/spanStreaming';
65
72
  export { profiler } from './profiling';
66
73
  export { instrumentFetchRequest } from './fetch';
67
74
  export { trpcMiddleware } from './trpc';
@@ -147,6 +154,8 @@ export { SDK_VERSION } from './utils/version';
147
154
  export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils/debug-ids';
148
155
  export { getFilenameToMetadataMap } from './metadata';
149
156
  export { escapeStringForRegex } from './vendor/escapeStringForRegex';
157
+ export { isV2BeforeSendSpanCallback, withStreamSpan } from './utils/beforeSendSpan';
158
+ export { shouldIgnoreSpan, reparentChildSpans } from './utils/should-ignore-span';
150
159
  export { Attachment } from './types-hoist/attachment';
151
160
  export { Breadcrumb, BreadcrumbHint, FetchBreadcrumbData, XhrBreadcrumbData, FetchBreadcrumbHint, XhrBreadcrumbHint, } from './types-hoist/breadcrumb';
152
161
  export { ClientReport, Outcome, EventDropReason } from './types-hoist/clientreport';
@@ -154,7 +163,7 @@ export { Context, Contexts, DeviceContext, OsContext, AppContext, CultureContext
154
163
  export { DataCategory } from './types-hoist/datacategory';
155
164
  export { DsnComponents, DsnLike, DsnProtocol } from './types-hoist/dsn';
156
165
  export { DebugImage, DebugMeta } from './types-hoist/debugMeta';
157
- export { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, SpanItem, LogEnvelope, MetricEnvelope, } from './types-hoist/envelope';
166
+ export { AttachmentItem, BaseEnvelopeHeaders, BaseEnvelopeItemHeaders, ClientReportEnvelope, ClientReportItem, DynamicSamplingContext, Envelope, EnvelopeItemType, EnvelopeItem, EventEnvelope, EventEnvelopeHeaders, EventItem, ReplayEnvelope, FeedbackItem, SessionEnvelope, SessionItem, UserFeedbackItem, CheckInItem, CheckInEnvelope, RawSecurityEnvelope, RawSecurityItem, ProfileItem, ProfileChunkEnvelope, ProfileChunkItem, SpanEnvelope, SpanV2Envelope, SpanItem, LogEnvelope, MetricEnvelope, } from './types-hoist/envelope';
158
167
  export { ExtendedError } from './types-hoist/error';
159
168
  export { Event, EventHint, EventType, ErrorEvent, TransactionEvent } from './types-hoist/event';
160
169
  export { EventProcessor } from './types-hoist/eventprocessor';
@@ -175,7 +184,7 @@ export { SdkInfo } from './types-hoist/sdkinfo';
175
184
  export { SdkMetadata } from './types-hoist/sdkmetadata';
176
185
  export { SessionAggregates, AggregationCounts, Session, SessionContext, SessionStatus, SerializedSession, } from './types-hoist/session';
177
186
  export { SeverityLevel } from './types-hoist/severity';
178
- export { Span, SentrySpanArguments, SpanOrigin, SpanAttributeValue, SpanAttributes, SpanTimeInput, SpanJSON, SpanContextData, TraceFlag, } from './types-hoist/span';
187
+ export { Span, SentrySpanArguments, SpanOrigin, SpanAttributeValue, SpanAttributes, SpanTimeInput, SpanJSON, SpanContextData, TraceFlag, SpanV2JSON, SpanV2JSONWithSegmentRef, SerializedSpanContainer, } from './types-hoist/span';
179
188
  export { SpanStatus } from './types-hoist/spanStatus';
180
189
  export { Log, LogSeverityLevel } from './types-hoist/log';
181
190
  export { Metric, MetricType, SerializedMetric, SerializedMetricContainer, SerializedMetricAttributeValue, } from './types-hoist/metric';
@@ -15,6 +15,10 @@ export declare function getIntegrationsToSetup(options: Pick<CoreOptions, 'defau
15
15
  * @param withDefault should enable default integrations
16
16
  */
17
17
  export declare function setupIntegrations(client: Client, integrations: Integration[]): IntegrationIndex;
18
+ /**
19
+ * Runs the `beforeSetup` hooks of the given integrations on the given client.
20
+ */
21
+ export declare function beforeSetupIntegrations(client: Client, integrations: Integration[]): void;
18
22
  /**
19
23
  * Execute the `afterAllSetup` hooks of the given integrations.
20
24
  */
@@ -2,8 +2,12 @@
2
2
  * Request-span correlation system for MCP server instrumentation
3
3
  *
4
4
  * Handles mapping requestId to span data for correlation with handler execution.
5
- * Uses WeakMap to scope correlation maps per transport instance, preventing
6
- * request ID collisions between different MCP sessions.
5
+ *
6
+ * Uses sessionId as the primary key for stateful transports. This handles the wrapper
7
+ * transport pattern (e.g., NodeStreamableHTTPServerTransport wrapping WebStandardStreamableHTTPServerTransport)
8
+ * where onmessage and send may receive different `this` values but share the same sessionId.
9
+ *
10
+ * Falls back to WeakMap by transport instance for stateless transports (no sessionId).
7
11
  */
8
12
  import { Span } from '../../types-hoist/span';
9
13
  import { MCPTransport, RequestId, ResolvedMcpOptions } from './types';
@@ -1,15 +1,21 @@
1
1
  /**
2
2
  * Session data management for MCP server instrumentation
3
+ *
4
+ * Uses sessionId as the primary key for stateful transports. This handles the wrapper
5
+ * transport pattern (e.g., NodeStreamableHTTPServerTransport wrapping WebStandardStreamableHTTPServerTransport)
6
+ * where different methods may receive different `this` values but share the same sessionId.
7
+ *
8
+ * Falls back to WeakMap by transport instance for stateless transports (no sessionId).
3
9
  */
4
10
  import { MCPTransport, PartyInfo, SessionData } from './types';
5
11
  /**
6
- * Stores session data for a transport with sessionId
12
+ * Stores session data for a transport
7
13
  * @param transport - MCP transport instance
8
14
  * @param sessionData - Session data to store
9
15
  */
10
16
  export declare function storeSessionDataForTransport(transport: MCPTransport, sessionData: SessionData): void;
11
17
  /**
12
- * Updates session data for a transport with sessionId (merges with existing data)
18
+ * Updates session data for a transport (merges with existing data)
13
19
  * @param transport - MCP transport instance
14
20
  * @param partialSessionData - Partial session data to merge with existing data
15
21
  */
@@ -0,0 +1,11 @@
1
+ export interface ServerSpanStreamingOptions {
2
+ /** Max spans per envelope batch (default: 1000) */
3
+ maxSpanLimit?: number;
4
+ /** Flush interval in ms (default: 5000) */
5
+ flushInterval?: number;
6
+ }
7
+ /**
8
+ * Span streaming integration used by server runtime SDKs.
9
+ */
10
+ export declare const spanStreamingIntegration: (options?: ServerSpanStreamingOptions | undefined) => import("../types-hoist/integration").Integration;
11
+ //# sourceMappingURL=spanStreaming.d.ts.map
@@ -18,7 +18,7 @@ export interface MetricOptions {
18
18
  scope?: Scope;
19
19
  }
20
20
  /**
21
- * @summary Increment a counter metric. Requires the `_experiments.enableMetrics` option to be enabled.
21
+ * @summary Increment a counter metric.
22
22
  *
23
23
  * @param name - The name of the counter metric.
24
24
  * @param value - The value to increment by (defaults to 1).
@@ -49,7 +49,7 @@ export interface MetricOptions {
49
49
  */
50
50
  export declare function count(name: string, value?: number, options?: MetricOptions): void;
51
51
  /**
52
- * @summary Set a gauge metric to a specific value. Requires the `_experiments.enableMetrics` option to be enabled.
52
+ * @summary Set a gauge metric to a specific value.
53
53
  *
54
54
  * @param name - The name of the gauge metric.
55
55
  * @param value - The current value of the gauge.
@@ -80,7 +80,7 @@ export declare function count(name: string, value?: number, options?: MetricOpti
80
80
  */
81
81
  export declare function gauge(name: string, value: number, options?: MetricOptions): void;
82
82
  /**
83
- * @summary Record a value in a distribution metric. Requires the `_experiments.enableMetrics` option to be enabled.
83
+ * @summary Record a value in a distribution metric.
84
84
  *
85
85
  * @param name - The name of the distribution metric.
86
86
  * @param value - The value to record in the distribution.
@@ -4,6 +4,7 @@
4
4
  *
5
5
  */
6
6
  export declare const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = "sentry.source";
7
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE = "sentry.span.source";
7
8
  /**
8
9
  * Attributes that holds the sample rate that was locally applied to a span.
9
10
  * If this attribute is not defined, it means that the span inherited a sampling decision.
@@ -50,7 +51,9 @@ export declare const SEMANTIC_ATTRIBUTE_CACHE_KEY = "cache.key";
50
51
  export declare const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = "cache.item_size";
51
52
  /** TODO: Remove these once we update to latest semantic conventions */
52
53
  export declare const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = "http.request.method";
54
+ export declare const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_TIME_TO_FIRST_BYTE = "http.request.time_to_first_byte";
53
55
  export declare const SEMANTIC_ATTRIBUTE_URL_FULL = "url.full";
56
+ export declare const SEMANTIC_ATTRIBUTE_URL_QUERY = "url.query";
54
57
  /**
55
58
  * A span link attribute to mark the link as a special span link.
56
59
  *
@@ -75,4 +78,39 @@ export declare const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = "sentry.link.type";
75
78
  * For LangGraph: configurable.thread_id
76
79
  */
77
80
  export declare const GEN_AI_CONVERSATION_ID_ATTRIBUTE = "gen_ai.conversation.id";
81
+ /** The release version of the application */
82
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = "sentry.release";
83
+ /** The environment name (e.g., "production", "staging", "development") */
84
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = "sentry.environment";
85
+ /** The segment name (e.g., "GET /users") */
86
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = "sentry.segment.name";
87
+ /** The id of the segment that this span belongs to. */
88
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = "sentry.segment.id";
89
+ /** The user ID (gated by sendDefaultPii) */
90
+ export declare const SEMANTIC_ATTRIBUTE_USER_ID = "user.id";
91
+ /** The user email (gated by sendDefaultPii) */
92
+ export declare const SEMANTIC_ATTRIBUTE_USER_EMAIL = "user.email";
93
+ /** The user IP address (gated by sendDefaultPii) */
94
+ export declare const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = "user.ip_address";
95
+ /** The user username (gated by sendDefaultPii) */
96
+ export declare const SEMANTIC_ATTRIBUTE_USER_USERNAME = "user.name";
97
+ /** The name of the Sentry SDK (e.g., "sentry.php", "sentry.javascript") */
98
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = "sentry.sdk.name";
99
+ /** The version of the Sentry SDK */
100
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = "sentry.sdk.version";
101
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_VALUE = "browser.web_vital.lcp.value";
102
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ELEMENT = "browser.web_vital.lcp.element";
103
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ID = "browser.web_vital.lcp.id";
104
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_URL = "browser.web_vital.lcp.url";
105
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_LOAD_TIME = "browser.web_vital.lcp.load_time";
106
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_RENDER_TIME = "browser.web_vital.lcp.render_time";
107
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_SIZE = "browser.web_vital.lcp.size";
108
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_VALUE = "browser.web_vital.cls.value";
109
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_SOURCES = "browser.web_vital.cls.source";
110
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_INP_VALUE = "browser.web_vital.inp.value";
111
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_VALUE = "browser.web_vital.ttfb.value";
112
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_REQUEST_TIME = "browser.web_vital.ttfb.request_time";
113
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_FP_VALUE = "browser.web_vital.fp.value";
114
+ export declare const SEMANTIC_ATTRIBUTE_WEB_VITAL_FCP_VALUE = "browser.web_vital.fcp.value";
115
+ export declare const SEMANTIC_ATTRIBUTE_BROWSER_CONNECTION_RTT = "browser.connection.rtt";
78
116
  //# sourceMappingURL=semanticAttributes.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { Client } from '../client';
2
+ import { Span } from '../types-hoist/span';
3
+ /**
4
+ * Captures a span and returns a JSON representation to be enqueued for sending.
5
+ *
6
+ * IMPORTANT: This function converts the span to JSON immediately to avoid writing
7
+ * to an already-ended OTel span instance (which is blocked by the OTel Span class).
8
+ */
9
+ export declare function captureSpan(span: Span, client?: Client<import("..").ClientOptions<import("..").BaseTransportOptions>> | undefined): void;
10
+ //# sourceMappingURL=captureSpan.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { Client } from '../client';
2
+ import { SpanV2JSONWithSegmentRef } from '../types-hoist/span';
3
+ export interface SpanBufferOptions {
4
+ /** Max spans per trace before auto-flush (default: 1000) */
5
+ maxSpanLimit?: number;
6
+ /** Flush interval in ms (default: 5000) */
7
+ flushInterval?: number;
8
+ }
9
+ /**
10
+ * A buffer for span JSON objects that flushes them to Sentry in Span v2 envelopes.
11
+ * Handles interval-based flushing, size thresholds, and graceful shutdown.
12
+ */
13
+ export declare class SpanBuffer {
14
+ private _spanTreeMap;
15
+ private _flushIntervalId;
16
+ private _client;
17
+ private _maxSpanLimit;
18
+ private _flushInterval;
19
+ constructor(client: Client, options?: SpanBufferOptions);
20
+ /**
21
+ * Add a span to the buffer.
22
+ */
23
+ addSpan(spanJSON: SpanV2JSONWithSegmentRef): void;
24
+ /**
25
+ * Flush all buffered traces.
26
+ */
27
+ flush(): void;
28
+ /**
29
+ * Flush spans of a specific trace.
30
+ * In contrast to {@link SpanBuffer.flush}, this method does not flush all traces, but only the one with the given traceId.
31
+ */
32
+ flushTrace(traceId: string): void;
33
+ private _debounceFlushInterval;
34
+ }
35
+ //# sourceMappingURL=spanBuffer.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { RawAttributes } from '../attributes';
2
+ import { Contexts } from '../types-hoist/context';
3
+ import { SpanV2JSON } from '../types-hoist/span';
4
+ /**
5
+ * Only set a span JSON attribute if it is not already set.
6
+ * This is used to safely set attributes on JSON objects without mutating already-ended span instances.
7
+ */
8
+ export declare function safeSetSpanJSONAttributes(spanJSON: SpanV2JSON, newAttributes: RawAttributes<Record<string, unknown>>): void;
9
+ /**
10
+ * Apply a user-provided beforeSendSpan callback to a span JSON.
11
+ */
12
+ export declare function applyBeforeSendSpanCallback(span: SpanV2JSON, beforeSendSpan: (span: SpanV2JSON) => SpanV2JSON): SpanV2JSON;
13
+ /**
14
+ * Converts a context object to a set of attributes.
15
+ * Only includes attributes that are primitives (for now).
16
+ * @param contexts - The context object to convert.
17
+ * @returns The attributes object.
18
+ */
19
+ export declare function contextsToAttributes(contexts: Contexts): RawAttributes<Record<string, unknown>>;
20
+ //# sourceMappingURL=spanFirstUtils.d.ts.map
@@ -186,6 +186,10 @@ export declare const GEN_AI_EMBED_DO_EMBED_OPERATION_ATTRIBUTE = "gen_ai.embed";
186
186
  * The span operation name for embedding many
187
187
  */
188
188
  export declare const GEN_AI_EMBED_MANY_DO_EMBED_OPERATION_ATTRIBUTE = "gen_ai.embed_many";
189
+ /**
190
+ * The span operation name for reranking
191
+ */
192
+ export declare const GEN_AI_RERANK_DO_RERANK_OPERATION_ATTRIBUTE = "gen_ai.rerank";
189
193
  /**
190
194
  * The span operation name for executing a tool
191
195
  */
@@ -1,5 +1,5 @@
1
1
  import { SpanLink } from '../types-hoist/link';
2
- import { SentrySpanArguments, Span, SpanAttributes, SpanAttributeValue, SpanContextData, SpanJSON, SpanTimeInput } from '../types-hoist/span';
2
+ import { SentrySpanArguments, Span, SpanAttributes, SpanAttributeValue, SpanContextData, SpanJSON, SpanTimeInput, SpanV2JSON } from '../types-hoist/span';
3
3
  import { SpanStatus } from '../types-hoist/spanStatus';
4
4
  import { TimedEvent } from '../types-hoist/timedEvent';
5
5
  /**
@@ -77,6 +77,15 @@ export declare class SentrySpan implements Span {
77
77
  * use `spanToJSON(span)` instead.
78
78
  */
79
79
  getSpanJSON(): SpanJSON;
80
+ /**
81
+ * Get SpanV2JSON representation of this span.
82
+ *
83
+ * @hidden
84
+ * @internal This method is purely for internal purposes and should not be used outside
85
+ * of SDK code. If you need to get a JSON representation of a span,
86
+ * use `spanToV2JSON(span)` instead.
87
+ */
88
+ getSpanV2JSON(): SpanV2JSON;
80
89
  /** @inheritdoc */
81
90
  isRecording(): boolean;
82
91
  /**
@@ -3,4 +3,5 @@ export declare const toolCallSpanMap: Map<string, Span>;
3
3
  export declare const INVOKE_AGENT_OPS: Set<string>;
4
4
  export declare const GENERATE_CONTENT_OPS: Set<string>;
5
5
  export declare const EMBEDDINGS_OPS: Set<string>;
6
+ export declare const RERANK_OPS: Set<string>;
6
7
  //# sourceMappingURL=constants.d.ts.map
@@ -26,9 +26,9 @@ export declare function _INTERNAL_cleanupToolCallSpan(toolCallId: string): void;
26
26
  */
27
27
  export declare function convertAvailableToolsToJsonString(tools: unknown[]): string;
28
28
  /**
29
- * Convert the prompt string to messages array
29
+ * Normalize the user input (stringified object with prompt, system, messages) to messages array
30
30
  */
31
- export declare function convertPromptToMessages(prompt: string): {
31
+ export declare function convertUserInputToMessagesFormat(userInput: string): {
32
32
  role: string;
33
33
  content: string;
34
34
  }[];
@@ -0,0 +1,19 @@
1
+ import { AttributeUnit } from '../attributes';
2
+ export type SerializedAttributes = Record<string, SerializedAttribute>;
3
+ export type SerializedAttribute = ({
4
+ type: 'string';
5
+ value: string;
6
+ } | {
7
+ type: 'integer';
8
+ value: number;
9
+ } | {
10
+ type: 'double';
11
+ value: number;
12
+ } | {
13
+ type: 'boolean';
14
+ value: boolean;
15
+ }) & {
16
+ unit?: AttributeUnit;
17
+ };
18
+ export type SerializedAttributeType = 'string' | 'integer' | 'double' | 'boolean';
19
+ //# sourceMappingURL=attributes.d.ts.map
@@ -11,7 +11,7 @@ import { Profile, ProfileChunk } from './profiling';
11
11
  import { ReplayEvent, ReplayRecordingData } from './replay';
12
12
  import { SdkInfo } from './sdkinfo';
13
13
  import { SerializedSession, SessionAggregates } from './session';
14
- import { SpanJSON } from './span';
14
+ import { SerializedSpanContainer, SpanJSON } from './span';
15
15
  export type DynamicSamplingContext = {
16
16
  trace_id: string;
17
17
  public_key: DsnComponents['publicKey'];
@@ -87,6 +87,21 @@ type ProfileChunkItemHeaders = {
87
87
  type SpanItemHeaders = {
88
88
  type: 'span';
89
89
  };
90
+ type SpanContainerItemHeaders = {
91
+ /**
92
+ * Same as v1 span item type but this envelope is distinguished by {@link SpanContainerItemHeaders.content_type}.
93
+ */
94
+ type: 'span';
95
+ /**
96
+ * The number of span items in the container. This must be the same as the number of span items in the payload.
97
+ */
98
+ item_count: number;
99
+ /**
100
+ * The content type of the span items. This must be `application/vnd.sentry.items.span.v2+json`.
101
+ * (the presence of this field also distinguishes the span item from the v1 span item)
102
+ */
103
+ content_type: 'application/vnd.sentry.items.span.v2+json';
104
+ };
90
105
  type LogContainerItemHeaders = {
91
106
  type: 'log';
92
107
  /**
@@ -120,6 +135,7 @@ export type FeedbackItem = BaseEnvelopeItem<FeedbackItemHeaders, FeedbackEvent>;
120
135
  export type ProfileItem = BaseEnvelopeItem<ProfileItemHeaders, Profile>;
121
136
  export type ProfileChunkItem = BaseEnvelopeItem<ProfileChunkItemHeaders, ProfileChunk>;
122
137
  export type SpanItem = BaseEnvelopeItem<SpanItemHeaders, Partial<SpanJSON>>;
138
+ export type SpanContainerItem = BaseEnvelopeItem<SpanContainerItemHeaders, SerializedSpanContainer>;
123
139
  export type LogContainerItem = BaseEnvelopeItem<LogContainerItemHeaders, SerializedLogContainer>;
124
140
  export type MetricContainerItem = BaseEnvelopeItem<MetricContainerItemHeaders, SerializedMetricContainer>;
125
141
  export type RawSecurityItem = BaseEnvelopeItem<RawSecurityHeaders, LegacyCSPReport>;
@@ -139,6 +155,9 @@ type ReplayEnvelopeHeaders = BaseEnvelopeHeaders;
139
155
  type SpanEnvelopeHeaders = BaseEnvelopeHeaders & {
140
156
  trace?: DynamicSamplingContext;
141
157
  };
158
+ type SpanV2EnvelopeHeaders = BaseEnvelopeHeaders & {
159
+ trace?: DynamicSamplingContext;
160
+ };
142
161
  type LogEnvelopeHeaders = BaseEnvelopeHeaders;
143
162
  type MetricEnvelopeHeaders = BaseEnvelopeHeaders;
144
163
  export type EventEnvelope = BaseEnvelope<EventEnvelopeHeaders, EventItem | AttachmentItem | UserFeedbackItem | FeedbackItem | ProfileItem>;
@@ -153,11 +172,12 @@ export type ReplayEnvelope = [
153
172
  ];
154
173
  export type CheckInEnvelope = BaseEnvelope<CheckInEnvelopeHeaders, CheckInItem>;
155
174
  export type SpanEnvelope = BaseEnvelope<SpanEnvelopeHeaders, SpanItem>;
175
+ export type SpanV2Envelope = BaseEnvelope<SpanV2EnvelopeHeaders, SpanContainerItem>;
156
176
  export type ProfileChunkEnvelope = BaseEnvelope<BaseEnvelopeHeaders, ProfileChunkItem>;
157
177
  export type RawSecurityEnvelope = BaseEnvelope<BaseEnvelopeHeaders, RawSecurityItem>;
158
178
  export type LogEnvelope = BaseEnvelope<LogEnvelopeHeaders, LogContainerItem>;
159
179
  export type MetricEnvelope = BaseEnvelope<MetricEnvelopeHeaders, MetricContainerItem>;
160
- export type Envelope = EventEnvelope | SessionEnvelope | ClientReportEnvelope | ProfileChunkEnvelope | ReplayEnvelope | CheckInEnvelope | SpanEnvelope | RawSecurityEnvelope | LogEnvelope | MetricEnvelope;
180
+ export type Envelope = EventEnvelope | SessionEnvelope | ClientReportEnvelope | ProfileChunkEnvelope | ReplayEnvelope | CheckInEnvelope | SpanEnvelope | SpanV2Envelope | RawSecurityEnvelope | LogEnvelope | MetricEnvelope;
161
181
  export type EnvelopeItem = Envelope[1][number];
162
182
  export {};
163
183
  //# sourceMappingURL=envelope.d.ts.map
@@ -11,6 +11,13 @@ export interface Integration {
11
11
  * It does not receives any arguments, and should only use for e.g. global monkey patching and similar things.
12
12
  */
13
13
  setupOnce?(): void;
14
+ /**
15
+ * This hook is called for all integrations before the `setup` hook.
16
+ * This is useful for integrations that need to e.g. modify client values before other integrations are set up.
17
+ * Use this hook with caution and prefer `setup` whenever possible.
18
+ * @param client
19
+ */
20
+ beforeSetup?(client: Client): void;
14
21
  /**
15
22
  * Set up an integration for the given client.
16
23
  * Receives the client as argument.
@@ -19,11 +19,11 @@ export interface SpanLink {
19
19
  * Link interface for the event envelope item. It's a flattened representation of `SpanLink`.
20
20
  * Can include additional fields defined by OTel.
21
21
  */
22
- export interface SpanLinkJSON extends Record<string, unknown> {
22
+ export interface SpanLinkJSON<TAttributes = SpanLinkAttributes> extends Record<string, unknown> {
23
23
  span_id: string;
24
24
  trace_id: string;
25
25
  sampled?: boolean;
26
- attributes?: SpanLinkAttributes;
26
+ attributes?: TAttributes;
27
27
  }
28
28
  export {};
29
29
  //# sourceMappingURL=link.d.ts.map
@@ -6,7 +6,7 @@ import { Log } from './log';
6
6
  import { Metric } from './metric';
7
7
  import { TracesSamplerSamplingContext } from './samplingcontext';
8
8
  import { SdkMetadata } from './sdkmetadata';
9
- import { SpanJSON } from './span';
9
+ import { SpanJSON, SpanV2JSON } from './span';
10
10
  import { StackLineParser, StackParser } from './stacktrace';
11
11
  import { TracePropagationTargets } from './tracing';
12
12
  import { BaseTransportOptions, Transport } from './transport';
@@ -450,6 +450,15 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
450
450
  * @default false
451
451
  */
452
452
  strictTraceContinuation?: boolean;
453
+ /**
454
+ * [Experimental] The trace lifecycle, determining whether spans are sent statically when the entire local span tree is complete, or
455
+ * in batches, following interval- and action-based triggers.
456
+ *
457
+ * @experimental this option is currently still experimental and its type, name, or entire presence is subject to break and change at any time.
458
+ *
459
+ * @default 'static'
460
+ */
461
+ traceLifecycle?: 'static' | 'stream';
453
462
  /**
454
463
  * The organization ID for your Sentry project.
455
464
  *
@@ -526,7 +535,7 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
526
535
  *
527
536
  * @returns The modified span payload that will be sent.
528
537
  */
529
- beforeSendSpan?: (span: SpanJSON) => SpanJSON;
538
+ beforeSendSpan?: ((span: SpanJSON) => SpanJSON) | SpanV2CompatibleBeforeSendSpanCallback;
530
539
  /**
531
540
  * An event-processing callback for transaction events, guaranteed to be invoked after all other event
532
541
  * processors. This allows an event to be modified or dropped before it's sent.
@@ -552,6 +561,13 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
552
561
  */
553
562
  beforeBreadcrumb?: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => Breadcrumb | null;
554
563
  }
564
+ /**
565
+ * A callback that is known to be compatible with actually receiving and returning a span v2 JSON object.
566
+ * Only useful in conjunction with the {@link CoreOptions.traceLifecycle} option.
567
+ */
568
+ export type SpanV2CompatibleBeforeSendSpanCallback = ((span: SpanV2JSON) => SpanV2JSON) & {
569
+ _v2: true;
570
+ };
555
571
  /** Base configuration options for every SDK. */
556
572
  export interface CoreOptions<TO extends BaseTransportOptions = BaseTransportOptions> extends Pick<Partial<ClientOptions<TO>>, Exclude<keyof Partial<ClientOptions<TO>>, 'integrations' | 'transport' | 'stackParser'>> {
557
573
  /**
@@ -1,3 +1,4 @@
1
+ import { Attributes } from '../attributes';
1
2
  import { SpanLink, SpanLinkJSON } from './link';
2
3
  import { Measurements } from './measurement';
3
4
  import { HrTime } from './opentelemetry';
@@ -17,6 +18,32 @@ export type SpanAttributes = Partial<{
17
18
  }> & Record<string, SpanAttributeValue | undefined>;
18
19
  /** This type is aligned with the OpenTelemetry TimeInput type. */
19
20
  export type SpanTimeInput = HrTime | number | Date;
21
+ /**
22
+ * JSON representation of a v2 span, as it should be sent to Sentry.
23
+ */
24
+ export interface SpanV2JSON {
25
+ trace_id: string;
26
+ parent_span_id?: string;
27
+ span_id: string;
28
+ name: string;
29
+ start_timestamp: number;
30
+ end_timestamp: number;
31
+ status: 'ok' | 'error';
32
+ is_segment: boolean;
33
+ attributes?: Attributes;
34
+ links?: SpanLinkJSON<Attributes>[];
35
+ }
36
+ /**
37
+ * A SpanV2JSON with an attached reference to the segment span.
38
+ * This reference is used to compute dynamic sampling context before sending.
39
+ * The reference MUST be removed before sending the span envelope.
40
+ */
41
+ export interface SpanV2JSONWithSegmentRef extends SpanV2JSON {
42
+ _segmentSpan: Span;
43
+ }
44
+ export type SerializedSpanContainer = {
45
+ items: Array<SpanV2JSON>;
46
+ };
20
47
  /** A JSON representation of a span. */
21
48
  export interface SpanJSON {
22
49
  data: SpanAttributes;
@@ -0,0 +1,22 @@
1
+ import { ClientOptions, SpanV2CompatibleBeforeSendSpanCallback } from '../types-hoist/options';
2
+ import { SpanV2JSON } from '../types-hoist/span';
3
+ /**
4
+ * A wrapper to use the new span format in your `beforeSendSpan` callback.
5
+ *
6
+ * @example
7
+ *
8
+ * Sentry.init({
9
+ * beforeSendSpan: withStreamSpan((span) => {
10
+ * return span;
11
+ * }),
12
+ * });
13
+ *
14
+ * @param callback
15
+ * @returns
16
+ */
17
+ export declare function withStreamSpan(callback: (span: SpanV2JSON) => SpanV2JSON): SpanV2CompatibleBeforeSendSpanCallback;
18
+ /**
19
+ * Typesafe check to identify the expected span json format of the `beforeSendSpan` callback.
20
+ */
21
+ export declare function isV2BeforeSendSpanCallback(callback: ClientOptions['beforeSendSpan']): callback is SpanV2CompatibleBeforeSendSpanCallback;
22
+ //# sourceMappingURL=beforeSendSpan.d.ts.map
@@ -0,0 +1,13 @@
1
+ export declare const FALSY_ENV_VALUES: Set<string>;
2
+ export declare const TRUTHY_ENV_VALUES: Set<string>;
3
+ export type StrictBoolCast = {
4
+ strict: true;
5
+ };
6
+ export type LooseBoolCast = {
7
+ strict?: false;
8
+ };
9
+ export type BoolCastOptions = StrictBoolCast | LooseBoolCast;
10
+ export declare function envToBool(value: unknown, options?: LooseBoolCast): boolean;
11
+ export declare function envToBool(value: unknown, options: StrictBoolCast): boolean | null;
12
+ export declare function envToBool(value: unknown, options?: BoolCastOptions): boolean | null;
13
+ //# sourceMappingURL=envToBool.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * Determines if the SDK is configured for span streaming.
4
+ * Span streaming is enabled when `traceLifecycle` is set to `stream`.
5
+ * (In Browser, users must add `spanStreamingIntegration` as well but it
6
+ * already checks itself and configures `traceLifecycle` appropriately)
7
+ */
8
+ export declare function hasSpanStreamingEnabled(maybeClient?: Client | undefined): boolean;
9
+ //# sourceMappingURL=hasSpanStreamingEnabled.d.ts.map