feat(observability): log successful wallet connections via useWalletConnectionLogger (#599) - #661
Merged
Chucks1093 merged 1 commit intoJul 27, 2026
Conversation
…onnectionLogger (accesslayerorg#599) Adds a debug-level structured log emitted the moment a wallet connection succeeds, so developers can trace wallet session activity without relying on browser extension logs. - New useWalletConnectionLogger hook watches wagmi's useAccount state and logs truncated_address (first 4 + last 4), connection_method (from the active connector), and connected_at once per connection event, deduped on the connected address so re-renders and cache updates never re-log. - Mounted once at the Web3Provider boundary so the log fires exactly once app-wide regardless of which UI (connect button, reconnect banner) initiated the connection. - Suppressed in the test environment by default, matching the cache-invalidation logging convention already used in useWallet.ts. - Full wallet address is never logged under any field name.
|
@Ajibose Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #599
Summary
Adds a debug-level structured log emitted the moment a wallet connection succeeds, so developers can trace wallet session activity without relying on browser extension logs.
What was implemented
useWalletConnectionLogger(src/hooks/useWalletConnectionLogger.ts): a hook that watches wagmi'suseAccount()state and, on a successful connection, emits:useRef, so the log fires once per connection event — not on re-renders, and not again for unrelated state or query-cache updates that leave the address unchanged.process.env.NODE_ENV === 'test', matching the existing[cache-invalidation]logging convention inuseWallet.ts.shortenAddressutil (src/lib/web3/format.ts).Web3Provider(src/providers/Web3Provider.tsx): mounts a small internalWalletConnectionLoggercomponent (calls the hook, rendersnull) inside the provider tree, so the log fires exactly once app-wide regardless of which UI —ConnectWalletButtonorWalletConnectCalloutBanner— initiated the connection, rather than duplicating the logic in each.Files
New files
src/hooks/useWalletConnectionLogger.ts— the logging hooksrc/hooks/__tests__/useWalletConnectionLogger.test.ts— unit testsModified files
src/providers/Web3Provider.tsx— mounts the logger once at the provider boundaryTests added
src/hooks/__tests__/useWalletConnectionLogger.test.ts(mockswagmi'suseAccount, matching the pattern used inuseNetworkMismatch.test.ts):truncated_address,connection_method, andconnected_aton a successful connectionidwhen nonameis available"unknown"when there is no connector at allHow to test
pnpm test src/hooks/__tests__/useWalletConnectionLogger.test.tsManually: connect a wallet via
ConnectWalletButtonin a non-test build and confirm the browser console prints a single[wallet-connection]debug log with a truncated address, the connector name, and a timestamp — and that navigating/re-rendering afterward does not print it again.