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: sentry sessions #26192

Merged
merged 30 commits into from
Jul 31, 2024
Merged

fix: sentry sessions #26192

merged 30 commits into from
Jul 31, 2024

Conversation

matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Jul 29, 2024

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

Related issues

Fixes: #2555 #15691

Manual testing steps

Screenshots/Recordings

Before

After

Updated Logs

Pre-merge author checklist

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.

@matthewwalsh0 matthewwalsh0 requested review from kumavis and a team as code owners July 29, 2024 16:09
@matthewwalsh0 matthewwalsh0 added DO-NOT-MERGE Pull requests that should not be merged team-confirmations Push issues to confirmations team labels Jul 29, 2024
Base automatically changed from chore/sentry-upgrade-8 to develop July 29, 2024 16:20
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners July 29, 2024 16:20
DDDDDanica
DDDDDanica previously approved these changes Jul 29, 2024
OGPoyraz
OGPoyraz previously approved these changes Jul 30, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [67c66b0]
Page Load Metrics (303 ± 270 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint632561084723
domContentLoaded9105312713
load391768303562270
domInteractive9105312713
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 10 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 1.42 KiB (0.02%)

Copy link

codecov bot commented Jul 30, 2024

Codecov Report

Attention: Patch coverage is 18.26923% with 85 lines in your changes missing coverage. Please review.

Project coverage is 69.95%. Comparing base (aceea3b) to head (b52bd00).
Report is 11 commits behind head on develop.

Files Patch % Lines
app/scripts/lib/setupSentry.js 15.62% 81 Missing ⚠️
app/scripts/lib/sentry-filter-events.ts 0.00% 3 Missing ⚠️
app/scripts/sentry-install.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #26192      +/-   ##
===========================================
- Coverage    69.96%   69.95%   -0.01%     
===========================================
  Files         1411     1411              
  Lines        49946    49963      +17     
  Branches     13805    13800       -5     
===========================================
+ Hits         34942    34948       +6     
- Misses       15004    15015      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@matthewwalsh0 matthewwalsh0 dismissed stale reviews from OGPoyraz and DDDDDanica via c65a4d5 July 30, 2024 11:33
Copy link

socket-security bot commented Jul 30, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@sentry/[email protected] None 0 329 kB benvinegar, billyvg, evanpurkhiser, ...8 more

🚮 Removed packages: npm/@sentry/[email protected]

View full report↗︎

@matthewwalsh0 matthewwalsh0 added the team-tiger Tiger team (for tech debt reduction + performance improvements) label Jul 30, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [a081498]
Page Load Metrics (252 ± 252 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint662171124120
domContentLoaded10121343115
load461904252524252
domInteractive10121343115
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -169 Bytes (-0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 606 Bytes (0.01%)

@metamaskbot
Copy link
Collaborator

Builds ready [d6d4112]
Page Load Metrics (231 ± 244 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint603051075828
domContentLoaded8161283517
load381980231509244
domInteractive8161283517
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -169 Bytes (-0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 606 Bytes (0.01%)

Copy link

sonarcloud bot commented Jul 30, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [b52bd00]
Page Load Metrics (240 ± 257 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint663661086330
domContentLoaded982252210
load371987240536257
domInteractive982242210
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -169 Bytes (-0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 661 Bytes (0.01%)

@DDDDDanica
Copy link
Contributor

Tested locally, work as expected 👍🏻

@matthewwalsh0 matthewwalsh0 merged commit ef05a5f into develop Jul 31, 2024
78 checks passed
@matthewwalsh0 matthewwalsh0 deleted the fix/sentry-session-toggle branch July 31, 2024 10:57
@github-actions github-actions bot locked and limited conversation to collaborators Jul 31, 2024
@metamaskbot metamaskbot added the release-12.4.0 Issue or pull request that will be included in release 12.4.0 label Jul 31, 2024
@metamaskbot metamaskbot added release-12.2.0 Issue or pull request that will be included in release 12.2.0 and removed release-12.4.0 Issue or pull request that will be included in release 12.4.0 labels Aug 28, 2024
@metamaskbot
Copy link
Collaborator

Missing release label release-12.2.0 on PR. Adding release label release-12.2.0 on PR and removing other release labels(release-12.4.0), as PR was cherry-picked in branch 12.2.0.

@gauthierpetetin gauthierpetetin added release-12.1.0 Issue or pull request that will be included in release 12.1.0 and removed release-12.2.0 Issue or pull request that will be included in release 12.2.0 labels Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.1.0 Issue or pull request that will be included in release 12.1.0 team-confirmations Push issues to confirmations team team-tiger Tiger team (for tech debt reduction + performance improvements)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants