From 4832161795a14d10d39e8ed823814c2185080c53 Mon Sep 17 00:00:00 2001 From: Daniel Sinclair Date: Fri, 8 Nov 2024 16:17:05 -0500 Subject: [PATCH] fix: walletType could be undefined during onboarding, import --- src/analytics/utils.ts | 1 + src/hooks/useInitializeWallet.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/analytics/utils.ts b/src/analytics/utils.ts index 50a95761552..042edf95da2 100644 --- a/src/analytics/utils.ts +++ b/src/analytics/utils.ts @@ -94,6 +94,7 @@ export async function getWalletContext(address: Address): Promise // currentAddressStore address is initialized to '' if (!address || address === ('' as Address)) return {}; + // walletType maybe undefined after initial wallet creation const { wallets } = store.getState(); const wallet = findWalletWithAccount(wallets.wallets || {}, address); diff --git a/src/hooks/useInitializeWallet.ts b/src/hooks/useInitializeWallet.ts index 1c6aa21d6d6..5f934050e9d 100644 --- a/src/hooks/useInitializeWallet.ts +++ b/src/hooks/useInitializeWallet.ts @@ -87,6 +87,7 @@ export default function useInitializeWallet() { }); // Capture wallet context in telemetry + // walletType maybe undefied after initial wallet creation const { walletType, walletAddressHash } = await getWalletContext(walletAddress as Address); const [deviceId] = await getOrCreateDeviceId(); @@ -97,7 +98,7 @@ export default function useInitializeWallet() { }); // Allows calling telemetry before currentAddress is available (i.e. onboarding) - if (walletType && walletAddressHash) analyticsV2.setWalletContext({ walletAddressHash, walletType }); + if (walletType || walletAddressHash) analyticsV2.setWalletContext({ walletAddressHash, walletType }); analyticsV2.setDeviceId(deviceId); analyticsV2.identify();