From c67e225c01aee7188a16ce9e29df88dbc60987d7 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 23 Jul 2024 17:19:55 +0200 Subject: [PATCH] small ref --- packages/core/src/baseclient.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/core/src/baseclient.ts b/packages/core/src/baseclient.ts index de4677b154c0..64410360e51d 100644 --- a/packages/core/src/baseclient.ts +++ b/packages/core/src/baseclient.ts @@ -986,13 +986,15 @@ function processBeforeSend( } if (beforeSendTransaction) { - // We store the # of spans before processing in SDK metadata, - // so we can compare it afterwards to determine how many spans were dropped - const spanCountBefore = event.spans ? event.spans.length : 0; - event.sdkProcessingMetadata = { - ...event.sdkProcessingMetadata, - spanCountBeforeProcessing: spanCountBefore, - }; + if (event.spans) { + // We store the # of spans before processing in SDK metadata, + // so we can compare it afterwards to determine how many spans were dropped + const spanCountBefore = event.spans.length; + event.sdkProcessingMetadata = { + ...event.sdkProcessingMetadata, + spanCountBeforeProcessing: spanCountBefore, + }; + } return beforeSendTransaction(event, hint); } }