feat: track connected wallet provider calls to be replaced with BE/infura (#7197)

* feat: track connected wallet provider calls to be replaced with be/infura

* update analytics events

* wrap analytics events in useEffects

* Update src/hooks/useContract.ts

Co-authored-by: Jordan Frankfurt <jordanwfrankfurt@gmail.com>

---------

Co-authored-by: Jordan Frankfurt <jordanwfrankfurt@gmail.com>
This commit is contained in:
Charles Bachmeier 2023-08-25 09:51:56 -07:00 committed by GitHub
parent 59db4c5b02
commit ce8105bf08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 8 deletions

@ -191,7 +191,7 @@
"@sentry/types": "^7.45.0",
"@types/react-window-infinite-loader": "^1.0.6",
"@uniswap/analytics": "^1.4.0",
"@uniswap/analytics-events": "^2.17.0",
"@uniswap/analytics-events": "^2.18.0",
"@uniswap/governance": "^1.0.2",
"@uniswap/liquidity-staker": "^1.0.2",
"@uniswap/merkle-distributor": "^1.0.1",

@ -1,4 +1,5 @@
import { Contract } from '@ethersproject/contracts'
import { InterfaceEventName } from '@uniswap/analytics-events'
import {
ARGENT_WALLET_DETECTOR_ADDRESS,
ChainId,
@ -26,9 +27,10 @@ import ERC721_ABI from 'abis/erc721.json'
import ERC1155_ABI from 'abis/erc1155.json'
import { ArgentWalletDetector, EnsPublicResolver, EnsRegistrar, Erc20, Erc721, Erc1155, Weth } from 'abis/types'
import WETH_ABI from 'abis/weth.json'
import { sendAnalyticsEvent } from 'analytics'
import { RPC_PROVIDERS } from 'constants/providers'
import { WRAPPED_NATIVE_CURRENCY } from 'constants/tokens'
import { useMemo } from 'react'
import { useEffect, useMemo } from 'react'
import { NonfungiblePositionManager, TickLens, UniswapInterfaceMulticall } from 'types/v3'
import { V3Migrator } from 'types/v3/V3Migrator'
import { getContract } from 'utils'
@ -145,11 +147,21 @@ export function useMainnetInterfaceMulticall() {
}
export function useV3NFTPositionManagerContract(withSignerIfPossible?: boolean): NonfungiblePositionManager | null {
return useContract<NonfungiblePositionManager>(
const { account } = useWeb3React()
const contract = useContract<NonfungiblePositionManager>(
NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
NFTPositionManagerABI,
withSignerIfPossible
)
useEffect(() => {
if (contract && account) {
sendAnalyticsEvent(InterfaceEventName.WALLET_PROVIDER_USED, {
source: 'useV3NFTPositionManagerContract',
contract,
})
}
}, [account, contract])
return contract
}
export function useTickLens(): TickLens | null {

@ -1,12 +1,14 @@
import { arrayify } from '@ethersproject/bytes'
import { parseBytes32String } from '@ethersproject/strings'
import { InterfaceEventName } from '@uniswap/analytics-events'
import { ChainId, Currency, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core'
import { sendAnalyticsEvent } from 'analytics'
import { asSupportedChain, isSupportedChain } from 'constants/chains'
import { useBytes32TokenContract, useTokenContract } from 'hooks/useContract'
import { NEVER_RELOAD, useSingleCallResult } from 'lib/hooks/multicall'
import useNativeCurrency from 'lib/hooks/useNativeCurrency'
import { useMemo } from 'react'
import { useEffect, useMemo } from 'react'
import { DEFAULT_ERC20_DECIMALS } from '../../constants/tokens'
import { TOKEN_SHORTHANDS } from '../../constants/tokens'
@ -83,6 +85,15 @@ export function useTokenFromMapOrNetwork(tokens: TokenMap, tokenAddress?: string
const token: Token | undefined = address ? tokens[address] : undefined
const tokenFromNetwork = useTokenFromActiveNetwork(token ? undefined : address ? address : undefined)
useEffect(() => {
if (tokenFromNetwork) {
sendAnalyticsEvent(InterfaceEventName.WALLET_PROVIDER_USED, {
source: 'useTokenFromActiveNetwork',
token: tokenFromNetwork,
})
}
}, [tokenFromNetwork])
return tokenFromNetwork ?? token
}

@ -6177,10 +6177,10 @@
"@typescript-eslint/types" "5.59.1"
eslint-visitor-keys "^3.3.0"
"@uniswap/analytics-events@^2.17.0":
version "2.17.0"
resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.17.0.tgz#cc0fab2737a673b740ba6d303f04eab365b1876e"
integrity sha512-8obHdI+YjfuFCcPH7XOqIDxYVMl30GSUBMZjTx9Ik5vZAXNFJpyOjBcb0aZbL5L6y3vzqkCR8HUpAgd3NuOBFA==
"@uniswap/analytics-events@^2.18.0":
version "2.18.0"
resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.18.0.tgz#22d38adcbe9c18aec7109e562fd005c0e4082edc"
integrity sha512-raJP1/xLnunxLwu6XyM4kRJuuIb4aHFR5X9fAovpR6gllpbHicwdjPnjKR5Z8DAnFe5ClFBT0T/foyE5SU5oQQ==
"@uniswap/analytics@^1.4.0":
version "1.4.0"