fix(analytics): drive walletType from wagmi useAccount#2974
Open
mgrabina wants to merge 1 commit into
Open
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📦 Next.js Bundle Analysis for aave-uiThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConnectKit's
onConnectcallback 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 theisReconnectedflag.setWalletTypewas wired to that callback, so on most sessionswalletTypestayedundefined.Drive
walletTypefromuseAccount()inWeb3Providerinstead. 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):
walletType: undefined0.05forfamilyAccountsProvidervs0.67forio.metamask— Aave Accounts users are sticky and reload more, so a disproportionate share of their transactions leak into the(none)bucketwalletTypeis set on everyconnectedstatus and cleared ondisconnected, regardless of how the connection was establishedHow it works
useAccountEffectexposesisReconnected: trueto detect new vs returning sessions. ConnectKit'suseConnectCallbackearly-returns on that case before invoking the user-suppliedonConnectprop. ReadinguseAccount().connector?.iddirectly bypasses that filter — wagmi knows the current connector regardless of how we got connected.The effect is gated on
status === 'connected'to avoid clearingwalletTypeduring the transientreconnectingstate (which would otherwise wipe it briefly on every page load).Test plan
walletSlice.walletTypereflects the connector idwalletTypeis repopulated (was previously cleared toundefined)walletTypereturns toundefinedwalletTypeis set after landing backwalletType: <connector id>instead ofnull