From 1ff35e4fbf3058bbcfbcdacc485b853e6a72508a Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Fri, 13 Sep 2024 14:53:52 +0200 Subject: [PATCH] fix: event processor failed to stop processing --- dart/lib/src/sentry_client.dart | 1 + dart/test/sentry_client_test.dart | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dart/lib/src/sentry_client.dart b/dart/lib/src/sentry_client.dart index e3809568da..65cf799d7a 100644 --- a/dart/lib/src/sentry_client.dart +++ b/dart/lib/src/sentry_client.dart @@ -558,6 +558,7 @@ class SentryClient { count: spanCountBeforeEventProcessors + 1); } _options.logger(SentryLevel.debug, 'Event was dropped by a processor'); + break; } else if (event is SentryTransaction && processedEvent is SentryTransaction) { // If event processor removed only some spans we still report them as dropped diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 07d5aab834..e58311169b 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -1249,6 +1249,7 @@ void main() { }); test('thrown error is handled', () async { + fixture.options.automatedTestMode = false; final exception = Exception("before send exception"); final beforeSendTransactionCallback = (SentryTransaction event) { throw exception; @@ -1311,6 +1312,7 @@ void main() { }); test('thrown error is handled', () async { + fixture.options.automatedTestMode = false; final exception = Exception("before send exception"); final beforeSendCallback = (SentryEvent event, Hint hint) { throw exception; @@ -1604,7 +1606,13 @@ void main() { }); test('record event processor dropping event', () async { - final client = fixture.getSut(eventProcessor: DropAllEventProcessor()); + bool secondProcessorCalled = false; + fixture.options.addEventProcessor(DropAllEventProcessor()); + fixture.options.addEventProcessor(FunctionEventProcessor((event, hint) { + secondProcessorCalled = true; + return event; + })); + final client = fixture.getSut(); await client.captureEvent(fakeEvent); @@ -1612,6 +1620,7 @@ void main() { DiscardReason.eventProcessor); expect( fixture.recorder.discardedEvents.first.category, DataCategory.error); + expect(secondProcessorCalled, isFalse); }); test('record event processor dropping transaction', () async { @@ -1885,7 +1894,8 @@ class Fixture { final transport = MockTransport(); final options = SentryOptions(dsn: fakeDsn) - ..platformChecker = MockPlatformChecker(platform: MockPlatform.iOS()); + ..platformChecker = MockPlatformChecker(platform: MockPlatform.iOS()) + ..automatedTestMode = true; late SentryTransactionContext _context; late SentryTracer tracer;