Skip to content

feat: return actual host for known public domains in analytics cp-7.64.0#25385

Merged
cryptodev-2s merged 7 commits intomainfrom
refactor/is-valid-public-domain-helper
Jan 30, 2026
Merged

feat: return actual host for known public domains in analytics cp-7.64.0#25385
cryptodev-2s merged 7 commits intomainfrom
refactor/is-valid-public-domain-helper

Conversation

@cryptodev-2s
Copy link
Copy Markdown
Contributor

@cryptodev-2s cryptodev-2s commented Jan 29, 2026

Description

Improves analytics data quality by returning the actual domain host for known public RPC providers instead of masking them as 'custom'.

  • Add isPublicRpcDomain helper in rpc-domain-utils.ts that checks if an RPC URL has a known public domain
  • Simplify isPublicEndpointUrl by using the new helper
  • sanitizeRpcUrl now returns the actual host (e.g., mainnet.infura.io, eth-mainnet.alchemyapi.io or any RPC from chainid.network) for known public domains, improving the accuracy of rpc_domain in analytics events

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/WPC-342

Manual testing steps

Feature: RPC domain analytics

  Scenario: Verify rpc_domain shows actual host when switching to public RPC via banner
    # Setup - Add Ink network with local RPC
    Given user navigates to Settings → Networks → Add Network
    And user adds Ink network (Chain ID: 57073) with local RPC endpoint: http://127.0.0.1:8545
    And user also adds public RPC endpoint: https://rpc-qnd.inkonchain.com
    And user sets the local RPC as the default endpoint
    And user switches to Ink network
    
    # Trigger degraded state
    When user disconnects local RPC (or it becomes unavailable)
    And user waits for banner showing "Still connecting to Ink..."
    
    # Trigger RPC update from banner
    Then the "Update RPC" button appears on the banner
    When user clicks "Update RPC" on the banner
    And user is navigated to Edit Network screen
    And user switches default RPC to https://rpc-qnd.inkonchain.com
    
    # Verify analytics in Segment
    When user checks Segment dashboard for "Network Connection Banner RPC Updated" event
    Then the event property from_rpc_domain should be "custom" (local RPC is private)
    And the event property to_rpc_domain should be "rpc-qnd.inkonchain.com" (known public domain)

  Scenario: Verify rpc_domain for Infura networks using Switch to MetaMask default
    # Setup - Configure Arbitrum with local RPC
    Given user starts a local Ganache server: npx ganache --chain.chainId 42161
    And user navigates to Settings → Networks → Arbitrum One
    And user adds a new RPC endpoint: http://127.0.0.1:8545
    And user sets the local RPC as the default endpoint
    
    # Trigger degraded state
    When user stops the Ganache server (Ctrl+C)
    And user waits for banner showing "Still connecting to Arbitrum One..."
    
    # Switch to Infura via banner button
    Then the "Switch to MetaMask default RPC" button appears on the banner
    When user clicks "Switch to MetaMask default RPC"
    Then the toast "Updated to MetaMask default" appears
    
    # Verify analytics
    When user checks Segment for "Network Connection Banner Switch To MetaMask Default RPC Clicked"
    Then rpc_domain should be "custom" (the local RPC being switched from)

Screenshots/Recordings

N/A - Internal analytics improvement, no UI changes.

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

Medium Risk
Changes the logic that decides whether an RPC URL is safe to include in analytics, which could affect privacy/data reporting if domains are misclassified. Also adds a new async initialization step during Engine startup (non-blocking) that reports failures to Sentry.

Overview
Improves RPC-domain analytics by recognizing known public RPC provider domains (e.g., Infura/Alchemy and domains learned from cached safe-chain RPC lists) as safe to report, so metrics can record the real host instead of lumping these under custom.

Adds isPublicRpcDomain to rpc-domain-utils and wires it into isPublicEndpointUrl in network-controller utilities; Engine now asynchronously preloads the provider-domain cache on startup and captures init errors via Sentry. Updates unit tests to cover invalid/localhost URLs and known public provider domains.

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

