-
Notifications
You must be signed in to change notification settings - Fork 69
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
Fix tracks identity cookie cache #9249
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: +844 B (0%) Total Size: 1.32 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.
Thanks for working on this @alefesouza
This is a creative approach. I've noted some concerns in the comments.
Primarily, I don't love the fact that we are recording events as a side effect of the getTracksIdentity
call.
What do you think of, removing the backend tracking for page views and instead recording from frontend when the page has loaded, using recordUserEvent
function?
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.
Nice improvements!
Requesting changes as the events are no longer recorded when WooPay is disabled.
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.
Nice work so far Alefe.
woocommerce_after_main_content
hook only runs on the product page. So with WooPay disabled, the page view events from the cart and the checkout pages are no longer recorded as the frontend script is not added.
Additionally, do you think we can use existing JS scripts to call the recordUserEvent
function on page load instead of dynamically adding a new script? I haven't checked if this is possible, and the current approach is okay if that's not possible.
@malithsen thanks, changed to
I don't think so because this function comes from the |
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.
When placing an order using WooPayments, checkout_order_placed
event is recorded via the checkout_order_processed
function. This internally uses the maybe_record_wcpay_shopper_event
function. Above event is no longer recorded. I haven't found why exactly but I am guessing because this event is emitted between page transitions, frontend scripts never gets a chance to be added on to the footer.
Sorry, I missed this earlier.
@malithsen fixed on 784b47f. |
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.
Looks great now. Thanks for working on this Alefe!
- Verified caching issue is fixed.
- No regressions in Tracks.
- Tracks user identity is preserved on page refreshes.
This reverts commit 2ce5bc7.
Fixes p1722880351733569-slack-C02CCT3F1QA
Changes proposed in this Pull Request
This PR uses the same approach introduced by #8185 to prevent breaking the cache for the products, cart and checkout pages.
Testing instructions
tk_ai
cookie.Set-Cookie
header (this breaks the cache)./wp-admin/admin-ajax.php
request.get_identity
action and thewcpay_product_page_view
event.tk_ai
cookie added by theget_identity
request.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