Skip to content

feat: split request_source to distinguish SDKv1 from MWP#28697

Merged
adonesky1 merged 2 commits intomainfrom
feat/split-request-source-sdkv1-mwp
Apr 13, 2026
Merged

feat: split request_source to distinguish SDKv1 from MWP#28697
adonesky1 merged 2 commits intomainfrom
feat/split-request-source-sdkv1-mwp

Conversation

@adonesky1
Copy link
Copy Markdown
Contributor

@adonesky1 adonesky1 commented Apr 10, 2026

Summary

Both SDKv1 (socket relay) and MWP/SDKv2 connections produced the same request_source value (MetaMask-SDK-Remote-Conn) on RPC pipeline events (Transaction Added, Signature Requested, etc.), making them indistinguishable in analytics.

Adds a transport field (socket_relay | mwp) to the analytics param passed to getRpcMethodMiddleware and branches getSource() on it:

  • SDKv1: MetaMask-SDK-Remote-Conn (unchanged — preserves data continuity)
  • MWP/V2: MetaMask-Connect (new)

Related

Test plan

  • Connect via SDKv1 → trigger a signature or transaction → verify request_source is MetaMask-SDK-Remote-Conn
  • Connect via MWP/V2 → trigger a signature or transaction → verify request_source is MetaMask-Connect
  • WalletConnect and in-app browser request_source values unchanged

Note

Low Risk
Low risk: small, additive analytics metadata change that only affects how request_source is computed for remote SDK connections; main risk is misclassification if transport is omitted or set incorrectly.

Overview
Remote SDK connections now pass an explicit analytics transport (e.g., socket_relay vs mwp) into getRpcMethodMiddleware, and getSource() uses it to split request_source between SDKv1 socket-relay (MetaMask-SDK-Remote-Conn, unchanged) and MWP/SDKv2 (MetaMask-Connect, new).

Adds the shared TransportType enum and wires it into SDKv1 bridge setup and SDKv2 RPC bridge adapter so RPC pipeline events can be attributed correctly in analytics.

Reviewed by Cursor Bugbot for commit e27ae07. Bugbot is set up for automated code reviews on this repo. Configure here.

Previously both SDKv1 (socket relay) and MWP/SDKv2 connections produced
the same request_source value 'MetaMask-SDK-Remote-Conn' on RPC pipeline
events (Transaction Added, Signature Requested, etc.), making them
indistinguishable in analytics.

Adds a transport field ('socket_relay' | 'mwp') to the analytics param
passed to getRpcMethodMiddleware, and branches getSource() on it:
- SDKv1: 'MetaMask-SDK-Remote-Conn' (unchanged, preserves data continuity)
- MWP/V2: 'MetaMask-Connect' (new)

Relates to WAPI-1398.
@adonesky1 adonesky1 requested a review from a team as a code owner April 10, 2026 23:04
@github-actions
Copy link
Copy Markdown
Contributor

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.

@metamaskbot metamaskbot added the team-wallet-integrations Wallet Integrations team label Apr 10, 2026
@github-actions github-actions Bot added size-S risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@wenfix wenfix added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Apr 13, 2026
wenfix
wenfix previously approved these changes Apr 13, 2026
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Apr 13, 2026
ffmcgee725
ffmcgee725 previously approved these changes Apr 13, 2026
Centralizes transport values (socket_relay, mwp, walletconnect) in a
TransportType constant alongside SourceType in useAnalytics.types.ts,
replacing scattered magic strings in the RPC middleware and bridge code.
@adonesky1 adonesky1 dismissed stale reviews from ffmcgee725 and wenfix via e27ae07 April 13, 2026 14:45
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeConfirmations, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeMultiChainAPI
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR introduces transport type differentiation for SDK connections in the RPC middleware layer:

  1. New TransportType enum (SOCKET_RELAY, MWP, WALLETCONNECT) added to analytics types - used to identify the underlying connection transport.

  2. New MM_CONNECT request source in AppConstants - a new source label for MWP (MetaMask Wallet Protocol) connections.

  3. RPCMethodMiddleware.getSource() now returns MM_CONNECT for MWP transport connections instead of SDK_REMOTE_CONN. This is the most impactful change as it affects how RPC requests are tagged/tracked.

  4. getDefaultBridgeParams.ts and setupBridge.ts (SDKConnect/socket relay path): Now explicitly tag analytics with SOCKET_RELAY transport.

  5. rpc-bridge-adapter.ts (SDKConnectV2/MWP path): Now explicitly tags analytics with MWP transport.

Risk Assessment:

  • The changes are primarily analytics/metadata changes - they don't alter RPC routing logic or permission checks
  • However, RPCMethodMiddleware is a critical path for ALL dApp interactions
  • The getSource() function change could affect any downstream logic that uses the source value (e.g., PPOM security checks, event tracking)
  • SDKConnectV2 (MWP) is the newer QR-based connection mechanism
  • These changes affect dApp connection flows, confirmations, and chain permissions

Selected Tags:

  • SmokeConfirmations: RPCMethodMiddleware is used in all transaction/signature confirmation flows; the source differentiation could affect confirmation behavior
  • SmokeNetworkAbstractions: Chain permission system uses RPC middleware; dApp chain switch requests go through this path
  • SmokeNetworkExpansion: Solana/multi-chain connections use the SDK connection infrastructure; MWP transport is relevant here
  • SmokeMultiChainAPI: CAIP-25 session management uses RPC middleware for dApp connections; the source tracking affects session handling

Tags NOT selected: SmokeAccounts, SmokeIdentity, SmokeTrade, SmokeWalletPlatform, SmokeRamps, SmokeCard, SmokePerps, SmokePredictions, SmokeSeedlessOnboarding, FlaskBuildTests - these are not directly affected by SDK connection transport type differentiation.

Performance Test Selection:
The changes are purely analytics/metadata differentiation for SDK connection transport types. No UI rendering, state management, data loading, or critical user flow performance is affected. The getSource() function change is a simple conditional check with negligible performance impact. No performance tests are warranted.

View GitHub Actions results

Copy link
Copy Markdown
Contributor

@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 1 potential issue.

Fix All in Cursor

❌ 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 e27ae07. Configure here.

export const TransportType = {
SOCKET_RELAY: 'socket_relay',
MWP: 'mwp',
WALLETCONNECT: 'walletconnect',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unused TransportType.WALLETCONNECT constant defined but never referenced

Low Severity

TransportType.WALLETCONNECT is defined but never referenced anywhere in the codebase. Only TransportType.MWP and TransportType.SOCKET_RELAY are used. WalletConnect connections pass analytics: {} (no isRemoteConn), so they bypass the transport check entirely in getSource() — making this constant unreachable by design.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e27ae07. Configure here.

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
11 value mismatches detected (expected — fixture represents an existing user).
View details

@adonesky1 adonesky1 added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit 06ce646 Apr 13, 2026
103 checks passed
@adonesky1 adonesky1 deleted the feat/split-request-source-sdkv1-mwp branch April 13, 2026 22:37
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 13, 2026
@weitingsun weitingsun added release-7.74.0 Issue or pull request that will be included in release 7.74.0 and removed INVALID-PR-TEMPLATE PR's body doesn't match template release-7.81.0 labels Apr 14, 2026
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Apr 14, 2026
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Apr 14, 2026
@adonesky1 adonesky1 restored the feat/split-request-source-sdkv1-mwp branch April 17, 2026 19:52
@adonesky1 adonesky1 deleted the feat/split-request-source-sdkv1-mwp branch April 17, 2026 20:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.74.0 Issue or pull request that will be included in release 7.74.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-S team-wallet-integrations Wallet Integrations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants