Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Cherry-pick of #26192 for v12.1.0. Original description: ## **Description** Fix the automatic tracking of Sentry sessions, and refactor Sentry setup to simplify logic and improve logging. Specifically: - Remove all dynamic `autoSessionTracking` enablement. - Add a custom Sentry transport to prevent any requests reaching Sentry if metrics are disabled. - Only consider metrics enabled when preference is set and onboarding is complete. - Enable Sentry if `METAMASK_ENVIRONMENT` is not `production` and `SENTRY_DSN_DEV` is specified. - Remove the arguments to the `setupSentry` function. - Since the file already references `process.env` and `global.stateHooks` internally. - Flatten all the functions within `setupSentry.js`. - Since they no longer require a dynamic `getState` callback. - Log all Sentry messages via the `debug` package based on the `DEBUG` environment variable. - Create separate loggers for UI and background to differentiate logs. - e.g. `DEBUG=metamask:sentry:*` in `.metamask.rc` - Add additional log messages for easier debug. - Including all sent events and completed sessions if `METAMASK_DEBUG` is enabled. - Add mock `SENTRY_DSN_DEV` to Flask and MMI test builds. - Remove duplication in package scripts. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26007?quickstart=1) ## **Related issues** Fixes: [#2555](MetaMask/MetaMask-planning#2555) #15691 ## **Manual testing steps** ## **Screenshots/Recordings** ### **Before** ### **After** <img width="713" alt="Updated Logs" src="https://github.com/user-attachments/assets/8351a968-baea-4cbd-b7b6-0b8000cf1a84"> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.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-extension/blob/develop/.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. Co-authored-by: Matthew Walsh <[email protected]>
- Loading branch information