Conversation
- Use RPC_METHODS.* constants in ANALYTICS_TRACKED_RPC_METHODS and add case-sensitivity comment documenting intentional behaviour - Add transport_type/rpc_method properties assertion to analytics tests in connectToChannel, handleConnectionMessage, and handleSendMessage
|
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. |
| // Comparison is intentionally case-sensitive: RPC method names are standardised | ||
| // and the SDK is expected to send them in canonical casing. |
There was a problem hiding this comment.
| // Comparison is intentionally case-sensitive: RPC method names are standardised | |
| // and the SDK is expected to send them in canonical casing. |
Align event names with segment-schema PR #512 review feedback: - wallet_connection_request_received → MMConnect Request Received - wallet_action_received → SDK RPC Request Received - wallet_action_user_approved → SDK RPC Request Approved - wallet_action_user_rejected → SDK RPC Request Rejected Uses Title Case "Object + Past-tense Verb" naming per repo conventions. Enum keys updated accordingly (MMCONNECT_REQUEST_RECEIVED, SDK_RPC_REQUEST_RECEIVED, etc.).
The event fires for all remote connection paths (SDK v1 socket relay, MetaMask Connect / MWP, and eventually WalletConnect), not just MMConnect. "Remote" correctly scopes it to connections that have a pre-permission lifecycle step distinct from the transport-agnostic Connect Request Started/Completed/Cancelled family.
Rename events to reflect cross-transport scope: - SDK RPC Request Received → Remote Connection RPC Request Received - SDK RPC Request Approved → Remote Connection RPC Request Approved - SDK RPC Request Rejected → Remote Connection RPC Request Rejected These events track post-connection RPC method calls from remotely connected dapps. Renaming from "SDK" to "Remote Connection" aligns with the segment-schema PR (Consensys/segment-schema#520) and sets up the schema for future MWP and WalletConnect instrumentation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #28322 +/- ##
==========================================
- Coverage 82.66% 82.12% -0.54%
==========================================
Files 4866 4911 +45
Lines 126134 129040 +2906
Branches 28268 28757 +489
==========================================
+ Hits 104273 105979 +1706
- Misses 14660 15790 +1130
- Partials 7201 7271 +70 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if (anonId) { | ||
| DevLogger.log( | ||
| `[MM SDK Analytics] event=wallet_connection_request_received anonId=${anonId}`, | ||
| `[MM SDK Analytics] event=Remote Connect Request Received anonId=${anonId}`, |
There was a problem hiding this comment.
| `[MM SDK Analytics] event=Remote Connect Request Received anonId=${anonId}`, | |
| `[MM SDK Analytics] event=${MetaMetricsEvents.REMOTE_CONNECT_REQUEST_RECEIVED} anonId=${anonId}`, |
is this a valid suggestion ? I'm assuming the value of MetaMetricsEvents.REMOTE_CONNECT_REQUEST_RECEIVED is what we want here
| @@ -180,9 +188,17 @@ async function connectToChannel({ | |||
| DevLogger.log( | |||
| `[MM SDK Analytics] event=wallet_connection_user_approved anonId=${anonId}`, | |||
There was a problem hiding this comment.
| `[MM SDK Analytics] event=wallet_connection_user_approved anonId=${anonId}`, | |
| `[MM SDK Analytics] event=${MetaMetricsEvents.WALLET_CONNECTION_USER_APPROVED} anonId=${anonId}`, |
same here if valid, even though you did not touch this piece of code, might as well do some cleaning (IF MetaMetricsEvents.WALLET_CONNECTION_USER_APPROVED is wallet_connection_user_approved which I'm not 100% sure of)
| @@ -193,20 +209,21 @@ async function connectToChannel({ | |||
| DevLogger.log( | |||
| `[MM SDK Analytics] event=wallet_connection_user_rejected anonId=${anonId}`, | |||
| if (anonId && ANALYTICS_TRACKED_RPC_METHODS.includes(message.method)) { | ||
| DevLogger.log( | ||
| `[MM SDK Analytics] event=wallet_action_received anonId=${anonId}`, | ||
| `[MM SDK Analytics] event=Remote Connection RPC Request Received anonId=${anonId}`, |
…1 events (#28390) ## Summary Same rationale as the V2 cleanup (#28358): V1 connections flow through the connection approval UI, which already fires `CONNECT_REQUEST_COMPLETED` / `CONNECT_REQUEST_CANCELLED`. Adding `wallet_connection_user_approved` / `wallet_connection_user_rejected` in the relay layer re-implements the same signal. **Removed:** * `wallet_connection_user_approved` tracking from `connectToChannel.ts` * `wallet_connection_user_rejected` tracking from `connectToChannel.ts` * Both event definitions from `MetaMetrics.events.ts` * Both test cases from `connectToChannel.test.ts` **Kept** (no existing MetaMetrics event covers these): * `Remote Connect Request Received` — fires before the permission check, needed to measure dapp-to-wallet drop-off * `Remote Connection RPC Request *` events — track per-RPC-method confirmation lifecycle, separate concern from connection approval **Renames in latest commit:** The `SDK RPC Request *` events have been renamed to `Remote Connection RPC Request *` to reflect their intended cross-transport scope. Currently only SDKv1 is instrumented but the schema supports `socket_relay`, `mwp`, and `walletconnect` transports. **Context:** The `useOriginSource` fix (WAPI-1380, #28290) ensures the `source` property is correct for both V1 and V2 connections on all permission events, so the existing events already carry the right attribution. ## Related schema PRs - [Consensys/segment-schema#519](Consensys/segment-schema#519) — `Remote Connect Request Received/Failed` schemas - [Consensys/segment-schema#520](Consensys/segment-schema#520) — `Remote Connection RPC Request Received/Approved/Rejected` schemas ## Test plan * `connectToChannel.test.ts` — all remaining tests pass * `handleConnectionMessage.test.ts` — updated for new event names * `handleSendMessage.test.ts` — updated for new event names <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: removes redundant MetaMetrics tracking and associated tests, with no changes to connection/permission behavior beyond analytics emission. > > **Overview** > Removes the SDK v1 relay-layer MetaMetrics events `wallet_connection_user_approved` and `wallet_connection_user_rejected`, including their definitions in `MetaMetrics.events.ts`. > > `connectToChannel.ts` no longer emits these events on `checkPermissions` success/failure, relying instead on the permission UI’s existing `CONNECT_REQUEST_COMPLETED` / `CONNECT_REQUEST_CANCELLED` tracking. The corresponding unit tests asserting those emissions are deleted and replaced with a clarifying comment. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1dc8ab6. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
- Rename `Remote Connect Request Received` → `Remote Connection Request Received` to match the finalized naming convention in segment-schema PR #519 - Rename `anon_id` property → `remote_session_id` across all remote connection/RPC analytics events for clarity - Update corresponding test assertions
…rties Aligns with the decision in PR #28470 — remote_session_id is a dapp-generated UUID for cross-side analytics correlation, not sensitive data. Keeping it in sensitiveProperties triggered the anonymous event split which prevented linking dapp sessions to wallet user activity.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 72d6d97. Configure here.
Aligns event names with the merged schema change in Consensys/segment-schema#526 which renamed "Remote Connection RPC Request *" → "SDK Legacy RPC Request *" to reflect that these events are SDKv1-only. Also removes unplanned wallet_version property (not in schema).
|
Pushed 2d4b465 — renamed event names from |
The comment was explaining why wallet_connection_user_approved/rejected were removed, which is useful in PR review but not in the codebase.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Why SmokeWalletPlatform: This tag covers EVM provider event handling and dApp communication flows, which exercise the SDKConnect layer. Running these tests validates that the analytics refactoring didn't accidentally break the connection flow or message handling. The changes touch core SDK connection infrastructure, so a smoke test of dApp-related functionality is prudent. Why not more tags: The changes are purely analytics instrumentation — no UI, no navigation, no transaction flows, no account management, no network switching. The risk of regression is low and confined to the SDK connection layer. Performance Test Selection: |
|
|
✅ E2E Fixture Validation — Schema is up to date |
Screen.Recording.2026-04-15.at.12.46.31.PM.movHaving trouble validating the segment events (even just in console. let alone segment) Seeing if someone can gut check me here |






Description
SDKv1 (socket relay) was tracking wallet-side analytics through two channels:
@metamask/sdk-analytics— external package with its own telemetry backend; enabled inSDKConnect.init()viaanalytics.enable().SendAnalyticsfrom@metamask/sdk-communication-layer— posted events directly tosocketServerUrl/evtBoth bypassed the MetaMetrics opt-in/opt-out pipeline entirely.
This PR removes both and replaces all call sites with
analytics.trackEvent()throughAnalyticsController.Four events are added to
MetaMetrics.events.ts:Remote Connection Request Received— fired inconnectToChannelwhen a connection request arrives (pre-permission, measures dapp→wallet drop-off)Remote Connection RPC Request Received— fired inhandleConnectionMessagewhen an RPC message arrivesRemote Connection RPC Request Approved/Remote Connection RPC Request Rejected— fired inhandleSendMessageon RPC outcomewallet_connection_user_approvedandwallet_connection_user_rejectedare intentionally omitted — the permission UI already firesCONNECT_REQUEST_COMPLETED/CONNECT_REQUEST_CANCELLEDwhich cover the same signal.A new
ANALYTICS_TRACKED_RPC_METHODSconstant inSDKConnectConstants.tsreplaces both theisAnalyticsTrackedRpcMethodhelper fromsdk-communication-layerand a local duplicate array.All events include
transport_type: 'socket_relay'to identify the SDKv1 source,rpc_methodfor RPC events,sdk_versionfromoriginatorInfo.apiVersion, andremote_session_id(a dapp-generated UUID for cross-side session correlation, kept in regular properties so the MetaMetrics privacy plugin does not split it into a separate anonymous event).Changelog
CHANGELOG entry: null
Related issues
Fixes: WAPI-1375
Manual testing steps
Screenshots/Recordings
Before
N/A — analytics-only change, no UI changes.
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Moderate risk because it changes instrumentation inside
SDKConnectconnection/RPC handling and removes the legacySendAnalyticspath; mistakes could silently drop or mislabel telemetry, but it should not affect core transaction or auth flows.Overview
Routes SDKv1 (socket relay) wallet-side analytics through the app’s MetaMetrics pipeline by replacing
@metamask/sdk-analytics/SendAnalyticsusage withanalytics.trackEvent()+AnalyticsEventBuilder.Adds four new MetaMetrics events (
REMOTE_CONNECTION_REQUEST_RECEIVED,SDK_LEGACY_RPC_REQUEST_RECEIVED,..._APPROVED,..._REJECTED) and a centralizedANALYTICS_TRACKED_RPC_METHODSallowlist, and updates unit tests accordingly; also removes@metamask/sdk-analyticsfrom dependencies and stops enabling it duringSDKConnect.init().Reviewed by Cursor Bugbot for commit fef4453. Bugbot is set up for automated code reviews on this repo. Configure here.