Skip to content

fix(analytics): drive walletType from wagmi useAccount#2974

Open
mgrabina wants to merge 1 commit into
mainfrom
fix/wallettype-tracking-reconnect
Open

fix(analytics): drive walletType from wagmi useAccount#2974
mgrabina wants to merge 1 commit into
mainfrom
fix/wallettype-tracking-reconnect

Conversation

@mgrabina
Copy link
Copy Markdown
Contributor

Summary

ConnectKit's onConnect callback only fires on the initial connect — wagmi auto-reconnects (every page reload with a saved session, every redirect-back from Aave Accounts) are suppressed via the isReconnected flag. setWalletType was wired to that callback, so on most sessions walletType stayed undefined.

Drive walletType from useAccount() in Web3Provider instead. It now stays accurate across reconnects, page reloads, and the Aave Accounts redirect-back flow.

Impact

Verified against production Amplitude (project 697123, last 30 days):

  • 125,939 of 145,425 Transaction events (86.6%) currently emit walletType: undefined
  • Tx/connect ratio is 0.05 for familyAccountsProvider vs 0.67 for io.metamask — Aave Accounts users are sticky and reload more, so a disproportionate share of their transactions leak into the (none) bucket
  • After this fix, walletType is set on every connected status and cleared on disconnected, regardless of how the connection was established

How it works

useAccountEffect exposes isReconnected: true to detect new vs returning sessions. ConnectKit's useConnectCallback early-returns on that case before invoking the user-supplied onConnect prop. Reading useAccount().connector?.id directly bypasses that filter — wagmi knows the current connector regardless of how we got connected.

The effect is gated on status === 'connected' to avoid clearing walletType during the transient reconnecting state (which would otherwise wipe it briefly on every page load).

Test plan

  • In Redux DevTools, connect with any wallet → walletSlice.walletType reflects the connector id
  • Reload the page while connected → walletType is repopulated (was previously cleared to undefined)
  • Disconnect → walletType returns to undefined
  • Connect with Aave Accounts via the accounts.aave.com redirect → walletType is set after landing back
  • Trigger a Transaction event — confirm the Amplitude payload contains walletType: <connector id> instead of null

ConnectKit's onConnect callback skips reconnects (wagmi emits
the connect event with isReconnected=true on every auto-reconnect),
so walletType was only set on fresh connects and lost on every
page reload. ~86% of Transaction events in Amplitude have
walletType=undefined as a result.

Drive walletType from useAccount() in Web3Provider instead, so
it stays accurate across reconnects, page reloads, and the
Aave Accounts redirect-back flow.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
interface Ready Ready Preview, Comment May 11, 2026 10:22pm

Request Review

@github-actions
Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@github-actions
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant