Skip to content

Commit

Permalink
Avoid duplicating Breadcrumbs on Android (#254)
Browse files Browse the repository at this point in the history
* Ignore breadcrumbs if unhandled on Android
  • Loading branch information
lucas-zimerman authored Nov 16, 2022
1 parent fd68f2b commit b83bd0f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
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

0 comments on commit b83bd0f

Please sign in to comment.