Commit c21b9379 authored by eddie's avatar eddie Committed by GitHub

feat: add Peer Wallet Name to WALLET_CONNECT_TXN_COMPLETED event (#6084)

* feat: add Peer Wallet Name to WALLET_CONNECT_TXN_COMPLETED event

* fix: yarn dedup

* feat: use agent instead of name

* fix: rename name to agent
parent 1610356a
import { Trans } from '@lingui/macro'
import { sendAnalyticsEvent, user } from '@uniswap/analytics'
import { CustomUserProperties, InterfaceEventName, WalletConnectionResult } from '@uniswap/analytics-events'
import { getWalletMeta } from '@uniswap/conedison/provider/meta'
import { useWeb3React } from '@web3-react/core'
import { Connector } from '@web3-react/types'
import { WalletConnect } from '@web3-react/walletconnect'
......@@ -130,16 +131,19 @@ const sendAnalyticsEventAndUserInfo = (
account: string,
walletType: string,
chainId: number | undefined,
isReconnect: boolean
isReconnect: boolean,
peerWalletAgent: string | undefined
) => {
sendAnalyticsEvent(InterfaceEventName.WALLET_CONNECT_TXN_COMPLETED, {
result: WalletConnectionResult.SUCCEEDED,
wallet_address: account,
wallet_type: walletType,
is_reconnect: isReconnect,
peer_wallet_agent: peerWalletAgent,
})
user.set(CustomUserProperties.WALLET_ADDRESS, account)
user.set(CustomUserProperties.WALLET_TYPE, walletType)
user.set(CustomUserProperties.PEER_WALLET_AGENT, peerWalletAgent ?? '')
if (chainId) {
user.postInsert(CustomUserProperties.ALL_WALLET_CHAIN_IDS, chainId)
}
......@@ -156,7 +160,7 @@ export default function WalletModal({
ENSName?: string
}) {
const dispatch = useAppDispatch()
const { connector, account, chainId } = useWeb3React()
const { connector, account, chainId, provider } = useWeb3React()
const previousAccount = usePrevious(account)
const location = useLocation()
......@@ -212,13 +216,14 @@ export default function WalletModal({
useEffect(() => {
if (account && account !== lastActiveWalletAddress) {
const walletType = getConnectionName(getConnection(connector).type)
const peerWalletAgent = provider ? getWalletMeta(provider)?.agent : undefined
const isReconnect =
connectedWallets.filter((wallet) => wallet.account === account && wallet.walletType === walletType).length > 0
sendAnalyticsEventAndUserInfo(account, walletType, chainId, isReconnect)
sendAnalyticsEventAndUserInfo(account, walletType, chainId, isReconnect, peerWalletAgent)
if (!isReconnect) addWalletToConnectedWallets({ account, walletType })
}
setLastActiveWalletAddress(account)
}, [connectedWallets, addWalletToConnectedWallets, lastActiveWalletAddress, account, connector, chainId])
}, [connectedWallets, addWalletToConnectedWallets, lastActiveWalletAddress, account, connector, chainId, provider])
const tryActivation = useCallback(
async (connector: Connector) => {
......
......@@ -4989,10 +4989,10 @@
"@typescript-eslint/types" "5.47.0"
eslint-visitor-keys "^3.3.0"
"@uniswap/analytics-events@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.4.0.tgz#910f727bf4c72f5d1890f17daec4687dc44ee6c0"
integrity sha512-oZl2KRCSTAO8C3sxEFX6BEdGujdPs8tk/Zyx7UwOZOUDcim3mxx6rsdRvnwsAgkZAJjV9I1HSUR7JEeJmQkRmQ==
"@uniswap/analytics-events@^2.5.1":
version "2.5.1"
resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.5.1.tgz#26095391518954dd3c1248703b3996f07f034579"
integrity sha512-CkatfcWlKZFIQat+/j53AuxhpVntwrgizBYiUgnxcjVQ0Qh87XrCFqgwfTq44QD5bYwgbYjjw263MXujdEqUYg==
"@uniswap/analytics@^1.3.1":
version "1.3.1"
......
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