Skip to content

Commit

Permalink
fix: only remove SES from exception if exception exists (#9867)
Browse files Browse the repository at this point in the history
## **Description**

Follow-up to
- #8584

There's been a recent spike in errors throwing at

https://github.com/MetaMask/metamask-mobile/blob/11ce2f3678039a73b20d5cc6e07782c5604ae24f/app/util/sentry/utils.js#L94-L95

This change ensures the error exists, before removing SES from the stack
trace frame

In a similar manner to how we've been doing it in

https://github.com/MetaMask/metamask-mobile/blob/11ce2f3678039a73b20d5cc6e07782c5604ae24f/app/util/sentry/utils.js#L44-L51

This doesn't impact users and will help assess the underlying error causing the spike

## **Related issues**

Fixes: #9221

## **Manual testing steps**

Same as: #8584

In below example, triggered by a button in: app/components/Views/OnboardingCarousel/index.js

## **Screenshots/Recordings**

<img width="1182" alt="Screenshot 2024-06-06 at 4 27 36 PM"
src="https://github.com/MetaMask/metamask-mobile/assets/1881059/6dd4a0ed-0ce6-459a-8859-9ceee85d5935">

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
leotm authored Jun 6, 2024
1 parent 11ce2f3 commit cf74dc5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/util/sentry/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ function removeDeviceName(report) {
* @param {*} report - the error event
*/
function removeSES(report) {
const stacktraceFrames = report.exception.values[0].stacktrace.frames;
const filteredFrames = stacktraceFrames.filter(
(frame) => frame.filename !== 'app:///ses.cjs',
);
report.exception.values[0].stacktrace.frames = filteredFrames;
const stacktraceFrames = report?.exception?.values[0]?.stacktrace?.frames;
if (stacktraceFrames) {
const filteredFrames = stacktraceFrames.filter(
(frame) => frame.filename !== 'app:///ses.cjs',
);
report.exception.values[0].stacktrace.frames = filteredFrames;
}
}

function rewriteReport(report) {
Expand Down

0 comments on commit cf74dc5

Please sign in to comment.