Skip to content

Commit f6cfc05

Browse files
committed
account for unmigrated beforeSendSpan with INP spans
1 parent e71da11 commit f6cfc05

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎packages/core/src/tracing/spans/captureSpan.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ export function captureSpan(span: Span, client: Client): SerializedStreamedSpanW
7575
// This also invokes the `processSpan` hook of all integrations
7676
client.emit('processSpan', spanJSON);
7777

78-
const { beforeSendSpan } = client.getOptions();
78+
const { beforeSendSpan, traceLifecycle } = client.getOptions();
7979
const processedSpan =
80-
beforeSendSpan && !isStaticBeforeSendSpanCallback(beforeSendSpan)
80+
// check for traceLifecycle here because in static lifecycle,
81+
// captureSpan is called for INP spans. If an unmigrated beforeSendSpan
82+
// callback is run on these spans, it will throw an error.
83+
traceLifecycle === 'stream' && beforeSendSpan && !isStaticBeforeSendSpanCallback(beforeSendSpan)
8184
? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)
8285
: spanJSON;
8386

0 commit comments

Comments
 (0)