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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fix

* Change order of event filtering mechanisms (#2001)

## 6.0.0-beta.2

* Fix: Android profiling initializes on first profile start (#2009)
Expand Down
55 changes: 31 additions & 24 deletions sentry/src/main/java/io/sentry/SentryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ private boolean shouldApplyScopeData(

options.getLogger().log(SentryLevel.DEBUG, "Capturing event: %s", event.getEventId());

if (event != null) {
final Throwable eventThrowable = event.getThrowable();
if (eventThrowable != null && options.containsIgnoredExceptionForType(eventThrowable)) {
options
.getLogger()
.log(
SentryLevel.DEBUG,
"Event was dropped as the exception %s is ignored",
eventThrowable.getClass());
options
.getClientReportRecorder()
.recordLostEvent(DiscardReason.EVENT_PROCESSOR, DataCategory.Error);
return SentryId.EMPTY_ID;
}
}

if (shouldApplyScopeData(event, hint)) {
// Event has already passed through here before it was cached
// Going through again could be reading data that is no longer relevant
Expand All @@ -95,6 +111,21 @@ private boolean shouldApplyScopeData(

event = processEvent(event, hint, options.getEventProcessors());

if (event != null) {
event = executeBeforeSend(event, hint);

if (event == null) {
options.getLogger().log(SentryLevel.DEBUG, "Event was dropped by beforeSend");
options
.getClientReportRecorder()
.recordLostEvent(DiscardReason.BEFORE_SEND, DataCategory.Error);
}
}

if (event == null) {
return SentryId.EMPTY_ID;
}

Session session = null;

if (event != null) {
Expand All @@ -115,30 +146,6 @@ private boolean shouldApplyScopeData(
}
}

if (event != null) {
if (event.getThrowable() != null
&& options.containsIgnoredExceptionForType(event.getThrowable())) {
options
.getLogger()
.log(
SentryLevel.DEBUG,
"Event was dropped as the exception %s is ignored",
event.getThrowable().getClass());
options
.getClientReportRecorder()
.recordLostEvent(DiscardReason.EVENT_PROCESSOR, DataCategory.Error);
return SentryId.EMPTY_ID;
}
event = executeBeforeSend(event, hint);

if (event == null) {
options.getLogger().log(SentryLevel.DEBUG, "Event was dropped by beforeSend");
options
.getClientReportRecorder()
.recordLostEvent(DiscardReason.BEFORE_SEND, DataCategory.Error);
}
}

SentryId sentryId = SentryId.EMPTY_ID;
if (event != null && event.getEventId() != null) {
sentryId = event.getEventId();
Expand Down