Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Create custom trace to measure performance of opening the account list #27907

Merged
merged 9 commits into from
Oct 18, 2024
1 change: 1 addition & 0 deletions shared/lib/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { log as sentryLogger } from '../../app/scripts/lib/setupSentry';
* The supported trace names.
*/
export enum TraceName {
AccountList = 'Account List',
BackgroundConnect = 'Background Connect',
DeveloperTest = 'Developer Test',
FirstRender = 'First Render',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { useContext, useState, useMemo, useCallback } from 'react';
import React, {
useContext,
useState,
useMemo,
useCallback,
useEffect,
} from 'react';
import PropTypes from 'prop-types';
import { useHistory } from 'react-router-dom';
import Fuse from 'fuse.js';
Expand Down Expand Up @@ -99,6 +105,7 @@ import {
AccountConnections,
MergedInternalAccount,
} from '../../../selectors/selectors.types';
import { endTrace, TraceName } from '../../../../shared/lib/trace';
import { HiddenAccountList } from './hidden-account-list';

const ACTION_MODES = {
Expand Down Expand Up @@ -198,6 +205,9 @@ export const AccountListMenu = ({
}: AccountListMenuProps) => {
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);
useEffect(() => {
endTrace({ name: TraceName.AccountList });
}, []);
const accounts: InternalAccountWithBalance[] = useSelector(
getMetaMaskAccountsOrdered,
);
Expand Down
6 changes: 5 additions & 1 deletion ui/components/multichain/account-picker/account-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { shortenAddress } from '../../../helpers/utils/util';
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
import { getCustodianIconForAddress } from '../../../selectors/institutional/selectors';
///: END:ONLY_INCLUDE_IF
import { trace, TraceName } from '../../../../shared/lib/trace';

export const AccountPicker = ({
address,
Expand Down Expand Up @@ -58,7 +59,10 @@ export const AccountPicker = ({
<ButtonBase
className={classnames('multichain-account-picker', className)}
data-testid="account-menu-icon"
onClick={onClick}
onClick={() => {
trace({ name: TraceName.AccountList });
onClick();
}}
backgroundColor={BackgroundColor.transparent}
borderRadius={BorderRadius.LG}
ellipsis
Expand Down