Skip to content

Conversation

@gantunesr
Copy link
Member

@gantunesr gantunesr commented Nov 18, 2025

Description

Add analytics tracking for the Pin & Hide Accounts feature to understand user engagement with account organization features.

This PR implements three new Segment events:

  • Account Pinned: Tracks when users pin/unpin accounts with counts
  • Account Hidden: Tracks when users hide/unhide accounts with counts
  • Account List Viewed: Tracks account list views with pinned, hidden, and total account counts

These events enable analysis of:

  • Pin vs hide feature adoption
  • Usage trends over time
  • Average pinned/hidden accounts per user
  • Total account distribution

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

MUL-125

Requires: https://github.com/Consensys/segment-schema/pull/353

Manual testing steps

  1. Open MetaMask extension and unlock wallet
  2. Navigate to account list (click account menu)
  3. Open the three-dot menu for any account
  4. Click "Pin to top" - verify Account Pinned event fires with pinned: true and pinned_count_after
  5. Click "Unpin" - verify Account Pinned event fires with pinned: false and updated count
  6. Click "Hide account" - verify Account Hidden event fires with hidden: true and hidden_count_after
  7. Open hidden accounts list and unhide - verify Account Hidden event fires with hidden: false
  8. Close and reopen account list - verify Account List Viewed event fires with pinned_count, hidden_count, and total_accounts

Screenshots/Recordings

Before

No analytics tracking for pin/hide account features

After

Analytics


Note

Add analytics for pin/hide actions in the multichain account menu and define new event names, with count properties and related state handling.

  • Analytics
    • Add MetaMetricsEventName entries: AccountPinned, AccountHidden in shared/constants/metametrics.ts.
  • UI (MultichainAccountMenu)
    • Track events on pin/unpin and hide/unhide via MetaMetricsContext with properties pinned/hidden and pinned_count_after/hidden_count_after.
    • Use selectors getPinnedAccountsList and getHiddenAccountsList to compute post-action counts.
    • Ensure state consistency: unhide before pinning; unpin before hiding.
  • Tests
    • Update mocks to include pinnedAccountList and hiddenAccountList.
    • Verify pin/hide actions and enforced unpin/unhide ordering in multichain-account-menu.test.tsx.

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

@gantunesr gantunesr marked this pull request as ready for review November 18, 2025 18:36
@gantunesr gantunesr requested a review from a team as a code owner November 18, 2025 18:36
@github-actions
Copy link
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 team-accounts-framework Accounts Framework team INVALID-PR-TEMPLATE PR's body doesn't match template labels Nov 18, 2025
@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🔑 @MetaMask/accounts-engineers (2 files, +58 -3)
  • 📁 ui/
    • 📁 components/
      • 📁 multichain-accounts/
        • 📁 multichain-account-menu/
          • 📄 multichain-account-menu.test.tsx +2 -0
          • 📄 multichain-account-menu.tsx +56 -3

// Calculate the count after the action
const pinnedCountAfter = willBePinned
? pinnedAccountsList.length + 1
: pinnedAccountsList.length - 1;
Copy link

Choose a reason for hiding this comment

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

Bug: Account Group Pinning: Count Mismatch

The pinnedCountAfter calculation assumes only one address is added or removed, but account groups can contain multiple addresses across different chains. When pinning or unpinning a group with N addresses, the count changes by N, not 1. The calculation uses stale list values captured at render time and doesn't account for the actual number of addresses in the account group being modified.

Fix in Cursor Fix in Web

// Calculate the count after the action
const hiddenCountAfter = willBeHidden
? hiddenAccountsList.length + 1
: hiddenAccountsList.length - 1;
Copy link

Choose a reason for hiding this comment

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

Bug: Hidden Count Mismatch for Account Groups

The hiddenCountAfter calculation assumes only one address is added or removed, but account groups can contain multiple addresses across different chains. When hiding or unhiding a group with N addresses, the count changes by N, not 1. The calculation uses stale list values captured at render time and doesn't account for the actual number of addresses in the account group being modified.

Fix in Cursor Fix in Web

@metamaskbot
Copy link
Collaborator

Builds ready [2db678e]
UI Startup Metrics (1248 ± 93 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1248107715569313161388
load108394513898811461222
domContentLoaded107794013778711381215
domInteractive2414131212079
firstPaint60686133843310741222
backgroundConnect2372242637240255
firstReactRender28194852939
getState21876112442
initialActions104112
loadScripts846710114186916982
setupStore1061921215
numNetworkReqs1367419671
BrowserifyPower User HomeuiStartup22651866295622823612956
load12131032179822314641798
domContentLoaded11901015178722614481787
domInteractive682720158129201
firstPaint973296179246414911792
backgroundConnect2582472676262267
firstReactRender86531382497138
getState22515133353276333
initialActions20113211
loadScripts956783153121812161531
setupStore281156103156
numNetworkReqs1239518730159187
WebpackStandard HomeuiStartup83269713761048271118
load609552105589602899
domContentLoaded602546102284596883
domInteractive1812165191458
firstPaint204611031198207609
backgroundConnect251377162572
firstReactRender3219218203538
getState1162431217
initialActions105111
loadScripts599545101282594873
setupStore1265471217
numNetworkReqs1367720871
WebpackPower User HomeuiStartup1063928141017111681410
load67257610241397831024
domContentLoaded65857210111357441011
domInteractive39131394489139
firstPaint3547210143287491014
backgroundConnect36111423145142
firstReactRender42385644256
getState1336116228149162
initialActions101011
loadScripts65457010011327321001
setupStore106266826
numNetworkReqs79651222083122
FirefoxBrowserifyStandard HomeuiStartup14401292209513314821651
load1217111015348512621396
domContentLoaded1217110915348512611396
domInteractive53332823853143
firstPaint------
backgroundConnect4324165244887
firstReactRender26224332734
getState1073941016
initialActions102122
loadScripts1191109315167912351365
setupStore12771111137
numNetworkReqs1266114757
BrowserifyPower User HomeuiStartup34262642448654838284486
load15951341222927317852229
domContentLoaded15941340222927317852229
domInteractive28592896228538896
firstPaint------
backgroundConnect741147129335811071293
firstReactRender83611051392105
getState181107600112189600
initialActions217137
loadScripts15411296219527117212195
setupStore853818437103184
numNetworkReqs1277423658206236
WebpackStandard HomeuiStartup16511467222513916581982
load13971261180710014261628
domContentLoaded13971261180710014261628
domInteractive60331782868118
firstPaint------
backgroundConnect46201702252108
firstReactRender352783133578
getState167155221350
initialActions203123
loadScripts1368123517279413991603
setupStore166101151349
numNetworkReqs1367018767
WebpackPower User HomeuiStartup30742545410247732144102
load16241411194818618651948
domContentLoaded16241410194718618651947
domInteractive23291566157435566
firstPaint------
backgroundConnect393149881235505881
firstReactRender866212618104126
getState1589025137187251
initialActions318238
loadScripts15811372192019018301920
setupStore892815538129155
numNetworkReqs1316924058197240
📊 Page Load Benchmark Results

Current Commit: 2db678e | Date: 11/18/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±52ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 722ms (±49ms) 🟢 | historical mean value: 724ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±13ms) 🟢 | historical mean value: 79ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 52ms 999ms 1.32s 1.08s 1.32s
domContentLoaded 722ms 49ms 693ms 1.01s 743ms 1.01s
firstPaint 76ms 13ms 60ms 192ms 84ms 192ms
firstContentfulPaint 76ms 13ms 60ms 192ms 84ms 192ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 53 Bytes (0%)
  • ui: 735 Bytes (0.01%)
  • common: 86 Bytes (0%)

Copy link
Contributor

@owencraston owencraston left a comment

Choose a reason for hiding this comment

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

The Account Pinned/Hidden events were firing but some of the property values were not correct. I did not see the Account List Viewed event fired at all.

Here is a summary of the events that fired and some of the issues in comments

[mock-segment]: Track event received: Account Pinned
{
  "pinned": true,
  "pinned_count_after": 1,
  "category": "Accounts",
  "locale": "en",
  "chain_id": "0xaa36a7",
  "environment_type": "popup"
}

[mock-segment]: Track event received: Account Pinned
{
  "pinned": false,
  "pinned_count_after": -1, // should have been 0 since I removed the only hidden account
  "category": "Accounts",
  "locale": "en",
  "chain_id": "0xaa36a7",
  "environment_type": "popup"
}

[mock-segment]: Track event received: Account Hidden
{
  "hidden": true,
  "hidden_count_after": 1,
  "category": "Accounts",
  "locale": "en",
  "chain_id": "0xaa36a7",
  "environment_type": "popup"
}

[mock-segment]: Track event received: Account Hidden
{
  "hidden": false,
  "hidden_count_after": -1, // should have been 0 since I removed the only hidden account
  "category": "Accounts",
  "locale": "en",
  "chain_id": "0xaa36a7",
  "environment_type": "popup"
}


[mock-segment]: Track event received: Account Pinned
{
  "pinned": true,
  "pinned_count_after": 1,
  "category": "Accounts",
  "locale": "en",
  "chain_id": "0xaa36a7",
  "environment_type": "popup"
}

[mock-segment]: Track event received: Account Pinned
{
  "pinned": true,
  "pinned_count_after": 1, // should have been 2 since I had two hidden accounts
  "category": "Accounts",
  "locale": "en",
  "chain_id": "0xaa36a7",
  "environment_type": "popup"
}

[mock-segment]: Track event received: Account Hidden
{
  "hidden": true,
  "hidden_count_after": 1,
  "category": "Accounts",
  "locale": "en",
  "chain_id": "0xaa36a7",
  "environment_type": "popup"
}
[mock-segment]: Track event received: Account Hidden
{
  "hidden": true,
  "hidden_count_after": 1, should have been 2 since I hid two accounts
  "category": "Accounts",
  "locale": "en",
  "chain_id": "0xaa36a7",
  "environment_type": "popup"
}
[mock-segment]: Track event received: Account Hidden
{
  "hidden": false,
  "hidden_count_after": -1, // should have been 1 since there was one hidden account
  "locale": "en",
  "chain_id": "0xaa36a7",
  "environment_type": "popup"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template size-S team-accounts-framework Accounts Framework team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants