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

[HC] woocommerce.com requested on every admin page #2738

Open
anastas10s-afk opened this issue May 22, 2024 · 6 comments
Open

[HC] woocommerce.com requested on every admin page #2738

anastas10s-afk opened this issue May 22, 2024 · 6 comments

Comments

@anastas10s-afk
Copy link

The https://api.woocommerce.com/payment/sift URL is being requested on every page in the admin, adding .67s (depending on the server response time) to the page generation time of admin pages.

The external request to the sift URL is found within the admin_print_footer_scripts action in the woocommerce-services\woocommerce-services.php file, on line #897:
add_action( ‘admin_print_footer_scripts’, array( $this, ‘add_sift_js_tracker’ ) );

This will load the “add_sift_js_tracker” function on every admin page, which then requests https://api.woocommerce.com/payment/sift

This can be seen below in the add_sift_js_tracker function which calls “get_sift_configuration” that makes the HTTP request to the woocomerce.com/payment/sift URL

    public function add_sift_js_tracker() {
        $sift_configurations = $this->api_client->get_sift_configuration();
    }
    public function get_sift_configuration() {
        return $this->request( 'GET', '/payment/sift' );
    }

Here is a tool to see the response time of that request from around the world:
https://tools.keycdn.com/performance?url=https://api.woocommerce.com/payment/sift

From Sydney it’s taking .74s to respond . This adds .74s to the backend page generation whilst WordPress waits for the request to finish.

From what I gather, related to #2689 .
Reported at:

@der-martin85
Copy link

der-martin85 commented Jun 26, 2024

I added these lines to the beginning of the add_sift_js_tracker method in "woocommerce-services.php":

                public function add_sift_js_tracker() {
                        global $pagenow;
                        if ($pagenow !== 'admin.php' || !isset($_GET['page']) || !in_array($_GET['page'], ['wc-orders'])) return;

So now the tracker is only added to pages where I think it is needed.

Maybe this can be solved by the page that requires the tracker to set some global variable that is being checked in the method instead of checking a list of pages in the method.

@AntonyXSI
Copy link

Is there a reason it needs to load on the orders page? Ideally there wouldn't be any external requests impacting the load time on the order listings page as it will be requested often. If it is required is there any way to cache the api.woocommerce.com/payment/sift get request for a short period or does the nonce, signature etc returned from that request need to be dynamic.

Bear in mind the wc-orders page is only for when HPOS is enabled otherwise the standard post type edit screen is requested (edit.php?post_type=shop_order)

@der-martin85
Copy link

I'm not 100% sure what this thing is used for, but I guess it's for creating Shipping Labels and on the wc-orders page (or the shop_order page) you can create Shipping Labels.

But, I will leave this conversation as I uninstalled the plugin, because in my search through why we have it in the first place I found out, that we don't need it. We had another Plugin for the Labels.

@openmindculture
Copy link

If WooCommerce needs to load external scripts, it should use proper WordPress enqueue hooks, so that we can dequeue them at least, or add an option in the WooCommerce settings.

  • What is Sift good for?
  • Is it safe to turn it off?
  • How to do so without patching plugin code?

@rferguson10
Copy link

agreed with all of the above. I tried using remove_action to get rid of this to no avail

@WildWolf-Ryzen
Copy link

Any update to fix this in the near future or maybe provide a code that will only call the API on necessary pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants