Skip to content

Commit

Permalink
fix: walletType could be undefined during onboarding, import
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSinclair committed Nov 8, 2024
1 parent 510a7be commit 4832161
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/analytics/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export async function getWalletContext(address: Address): Promise<WalletContext>
// 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);

Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useInitializeWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand Down

0 comments on commit 4832161

Please sign in to comment.