From 625eaa9875eb66bb5d8eb3f87366b8774fe17f51 Mon Sep 17 00:00:00 2001 From: Hemant Date: Tue, 6 Aug 2024 22:38:10 +0530 Subject: [PATCH] chore: revamped the connect wallet tracking code --- src/components/Navbar.tsx | 44 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index dcc90bf..23f744e 100755 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -69,35 +69,28 @@ export default function Navbar(props: NavbarProps) { return balance.amount; }; + useEffect(() => { + if (address) { + mixpanel.track('wallet connect trigger', { + address, + ethAmount: getTokenBalance('ETH', address), + usdcAmount: getTokenBalance('USDC', address), + strkAmount: getTokenBalance('STRK', address), + }); + } + }, [address]); + // Connect wallet using starknetkit const connectWallet = async () => { try { const result = await starknetkitConnectModal1(); connect({ connector: result.connector }); - - if (address) { - mixpanel.track('manual connect wallet', { - address, - ethAmount: getTokenBalance('ETH', address), - usdcAmount: getTokenBalance('USDC', address), - strkAmount: getTokenBalance('STRK', address), - }); - } } catch (error) { console.warn('connectWallet error', error); try { const result = await starknetkitConnectModal2(); connect({ connector: result.connector }); - - if (address) { - mixpanel.track('manual connect wallet', { - address, - ethAmount: getTokenBalance('ETH', address), - usdcAmount: getTokenBalance('USDC', address), - strkAmount: getTokenBalance('STRK', address), - }); - } } catch (error) { console.error('connectWallet error', error); alert('Error connecting wallet'); @@ -114,14 +107,6 @@ export default function Navbar(props: NavbarProps) { ); if (connectorIndex >= 0) { connect({ connector: MYCONNECTORS[connectorIndex] }); - if (address) { - mixpanel.track('auto connect wallet', { - address, - ethAmount: getTokenBalance('ETH', address), - usdcAmount: getTokenBalance('USDC', address), - strkAmount: getTokenBalance('STRK', address), - }); - } } } } catch (error) { @@ -169,6 +154,13 @@ export default function Navbar(props: NavbarProps) { {''} +