-
Notifications
You must be signed in to change notification settings - Fork 68
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
Ensure ECE button load events are triggered for multiple buttons on the same page #9845
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: +55 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
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.
Code looks great! I just left a non-blocking comment for you, @rafaelzaleski.
I tested that the tracking events/requests are correctly triggered on the following pages:
- Product Page.
- Cart Page (Block, Shortcode)
- Checkout Page (Block, Shortcode)
- WooPay enabled/disabled.
However, I noticed an unintended behavior with WooPay: the tracking event is triggered multiple times (at least twice) on the block-based Cart page. We should probably apply the same fix here to ensure the event is called at least once every second or only once. While this isn’t related to this PR, I wanted to bring up the issue.
@@ -17,20 +17,29 @@ export const trackExpressCheckoutButtonClick = ( paymentMethod, source ) => { | |||
recordUserEvent( event, { source } ); | |||
}; | |||
|
|||
const debouncedTrackApplePayButtonLoad = debounce( ( { source } ) => { |
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.
@rafaelzaleski Is there a scenario where debounce
is truly necessary? It seems we only want to register the tracking event once per page load, regardless of how many times the Express Checkout buttons are rendered. Wouldn’t it be simpler to use lodash’s once
function (didn't test), or even avoid lodash entirely by using an internal flag to prevent multiple calls?
In my tests, I didn’t observe the tracking event being triggered multiple times, but I also didn’t render the Express Checkout buttons multiple times. I still think it’s important to ensure the tracking event runs only once per page load, so I’m unsure if allowing it to be called multiple times after 1 second is the desired behavior.
* develop: Ensure ECE button load events are triggered for multiple buttons on the same page (#9845) Payouts: Add payout bank reference key to payout reports and CSV (#9832) Fix WooPay component spacing (#9748) Use paragraph selector instead of label for pmme appearance (#9840) Allow redirect to the settings page from WCPay connect (#9827) Update references to woocommerce_payments_server (#9824) Fix return types in DocBlocks (#9815) Fix WooPay trial subscriptions purchases (#9778)
Fixes #9795
Changes proposed in this Pull Request
This PR resolves an issue where Apple Pay and Google Pay button load events were not triggered when both buttons were present on the same page. The root cause was the debouncing of trackExpressCheckoutButtonLoad, which suppressed subsequent calls with different arguments. The implementation now debounces load events independently for each payment method, ensuring all events are correctly tracked.
Testing instructions
Prerequisites:
Test the fix:
gpay_button_load
andapplepay_button_load
events are sent when the page loads. (search foradmin-ajax
calls)class-woopay-tracker.php
.$event_obj
variable.gpay_button_load
and one forapplepay_button_load
.Expected Outcome:
gpay_button_load
andapplepay_button_load
events should be triggered when the respective buttons load.npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge