[LWD] feat(tracking): add tracking contact send flow lwd - #21465
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Recipient resolution misclassifies ENS→contact-address matches due to comparing the contact address against the raw ENS query string.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds contacts-related analytics to the Ledger Wallet Desktop (LWD) Send MVVM flow by introducing a flow-scoped tracking context and recipient/contact resolution helpers, then wiring new track / trackPage events across recipient selection, contact add flows, amount, and confirmation.
Changes:
- Added
SendFlowTrackingContextto persist recipient input method + recipient resolution metadata across the whole Send flow. - Introduced
contactTrackingutilities (getRecipientResolution,getSendFlowTrackingPage) and integrated them into recipient/contact steps for consistent analytics properties. - Updated recipient/contact UI + view models to capture additional analytics (contact selection, address rank, unsupported network tooltip) and added/updated unit tests.
File summaries
| File | Description |
|---|---|
| apps/ledger-live-desktop/src/mvvm/features/Send/utils/contactTracking.ts | New helper for tracking page names and recipient resolution classification. |
| apps/ledger-live-desktop/src/mvvm/features/Send/utils/tests/contactTracking.test.ts | Unit tests for recipient resolution + page name normalization. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/hooks/useRecipientScreenViewModel.ts | Adds contacts-derived tracking properties and moves initial trackPage to an effect. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/hooks/useRecipientAddressModalViewModel.ts | Adds recipient-result tracking, contact/address selection tracking, and recipient-resolution propagation into context. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/hooks/useAddressMatchedSectionViewModel.ts | Extends VM to accept onUnsupportedNetwork handler for recipient card tooltip interactions. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/hooks/tests/useRecipientScreenViewModel.test.ts | Updates mocks/assertions for new contacts tracking props. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/hooks/tests/useRecipientAddressModalViewModel.test.ts | Adds assertions for “recipient result” tracking and updated contact-address selection signature. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/components/RecipientContactAddressSelection.tsx | Passes full address object + rank to selection handler for richer analytics. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/components/RecipientCard.tsx | Adds unsupported-network pointer interaction hook for analytics when add-contact is disabled. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/components/RecipientAddressModalView.tsx | Updates prop types for contact-address selection (address + rank). |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/components/AddressMatchedSection.tsx | Wires onUnsupportedNetwork into RecipientCard. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/components/tests/RecipientContactAddressSelection.test.tsx | Updates expectations for new (address, rank) selection callback. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Recipient/components/tests/AddressMatchedSection.test.tsx | Updates test container to provide onUnsupportedNetwork. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Confirmation/hooks/useConfirmationViewModel.ts | Adds recipientType + savedContactDuringFlow to confirmation tracking and tracks close click. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Confirmation/hooks/tests/useConfirmationViewModel.test.tsx | Updates mocks/assertions for new confirmation tracking properties. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/Amount/hooks/useAmountScreen.ts | Adds recipientType to amount-step tracking properties. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/AddToExistingContact/hooks/useAddToExistingContactViewModel.ts | Tracks page view + contact selection in “select existing contact” step. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/AddToExistingContact/hooks/tests/useAddToExistingContactViewModel.test.tsx | Updates mocks/wrapping and adds required contacts-feature mock. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/AddNewContact/hooks/useAddNewContactViewModel.ts | Reworks add-contact VM to use flow-contacts add-contact VM and adds tracking for open/confirm/error/success. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/AddNewContact/hooks/tests/useAddNewContactViewModel.test.tsx | Updates test to new add-contact VM API and wiring. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/AddContact/hooks/useAddContactViewModel.ts | Tracks page view and button clicks in add-contact options step. |
| apps/ledger-live-desktop/src/mvvm/features/Send/screens/AddContact/hooks/tests/useAddContactViewModel.test.ts | Adds SendFlowContext mock required by new tracking properties usage. |
| apps/ledger-live-desktop/src/mvvm/features/Send/index.tsx | Wraps Send flow UI in SendFlowTrackingProvider. |
| apps/ledger-live-desktop/src/mvvm/features/Send/hooks/useSendPrefillAddAddressFlow.ts | Adds tracking for name/review/signing steps of prefilled add-address flow + persists “saved during flow” flag. |
| apps/ledger-live-desktop/src/mvvm/features/Send/hooks/useSendHeaderModel.ts | Adds close/paste/QR tracking and uses tracking context for recipient input method + close metadata. |
| apps/ledger-live-desktop/src/mvvm/features/Send/hooks/tests/useSendHeaderModel.test.tsx | Updates mocks for new tracking context usage and reformats test inputs. |
| apps/ledger-live-desktop/src/mvvm/features/Send/context/SendFlowTrackingContext.tsx | New context/provider to persist send-flow tracking metadata. |
| apps/ledger-live-desktop/src/mvvm/features/Send/context/tests/SendFlowTrackingContext.test.tsx | Unit test validating send-flow tracking context state updates. |
| apps/ledger-live-desktop/src/mvvm/features/Send/components/SendHeader.tsx | Routes dialog close + paste events through the header model (enabling tracking). |
| apps/ledger-live-desktop/src/mvvm/features/Send/components/SendFlowLayout.tsx | Adds recipientType + normalized page naming to dialog-close tracking. |
| apps/ledger-live-desktop/src/mvvm/features/Send/components/tests/SendHeader.test.tsx | Updates header-model mock shape to include close/paste handlers. |
| .changeset/violet-flowers-try.md | Declares a minor changeset for the desktop package for this tracking feature. |
Review details
- Files reviewed: 32/32 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ba928dd to
2025770
Compare
Web Tools Build Status
|
3fb6266 to
063f8b5
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Close analytics can be mis-attributed during the “select contact address” subview when closing via ESC/click-outside, which undermines the PR’s tracking accuracy goals.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 32/32 changed files
- Comments generated: 1
- Review effort level: Lite
| const handleDialogOpenChange = useCallback( | ||
| (open: boolean) => { | ||
| if (!open) { | ||
| track("button_clicked", { | ||
| button: "close", | ||
| page: `step ${wizard.currentStep}`, | ||
| page: getSendFlowTrackingPage(wizard.currentStep), | ||
| recipientType, | ||
| ...sendFlowTrackingProperties, | ||
| }); |
There was a problem hiding this comment.
🟡 Changes recommended
There is at least one confirmed functional regression risk in the Recipient contact-selection path (memo handling bypass) and an analytics-page inconsistency for close events during nested contact-address selection.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
apps/ledger-live-desktop/src/mvvm/features/Send/components/SendFlowLayout.tsx:46
- The close tracking here uses
getSendFlowTrackingPage(wizard.currentStep)without theisSelectingContactAddressflag. As a result, closing the modal via overlay/escape while in the nested “select contact address” UI will be tracked as “step recipient”, while other close paths (e.g. the header close) can correctly report “select contact address”, leading to inconsistent analytics for the same UI state.
track("button_clicked", {
button: "close",
page: getSendFlowTrackingPage(wizard.currentStep),
recipientType,
...sendFlowTrackingProperties,
- Files reviewed: 32/32 changed files
- Comments generated: 1
- Review effort level: Lite
Rsdoctor Bundle Diff AnalysisFound 7 projects in monorepo, 1 project with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 desktop-rendererPath:
📦 Download Diff Report: desktop-renderer Bundle Diff Generated by Rsdoctor GitHub Action |
063f8b5 to
cb2caec
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The changes are scoped to analytics enrichment, avoid leaking raw recipient input, and include targeted unit-test updates for the new helpers and tracking behavior.
Review details
- Files reviewed: 32/32 changed files
- Comments generated: 0 new
- Review effort level: Lite
📝 Description
This PR adds contacts-related analytics to the Send flow for LWD. It introduces
SendFlowTrackingContextand shared helpers to track recipient resolution, input method, contact actions, and related properties across recipient, amount, confirmation, and add-contact steps🔗 Context