Skip to content

Conversation

@mj-kiwi
Copy link
Contributor

@mj-kiwi mj-kiwi commented Jan 6, 2026

Description

This PR improves error observability for the gator snap by introducing Sentry-based error tracking via MetaMask.

A new ErrorTracker abstraction is added, which reports errors using the snap_trackError method so that runtime failures inside snaps can be surfaced in Sentry. Since snap_trackError currently only supports a basic error payload and does not expose Sentry-specific features such as tags, relevant snap metadata (e.g. snap name) is embedded into the error message itself.

On the Sentry side, alerts are configured to filter errors originating from gator-permissions-snap and permissions-kernel-snap, and forward those errors to the team via email notifications. This allows us to proactively monitor snap errors and respond more quickly to production issues.

Related issues

Fixes: N/A

Manual testing steps

  1. Trigger a known error path inside the gator snap (e.g. throw an error from a snap handler).
  2. Verify that ErrorTracker calls snap_trackError with the expected error payload.
  3. Confirm the error appears in Sentry with the snap metadata included in the error message.
  4. Verify that the Sentry alert is triggered and an email is sent to the team for gator-related errors.

Screenshots/Recordings

Before

After

Email as below

image

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.

Note

Medium Risk
Medium risk because it changes runtime error-handling paths in both snaps and introduces fire-and-forget calls to snap_trackError, which could affect observability and (if misused) send sensitive request.params to tracking.

Overview
Adds a shared SnapErrorTracker (packages/shared/src/utils/errorTracking.ts) that reports errors via snap_trackError, including structured metadata (snap name, method, URL/status/response data, and request params) embedded in the error message.

Wires this tracker into gator-permissions-snap and permissions-kernel-snap onRpcRequest handlers, wrapping execution in try/catch to capture errors asynchronously and then rethrow the original error (with the kernel snap preserving its processing-lock behavior).

Updates shared exports/tests and adds @metamask/snaps-sdk to packages/shared dependencies to support JSON error serialization.

Written by Cursor Bugbot for commit e6cc6b0. This will update automatically on new commits. Configure here.

@mj-kiwi mj-kiwi marked this pull request as ready for review January 15, 2026 21:20
@mj-kiwi mj-kiwi requested a review from a team as a code owner January 15, 2026 21:20
@mj-kiwi mj-kiwi changed the title [DRAFT] feat: integrate error tracking service with RPC handlers feat: integrate error tracking service with RPC handlers Jan 15, 2026
Copy link
Contributor

@MoMannn MoMannn left a comment

Choose a reason for hiding this comment

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

Also some cursor bug bot things to address

@mj-kiwi mj-kiwi marked this pull request as draft January 19, 2026 19:57
@mj-kiwi mj-kiwi marked this pull request as ready for review January 27, 2026 07:47
@mj-kiwi mj-kiwi requested a review from MoMannn January 28, 2026 19:40
Copy link
Contributor

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

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

Looking really good, and we could probably ship it as is, but I've left a couple minor comments/thoughts/opinions.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Copy link
Contributor

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

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

This looks good to me!

Because we are using this in multiple places, we're having to duplicate the setup logic in the two snaps, so in the future it might be useful to look at doing something like:

const errorTracker = new ErrorTracker({...});

// ...

errorTracker.trackErrors(() => {
  // logic in which tracked error may be thrown
});

I don't think we should do this now, but it might be a nice future tidy up.

@mj-kiwi mj-kiwi dismissed MoMannn’s stale review February 1, 2026 21:38

I fixed the issues he mentioned on the PR and he is out this week.

@mj-kiwi mj-kiwi merged commit f387630 into main Feb 1, 2026
16 checks passed
@mj-kiwi mj-kiwi deleted the feat/error-tracking branch February 1, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants