From b022b443582f007b34f2dbff708d5c07893abe62 Mon Sep 17 00:00:00 2001 From: Alejandro Loaiza Date: Wed, 4 Dec 2024 15:42:24 +1100 Subject: [PATCH 1/3] feat: Adding tx hash to tracking events (#2450) --- .../src/widgets/on-ramp/views/OnRampMain.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx b/packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx index 04215250b5..244e6a638e 100644 --- a/packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx +++ b/packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx @@ -108,7 +108,10 @@ export function OnRampMain({ screen: 'OrderInProgress', control: 'PaymentProcessing', controlType: 'IframeEvent', - extras: { ...miscProps }, + extras: { + ...miscProps, + transactionHash: event.data.transactionHash, + }, }); // checkoutOnRampOrderInProgress_PaymentProcessingIframeEvent } if (event.data.status === TransakStatuses.COMPLETED) { @@ -117,7 +120,10 @@ export function OnRampMain({ screen: 'Success', control: 'PaymentCompleted', controlType: 'IframeEvent', - extras: { ...miscProps }, + extras: { + ...miscProps, + transactionHash: event.data.transactionHash, + }, }); // checkoutOnRampSuccess_PaymentCompletedIframeEvent } break; From 8ffab27d81d3ce29569939e2431623e6b98cfdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=A3=20de=20Souza?= Date: Wed, 4 Dec 2024 16:05:48 +1100 Subject: [PATCH 2/3] chore: Fix typo on Add Tokens onboarding (#2449) --- packages/checkout/widgets-lib/src/locales/en.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/checkout/widgets-lib/src/locales/en.json b/packages/checkout/widgets-lib/src/locales/en.json index 25f62baf61..2888458a28 100644 --- a/packages/checkout/widgets-lib/src/locales/en.json +++ b/packages/checkout/widgets-lib/src/locales/en.json @@ -661,7 +661,7 @@ "from":{ "label": "Send from", "caption": "Choose a wallet to bridge or swap from" - }, + }, "to": { "label": "Deliver to", "caption": "Choose where you want your tokens to go" @@ -839,7 +839,7 @@ }, "screen2": { "title": "You can deliver tokens to Passport\n& pay from any wallet", - "caption": "whats evolved", + "caption": "what's evolved", "buttonText": "Next" }, "screen3": { From f8623bc5729a2b9ffec915d80b20c776a6373e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=A3=20de=20Souza?= Date: Wed, 4 Dec 2024 16:14:25 +1100 Subject: [PATCH 3/3] fix: Move identify call to destination wallet on Add Tokens flow (#2451) --- .../WalletDrawer/DeliverToWalletDrawer.tsx | 1 - .../WalletDrawer/PayWithWalletDrawer.tsx | 1 + .../widgets/add-tokens/views/AddTokens.tsx | 21 +++++++++++++++++-- .../components/ui/add-tokens/addTokens.tsx | 9 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/checkout/widgets-lib/src/components/WalletDrawer/DeliverToWalletDrawer.tsx b/packages/checkout/widgets-lib/src/components/WalletDrawer/DeliverToWalletDrawer.tsx index 9d371e2bf2..23c0c231e7 100644 --- a/packages/checkout/widgets-lib/src/components/WalletDrawer/DeliverToWalletDrawer.tsx +++ b/packages/checkout/widgets-lib/src/components/WalletDrawer/DeliverToWalletDrawer.tsx @@ -53,7 +53,6 @@ export function DeliverToWalletDrawer({ getShouldRequestWalletPermissions={ selectedSameFromWalletType } - shouldIdentifyUser={false} /> ); } diff --git a/packages/checkout/widgets-lib/src/components/WalletDrawer/PayWithWalletDrawer.tsx b/packages/checkout/widgets-lib/src/components/WalletDrawer/PayWithWalletDrawer.tsx index 8c6bdd9522..27c767d578 100644 --- a/packages/checkout/widgets-lib/src/components/WalletDrawer/PayWithWalletDrawer.tsx +++ b/packages/checkout/widgets-lib/src/components/WalletDrawer/PayWithWalletDrawer.tsx @@ -79,6 +79,7 @@ export function PayWithWalletDrawer({ disabledOptions={disabledOptions} bottomSlot={payWithCardItem} onConnect={handleOnConnect} + shouldIdentifyUser={false} /> ); } diff --git a/packages/checkout/widgets-lib/src/widgets/add-tokens/views/AddTokens.tsx b/packages/checkout/widgets-lib/src/widgets/add-tokens/views/AddTokens.tsx index c550a6c3e7..84a1be36c9 100644 --- a/packages/checkout/widgets-lib/src/widgets/add-tokens/views/AddTokens.tsx +++ b/packages/checkout/widgets-lib/src/widgets/add-tokens/views/AddTokens.tsx @@ -71,6 +71,7 @@ import { checkSanctionedAddresses } from '../functions/checkSanctionedAddresses' import { getFormattedAmounts } from '../functions/getFormattedNumber'; import { RouteData } from '../../../lib/squid/types'; import { SQUID_NATIVE_TOKEN } from '../../../lib/squid/config'; +import { identifyUser } from '../../../lib/analytics/identifyUser'; interface AddTokensProps { checkout: Checkout; @@ -119,8 +120,13 @@ export function AddTokens({ isSwapAvailable, } = addTokensState; + const { + track, + page, + identify, + user, + } = useAnalytics(); const { viewDispatch } = useContext(ViewContext); - const { track, page } = useAnalytics(); const { t } = useTranslation(); const { @@ -259,6 +265,17 @@ export function AddTokens({ [providers], ); + useEffect(() => { + if (!lockedToProvider) { return; } + + (async () => { + const userData = user ? await user() : undefined; + const anonymousId = userData?.anonymousId(); + + await identifyUser(identify, toProvider!, { anonymousId }); + })(); + }, [toProvider, lockedToProvider]); + const toChain = useMemo( () => chains?.find((chain) => chain.id === ChainId.IMTBL_ZKEVM_MAINNET.toString()), [chains], @@ -638,7 +655,7 @@ export function AddTokens({ /> - {`${t('views.ADD_TOKENS.fees.fiatPricePrefix')} + {`${t('views.ADD_TOKENS.fees.fiatPricePrefix')} $${getFormattedAmounts(selectedAmountUsd)}`} diff --git a/packages/checkout/widgets-sample-app/src/components/ui/add-tokens/addTokens.tsx b/packages/checkout/widgets-sample-app/src/components/ui/add-tokens/addTokens.tsx index 50fb3700a8..3b2a0d51d7 100644 --- a/packages/checkout/widgets-sample-app/src/components/ui/add-tokens/addTokens.tsx +++ b/packages/checkout/widgets-sample-app/src/components/ui/add-tokens/addTokens.tsx @@ -45,7 +45,8 @@ function AddTokensUI() { [checkout] ); - const [presetToProvider, setPresetToProvider] = useState(false); + const getPersistedToPresetProvider = () => localStorage.getItem('imtbl/addtokens_presetToProvider') === 'true'; + const [presetToProvider, setPresetToProvider] = useState(getPersistedToPresetProvider()); const [toProvider, setToProvider] = useState(undefined); const [toTokenAddress, setToTokenAddress] = useState(undefined); @@ -81,6 +82,12 @@ function AddTokensUI() { }, []); useEffect(() => { + const presetToProviderValue = getPersistedToPresetProvider(); + + if (presetToProviderValue !== presetToProvider) { + localStorage.setItem('imtbl/addtokens_presetToProvider', presetToProvider.toString()); + } + if (!checkout || !factory) return; if (!presetToProvider) { toProvider && addTokens.unmount();