Skip to content
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

Improve Shopper Tracks performance #9677

Open
malithsen opened this issue Nov 5, 2024 · 3 comments
Open

Improve Shopper Tracks performance #9677

malithsen opened this issue Nov 5, 2024 · 3 comments
Labels
component: telemetry The issue is related to Tracks instrumentation focus: checkout payments priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.

Comments

@malithsen
Copy link
Member

Describe the issue

Shopper usage tracking utilizes Ajax requests to record activity at various touchpoints during the checkout process. Each record event emits a separate Ajax request. For high-traffic stores, there can be a high amount of Tracks originated requests hitting the merchant server.

We need to investigate ways to reduce the number of requests going to the merchant server. One option is making these requests in batches. One thing to be cautious of with such an approach is that we need to store the correct timestamp of the user action (not the request timestamp). This will require some refactoring of tracks_build_event_obj function.

Additionally, we can also consider introducing a new filter to disable front-end tracking altogether when needed.

@malithsen malithsen added component: telemetry The issue is related to Tracks instrumentation type: enhancement The issue is a request for an enhancement. labels Nov 5, 2024
@haszari
Copy link
Contributor

haszari commented Nov 6, 2024

Labelling as checkout payments since the majority of shopper tracking will be related to checkout flows in some way.

Some drive-by thoughts:

Additionally, we can also consider introducing a new filter to disable front-end tracking altogether when needed.

Would this be an additional setting/option on top of global tracking options? IMO we should keep settings related to tracking opt-in/out in one place and simple to use. Ideally, all tracking would respect the Woo wide opt-in setting. If it's worthwhile adding a sub-setting then perhaps this should be at the Woo level.

Shopper usage tracking utilizes Ajax requests to record activity at various touchpoints during the checkout process. Each record event emits a separate Ajax request. For high-traffic stores, there can be a high amount of Tracks originated requests hitting the merchant server.

We need to investigate ways to reduce the number of requests going to the merchant server. One option is making these requests in batches.

Do we know this is a problem? If so, ideally we could define the problem with data / numbers, and relate to merchant or shopper impact.

I also wonder if this problem (tracks performance) is unique to WooPayments shopper events, or if there's a fix/solution already available (either in tracks system or in WPCOM or Jetpack code).

@glagonikas
Copy link

glagonikas commented Nov 6, 2024

Would this be an additional setting/option on top of global tracking options? IMO we should keep settings related to tracking opt-in/out in one place and simple to use. Ideally, all tracking would respect the Woo wide opt-in setting. If it's worthwhile adding a sub-setting then perhaps this should be at the Woo level.

As it stands, none of those tracks appear to respect the global woo setting in WooCommerce ➔ Settings ➔ Advanced ➔ WooCommerce.com ➔ Usage Tracking. In our case, we've explicitly set the global settings to "off" and the platform_tracks still occur.

Disabling platform_tracks using the filter add_filter('wcpay_frontend_tracks', '__return_empty_array', 20); removes some, but there are still some, like the Apple & Google Pay are hardcoded and cannot be removed using this filter.

Do we know this is a problem? If so, ideally we could define the problem with data / numbers, and relate to merchant or shopper impact.

We reported this as we noticed a large number of admin-ajax.php requests on our checkout caused by WooPayments. On very large websites, uncached requests (of any type) take a couple of seconds to complete. Even though those are async and do not really affect the customer, they still incur a load on the servers, because the entire code is loaded.

On quiet days, those will go unnoticed, but during large promotions, you want the site to run as efficiently as possible and reduce the number of uncached requests and therefore the overall server load, so as a minimum, WooPay should respect the global setting.

The Stripe plugin doesn't have such tracking and if those requests were hitting your own servers, they wouldn't cause a load issue, but this is not the case.

Also, I don't see why you need to use /wp-admin/admin-ajax.php instead of a different Ajax handler. Doesn't it make sense to use /wp-admin/admin-ajax.php for backend-related ajax? why bring /wp-admin/ on anything front-end?

I'd treat this as a bug rather than enhancement, considering the global setting is not respected, forcing you to use a filter and even then, some tracking cannot be disabled

@sverleis sverleis added type: bug The issue is a confirmed bug. and removed type: enhancement The issue is a request for an enhancement. labels Nov 11, 2024
@sverleis
Copy link

As per a customer request, I'm switching this label to "bug" rather than "enhancement" since:

  1. WooPayments is tracking when the global settings are off and
  2. Even when customers use the filter, some tracking is not disabled

@pierorocca pierorocca added the priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: telemetry The issue is related to Tracks instrumentation focus: checkout payments priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.
Projects
None yet
Development

No branches or pull requests

5 participants