feat: add new hardware wallet flows analytics#27675
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
bb69d9d to
e905f31
Compare
|
did an initial round of testing and here were the results: Overall, the events made sense and the properties for the most part were correct. The only issue I can see is that the location was always set to |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Why SmokeAccounts: The SmokeAccounts tag covers QR-based hardware wallet account addition flows, which directly exercise the HardwareWalletProvider and its connection flow. The changes to Why SmokeConfirmations: Hardware wallet signing flows (personal_sign, typed data, transactions) go through the HardwareWalletProvider's No E2E tests found specifically for hardware wallet flows in the test suite (searched tests/smoke//* and e2e//*), so these tags cover the closest related flows. The changes are analytics-only additions with no functional logic changes to connection/signing, making the risk medium rather than high. The Performance Test Selection: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| }); | ||
|
|
||
| const awaitingConfirmationRejectRef = useRef<(() => void) | null>(null); | ||
| const operationTypeRef = useRef<'transaction' | 'message' | null>(null); |
There was a problem hiding this comment.
Unused operationTypeRef is written but never read
Low Severity
operationTypeRef is declared, assigned in showAwaitingConfirmation, and cleared in hideAwaitingConfirmation, but its .current value is never read anywhere — not in the provider, not in the context value, and not passed to any child component or hook. This is dead code introduced in this PR.
Additional Locations (2)
There was a problem hiding this comment.
Will fix in a small follow up since this was tested manually and approved already
|
owencraston
left a comment
There was a problem hiding this comment.
Tested my with my Ledger Flex using all three flows (swaps, send and dapps) and everything worked as expected. here were the results...
{
"type": "track",
"event": "Hardware Wallet Recovery Modal Viewed",
"properties": {
"location": "Send",
"device_type": "Ledger",
"error_type": "Device Locked",
"error_type_view_count": 1,
"error_code": "1100",
"error_message": "Unlock it and try again to continue"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery CTA Clicked",
"properties": {
"location": "Send",
"device_type": "Ledger",
"error_type": "Device Locked",
"error_type_view_count": 1,
"error_code": "1100",
"error_message": "Unlock it and try again to continue"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery Modal Viewed",
"properties": {
"location": "Send",
"device_type": "Ledger",
"error_type": "Ethereum App Not Opened",
"error_type_view_count": 1,
"error_code": "6003",
"error_message": "Open Ethereum app on device"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery CTA Clicked",
"properties": {
"location": "Send",
"device_type": "Ledger",
"error_type": "Ethereum App Not Opened",
"error_type_view_count": 1,
"error_code": "6003",
"error_message": "Open Ethereum app on device"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery Modal Viewed",
"properties": {
"location": "Send",
"device_type": "Ledger",
"error_type": "Ethereum App Not Opened",
"error_type_view_count": 2,
"error_code": "6003",
"error_message": "Open Ethereum app on device"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery Success Modal Viewed",
"properties": {
"location": "Send",
"device_type": "Ledger",
"error_type": "Ethereum App Not Opened",
"error_type_view_count": 2,
"error_code": "6003",
"error_message": "Open Ethereum app on device"
}
}
// swap
{
"type": "track",
"event": "Hardware Wallet Recovery Modal Viewed",
"properties": {
"location": "Swaps",
"device_type": "Ledger",
"error_type": "Device Locked",
"error_type_view_count": 1,
"error_code": "1100",
"error_message": "Unlock it and try again to continue"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery CTA Clicked",
"properties": {
"location": "Swaps",
"device_type": "Ledger",
"error_type": "Device Locked",
"error_type_view_count": 1,
"error_code": "1100",
"error_message": "Unlock it and try again to continue"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery Modal Viewed",
"properties": {
"location": "Swaps",
"device_type": "Ledger",
"error_type": "Ethereum App Not Opened",
"error_type_view_count": 1,
"error_code": "6003",
"error_message": "Open Ethereum app on device"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery CTA Clicked",
"properties": {
"location": "Swaps",
"device_type": "Ledger",
"error_type": "Ethereum App Not Opened",
"error_type_view_count": 1,
"error_code": "6003",
"error_message": "Open Ethereum app on device"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery Success Modal Viewed",
"properties": {
"location": "Swaps",
"device_type": "Ledger",
"error_type": "Ethereum App Not Opened",
"error_type_view_count": 1,
"error_code": "6003",
"error_message": "Open Ethereum app on device"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery Modal Viewed",
"properties": {
"location": "Swaps",
"device_type": "Ledger",
"error_type": "Blind Signing Not Enabled",
"error_type_view_count": 1,
"error_code": "6001",
"error_message": "Blind signing is disabled. Please enable it in your device settings"
}
}
// dapps
{
"type": "track",
"event": "Hardware Wallet Recovery Modal Viewed",
"properties": {
"location": "Message",
"device_type": "Ledger",
"error_type": "Device Locked",
"error_type_view_count": 1,
"error_code": "1100",
"error_message": "Unlock it and try again to continue"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery CTA Clicked",
"properties": {
"location": "Message",
"device_type": "Ledger",
"error_type": "Device Locked",
"error_type_view_count": 1,
"error_code": "1100",
"error_message": "Unlock it and try again to continue"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery Modal Viewed",
"properties": {
"location": "Message",
"device_type": "Ledger",
"error_type": "Ethereum App Not Opened",
"error_type_view_count": 1,
"error_code": "6003",
"error_message": "Open Ethereum app on device"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery Success Modal Viewed",
"properties": {
"location": "Message",
"device_type": "Ledger",
"error_type": "Ethereum App Not Opened",
"error_type_view_count": 1,
"error_code": "6003",
"error_message": "Open Ethereum app on device"
}
}
{
"type": "track",
"event": "Signature Rejected",
"properties": {
"account_type": "Ledger",
"dapp_host_name": "[[metamask.github.io](http://metamask.github.io/)](http://metamask.github.io/)",
"signature_type": "eth_signTypedData",
"version": "V1",
"chain_id": "1",
"request_source": "In-App-Browser",
"security_alert_response": "Benign",
"security_alert_reason": "",
"security_alert_source": "api"
}
}
{
"type": "track",
"event": "Hardware Wallet Recovery Modal Viewed",
"properties": {
"location": "Message",
"device_type": "Ledger",
"error_type": "Generic Error",
"error_type_view_count": 1,
"error_code": "99999",
"error_message": "Make sure your Ledger is set up with the Secret Recovery Phrase or passphrase for this account"
}
}
|
Pr to remove unused values from schema: https://github.com/Consensys/segment-schema/pull/501 |





Description
Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/MUL-1546
Manual testing steps
no manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches the hardware wallet connection flow and bottom-sheet callbacks to emit new analytics, so incorrect state resets or callback wiring could affect connection UX/cleanup. No auth or funds-handling logic changes, and coverage is added with extensive unit tests.
Overview
Adds a new hardware-wallet analytics module that classifies flow context (Connection/Send/Swaps/Transaction/Message) and normalizes error types/details, then emits three new MetaMetrics events for recovery:
HARDWARE_WALLET_RECOVERY_MODAL_VIEWED,..._CTA_CLICKED, and..._SUCCESS_MODAL_VIEWED.Wires this into the hardware wallet UI/flow by deriving the analytics flow from the first pending approval at the start of each
ensureDeviceReadyrun, tracking CTA taps from error screens via a newonCTAClickedprop onHardwareWalletBottomSheet, and resetting analytics state when the sheet is closed. Includes comprehensive unit tests for helper mappings, Redux-derived flow detection, and event firing/counting behavior.Written by Cursor Bugbot for commit 9bec1b0. This will update automatically on new commits. Configure here.