Skip to content

feat: Add errorCode field to TransakService#8153

Open
imyugioh wants to merge 1 commit intoMetaMask:mainfrom
imyugioh:feat/ramp-transak-error-code-analytics
Open

feat: Add errorCode field to TransakService#8153
imyugioh wants to merge 1 commit intoMetaMask:mainfrom
imyugioh:feat/ramp-transak-error-code-analytics

Conversation

@imyugioh
Copy link

@imyugioh imyugioh commented Mar 9, 2026

Explanation

This PR adds errorCode support to the TransakDepositOrder type in @metamask/ramps-controller, enabling Transak error codes to flow through to analytics events.

Current state:

  • TransakDepositOrder has statusDescription for failed order messages but no structured error code field.
  • The RAMPS_TRANSACTION_FAILED Segment event logs error_message but has no way to distinguish specific failure reasons (e.g., KYC incomplete, duplicate order, fraud detection).
  • Transak returns errorCode in API error responses (e.g., 4002 for KYC required, 4005 for duplicate order).

What changed:

  • Added errorCode?: string to TransakDepositOrder type in TransakService.ts.
  • The getOrder() method already spreads the full API response into the return object, so errorCode passes through automatically when present.
  • Added unit tests verifying errorCode is passed through when present and undefined when absent.

Why this matters:

  • Enables metamask-mobile to include error_code in the RAMPS_TRANSACTION_FAILED analytics event.
  • Allows the ramps team to distinguish specific failure reasons instead of seeing generic "Something went wrong" messages.
  • Supports root-cause analysis: e.g., "10% of users get error 4002 (KYC incomplete)" vs "orders are failing."

References

Ref: TRAM-3267

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Low risk type-surface change that only adds an optional field and test coverage; runtime behavior is unchanged aside from allowing the API-provided errorCode to be returned to callers.

Overview
Adds errorCode support to deposit orders returned by TransakService. TransakDepositOrder now includes optional errorCode?: string, allowing the orders API response field to pass through to consumers.

Extends getOrder unit coverage to assert errorCode is preserved when present and undefined when absent.

Written by Cursor Bugbot for commit e093f3d. This will update automatically on new commits. Configure here.

@imyugioh imyugioh requested a review from a team as a code owner March 9, 2026 21:58
@imyugioh imyugioh force-pushed the feat/ramp-transak-error-code-analytics branch from 54c4d9a to e093f3d Compare March 9, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant