From f507ebe5044faccacd5cf3689b089e859e03987c Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 21 Mar 2024 12:14:09 -0500 Subject: [PATCH] fix: Prevent trackEvent being called multiple times for --- ui/components/app/asset-list/asset-list.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ui/components/app/asset-list/asset-list.js b/ui/components/app/asset-list/asset-list.js index 154454e42de1..7827576c9588 100644 --- a/ui/components/app/asset-list/asset-list.js +++ b/ui/components/app/asset-list/asset-list.js @@ -64,13 +64,13 @@ const AssetList = ({ onClickAsset }) => { const selectedAccountBalance = useSelector(getSelectedAccountCachedBalance); const nativeCurrency = useSelector(getNativeCurrency); const showFiat = useSelector(getShouldShowFiat); - const currentNetwork = useSelector(getCurrentNetwork); + const { chainId, nickname } = useSelector(getCurrentNetwork); const currentLocale = useSelector(getCurrentLocale); const isMainnet = useSelector(getIsMainnet); const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences); const { ticker, type } = useSelector(getProviderConfig); const isOriginalNativeSymbol = useIsOriginalNativeTokenSymbol( - currentNetwork.chainId, + chainId, ticker, type, ); @@ -132,9 +132,9 @@ const AssetList = ({ onClickAsset }) => { event: MetaMetricsEventName.EmptyBuyBannerDisplayed, category: MetaMetricsEventCategory.Navigation, properties: { - chain_id: currentNetwork.chainId, + chain_id: chainId, locale: currentLocale, - network: currentNetwork.nickname, + network: nickname, referrer: ORIGIN_METAMASK, }, }); @@ -144,9 +144,9 @@ const AssetList = ({ onClickAsset }) => { event: MetaMetricsEventName.EmptyReceiveBannerDisplayed, category: MetaMetricsEventCategory.Navigation, properties: { - chain_id: currentNetwork.chainId, + chain_id: chainId, locale: currentLocale, - network: currentNetwork.nickname, + network: nickname, referrer: ORIGIN_METAMASK, }, }); @@ -155,7 +155,8 @@ const AssetList = ({ onClickAsset }) => { shouldShowBuy, shouldShowReceive, trackEvent, - currentNetwork, + chainId, + nickname, currentLocale, ]); @@ -194,7 +195,7 @@ const AssetList = ({ onClickAsset }) => { properties: { location: 'Home', text: 'Buy', - chain_id: currentNetwork.chainId, + chain_id: chainId, token_symbol: defaultSwapsToken, }, });