feat(ramps): add Unified Buy v2 analytics events#26374
Conversation
Add 18 new event enum values and TypeScript interfaces for comprehensive Unified Buy v2 analytics tracking. Instrument TokenSelection and BuildQuote screens with: - Screen viewed events - Token search (debounced) - Network filter clicks - Quick amount pill selection - Payment method selector clicks - Change provider button clicks - Continue button clicked (KPI) - Settings button clicks - Unsupported token tooltip clicks Update existing RAMPS_TOKEN_SELECTED to include ramp_type differentiation for UB2 phase comparison. Remaining screens (NativeFlow, Checkout, Order Details, modals) will be instrumented in follow-up commits. Co-authored-by: Cursor <cursoragent@cursor.com>
|
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. |
Flow identity uses ramp_type only (e.g. UNIFIED BUY 2) for Segment and Data Council. Update PR description to state ramp_type-only; see pr_26374_body.md for body copy. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Co-authored-by: Cursor <cursoragent@cursor.com>
998158b to
640cb83
Compare
…ildQuote lints - Remove feature_flag_unified_buy_v2 from all ramp analytics events in TokenSelection and BuildQuote - Use UnifiedRampRoutingType.AGGREGATOR for ramp_routing fallback - Use userRegion.regionCode for region (Country has isoCode, not code) - Remove redundant useCallback deps and unused useRampsUnifiedV2Enabled in BuildQuote Co-authored-by: Cursor <cursoragent@cursor.com>
Use UNIFIED_BUY_2 and UNIFIED_BUY (underscored) to match the segment schema enum values. Updates event payloads, TypeScript types, and tests. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve merge conflict in BuildQuote.tsx: keep analytics tracking for RAMPS_PAYMENT_METHOD_SELECTOR_CLICKED with main's simplified callback structure. Add analytics tracking to new V2 order details screens: - OrderDetails: RAMPS_SCREEN_VIEWED on mount - OrderContent: RAMPS_EXTERNAL_LINK_CLICKED on provider link press - DepositOrderDetails: RAMPS_SCREEN_VIEWED on mount - Checkout: RAMPS_SCREEN_VIEWED + RAMPS_CLOSE_BUTTON_CLICKED Co-authored-by: Cursor <cursoragent@cursor.com>
Add RAMPS_SCREEN_VIEWED to native flow screens (Verify Identity, Enter Email, OTP Code) for both V2 and Deposit paths. Add RAMPS_BACK_BUTTON_CLICKED via navbar onClose callbacks for all screens: Verify Identity, Enter Email, OTP Code, Order Details. Add RAMPS_TERMS_CONSENT_CLICKED to Verify Identity screens. Add RAMPS_EXTERNAL_LINK_CLICKED to Verify Identity link handlers. Add RAMPS_SETTING_OPTION_CLICKED to Settings modal options (View Order History, Contact Support, Log Out). Add RAMPS_PROVIDER_SELECTED to ProviderSelectionModal. Add RAMPS_CHANGE_PROVIDER_BUTTON_CLICKED to TokenNotAvailableModal. Add RAMPS_QUOTE_ERROR to BuildQuote when quote fetch fails. Add RAMPS_CLOSE_BUTTON_CLICKED to OrderDetails close button. Made-with: Cursor
- Track payment method selection (RAMPS_PAYMENT_METHOD_SELECTED) in PaymentSelectionModal when user picks a method like Apple Pay - Track change provider click from PaymentSelectionModal - Track info tooltip click on Order Details (Processing Info) - Track support link click from ProcessingInfoModal - Update RampsPaymentMethodSelected type to accept UNIFIED_BUY_2 Made-with: Cursor
…event Replace RAMPS_EXTERNAL_LINK_CLICKED with RAMPS_INFO_TOOLTIP_CLICKED for the order details info icon, since it opens an in-app modal rather than an external link. Made-with: Cursor
- Add onBackPress callback to getRampsBuildQuoteNavbarOptions - Fire RAMPS_BACK_BUTTON_CLICKED from BuildQuote (Amount Input) - Fire RAMPS_BACK_BUTTON_CLICKED from Checkout (Aggregator Checkout) Made-with: Cursor
The back arrow is rendered even with showBack: false since showClose defaults to true in getDepositNavbarOptions. Made-with: Cursor
Use a ref guard so RAMPS_SCREEN_VIEWED fires only once per screen mount in BuildQuote and TokenSelection, preventing duplicate events when rampRoutingDecision changes during navigation to Checkout. Made-with: Cursor
- Remove explicit `= undefined` default from getRampsOrderDetailsNavbarOptions onClose param to fix TS type narrowing issue - Widen TokenNetworkFilterBar setNetworkFilter prop type to accept plain callback since the component only calls it with direct values - Fix useAnalytics mock in TokenSelection and OrderContent tests to export named trackEvent via arrow wrapper (avoids Jest hoisting timing issue) - Mock useDebouncedValue in TokenSelection tests to prevent async cleanup issues during test teardown - Update TokenSelection snapshots Made-with: Cursor
…reateEventBuilder Replace Ramp-specific trackRampsEvent calls with the shared useAnalytics hook and createEventBuilder pattern across all 17 Unified Buy v2 source files. Remove redundant per-file useAnalytics mocks from test files since the global testSetup.js already provides this mock. Remove analytics assertion test cases that only tested implementation wiring. Made-with: Cursor
…y-v2-analytics Made-with: Cursor # Conflicts: # app/components/UI/Ramp/Views/Checkout/Checkout.tsx
- Gate TokenSelection analytics on isV2UnifiedEnabled flag (HIGH: v2 events were firing for v1 users) - Add hasTrackedScreenViewRef guard to Checkout screen viewed (MED: event could fire multiple times) - Prevent token search re-firing on network filter change by tracking previous search string - Update E2E test to expect UNIFIED_BUY_2 when v2 flag is enabled - Remove duplicate useRampsUnifiedV2Enabled hook call in TokenSelection Made-with: Cursor
- Wrap new URL() in try-catch in ProcessingInfoModal to prevent crash on malformed URLs - Add ref guard to quote error event to prevent duplicate firing on dependency changes Made-with: Cursor
Move new URL() out of the try block that opens the browser so a malformed provider URL does not prevent the link from opening. Made-with: Cursor
Made-with: Cursor
… Segment PR feedback - Rename text to button_text for Ramps Button Clicked (all call sites) - Rename text to external_link_description for Ramps External Link Clicked - FundActionMenu v2: button_text Buy (not Add funds); Sell unchanged - Card add funds: button_text Fund with cash to match visible label - Update tests for new property names Made-with: Cursor
Made-with: Cursor
… type Align interface with Segment schema and call sites (ProcessingInfoModal, OrderContent, VerifyIdentity). Made-with: Cursor
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
The changes are primarily analytics-focused and don't fundamentally change the user-facing functionality, but they do touch the Ramps flow extensively. The SmokeRamps tag is the appropriate choice as it covers:
No other tags are needed because:
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.


