Skip to content
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

Avoid duplicating Breadcrumbs on Android #254

Merged
merged 2 commits into from
Nov 16, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- Avoid duplicating Breadcrumbs on Android ([#254](https://github.com/getsentry/sentry-capacitor/pull/254))

### Dependencies

- Bump Sentry JavaScript SDK to `7.15.0` ([#244](https://github.com/getsentry/sentry-capacitor/pull/244))
Expand Down
4 changes: 3 additions & 1 deletion src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export const NATIVE = {
We then remove the breadcrumbs in all cases but if it is handled == false,
this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read
the envelope.
Since unhandled errors from Javascript are not going to crash the App, we can't rely on the
handled flag for filtering breadcrumbs.
*/
if (event.exception?.values?.[0]?.mechanism?.handled != false && event.breadcrumbs) {
if (event.breadcrumbs) {
event.breadcrumbs = [];
}
}
Expand Down
10 changes: 3 additions & 7 deletions test/wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ describe('Tests Native Wrapper', () => {
exception: {
values: [{
mechanism: {
handled: false
handled: true
}
}]
},
Expand All @@ -327,18 +327,14 @@ describe('Tests Native Wrapper', () => {
});
const expectedPayload = JSON.stringify({
...event,
breadcrumbs: [
{
message: 'crumb!',
},
],
breadcrumbs: [],
message: {
message: event.message,
},
exception: {
values: [{
mechanism: {
handled: false
handled: true
}
}]
}
Expand Down