@cryptodev-2s cryptodev-2s requested a review from mcmire January 29, 2026 14:47
@cryptodev-2s cryptodev-2s self-assigned this Jan 29, 2026
@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.

@cryptodev-2s cryptodev-2s force-pushed the refactor/is-valid-public-domain-helper branch from 1a3e690 to c57a859 Compare January 29, 2026 14:47
@metamaskbot metamaskbot added the team-core-platform Core Platform team label Jan 29, 2026
@cryptodev-2s cryptodev-2s force-pushed the refactor/is-valid-public-domain-helper branch from c57a859 to 053a3a6 Compare January 29, 2026 14:50
@cryptodev-2s cryptodev-2s marked this pull request as ready for review January 29, 2026 14:54
@cryptodev-2s cryptodev-2s force-pushed the refactor/is-valid-public-domain-helper branch from 053a3a6 to 94e1850 Compare January 29, 2026 14:59
@cryptodev-2s cryptodev-2s force-pushed the refactor/is-valid-public-domain-helper branch from 94e1850 to 31cac05 Compare January 29, 2026 15:28
Previously, sanitizeRpcUrl returned 'custom' for all non-Infura/Quicknode
endpoints. Now it returns the actual domain host for known public providers
(Infura, Alchemy, etc.), improving analytics data quality.
@cryptodev-2s cryptodev-2s force-pushed the refactor/is-valid-public-domain-helper branch from 31cac05 to 5009a46 Compare January 29, 2026 16:33
@cryptodev-2s cryptodev-2s requested a review from a team as a code owner January 29, 2026 19:03
@cryptodev-2s cryptodev-2s requested a review from mcmire January 29, 2026 19:15
@cryptodev-2s cryptodev-2s requested a review from mcmire January 29, 2026 19:39
@github-actions github-actions bot added size-M and removed size-S labels Jan 29, 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.

@github-actions github-actions bot added size-S and removed size-M labels Jan 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes add RPC domain validation functionality for analytics purposes:

  1. Engine.ts: Adds async initialization of initializeRpcProviderDomains() during Engine startup. This is non-blocking and errors are captured via Sentry. While Engine.ts is critical, this change is additive and doesn't modify existing initialization order or controller dependencies.

  2. rpc-domain-utils.ts: Adds a new isPublicRpcDomain() function that checks if an RPC endpoint URL has a valid public domain by extracting the domain and verifying it's not private, invalid, or unknown.

  3. network-controller/utils.ts: Extends isPublicEndpointUrl() to also check isPublicRpcDomain() as an additional condition for determining if an endpoint is public.

The isPublicEndpointUrl function is used in:

  • Network settings UI (NetworkSettings/index.js) - for displaying network configuration
  • Network connection banner hook (useNetworkConnectionBanner) - for showing connection status
  • Network controller messenger action handlers - for RPC service events

These changes are focused on network-related analytics and validation, not core transaction or account flows. The changes are well-tested with comprehensive unit tests. SmokeNetworkAbstractions is the appropriate tag as it covers network management, network selection, and network-related UI components.

Performance Test Selection:
The changes are focused on RPC domain validation for analytics purposes. The new initializeRpcProviderDomains() function runs asynchronously and doesn't block Engine initialization. The isPublicRpcDomain() function is a simple synchronous check that extracts a domain from a URL and checks against a cached set. These changes don't impact UI rendering performance, data loading patterns, or critical user flows. No performance tests are needed.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@cryptodev-2s cryptodev-2s disabled auto-merge January 30, 2026 13:53
@cryptodev-2s cryptodev-2s changed the title feat: return actual host for known public domains in analytics feat: return actual host for known public domains in analytics cp-7.64.0 Jan 30, 2026
@cryptodev-2s cryptodev-2s added this pull request to the merge queue Jan 30, 2026
Merged via the queue into main with commit 910d769 Jan 30, 2026
103 checks passed
@cryptodev-2s cryptodev-2s deleted the refactor/is-valid-public-domain-helper branch January 30, 2026 16:01
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2026
@metamaskbot metamaskbot added the release-7.65.0 Issue or pull request that will be included in release 7.65.0 label Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.65.0 Issue or pull request that will be included in release 7.65.0 size-S team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants