From 155f8423f403b31725671c1034a985e38514a80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rui=20Sim=C3=A3o?= Date: Fri, 31 Jan 2025 11:13:22 +0000 Subject: [PATCH] feat: final --- .../ActivityButton/ActivityButton.tsx | 3 ++ .../ActivityButton/ActivityButton.tsx | 3 ++ .../Profile/ProfileBlockscoutTokenList.tsx | 8 ++++- .../components/Profile/ProfileTokenList.tsx | 4 +-- .../src/components/Profile/ProfileTokens.tsx | 12 +++++-- apps/evm/src/hooks/useLogin.ts | 2 +- apps/evm/src/lib/posthog/events/index.ts | 4 +-- apps/evm/src/lib/posthog/events/wallet.ts | 8 ++++- apps/evm/src/locales/en.po | 24 +++++++------- apps/evm/src/locales/zh.po | 33 +++++-------------- 10 files changed, 55 insertions(+), 46 deletions(-) diff --git a/apps/evm/src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx b/apps/evm/src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx index 50214450..aa29baa6 100644 --- a/apps/evm/src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx +++ b/apps/evm/src/app/[lang]/(bridge)/bridge/components/ActivityButton/ActivityButton.tsx @@ -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(); @@ -32,6 +33,8 @@ const ActivityButton = (): JSX.Element => { } } })); + + posthogEvents.wallet.drawer.activity('bridge'); }; const isLoggedIn = !!(evmAddress || btcAddress); diff --git a/apps/evm/src/app/[lang]/(bridge)/stake/components/ActivityButton/ActivityButton.tsx b/apps/evm/src/app/[lang]/(bridge)/stake/components/ActivityButton/ActivityButton.tsx index b365717f..ef889d84 100644 --- a/apps/evm/src/app/[lang]/(bridge)/stake/components/ActivityButton/ActivityButton.tsx +++ b/apps/evm/src/app/[lang]/(bridge)/stake/components/ActivityButton/ActivityButton.tsx @@ -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(); @@ -30,6 +31,8 @@ const ActivityButton = (): JSX.Element => { } } })); + + posthogEvents.wallet.drawer.activity('strategies'); }; const isLoggedIn = !!(evmAddress || btcAddress); diff --git a/apps/evm/src/components/Profile/ProfileBlockscoutTokenList.tsx b/apps/evm/src/components/Profile/ProfileBlockscoutTokenList.tsx index aa72eba8..446c4628 100644 --- a/apps/evm/src/components/Profile/ProfileBlockscoutTokenList.tsx +++ b/apps/evm/src/components/Profile/ProfileBlockscoutTokenList.tsx @@ -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(); @@ -47,9 +48,14 @@ const ProfileBlockscoutTokenList = () => { }); }; + const handleExpand = () => { + setExpanded((s) => !s); + posthogEvents.wallet.drawer.tokens.others(); + }; + return ( <> - setExpanded((s) => !s)}> + Others ({list.length}) diff --git a/apps/evm/src/components/Profile/ProfileTokenList.tsx b/apps/evm/src/components/Profile/ProfileTokenList.tsx index 12c7c2f9..4d512296 100644 --- a/apps/evm/src/components/Profile/ProfileTokenList.tsx +++ b/apps/evm/src/components/Profile/ProfileTokenList.tsx @@ -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) => { @@ -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) => { diff --git a/apps/evm/src/components/Profile/ProfileTokens.tsx b/apps/evm/src/components/Profile/ProfileTokens.tsx index 461b6535..fb47e7cd 100644 --- a/apps/evm/src/components/Profile/ProfileTokens.tsx +++ b/apps/evm/src/components/Profile/ProfileTokens.tsx @@ -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; @@ -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 ( {isTokensPending ? ( @@ -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' }); }} /> {!isTokensPending && } diff --git a/apps/evm/src/hooks/useLogin.ts b/apps/evm/src/hooks/useLogin.ts index dc5826a5..b2abb1ef 100644 --- a/apps/evm/src/hooks/useLogin.ts +++ b/apps/evm/src/hooks/useLogin.ts @@ -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); }, diff --git a/apps/evm/src/lib/posthog/events/index.ts b/apps/evm/src/lib/posthog/events/index.ts index 092db035..967d5dfb 100644 --- a/apps/evm/src/lib/posthog/events/index.ts +++ b/apps/evm/src/lib/posthog/events/index.ts @@ -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 }; diff --git a/apps/evm/src/lib/posthog/events/wallet.ts b/apps/evm/src/lib/posthog/events/wallet.ts index f3230294..386e2f37 100644 --- a/apps/evm/src/lib/posthog/events/wallet.ts +++ b/apps/evm/src/lib/posthog/events/wallet.ts @@ -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') + } } }; diff --git a/apps/evm/src/locales/en.po b/apps/evm/src/locales/en.po index ef2b64c4..4ec6efa2 100644 --- a/apps/evm/src/locales/en.po +++ b/apps/evm/src/locales/en.po @@ -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" @@ -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" @@ -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" @@ -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" @@ -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." @@ -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" diff --git a/apps/evm/src/locales/zh.po b/apps/evm/src/locales/zh.po index b9b1e6ee..3240be0e 100644 --- a/apps/evm/src/locales/zh.po +++ b/apps/evm/src/locales/zh.po @@ -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 "" @@ -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 "" @@ -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 "" @@ -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 "" @@ -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 "" @@ -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 ""