Skip to content

Breadcrumbs should not be duplicated if there is no mechaism on Android #936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 7, 2022
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 @@ -4,6 +4,7 @@

### Fixes

* Breadcrumbs should not be duplicated if there is no mechanism on Android ([#936](https://github.com/getsentry/sentry-dart/pull/936))
* Maps with Key Object, Object would fail during serialization if not String, Object ([#935](https://github.com/getsentry/sentry-dart/pull/935))

## 6.6.3
Expand Down
9 changes: 4 additions & 5 deletions dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,11 @@ class SentryClient {
}

SentryEvent _eventWithRemovedBreadcrumbsIfHandled(SentryEvent event) {
final exceptions = event.exceptions ?? [];
final handled = exceptions.isNotEmpty
? exceptions.first.mechanism?.handled == true
: false;
final foundNotHandled = event.exceptions
?.any((element) => element.mechanism?.handled == false) ??
false;

if (handled) {
if (!foundNotHandled) {
return event.copyWith(breadcrumbs: []);
} else {
return event;
Expand Down
22 changes: 22 additions & 0 deletions dart/test/sentry_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,28 @@ void main() {
expect((capturedEvent.breadcrumbs ?? []).isEmpty, true);
});

test('Clears breadcrumbs on Android if theres no mechanism', () async {
fixture.options.enableScopeSync = true;
fixture.options.platformChecker =
MockPlatformChecker(platform: MockPlatform.android());

final client = fixture.getSut();
final event = SentryEvent(exceptions: [
SentryException(
type: "type",
value: "value",
)
], breadcrumbs: [
Breadcrumb()
]);
await client.captureEvent(event);

final capturedEnvelope = (fixture.transport).envelopes.first;
final capturedEvent = await eventFromEnvelope(capturedEnvelope);

expect((capturedEvent.breadcrumbs ?? []).isEmpty, true);
});

test('Does not clear breadcrumbs on Android if mechanism.handled is false',
() async {
fixture.options.enableScopeSync = true;
Expand Down