@@ -404,7 +404,7 @@ class SentryClient {
404404 SentryEvent event,
405405 Hint hint,
406406 ) async {
407- SentryEvent ? eventOrTransaction = event;
407+ SentryEvent ? processedEvent = event;
408408 final spanCountBeforeCallback =
409409 event is SentryTransaction ? event.spans.length : 0 ;
410410
@@ -415,18 +415,18 @@ class SentryClient {
415415 try {
416416 if (event is SentryTransaction && beforeSendTransaction != null ) {
417417 beforeSendName = 'beforeSendTransaction' ;
418- final e = beforeSendTransaction (event);
419- if (e is Future <SentryTransaction ?>) {
420- eventOrTransaction = await e ;
418+ final callbackResult = beforeSendTransaction (event);
419+ if (callbackResult is Future <SentryTransaction ?>) {
420+ processedEvent = await callbackResult ;
421421 } else {
422- eventOrTransaction = e ;
422+ processedEvent = callbackResult ;
423423 }
424424 } else if (beforeSend != null ) {
425- final e = beforeSend (event, hint);
426- if (e is Future <SentryEvent ?>) {
427- eventOrTransaction = await e ;
425+ final callbackResult = beforeSend (event, hint);
426+ if (callbackResult is Future <SentryEvent ?>) {
427+ processedEvent = await callbackResult ;
428428 } else {
429- eventOrTransaction = e ;
429+ processedEvent = callbackResult ;
430430 }
431431 }
432432 } catch (exception, stackTrace) {
@@ -441,7 +441,7 @@ class SentryClient {
441441 }
442442 }
443443
444- if (eventOrTransaction == null ) {
444+ if (processedEvent == null ) {
445445 _options.recorder
446446 .recordLostEvent (DiscardReason .beforeSend, _getCategory (event));
447447 if (event is SentryTransaction ) {
@@ -455,9 +455,9 @@ class SentryClient {
455455 '${event .runtimeType } was dropped by $beforeSendName callback' ,
456456 );
457457 } else if (event is SentryTransaction &&
458- eventOrTransaction is SentryTransaction ) {
459- // If beforeSend removed spans but not all we still record them as lost
460- final spanCountAfterCallback = eventOrTransaction .spans.length;
458+ processedEvent is SentryTransaction ) {
459+ // If beforeSend removed only some spans we still report them as dropped
460+ final spanCountAfterCallback = processedEvent .spans.length;
461461 final droppedSpanCount = spanCountBeforeCallback - spanCountAfterCallback;
462462 if (droppedSpanCount > 0 ) {
463463 _options.recorder.recordLostEvent (
@@ -466,7 +466,7 @@ class SentryClient {
466466 }
467467 }
468468
469- return eventOrTransaction ;
469+ return processedEvent ;
470470 }
471471
472472 Future <SentryEvent ?> _runEventProcessors (
0 commit comments