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

fix: Refactor/9083 logger class #9307

Merged
merged 6 commits into from
Apr 18, 2024
Merged

fix: Refactor/9083 logger class #9307

merged 6 commits into from
Apr 18, 2024

Conversation

Cal-L
Copy link
Contributor

@Cal-L Cal-L commented Apr 18, 2024

Description

This PR refactors the Logger class's error method to take Error object. While we updated the first parameter of the error method to be type Error, the business logic still handles string inputs to prevent breakage (in case there are strings still being passed). Furthermore, this PR converts places where strings were being passed into the error method to pass Error objects instead.

The reason for only allowing for Error objects as the input is because Sentry stack traces relies on the Error object being created at the origin of the error instead of being reconstructed in the Logger class. After these changes, we should see the correct stack trace for errors reported via Logger class.

Related issues

Fixes: #9083

Manual testing steps

  • I'd recommend setting up your own Sentry instance for testing
  • Once own Sentry instance is setup, update the sentry.properties file with your project values
  • Ensure SENTRY_DISABLE_AUTO_UPLOAD is "false"
  • Hardcode an error anywhere in the app to call Logger.error and pass in Error object
  • In the next line, hardcode an error anywhere in the app to call Logger.error and pass in string object
  • Build app in release mode
  • Trigger the errors
  • Notice the two errors show in Sentry
  • The error reported with a string will be missing the trace of the original error
  • The error reported with an error will show the correct trace of the original error

Screenshots/Recordings

Before

Stack trace doesn't show origin of error since Logger.error was passed a string
image

After

Stack trace shows origin of error after Logger.error is passed an Error object
image

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). 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.

@Cal-L Cal-L requested review from a team as code owners April 18, 2024 03:44
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@Cal-L Cal-L added team-mobile-platform needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. and removed No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. labels Apr 18, 2024
@Cal-L Cal-L added the Run Smoke E2E Triggers smoke e2e on Bitrise label Apr 18, 2024
Copy link
Contributor

github-actions bot commented Apr 18, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: d3fa3b2
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/26fb6051-f260-4676-b0fe-0b1d3e5375c6

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@Cal-L Cal-L added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Apr 18, 2024
Copy link
Contributor

github-actions bot commented Apr 18, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 687807e
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/add177a4-a772-4b07-b90a-3082e0b1183c

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@Cal-L
Copy link
Contributor Author

Cal-L commented Apr 18, 2024

E2E failure not related to this PR

Copy link

sonarcloud bot commented Apr 18, 2024

Copy link
Member

@wachunei wachunei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
Please fill the PR description properly for ruture reference and ease of search and tracking:

  • issue link
  • manual testing (even if just running a unit test and checking it works)
  • check boxes in checklist, just to show you considered each item

@Cal-L
Copy link
Contributor Author

Cal-L commented Apr 18, 2024

Looks good to me. Please fill the PR description properly for ruture reference and ease of search and tracking:

  • issue link
  • manual testing (even if just running a unit test and checking it works)
  • check boxes in checklist, just to show you considered each item

Thanks for the reminder! Updated ticket description to match just that 👍

@Cal-L Cal-L merged commit e1a3ada into main Apr 18, 2024
46 of 47 checks passed
@Cal-L Cal-L deleted the refactor/9083-logger-class branch April 18, 2024 16:35
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2024
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Apr 18, 2024
@metamaskbot metamaskbot added the release-7.22.0 Issue or pull request that will be included in release 7.22.0 label Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. release-7.22.0 Issue or pull request that will be included in release 7.22.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Refactor Logger class to take only Error types
4 participants