-
Notifications
You must be signed in to change notification settings - Fork 72
Phase 2: Implement request batching for shopper tracking events #11189
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
Closed
rtio
wants to merge
2
commits into
woopmnt-4451-update-shopper-tracks-events-enablement-criteria
from
woopmnt-4451-update-shopper-tracks-events-enablement-criteria-2
Closed
Conversation
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
Client-side changes: - Batch multiple tracking events into single requests - Use debounced flush (2s) to group rapid events - Flush immediately on page unload to prevent data loss - Preserve accurate event timestamps from client Server-side changes: - Add platform_tracks_batch Ajax action to handle batch requests - Support custom client timestamps in tracks_build_event_obj - Process multiple events efficiently in single handler Express checkout: - Add tracking enablement check for Apple/Google Pay events - Respect wcpaySettings.enableShopperTracking flag - Maintain backward compatibility when flag not present Testing: - Add unit tests for batch handler validation - Tests for nonce, events format, and error cases Expected impact: 70-85% reduction in tracking-related requests Fixes WOOPMNT-4451 (Phase 2)
Contributor
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. |
Contributor
|
Size Change: +4.44 kB (0%) Total Size: 930 kB
ℹ️ View Unchanged
|
Member
Author
|
Closing since this is not working as I expected. |
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.
Fixes #9677
Note: This PR builds on top of Phase 1 (#11188) and should be merged after it.
Changes proposed in this Pull Request
This PR implements request batching for shopper tracking events to dramatically reduce server load on high-traffic stores. This is Phase 2 of the solution for WOOPMNT-4451.
Problem:
Each shopper tracking event generates a separate Ajax request to
/wp-admin/admin-ajax.php. For high-traffic stores, this creates significant server load:Solution:
Client-side batching:
Server-side batch handler:
platform_tracks_batchAjax actionExpress checkout improvements:
wcpaySettings.enableShopperTrackingflagWhy this approach:
Trade-offs:
How this code can break:
What we're doing to prevent breakage:
Testing instructions
Test 1: Verify batching reduces requests
admin-ajax.phpaction=platform_tracks_batchinstead of 5+ separate requestsTest 2: Verify events are still tracked correctly
Test 3: Test page unload flushing
Test 4: Express checkout tracking respects opt-out
add_filter( 'wcpay_enable_shopper_tracking', '__return_false' );Test 5: Backward compatibility
platform_tracksendpoint still worksTest 6: Unit tests
Test 7: High-traffic simulation
Expected Results:
npm run changelogto add a changelog file, choosepatchto 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