Commit 75175b8e authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

fix: don't track balances/values (#4539)

parent e3d8599d
import { Token } from '@uniswap/sdk-core'
import { nativeOnChain } from '../../constants/tokens'
/** /**
* Event names that can occur in this application. * Event names that can occur in this application.
* *
...@@ -41,21 +37,7 @@ export enum CUSTOM_USER_PROPERTIES { ...@@ -41,21 +37,7 @@ export enum CUSTOM_USER_PROPERTIES {
SCREEN_RESOLUTION_HEIGHT = 'screen_resolution_height', SCREEN_RESOLUTION_HEIGHT = 'screen_resolution_height',
SCREEN_RESOLUTION_WIDTH = 'screen_resolution_width', SCREEN_RESOLUTION_WIDTH = 'screen_resolution_width',
WALLET_ADDRESS = 'wallet_address', WALLET_ADDRESS = 'wallet_address',
WALLET_NATIVE_CURRENCY_AMOUNT = 'wallet_native_currency_amount',
WALLET_NATIVE_CURRENCY_BALANCE_USD = 'wallet_native_currency_balance_usd',
WALLET_TYPE = 'wallet_type', WALLET_TYPE = 'wallet_type',
WALLET_USDC_AMOUNT = 'wallet_usdc_amount',
WALLET_USDC_BALANCE_USD = 'wallet_usdc_balance_usd',
WALLET_WETH_AMOUNT = 'wallet_weth_amount',
WALLET_WETH_BALANCE_USD = 'wallet_weth_balance_usd',
}
const ETH = nativeOnChain(1)
const USDC = new Token(1, '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 6, 'USDC')
export const TOKENS_TO_TRACK = {
USDC,
WETH: ETH.wrapped,
} }
export enum BROWSER { export enum BROWSER {
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { Currency, CurrencyAmount, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { Connector } from '@web3-react/types' import { Connector } from '@web3-react/types'
import { sendAnalyticsEvent, user } from 'components/AmplitudeAnalytics' import { sendAnalyticsEvent, user } from 'components/AmplitudeAnalytics'
import { import { CUSTOM_USER_PROPERTIES, EventName, WALLET_CONNECTION_RESULT } from 'components/AmplitudeAnalytics/constants'
CUSTOM_USER_PROPERTIES,
EventName,
TOKENS_TO_TRACK,
WALLET_CONNECTION_RESULT,
} from 'components/AmplitudeAnalytics/constants'
import { formatToDecimal } from 'components/AmplitudeAnalytics/utils'
import { sendEvent } from 'components/analytics' import { sendEvent } from 'components/analytics'
import { AutoColumn } from 'components/Column' import { AutoColumn } from 'components/Column'
import { AutoRow } from 'components/Row' import { AutoRow } from 'components/Row'
import { getConnection, getConnectionName, getIsCoinbaseWallet, getIsInjected, getIsMetaMask } from 'connection/utils' import { getConnection, getConnectionName, getIsCoinbaseWallet, getIsInjected, getIsMetaMask } from 'connection/utils'
import { RedesignVariant, useRedesignFlag } from 'featureFlags/flags/redesign' import { RedesignVariant, useRedesignFlag } from 'featureFlags/flags/redesign'
import { useStablecoinValue } from 'hooks/useStablecoinPrice'
import useCurrencyBalance, { useTokenBalance } from 'lib/hooks/useCurrencyBalance'
import useNativeCurrency from 'lib/hooks/useNativeCurrency'
import { useCallback, useEffect, useState } from 'react' import { useCallback, useEffect, useState } from 'react'
import { ArrowLeft } from 'react-feather' import { ArrowLeft } from 'react-feather'
import { updateConnectionError } from 'state/connection/reducer' import { updateConnectionError } from 'state/connection/reducer'
...@@ -148,32 +138,6 @@ const sendAnalyticsEventAndUserInfo = ( ...@@ -148,32 +138,6 @@ const sendAnalyticsEventAndUserInfo = (
user.postInsert(CUSTOM_USER_PROPERTIES.ALL_WALLET_ADDRESSES_CONNECTED, account) user.postInsert(CUSTOM_USER_PROPERTIES.ALL_WALLET_ADDRESSES_CONNECTED, account)
} }
function useLogToken(
tokenBalanceUsdValue: string | undefined,
tokenBalance: CurrencyAmount<Token | Currency> | undefined,
shouldLogTokenBalance: boolean,
setShouldLogTokenBalance: (shouldLog: boolean) => void,
tokenAmountProperty: string,
tokenUsdBalanceProperty: string
) {
useEffect(() => {
if (shouldLogTokenBalance && tokenBalance && tokenBalanceUsdValue) {
const tokenBalanceUsd = tokenBalanceUsdValue ? parseFloat(tokenBalanceUsdValue) : 0
const tokenBalanceAmount = formatToDecimal(tokenBalance, tokenBalance.currency.decimals)
user.set(tokenAmountProperty, tokenBalanceAmount)
user.set(tokenUsdBalanceProperty, tokenBalanceUsd)
setShouldLogTokenBalance(false)
}
}, [
tokenBalanceUsdValue,
tokenBalance,
shouldLogTokenBalance,
setShouldLogTokenBalance,
tokenAmountProperty,
tokenUsdBalanceProperty,
])
}
export default function WalletModal({ export default function WalletModal({
pendingTransactions, pendingTransactions,
confirmedTransactions, confirmedTransactions,
...@@ -191,9 +155,6 @@ export default function WalletModal({ ...@@ -191,9 +155,6 @@ export default function WalletModal({
const redesignFlagEnabled = redesignFlag === RedesignVariant.Enabled const redesignFlagEnabled = redesignFlag === RedesignVariant.Enabled
const [walletView, setWalletView] = useState(WALLET_VIEWS.ACCOUNT) const [walletView, setWalletView] = useState(WALLET_VIEWS.ACCOUNT)
const [lastActiveWalletAddress, setLastActiveWalletAddress] = useState<string | undefined>(account) const [lastActiveWalletAddress, setLastActiveWalletAddress] = useState<string | undefined>(account)
const [shouldLogUsdcBalance, setShouldLogUsdcBalance] = useState(false)
const [shouldLogWethBalance, setShouldLogWethBalance] = useState(false)
const [shouldLogNativeBalance, setShouldLogNativeBalance] = useState(false)
const [pendingConnector, setPendingConnector] = useState<Connector | undefined>() const [pendingConnector, setPendingConnector] = useState<Connector | undefined>()
const pendingError = useAppSelector((state) => const pendingError = useAppSelector((state) =>
...@@ -203,15 +164,6 @@ export default function WalletModal({ ...@@ -203,15 +164,6 @@ export default function WalletModal({
const walletModalOpen = useModalIsOpen(ApplicationModal.WALLET) const walletModalOpen = useModalIsOpen(ApplicationModal.WALLET)
const toggleWalletModal = useToggleWalletModal() const toggleWalletModal = useToggleWalletModal()
const native = useNativeCurrency()
const usdcBalance = useTokenBalance(account, TOKENS_TO_TRACK.USDC)
const wethBalance = useTokenBalance(account, TOKENS_TO_TRACK.WETH)
const nativeCurrencyBalance = useCurrencyBalance(account, native)
const usdcBalanceUsdValue = useStablecoinValue(usdcBalance)?.toFixed(2)
const wethBalanceUsdValue = useStablecoinValue(wethBalance)?.toFixed(2)
const nativeCurrencyBalanceUsdValue = useStablecoinValue(nativeCurrencyBalance)?.toFixed(2)
const openOptions = useCallback(() => { const openOptions = useCallback(() => {
setWalletView(WALLET_VIEWS.OPTIONS) setWalletView(WALLET_VIEWS.OPTIONS)
}, [setWalletView]) }, [setWalletView])
...@@ -236,40 +188,11 @@ export default function WalletModal({ ...@@ -236,40 +188,11 @@ export default function WalletModal({
const isReconnect = const isReconnect =
connectedWallets.filter((wallet) => wallet.account === account && wallet.walletType === walletType).length > 0 connectedWallets.filter((wallet) => wallet.account === account && wallet.walletType === walletType).length > 0
sendAnalyticsEventAndUserInfo(account, walletType, chainId, isReconnect) sendAnalyticsEventAndUserInfo(account, walletType, chainId, isReconnect)
setShouldLogNativeBalance(true)
setShouldLogUsdcBalance(true)
setShouldLogWethBalance(true)
if (!isReconnect) addWalletToConnectedWallets({ account, walletType }) if (!isReconnect) addWalletToConnectedWallets({ account, walletType })
} }
setLastActiveWalletAddress(account) setLastActiveWalletAddress(account)
}, [connectedWallets, addWalletToConnectedWallets, lastActiveWalletAddress, account, connector, chainId]) }, [connectedWallets, addWalletToConnectedWallets, lastActiveWalletAddress, account, connector, chainId])
// Send wallet balances info once it becomes available.
useLogToken(
nativeCurrencyBalanceUsdValue,
nativeCurrencyBalance,
shouldLogNativeBalance,
setShouldLogNativeBalance,
CUSTOM_USER_PROPERTIES.WALLET_NATIVE_CURRENCY_AMOUNT,
CUSTOM_USER_PROPERTIES.WALLET_NATIVE_CURRENCY_BALANCE_USD
)
useLogToken(
usdcBalanceUsdValue,
usdcBalance,
shouldLogUsdcBalance,
setShouldLogUsdcBalance,
CUSTOM_USER_PROPERTIES.WALLET_USDC_AMOUNT,
CUSTOM_USER_PROPERTIES.WALLET_USDC_BALANCE_USD
)
useLogToken(
wethBalanceUsdValue,
wethBalance,
shouldLogWethBalance,
setShouldLogWethBalance,
CUSTOM_USER_PROPERTIES.WALLET_WETH_AMOUNT,
CUSTOM_USER_PROPERTIES.WALLET_WETH_BALANCE_USD
)
const tryActivation = useCallback( const tryActivation = useCallback(
async (connector: Connector) => { async (connector: Connector) => {
const connectionType = getConnection(connector).type const connectionType = getConnection(connector).type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment