Skip to content

Commit

Permalink
feat: final
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Jan 31, 2025
1 parent eaac036 commit 155f842
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useAccount as useSatsAccount } from '@gobob/sats-wagmi';
import { SharedStoreProfileTxStatus, SharedStoreProfileTxType, ShareStoreProfileTabs, store } from '@/lib/store';
import { useGetBridgeTransactions } from '@/hooks';
import { useConnectModal } from '@/connect-ui';
import { posthogEvents } from '@/lib/posthog';

const ActivityButton = (): JSX.Element => {
const { address: evmAddress } = useAccount();
Expand All @@ -32,6 +33,8 @@ const ActivityButton = (): JSX.Element => {
}
}
}));

posthogEvents.wallet.drawer.activity('bridge');
};

const isLoggedIn = !!(evmAddress || btcAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Trans } from '@lingui/macro';

import { useConnectModal } from '@/connect-ui';
import { SharedStoreProfileTxType, ShareStoreProfileTabs, store } from '@/lib/store';
import { posthogEvents } from '@/lib/posthog';

const ActivityButton = (): JSX.Element => {
const { address: evmAddress } = useAccount();
Expand All @@ -30,6 +31,8 @@ const ActivityButton = (): JSX.Element => {
}
}
}));

posthogEvents.wallet.drawer.activity('strategies');
};

const isLoggedIn = !!(evmAddress || btcAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { chainL2 } from '@/constants';
import { useBlockscoutBalances } from '@/hooks/blockscout/useBlockscoutBalances';
import { useBlockscoutTokens } from '@/hooks/blockscout/useBlockscoutTokens';
import { calculateAmountUSD } from '@/utils';
import { posthogEvents } from '@/lib/posthog';

const ProfileBlockscoutTokenList = () => {
const { i18n } = useLingui();
Expand Down Expand Up @@ -47,9 +48,14 @@ const ProfileBlockscoutTokenList = () => {
});
};

const handleExpand = () => {
setExpanded((s) => !s);
posthogEvents.wallet.drawer.tokens.others();
};

return (
<>
<UnstyledButton aria-label={t(i18n)`show/hide other tokens list`} onPress={() => setExpanded((s) => !s)}>
<UnstyledButton aria-label={t(i18n)`show/hide other tokens list`} onPress={handleExpand}>
<Flex alignItems='center' gap='md' justifyContent='space-between' paddingX='s' paddingY='lg'>
<Span color='grey-50' size='s'>
<Trans>Others</Trans> ({list.length})
Expand Down
4 changes: 2 additions & 2 deletions apps/evm/src/components/Profile/ProfileTokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ProfileTokenListProps = {
items?: TokenData[];
currentChain: Chain;
otherChain: Chain;
onPressNavigate?: () => void;
onPressNavigate?: (symbol: string) => void;
};

const ProfileTokenList = ({ items, currentChain, otherChain, onPressNavigate }: ProfileTokenListProps) => {
Expand Down Expand Up @@ -55,7 +55,7 @@ const ProfileTokenList = ({ items, currentChain, otherChain, onPressNavigate }:
router.push(`${RoutesPath.BRIDGE}?type=deposit&network=ethereum&receive=${currency.symbol}`);
}

onPressNavigate?.();
onPressNavigate?.(currency.symbol);
};

return list?.map((item) => {
Expand Down
12 changes: 10 additions & 2 deletions apps/evm/src/components/Profile/ProfileTokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { WalletIcon } from '@/connect-ui';
import { L1_CHAIN, L2_CHAIN, RoutesPath } from '@/constants';
import { useBalances, useTokens } from '@/hooks';
import { calculateAmountUSD } from '@/utils';
import { posthogEvents } from '@/lib/posthog';

type ProfileTokensProps = {
currentChain: Chain;
Expand Down Expand Up @@ -45,6 +46,11 @@ const ProfileTokens = ({ currentChain, otherChain, onPressNavigate }: ProfileTok
(evmAddress && (isl1TokensPending || isl2TokensPending || isL1BalancesPending || isL2BalancesPending)) ||
(btcAddress && isSatsBalancePending);

const handleTokensNavigate = (symbol: string) => {
onPressNavigate?.();
posthogEvents.wallet.drawer.tokens.navigate({ ticker: symbol, to: 'bridge' });
};

return (
<Flex direction='column' elementType='ul' flex={1} marginTop='md'>
{isTokensPending ? (
Expand Down Expand Up @@ -76,23 +82,25 @@ const ProfileTokens = ({ currentChain, otherChain, onPressNavigate }: ProfileTok
onPressBridge={() => {
router.push(`${RoutesPath.BRIDGE}?type=deposit&network=bitcoin`);
onPressNavigate?.();
posthogEvents.wallet.drawer.tokens.navigate({ ticker: 'BTC', to: 'bridge' });
}}
onPressStake={() => {
router.push(RoutesPath.STRATEGIES);
onPressNavigate?.();
posthogEvents.wallet.drawer.tokens.navigate({ ticker: 'BTC', to: 'stake' });
}}
/>
<ProfileTokenList
currentChain={currentChain}
items={currentChain.id === L1_CHAIN ? l1Tokens : l2Tokens}
otherChain={otherChain}
onPressNavigate={onPressNavigate}
onPressNavigate={handleTokensNavigate}
/>
<ProfileTokenList
currentChain={otherChain}
items={currentChain.id === L1_CHAIN ? l2Tokens : l1Tokens}
otherChain={currentChain}
onPressNavigate={onPressNavigate}
onPressNavigate={handleTokensNavigate}
/>
{!isTokensPending && <ProfileBlockscoutTokenList />}
</>
Expand Down
2 changes: 1 addition & 1 deletion apps/evm/src/hooks/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const useLogin = () => {
},
onSuccess: async (_, address) => {
sendGAEvent('event', 'login', { evm_address: JSON.stringify(address) });
posthogEvents.fusion.signIn();
posthogEvents.fusion.login();

setTimeout(() => queryClient.refetchQueries({ queryKey: fusionKeys.user() }), 1000);
},
Expand Down
4 changes: 2 additions & 2 deletions apps/evm/src/lib/posthog/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const posthogEvents = {
bridge: bridgeEvents,
strategies: strategiesEvents,
fusion: {
signUp: () => posthog.capture('user_fusion_sign_up', {}, { $set_once: { fusion_user: true } }),
signIn: () => posthog.capture('user_fusion_sign_in', {}, { $set_once: { fusion_user: true } })
signUp: () => posthog.capture('fusion_sign_up', {}, { $set_once: { fusion_user: true } }),
login: () => posthog.capture('fusion_login', {}, { $set_once: { fusion_user: true } })
},
wallet: walletEvents
};
Expand Down
8 changes: 7 additions & 1 deletion apps/evm/src/lib/posthog/events/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ const walletEvents = {
disconnect: () => posthog.capture('btc_disconnect_wallet')
},
drawer: {
buy: () => posthog.capture('wallet_drawer_buy')
buy: () => posthog.capture('wallet_drawer_buy'),
activity: (source: 'bridge' | 'strategies') => posthog.capture('wallet_drawer_activity', { source }),
tokens: {
navigate: (properties: { to: 'bridge' | 'stake'; ticker: string }) =>
posthog.capture('wallet_drawer_tokens', properties),
others: () => posthog.capture('wallet_drawer_tokens_others')
}
}
};

Expand Down
24 changes: 12 additions & 12 deletions apps/evm/src/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ msgstr "About"
msgid "About Babylon Campaign"
msgstr "About Babylon Campaign"

#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:75
#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:78
msgid "Action needed"
msgstr "Action needed"

Expand All @@ -101,9 +101,9 @@ msgstr "Action needed"
msgid "Active Superchain users who have received any of the five OP Airdrops qualify for an exclusive 50% bonus on all Spice harvested between 9 December 2024 and 12 January 2025. The bonus will be applied at the end of the campaign."
msgstr "Active Superchain users who have received any of the five OP Airdrops qualify for an exclusive 50% bonus on all Spice harvested between 9 December 2024 and 12 January 2025. The bonus will be applied at the end of the campaign."

#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:51
#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:80
#: src/app/[lang]/(bridge)/stake/components/ActivityButton/ActivityButton.tsx:46
#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:54
#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:83
#: src/app/[lang]/(bridge)/stake/components/ActivityButton/ActivityButton.tsx:49
#: src/components/Profile/Profile.tsx:152
msgid "Activity"
msgstr "Activity"
Expand Down Expand Up @@ -1241,7 +1241,7 @@ msgstr "Optional: It's possible to repeat steps 2-4 multiple times."
msgid "or"
msgstr "or"

#: src/components/Profile/ProfileBlockscoutTokenList.tsx:55
#: src/components/Profile/ProfileBlockscoutTokenList.tsx:61
msgid "Others"
msgstr "Others"

Expand Down Expand Up @@ -1497,7 +1497,7 @@ msgstr "Show less"
msgid "Show secondary navigation"
msgstr "Show secondary navigation"

#: src/components/Profile/ProfileBlockscoutTokenList.tsx:52
#: src/components/Profile/ProfileBlockscoutTokenList.tsx:58
msgid "show/hide other tokens list"
msgstr "show/hide other tokens list"

Expand All @@ -1515,8 +1515,8 @@ msgstr "Solv XP"

#: src/app/[lang]/(bridge)/bridge/components/BridgeForm/BobBridgeForm.tsx:130
#: src/app/[lang]/fusion/components/LotterySections/LotteryModal/LotteryModal.tsx:60
#: src/hooks/useLogin.ts:50
#: src/hooks/useSignUp.ts:65
#: src/hooks/useLogin.ts:53
#: src/hooks/useSignUp.ts:68
msgid "Something went wrong. Please try again later."
msgstr "Something went wrong. Please try again later."

Expand Down Expand Up @@ -1980,10 +1980,10 @@ msgstr "Use your bridged assets in apps to maximise your Spice harvest.<0/>TIP:
msgid "Use your Spice total to support your favourite BOB builders. Winners will be announced each week."
msgstr "Use your Spice total to support your favourite BOB builders. Winners will be announced each week."

#: src/app/[lang]/(bridge)/bridge/components/BridgeForm/BobBridgeForm.tsx:129
#: src/connect-ui/component/ConnectModal/ConnectModal.tsx:96
#: src/hooks/useLogin.ts:48
#: src/hooks/useSignUp.ts:63
#: src/app/[lang]/(bridge)/bridge/components/BridgeForm/BobBridgeForm.tsx:128
#: src/connect-ui/component/ConnectModal/ConnectModal.tsx:100
#: src/hooks/useLogin.ts:51
#: src/hooks/useSignUp.ts:66
msgid "User rejected the request"
msgstr "User rejected the request"

Expand Down
33 changes: 8 additions & 25 deletions apps/evm/src/locales/zh.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ msgstr "关于"
msgid "About Babylon Campaign"
msgstr ""

#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:75
#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:78
msgid "Action needed"
msgstr ""

Expand All @@ -134,9 +134,9 @@ msgstr ""
msgid "Active Superchain users who have received any of the five OP Airdrops qualify for an exclusive 50% bonus on all Spice harvested between 9 December 2024 and 12 January 2025. The bonus will be applied at the end of the campaign."
msgstr ""

#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:51
#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:80
#: src/app/[lang]/(bridge)/stake/components/ActivityButton/ActivityButton.tsx:46
#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:54
#: src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx:83
#: src/app/[lang]/(bridge)/stake/components/ActivityButton/ActivityButton.tsx:49
#: src/components/Profile/Profile.tsx:152
msgid "Activity"
msgstr ""
Expand Down Expand Up @@ -1456,7 +1456,7 @@ msgstr "可选:可以多次重复步骤2-4。"
msgid "or"
msgstr "或"

#: src/components/Profile/ProfileBlockscoutTokenList.tsx:55
#: src/components/Profile/ProfileBlockscoutTokenList.tsx:61
msgid "Others"
msgstr ""

Expand Down Expand Up @@ -1741,7 +1741,7 @@ msgstr ""
msgid "Show secondary navigation"
msgstr ""

#: src/components/Profile/ProfileBlockscoutTokenList.tsx:52
#: src/components/Profile/ProfileBlockscoutTokenList.tsx:58
msgid "show/hide other tokens list"
msgstr ""

Expand All @@ -1759,18 +1759,8 @@ msgstr ""

#: src/app/[lang]/(bridge)/bridge/components/BridgeForm/BobBridgeForm.tsx:130
#: src/app/[lang]/fusion/components/LotterySections/LotteryModal/LotteryModal.tsx:60
<<<<<<< HEAD
<<<<<<< HEAD
#: src/hooks/useLogin.ts:50
#: src/hooks/useSignUp.ts:65
=======
#: src/hooks/useLogin.ts:55
#: src/hooks/useSignUp.ts:58
>>>>>>> 15767a17 (feat: add more events)
=======
#: src/hooks/useLogin.ts:53
#: src/hooks/useSignUp.ts:57
>>>>>>> 8c159c07 (feat: final)
#: src/hooks/useSignUp.ts:68
msgid "Something went wrong. Please try again later."
msgstr ""

Expand Down Expand Up @@ -2371,17 +2361,10 @@ msgstr "在应用中使用你跨链的资产以最大化你的Spice收获。<0/>
msgid "Use your Spice total to support your favourite BOB builders. Winners will be announced each week."
msgstr "用你的Spice总数来支持你最喜爱的BOB构建者。获胜者将每周公布。"

<<<<<<< HEAD
#: src/app/[lang]/(bridge)/bridge/components/BridgeForm/BobBridgeForm.tsx:129
#: src/connect-ui/component/ConnectModal/ConnectModal.tsx:96
#: src/hooks/useLogin.ts:48
#: src/hooks/useSignUp.ts:63
=======
#: src/app/[lang]/(bridge)/bridge/components/BridgeForm/BobBridgeForm.tsx:128
#: src/connect-ui/component/ConnectModal/ConnectModal.tsx:100
#: src/hooks/useLogin.ts:51
#: src/hooks/useSignUp.ts:55
>>>>>>> 8c159c07 (feat: final)
#: src/hooks/useSignUp.ts:66
msgid "User rejected the request"
msgstr ""

Expand Down

0 comments on commit 155f842

Please sign in to comment.