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

chore: Token list performance measurement #13084

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
16 changes: 11 additions & 5 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,17 @@ const App = (props) => {
const sdkInit = useRef();
const [onboarded, setOnboarded] = useState(false);

trace({
name: TraceName.NavInit,
parentContext: getUIStartupSpan(),
op: TraceOperation.NavInit,
});
const isFirstRender = useRef(true);

if (isFirstRender.current) {
trace({
name: TraceName.NavInit,
parentContext: getUIStartupSpan(),
op: TraceOperation.NavInit,
});

isFirstRender.current = false;
}

const triggerSetCurrentRoute = (route) => {
dispatch(setCurrentRoute(route));
Expand Down
15 changes: 13 additions & 2 deletions app/components/UI/Tokens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ import { selectNetworkName } from '../../../selectors/networkInfos';
import ButtonIcon from '../../../component-library/components/Buttons/ButtonIcon';
import { selectAccountTokensAcrossChains } from '../../../selectors/multichain';
import { filterAssets } from './util/filterAssets';
import { TraceName, endTrace, trace } from '../../../util/trace';
import { getTraceTags } from '../../../util/sentry/tags';
import { store } from '../../../store';


// this will be imported from TokenRatesController when it is exported from there
// PR: https://github.com/MetaMask/core/pull/4622
Expand Down Expand Up @@ -145,6 +149,10 @@ const Tokens: React.FC<TokensI> = ({ tokens }) => {
const styles = createStyles(colors);

const tokensList = useMemo((): TokenI[] => {
trace({
name: TraceName.Tokens,
tags: getTraceTags(store.getState()),
});
// if it is not popular network, display tokens only for current network
const filteredAssetsParam = isPopularNetwork
? tokenNetworkFilter
Expand Down Expand Up @@ -248,8 +256,11 @@ const Tokens: React.FC<TokensI> = ({ tokens }) => {
...token,
tokenFiatAmount: tokenFiatBalances[i],
}));

return sortAssets(tokensWithBalances, tokenSortConfig);
const tokensSorted = sortAssets(tokensWithBalances, tokenSortConfig);
endTrace({
name: TraceName.Tokens,
});
return tokensSorted;
tommasini marked this conversation as resolved.
Show resolved Hide resolved
}
// Previous implementation
// Filter tokens based on hideZeroBalanceTokens flag
Expand Down
2 changes: 0 additions & 2 deletions app/util/sentry/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,6 @@ export function setupSentry() {
beforeBreadcrumb: (breadcrumb) => rewriteBreadcrumb(breadcrumb),
beforeSendTransaction: (event) => excludeEvents(event),
enabled: metricsOptIn === AGREED,
// We need to deactivate this to have the same output consistently on IOS and Android
enableAutoPerformanceTracing: false,
});
};
init();
Expand Down
1 change: 1 addition & 0 deletions app/util/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export enum TraceName {
VaultCreation = 'Login Vault Creation',
AccountList = 'Account List',
StoreInit = 'Store Initialization',
Tokens = 'Tokens List',
}

export enum TraceOperation {
Expand Down
Loading