Skip to content

Commit

Permalink
chore: revamped the connect wallet tracking code
Browse files Browse the repository at this point in the history
  • Loading branch information
hemantwasthere committed Aug 6, 2024
1 parent ebedf90 commit 625eaa9
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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) {
Expand Down Expand Up @@ -169,6 +154,13 @@ export default function Navbar(props: NavbarProps) {
{''}
</Text>
</Center>
<Button
onClick={() => {
mixpanel.track('click for track');
}}
>
Click for track
</Button>
<Box
width={'100%'}
maxWidth="1400px"
Expand Down

0 comments on commit 625eaa9

Please sign in to comment.