Description
Add comprehensive analytics events to the Unified Buy v2 flow, covering every user interaction across Token Selection and Amount Input screens. Flow identity uses
ramp_typeonly (e.g.'UNIFIED BUY 2'); for a single dimension in Segment and Data Council.Reason for change: Measure UB2 funnel conversion and drop-offs; compare UB2 vs UB1.
Improvement: 18 new events + enhanced existing events; screen viewed once per visit; Change provider only in Payment Selection modal.
Changes
RAMPS_TOKEN_SELECTEDandRAMPS_BUTTON_CLICKEDacceptramp_type: 'UNIFIED BUY 2'.Related PRs
Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3028
Manual testing steps
Screenshots/Recordings
Ramps Unified Buy V2 Analytics Walkthrough - Watch Video
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Adds/changes analytics instrumentation across multiple ramp screens and entry points, which is moderately risky due to potential schema regressions or event-volume changes (but no funds/auth logic is altered).
Overview
Adds Unified Buy v2 (UB2) analytics instrumentation across the ramps flow, introducing a new
ramp_typevalue (UNIFIED_BUY_2) and a set of new MetaMetrics events (screen views, back/close, settings, quick amounts, provider/payment selection, external links, quote errors, tooltips, etc.).Updates existing ramps events to match the new schema (notably renaming the
RAMPS_BUTTON_CLICKEDproperty fromtexttobutton_text) and wires UB2-awareramp_typeselection into multiple entry points (e.g.,BalanceEmptyState,FundActionMenu,AccountsMenu, Card add-funds deposit).Extends navigation header helpers to support an optional
onBackPresscallback so screens can track back navigation, and adjusts unit/smoke tests and snapshots accordingly.Written by Cursor Bugbot for commit 2fb77db. This will update automatically on new commits. Configure here.