Skip to content

Transaction confirmation event fired incorrectly#664

Merged
ebma merged 2 commits into
stagingfrom
657-transaction-confirmation-event-fired-incorrectly
May 23, 2025
Merged

Transaction confirmation event fired incorrectly#664
ebma merged 2 commits into
stagingfrom
657-transaction-confirmation-event-fired-incorrectly

Conversation

@Sharqiewicz
Copy link
Copy Markdown
Member

@Sharqiewicz Sharqiewicz commented May 22, 2025

We called transaction_confirmation 3 times in incorrect places, now we call it only once after startRamp

@Sharqiewicz Sharqiewicz linked an issue May 22, 2025 that may be closed by this pull request
@netlify
Copy link
Copy Markdown

netlify Bot commented May 22, 2025

Deploy Preview for pendulum-pay ready!

Name Link
🔨 Latest commit 31d24b8
🔍 Latest deploy log https://app.netlify.com/projects/pendulum-pay/deploys/682f6df84932e00008e460cf
😎 Deploy Preview https://deploy-preview-664--pendulum-pay.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Sharqiewicz Sharqiewicz requested review from a team and Copilot May 22, 2025 18:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Centralize the transaction confirmation event logic by extracting it into a dedicated hook and removing duplicate tracking calls across multiple submission and quote hooks.

  • Introduce useTrackRampConfirmation to encapsulate transaction_confirmation event
  • Remove redundant trackEvent calls from useRampSubmission, useQuoteService, and useSubmitRamp
  • Integrate the new hook in useStartRamp and simplify quote store usage

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/hooks/useTrackRampConfirmation.ts New hook for firing the transaction_confirmation event
frontend/src/hooks/ramp/useRampSubmission.ts Removed inlined tracking logic
frontend/src/hooks/ramp/useQuoteService.ts Removed quote-based tracking effect and unused quote destructuring
frontend/src/hooks/offramp/useSubmitRamp.ts Removed inline transaction confirmation tracking
frontend/src/hooks/offramp/useRampService/useStartRamp.ts Added useTrackRampConfirmation hook to fire event after start
Comments suppressed due to low confidence (1)

frontend/src/hooks/useTrackRampConfirmation.ts:16

  • Add unit tests for this hook to verify that trackEvent is called with the correct payload under both ONRAMP and OFFRAMP directions.
return useCallback(() => {

import { useQuoteStore } from '../stores/ramp/useQuoteStore';
import { RampDirection } from '../components/RampToggle';
import { useEventsContext } from '../contexts/events';

Copy link

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a JSDoc comment above this hook to explain its purpose and parameters for future maintainers.

Suggested change
/**
* A custom hook that tracks the confirmation of a ramp transaction.
*
* This hook uses various stores and contexts to gather information about the
* transaction, such as the ramp direction, input amount, and quote details.
* It then triggers an event to log the transaction confirmation.
*
* Dependencies:
* - `useRampDirection`: Determines the direction of the ramp (ONRAMP/OFFRAMP).
* - `useEventsContext`: Provides the `trackEvent` function for logging events.
* - `useFiatToken`, `useOnChainToken`: Retrieve the fiat and on-chain tokens.
* - `useInputAmount`: Gets the input amount for the transaction.
* - `useQuoteStore`: Provides the quote details, including the output amount.
*
* @returns {Function} A callback function that logs the transaction confirmation event.
*/

Copilot uses AI. Check for mistakes.
const fromAsset = rampDirection === RampDirection.ONRAMP ? fiatToken : onChainToken;
const toAsset = rampDirection === RampDirection.ONRAMP ? onChainToken : fiatToken;
trackEvent({
event: 'transaction_confirmation',
Copy link

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract the magic string 'transaction_confirmation' into a shared constant to avoid typos and make updates easier.

Suggested change
event: 'transaction_confirmation',
event: TRANSACTION_CONFIRMATION_EVENT,

Copilot uses AI. Check for mistakes.
@ebma ebma merged commit 66be8ee into staging May 23, 2025
5 checks passed
@ebma ebma deleted the 657-transaction-confirmation-event-fired-incorrectly branch May 23, 2025 09:45
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.

Transaction confirmation event fired incorrectly

3 participants