You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(runway): cherry-pick feat: return actual host for known public domains in analytics cp-7.64.0 (#25448)
- feat: return actual host for known public domains in analytics
cp-7.64.0 (#25385)
## **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**
```gherkin
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**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Mainly affects analytics sanitization/allowlisting for RPC endpoint
URLs, which has privacy implications if misclassified. Also adds a new
async init step during `Engine` startup (non-blocking) that could
surface new runtime errors (captured to Sentry).
>
> **Overview**
> **Improves RPC-domain analytics classification.** Adds
`isPublicRpcDomain` in `rpc-domain-utils.ts` to treat endpoints with
known public provider domains (from cached Safe Chains data and
allowlisted providers like Infura/Alchemy) as public, while still
excluding localhost/invalid/unknown domains.
>
> `isPublicEndpointUrl` (network-controller utils) now delegates to this
helper, and `Engine` asynchronously warms the RPC provider domain cache
on startup (errors reported via Sentry). Tests are expanded to cover
localhost/invalid URLs and known public providers (e.g., Alchemy).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
c976dd0. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[910d769](910d769)
Co-authored-by: cryptodev-2s <109512101+cryptodev-2s@users.noreply.github.com>
0 commit comments