Transaction confirmation event fired incorrectly#664
Merged
ebma merged 2 commits intoMay 23, 2025
Conversation
✅ Deploy Preview for pendulum-pay ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
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
useTrackRampConfirmationto encapsulatetransaction_confirmationevent - Remove redundant
trackEventcalls fromuseRampSubmission,useQuoteService, anduseSubmitRamp - Integrate the new hook in
useStartRampand 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
trackEventis 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'; | ||
|
|
There was a problem hiding this comment.
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. | |
| */ |
| const fromAsset = rampDirection === RampDirection.ONRAMP ? fiatToken : onChainToken; | ||
| const toAsset = rampDirection === RampDirection.ONRAMP ? onChainToken : fiatToken; | ||
| trackEvent({ | ||
| event: 'transaction_confirmation', |
There was a problem hiding this comment.
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, |
ebma
approved these changes
May 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We called
transaction_confirmation3 times in incorrect places, now we call it only once after startRamp