feat: Accounts metrics#41918
Conversation
|
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. |
Builds ready [80fadf9]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
e99084c to
dcf4534
Compare
Builds ready [dcf4534]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [38a4058]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [bb8fc89]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [99e5c47]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
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 0716987. Configure here.
Builds ready [0716987]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
0716987 to
46225e1
Compare
a0b5d13 to
d6cacf3
Compare
Builds ready [d6cacf3]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [d651505]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
Builds ready [4a7f5aa]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|




Description
This PR adds detailed wallet composition metrics derived from the accounts controller. The goal here is to be able to answer questions about...
Fixes account wallet composition user properties that were unreliable when the wallet was locked.
Previously, several traits were derived from keyrings, which is unavailable in locked state. This PR
migrates all wallet composition traits to use internalAccounts, which is always available.
Root cause: #getNumberOfHDEntropies read from metamaskState.keyrings, returning stale/empty data when
locked.
Fix: Replaced with #getAccountCompositionTraits, a single O(n) pass over internalAccounts.accounts that
computes all wallet composition traits atomically.
New/updated user properties schema
Total wallet count can be derived in Segment as:
number_of_hd_entropies + number_of_hardware_wallets + number_of_imported_accounts
Test plan
groups, multiple SRPs, hardware-only wallets, imported-only accounts, unknown/missing keyring metadata,
and the total wallet derivation formula.
Mobile equivalent: MetaMask/metamask-mobile#29015
Changelog
CHANGELOG entry: Update metrics to track wallet composition (number of accounts, number of hardware wallets etc)
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/MUL-1396
Manual testing steps
node development/mock-segment.jsIdentify event receivedlogged with the correctnumber_of_account_groupslogged as well asnumber_of_hd_entropiesIdentify event receivedlogged with the updatednumber_of_account_groupsandnumber_of_imported_accountsIdentify event receivedlogged with updatednumber_of_account_groups, updatednumber_of_ledger_accountsandnumber_of_hardware_walletsScreenshots/Recordings
Before
N/A
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Changes MetaMetrics identify trait calculation and schema for wallet/account composition, which could affect analytics accuracy and downstream dashboards even though it doesn't impact core wallet operations.
Overview
Improves MetaMetrics wallet composition reporting by deriving counts from
internalAccountsinstead ofkeyrings(fixing incorrect/stale values when the wallet is locked).Adds new user traits for account groups and hardware/imported account breakdown (
number_of_account_groups, per-hardware-type counts, andnumber_of_hardware_wallets), including BIP44 multichain deduping by{entropyId, groupIndex}.Updates and expands tests to cover the new trait calculations (multichain grouping, SRP entropy counting, imported vs hardware types, unknown/missing metadata), and adds test helpers for building mock internal accounts.
Reviewed by Cursor Bugbot for commit 4a7f5aa. Bugbot is set up for automated code reviews on this repo. Configure here.