Skip to content

feat: Add self reported dapp url in CONNECT_REQUEST_COMPLETED event#28111

Merged
jiexi merged 6 commits intomainfrom
jl/WAPI-1338/self-reported-dapp-url-in-connection-request-completed
Apr 2, 2026
Merged

feat: Add self reported dapp url in CONNECT_REQUEST_COMPLETED event#28111
jiexi merged 6 commits intomainfrom
jl/WAPI-1338/self-reported-dapp-url-in-connection-request-completed

Conversation

@jiexi
Copy link
Copy Markdown
Member

@jiexi jiexi commented Mar 30, 2026

Description

Uses the self reported dapp url when available for the CONNECT_REQUEST_COMPLETED event when the connection is a SDKv1, SDKv2, or WC connection. It uses the trusted origin otherwise.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/WAPI-1338

Manual testing steps

  1. Establish a WC or SDKv1 or SDKv2 connection
  2. Check analytics events for a property value referrer that should be the dapp's url, not a UUID

It may be easier to use an expo build and the js debugger to view analytic network events.

Screenshots/Recordings

Before

After

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

Low Risk
Low risk analytics-only change that alters the referrer value emitted for CONNECT_REQUEST_COMPLETED, potentially affecting downstream dashboards but not user-facing behavior.

Overview
Updates analytics for connection approvals so MetaMetricsEvents.CONNECT_REQUEST_COMPLETED now reports a computed referrer (SDK/WC self-reported dapp URL when available, otherwise the trusted hostname/origin) instead of always using request.metadata.origin.

Applies the same referrer logic in both AccountConnect and MultichainAccountConnect, and wires it into the handleConnect tracking dependencies.

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

@jiexi jiexi requested a review from a team as a code owner March 30, 2026 18:36
@metamaskbot metamaskbot added the team-wallet-integrations Wallet Integrations team label Mar 30, 2026
@github-actions github-actions bot added size-S risk-low Low testing needed · Low bug introduction risk labels Mar 30, 2026
Copy link
Copy Markdown

@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.

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.

? dappUrl
: isOriginWalletConnect
? wc2Metadata?.url
: channelIdOrHostname;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

V2 SDK connections not handled in referrer computation

Medium Severity

The referrer computation only checks isOriginMMSDKRemoteConn (v1 SDK connections) but this component also supports v2 SDK connections via isOriginMMSDKV2RemoteConn. For v2 SDK connections, isOriginMMSDKRemoteConn is false, so referrer falls through to channelIdOrHostname instead of using the self-reported dapp URL from dappUrl (which already includes sdkV2Connection?.originatorInfo?.url at lines 478–481). This defeats the PR's purpose of reporting the self-reported dapp URL for SDK connections.

Fix in Cursor Fix in Web

@jiexi jiexi added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Mar 30, 2026
@jiexi jiexi changed the title jl/WAPI 1338/self reported dapp url in connection request completed WIP: self reported dapp url in connection request completed Mar 30, 2026
Comment on lines +289 to +295
// Should be the self reported dapp url if SDK or WC connection, null if no self reported dapp url.
// If not SDK or WC connection, i.e. a regular external connection, it should be the hostname.
const referrer = isOriginMMSDKRemoteConn
? dappUrl
: isOriginWalletConnect
? wc2Metadata?.url
: channelIdOrHostname;
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.

looks like dappUrl will default to '' not null? not sure about wc2Metadata?.url

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah good point. The comment is wrong. I really just want the value to be falsey here (i.e. not the channelId) when the connection is SDK or WC and the self reported dapp url is not available.

@github-actions github-actions bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 1, 2026
@jiexi jiexi changed the title WIP: self reported dapp url in connection request completed feat: Add self reported dapp url in CONNECT_REQUEST_COMPLETED event Apr 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

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.

@github-actions github-actions bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes in this PR are analytics-only fixes to the referrer field in two dApp account connection components:

  1. AccountConnect.tsx: Changed referrer from request.metadata.origin to a computed value that correctly uses dappUrl for SDK connections, wc2Metadata?.url for WalletConnect, and channelIdOrHostname for regular connections.

  2. MultichainAccountConnect.tsx: Same analytics referrer fix applied to the multichain account connect flow.

These changes do NOT affect:

  • Connection logic or permission flows
  • UI rendering
  • State management
  • Any non-analytics behavior

However, since these components are in the critical dApp connection path (both EVM and multichain), it's prudent to run tests that exercise these flows to ensure no regressions were introduced:

  • SmokeNetworkExpansion: Directly tests dApp connect/disconnect flows (Solana Wallet Standard connect.spec.ts, multiple-provider-connections.spec.ts) which use AccountConnect/MultichainAccountConnect
  • SmokeMultiChainAPI: Tests CAIP-25 session creation (wallet_createSession) which involves the account connection flow
  • SmokeNetworkAbstractions: Required by SmokeMultiChainAPI's description (permission UI integration)
  • SmokeConfirmations: Required by SmokeNetworkExpansion's description (Solana transaction/signing flows hit confirmations)

Performance tests are not warranted as these are pure analytics property changes with no UI rendering, data loading, or performance-sensitive code paths affected.

Performance Test Selection:
The changes are limited to analytics event property fixes (referrer field) in the dApp connection components. No UI rendering, state management, data loading, or performance-sensitive code paths are affected. Performance tests are not warranted.

View GitHub Actions results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

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

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

@jiexi jiexi added this pull request to the merge queue Apr 2, 2026
Merged via the queue into main with commit 0c0ad7b Apr 2, 2026
175 of 181 checks passed
@jiexi jiexi deleted the jl/WAPI-1338/self-reported-dapp-url-in-connection-request-completed branch April 2, 2026 23:04
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2026
@weitingsun weitingsun added release-7.74.0 Issue or pull request that will be included in release 7.74.0 and removed release-99999.1.0 labels Apr 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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-low Low testing needed · Low bug introduction risk size-S team-wallet-integrations Wallet Integrations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants