Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Bump: sentry-android to v4.3.0 (#343)
* Fix: Multiple FlutterError.onError calls in FlutterErrorIntegration (#345)
* Fix: EventProcessors were not dropping events when returning null (#353)

# 4.1.0-nullsafety.0

Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class Scope {
SentryEvent? processedEvent = event;
for (final processor in _eventProcessors) {
try {
processedEvent = await processor(processedEvent!, hint: hint)!;
processedEvent = await processor(processedEvent!, hint: hint);
} catch (err) {
_options.logger(
SentryLevel.error,
Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class SentryClient {
SentryEvent? processedEvent = event;
for (final processor in eventProcessors) {
try {
processedEvent = await processor(processedEvent!, hint: hint)!;
processedEvent = await processor(processedEvent!, hint: hint);
} catch (err) {
_options.logger(
SentryLevel.error,
Expand Down
11 changes: 11 additions & 0 deletions dart/test/scope_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ void main() {
expect(updatedEvent?.level, SentryLevel.error);
});
});

test('event processor drops the event', () async {
final sut = fixture.getSut();

sut.addEventProcessor(fixture.processor);

final event = SentryEvent();
var newEvent = await sut.applyToEvent(event, null);

expect(newEvent, isNull);
});
}

class Fixture {
Expand Down
12 changes: 12 additions & 0 deletions dart/test/sentry_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ void main() {
);
expect(event.fingerprint!.contains('process'), true);
});

test('event processor drops the event', () async {
options.addEventProcessor(eventProcessorDropEvent);
final client = SentryClient(options);
await client.captureEvent(fakeEvent);

expect((options.transport as MockTransport).called(0), true);
});
});
}

Expand All @@ -523,3 +531,7 @@ SentryEvent beforeSendCallback(SentryEvent event, {dynamic hint}) {
..sdk!.addIntegration('testIntegration')
..sdk!.addPackage('test-pkg', '1.0');
}

SentryEvent? eventProcessorDropEvent(SentryEvent event, {dynamic hint}) {
return null;
}