fix(ramps): TRAM-3534 UB2 V2 orderType + callback purchase analytics#29629
fix(ramps): TRAM-3534 UB2 V2 orderType + callback purchase analytics#29629
Conversation
…trics - Normalize Ramps orderType (buy/BUY) for FiatOrder and purchase event routing - Use isRampsOrderTypeBuy/Sell in controller V2 analytics payload builder - Fire handleOrderStatusChangedForMetrics after WebView callback when status changes - Fix OFFRAMP_PURCHASE_FAILED Aggregator type (OffRampPurchaseFailed) Refs: https://consensyssoftware.atlassian.net/browse/TRAM-3534 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. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #29629 +/- ##
==========================================
- Coverage 82.15% 81.83% -0.33%
==========================================
Files 5178 5227 +49
Lines 137450 138616 +1166
Branches 31079 31469 +390
==========================================
+ Hits 112924 113434 +510
- Misses 16875 17447 +572
- Partials 7651 7735 +84 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These changes are entirely within the ramps/fiat on-off-ramp domain. 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.
Reviewed by Cursor Bugbot for commit f880d75. Configure here.
| export function normalizeRampsOrderTypeForFiatOrder( | ||
| orderType: string | undefined, | ||
| ): FiatOrder['orderType'] { | ||
| const upper = String(orderType ?? '').toUpperCase(); |
There was a problem hiding this comment.
Missing .trim() in normalize vs sibling predicates
Medium Severity
normalizeRampsOrderTypeForFiatOrder omits .trim() on line 12 while the sibling isRampsOrderTypeBuy and isRampsOrderTypeSell in the same file both .trim() before comparing. A whitespace-padded value like ' SELL ' is correctly identified as sell by the predicates (tested explicitly in the analytics test), but normalizeRampsOrderTypeForFiatOrder falls through to the raw passthrough on line 22, storing the un-normalized value in the FiatOrder. This causes a mismatch between how orders are classified for analytics vs how they're stored.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit f880d75. Configure here.
|





Description
UB2 unified buy (V2) orders sometimes carried
orderTypeasbuy(lowercase) from the ramps controller precreated stub or API, while purchase analytics compared strictly toBUY. Buy completions could then emit off-ramp MetaMetrics events (OFFRAMP_PURCHASE_COMPLETED, etc.) even though the flow was on-ramp.This PR:
app/util/ramps/normalizeRampsOrderTypeForFiatOrder.tsand usesisRampsOrderTypeBuy/isRampsOrderTypeSellin the ramps controller V2 analytics payload builder and ingetRampsV2AnalyticsPayload.orderTypewhen mapping aRampsOrdertoFiatOrderinunifiedOrderProcessor.OrderDetails, calls existinghandleOrderStatusChangedForMetricswhen the order status changes (reuses the sameONRAMP_PURCHASE_COMPLETED/ failed / cancelled pipeline as controller polling transitions).OFFRAMP_PURCHASE_FAILEDin Aggregator analytics types toOffRampPurchaseFailed.Changelog
This change is not end-user visible in the product UI; it corrects analytics / instrumentation only.
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3534
Manual testing steps
Screenshots/Recordings
Not applicable (analytics / instrumentation only).
Before
N/A
After
N/A
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Automated tests run
Supersedes closed draft: #29628
Note
Medium Risk
Changes how V2 ramp orders are classified as BUY vs SELL and when terminal-status analytics events are emitted, which could affect downstream metrics and any logic keyed off
FiatOrder.orderType. UI behavior is mostly unchanged, but the new callback-driven analytics trigger could alter event volumes/timing.Overview
Fixes misclassified UB2 (RAMPS_V2) purchase analytics by normalizing
orderType(e.g., handling lowercase/whitespace) and using sharedisRampsOrderTypeBuy/isRampsOrderTypeSellhelpers across the unified order processor and analytics payload builders.Adds a guard to skip terminal-state analytics for non buy/sell order types (e.g.,
TRANSFER/DEPOSIT), and updatesOrderDetailsto emit purchase status-change analytics after callback-based order fetches when the fetched status differs from the prior stored status.Corrects the
AnalyticsEventstyping forOFFRAMP_PURCHASE_FAILEDto useOffRampPurchaseFailed(instead ofOfframpCanceled) and extends test coverage for the new normalization and callback analytics behavior.Reviewed by Cursor Bugbot for commit f880d75. Bugbot is set up for automated code reviews on this repo. Configure here.