-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(deposit): transactions analytics #17339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…to feat/deposit/transactions-analytics
|
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. |
…to feat/deposit/transactions-analytics
|
app/components/UI/Ramp/Deposit/Views/OrderProcessing/OrderProcessing.tsx
Outdated
Show resolved
Hide resolved
|
|
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unnecessary Dependencies Cause Duplicate Analytics Events
The useEffect hook responsible for tracking RAMPS_TRANSACTION_COMPLETED and RAMPS_TRANSACTION_FAILED analytics events has an overly broad dependency array. It includes navigation and orderId, which are not used within the effect's analytics logic, and depends on the entire order object. This causes the effect to re-run unnecessarily and fire duplicate analytics events whenever these dependencies change, even if the order's completion or failure state has not changed.
app/components/UI/Ramp/Deposit/Views/OrderProcessing/OrderProcessing.tsx#L87-L146
metamask-mobile/app/components/UI/Ramp/Deposit/Views/OrderProcessing/OrderProcessing.tsx
Lines 87 to 146 in d125ef0
| useEffect(() => { | |
| if (!order) return; | |
| const isCompleted = order.state === FIAT_ORDER_STATES.COMPLETED; | |
| const isFailed = order.state === FIAT_ORDER_STATES.FAILED; | |
| if (isCompleted || isFailed) { | |
| if (hasDepositOrderField(order.data, 'cryptoCurrency')) { | |
| const cryptoCurrency = getCryptoCurrencyFromTransakId( | |
| (order.data as DepositOrder).cryptoCurrency, | |
| ); | |
| const baseAnalyticsData = { | |
| ramp_type: 'DEPOSIT' as const, | |
| amount_source: Number(order.data.fiatAmount), | |
| amount_destination: Number(order.cryptoAmount), | |
| exchange_rate: Number(order.data.exchangeRate), | |
| payment_method_id: order.data.paymentMethod, | |
| country: selectedRegion?.isoCode || '', | |
| chain_id: cryptoCurrency?.chainId || '', | |
| currency_destination: | |
| selectedWalletAddress || order.data.walletAddress, | |
| currency_source: order.data.fiatCurrency, | |
| }; | |
| if (isCompleted) { | |
| trackEvent('RAMPS_TRANSACTION_COMPLETED', { | |
| ...baseAnalyticsData, | |
| gas_fee: order.data.networkFees | |
| ? Number(order.data.networkFees) | |
| : 0, | |
| processing_fee: order.data.partnerFees | |
| ? Number(order.data.partnerFees) | |
| : 0, | |
| total_fee: Number(order.data.totalFeesFiat), | |
| }); | |
| } else if (isFailed) { | |
| trackEvent('RAMPS_TRANSACTION_FAILED', { | |
| ...baseAnalyticsData, | |
| gas_fee: order.data.networkFees | |
| ? Number(order.data.networkFees) | |
| : 0, | |
| processing_fee: order.data.partnerFees | |
| ? Number(order.data.partnerFees) | |
| : 0, | |
| total_fee: Number(order.data.totalFeesFiat), | |
| error_message: order.data.statusDescription || 'transaction_failed', | |
| }); | |
| } | |
| } | |
| } | |
| }, [ | |
| order, | |
| navigation, | |
| orderId, | |
| trackEvent, | |
| selectedWalletAddress, | |
| selectedRegion, | |
| ]); |
Was this report helpful? Give feedback by reacting with 👍 or 👎
…to feat/deposit/transactions-analytics
|
|



Description
This PR adds analytics tracking for Transaction related events. (Confirmed, Completed, Failed)
Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist