-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Create custom spans for account overview tabs (#28086)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28086?quickstart=1) ### Motivation - Creating a Sentry custom span that would capture this performance issue: - #27500 - It was determined that the issue is not captured by the existing "UI Startup" custom span (MetaMask/MetaMask-planning#3398). ### Approach I've decided to widen the scope of this ticket so that it covers performance issues with all accounts in general (not just those created with the `account-watcher` snap). To this end, I've defined three new custom spans: - `'Account Overview - Asset List Tab'` - `'Account Overview - Nfts Tab'` - `'Account Overview - Activity Tab'` #### Behavior - **Triggers** a) when an account list item is clicked in the account list menu component, or b) when an account overview tab (e.g. "Tokens", "NFTs", "Activity") is clicked, or c) (Only for `"Account Overview - Asset List Tab"`) the "Import" button in the detected token selection popover is clicked. - **Terminates** when one of the following happens (race): - A different account is clicked in the account list menu. - An account overview tab is clicked. - The newly selected tab component finishes loading -- including its resources. - If there is no data to display, the loading spinner/message disappears, and the appropriate filler content renders. #### Helpers - Added selector for the `defaultHomeActiveTabName` property of the `metamask` slice. - Added enum `AccountOverviewTabKey` and objects `ACCOUNT_OVERVIEW_TAB_KEY_TO_METAMETRICS_EVENT_NAME_MAP`, `ACCOUNT_OVERVIEW_TAB_KEY_TO_TRACE_NAME_MAP`. ### Results - The custom spans function as expected. - The spans successfully distinguish periods of inactivity with loading time. - The spans continue to capture delays while the UI toggles between accounts and account overview tabs. <img width="1677" alt="Screenshot 2024-11-12 at 8 52 58 AM" src="https://github.com/user-attachments/assets/62eda693-f488-46f5-a808-6f25a1763d52"> - The custom spans capture the performance issues that motivated this ticket - #27500 (see 1.46m long Nfts Tab span and 5.49s Asset List Tab span) <img width="1214" alt="Screenshot 2024-11-13 at 1 24 17 AM" src="https://github.com/user-attachments/assets/9c1f0108-f194-4074-bcc4-1a96f94781d5"> - #28130 (see 1.28m long Nfts Tab span and Error message: "Cannot destructure property 'imageOriginal' ...") <img width="1214" alt="Screenshot 2024-11-13 at 1 30 00 AM" src="https://github.com/user-attachments/assets/9baaf40c-d4da-465b-aef5-cbd684d6f450"> ## **Related issues** - Closes MetaMask/MetaMask-planning#3516 ## **Manual testing steps** 1. Click one or more of the account overview tabs ("Tokens", "NFTs", "Activity"). 2. Click Account Menu 3. Switch account and repeat. - Add accounts as necessary. - For load testing, add whale account(s) using the experimental "Watch Account" feature. ## **Screenshots/Recordings** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.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.
- Loading branch information
Showing
16 changed files
with
113 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { TraceName } from '../lib/trace'; | ||
import { MetaMetricsEventName } from './metametrics'; | ||
|
||
export enum AccountOverviewTabKey { | ||
Tokens = 'tokens', | ||
Nfts = 'nfts', | ||
Activity = 'activity', | ||
} | ||
|
||
export const ACCOUNT_OVERVIEW_TAB_KEY_TO_METAMETRICS_EVENT_NAME_MAP = { | ||
[AccountOverviewTabKey.Tokens]: MetaMetricsEventName.TokenScreenOpened, | ||
[AccountOverviewTabKey.Nfts]: MetaMetricsEventName.NftScreenOpened, | ||
[AccountOverviewTabKey.Activity]: MetaMetricsEventName.ActivityScreenOpened, | ||
} as const; | ||
|
||
export const ACCOUNT_OVERVIEW_TAB_KEY_TO_TRACE_NAME_MAP = { | ||
[AccountOverviewTabKey.Tokens]: TraceName.AccountOverviewAssetListTab, | ||
[AccountOverviewTabKey.Nfts]: TraceName.AccountOverviewNftsTab, | ||
[AccountOverviewTabKey.Activity]: TraceName.AccountOverviewActivityTab, | ||
} as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { AccountOverviewTabKey } from '../../../../shared/constants/app-state'; | ||
|
||
export type AccountOverviewCommonProps = { | ||
onTabClick: (tabName: string) => void; | ||
setBasicFunctionalityModalOpen: () => void; | ||
///: BEGIN:ONLY_INCLUDE_IF(build-main) | ||
onSupportLinkClick: () => void; | ||
///: END:ONLY_INCLUDE_IF | ||
defaultHomeActiveTabName: string; | ||
defaultHomeActiveTabName: AccountOverviewTabKey | null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters