MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.04k stars 1.06k forks source link

fix: convert Sentry messages to log #10168

Closed NicolasMassart closed 4 days ago

NicolasMassart commented 4 days ago

Description

Convert Logger.message to Logger.log as to provide breadcrumb for next event instead of filling Sentry with events that are hitting our quotas.

Our Logger.message util internally uses Sentry captureMessage and Logger.message util internally uses Sentry addBreadcrumb.

Sentry breadcrumbs vs message

/**
 * Captures a message event and sends it to Sentry.
 *
 * @param exception The exception to capture.
 * @param captureContext Define the level of the message or pass in additional data to attach to the message.
 * @returns the id of the captured message.
 */
export declare function captureMessage(message: string, captureContext?: CaptureContext | Severity | SeverityLevel): string;

/**
 * Records a new breadcrumb which will be attached to future events.
 *
 * Breadcrumbs will be added to subsequent events to provide more context on
 * user's actions prior to an error or crash.
 *
 * @param breadcrumb The breadcrumb to record.
 */
export declare function addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): ReturnType<Hub['addBreadcrumb']>;

Improvement suggestion

In order to prevent this Logger.message to be used again I recommend to completely remove it from utils and force the use of either logs or errors. We had only 3 places it was used, as they are now removed, deleting the utility function has no impact.

Related issues

see MetaMask/mobile-planning/issues/1814

Manual testing steps

NA

Screenshots/Recordings

Before

NA

After

NA

Pre-merge author checklist

Pre-merge reviewer checklist

github-actions[bot] commented 4 days ago

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.

sonarcloud[bot] commented 4 days ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud