@@ -6,7 +6,7 @@ import type { Log } from './log';
66import type { Metric } from './metric' ;
77import type { TracesSamplerSamplingContext } from './samplingcontext' ;
88import type { SdkMetadata } from './sdkmetadata' ;
9- import type { SpanJSON } from './span' ;
9+ import type { SpanJSON , StreamedSpanJSON } from './span' ;
1010import type { StackLineParser , StackParser } from './stacktrace' ;
1111import type { TracePropagationTargets } from './tracing' ;
1212import type { BaseTransportOptions , Transport } from './transport' ;
@@ -500,6 +500,14 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
500500 */
501501 strictTraceContinuation ?: boolean ;
502502
503+ /**
504+ * The trace lifecycle, determining whether spans are sent statically when the entire local span tree is complete,
505+ * or streamed in batches, following interval- and action-based triggers.
506+ *
507+ * @default 'static'
508+ */
509+ traceLifecycle ?: 'static' | 'stream' ;
510+
503511 /**
504512 * The organization ID for your Sentry project.
505513 *
@@ -579,11 +587,14 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
579587 /**
580588 * This function can be defined to modify a child span before it's sent.
581589 *
590+ * When using `traceLifecycle: 'stream'`, wrap your callback with {@link withStreamedSpan}
591+ * to receive and return {@link StreamedSpanJSON} instead.
592+ *
582593 * @param span The span generated by the SDK.
583594 *
584595 * @returns The modified span payload that will be sent.
585596 */
586- beforeSendSpan ?: ( span : SpanJSON ) => SpanJSON ;
597+ beforeSendSpan ?: ( ( span : SpanJSON ) => SpanJSON ) | BeforeSendStramedSpanCallback ;
587598
588599 /**
589600 * An event-processing callback for transaction events, guaranteed to be invoked after all other event
@@ -615,6 +626,19 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
615626 beforeBreadcrumb ?: ( breadcrumb : Breadcrumb , hint ?: BreadcrumbHint ) => Breadcrumb | null ;
616627}
617628
629+ /**
630+ * A callback for processing streamed spans before they are sent.
631+ *
632+ * @see {@link StreamedSpanJSON } for the streamed span format used with `traceLifecycle: 'stream'`
633+ */
634+ export type BeforeSendStramedSpanCallback = ( ( span : StreamedSpanJSON ) => StreamedSpanJSON ) & {
635+ /**
636+ * When true, indicates this callback is designed to handle the {@link StreamedSpanJSON} format
637+ * used with `traceLifecycle: 'stream'`. Set this by wrapping your callback with `withStreamedSpan`.
638+ */
639+ _streamed ?: true ;
640+ } ;
641+
618642/** Base configuration options for every SDK. */
619643export interface CoreOptions < TO extends BaseTransportOptions = BaseTransportOptions >
620644 extends Omit < Partial < ClientOptions < TO > > , 'integrations' | 'transport' | 'stackParser' > {
0 commit comments