Skip to content

Conversation

chihsuan
Copy link
Member

@chihsuan chihsuan commented Sep 19, 2025

Related to pfKYZu-2Yt-p2#comment-3041

Proposed changes

This PR introduces a proxy speed module that inspired by Plausible's proxy speed module for WooCommerce Analytics to enhance the proxy API performance.

The module is placed in the mu-plugins directory to prevent unnecessary plugins from being loaded during proxy requests, thereby improving performance.

Other information

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

n/a

Does this pull request change what data or activity we track or use?

n/a

Testing instructions

Confirm proxy speed module is added/removed as Jetpack is activated/deactivated

  1. Set up a WordPress site with both Jetpack and WooCommerce installed.
  2. Check out and activate this branch of Jetpack.
  3. If you have the local WooCommerce Analytics plugin activated, deactivate it. We will add similar logic in Woo Analytics so that the proxy speed module is added/removed as Woo Analytics is activated/deactivated.
  4. Deactivate Jetpack. Then, verify that the file wp-content/mu-plugins/woocommerce-analytics-proxy-speed-module.php does not exist.
  5. Activate Jetpack. Then, verify that the file wp-content/mu-plugins/woocommerce-analytics-proxy-speed-module.php does exist.
  6. (Optional) Repeat steps 4 and 5 to confirm the file is created/removed as Jetpack is activated/deactivated.

Test REST API request

  1. Install Code Snippets plugin
  2. Add the following code snippet to the site:
function test_add_rest_api( ) {
 error_log( 'test_add_rest_api is called' );
}

add_action( 'rest_api_init', 'test_add_rest_api' );
  1. Test request to the cart API:
curl https://your-site.com/wp-json/wc/store/v1/cart
  1. Confirm that the test_add_rest_api function is called is logged in the wp-content/debug.log file.
  2. Test request to the proxy API
curl -X POST https://your-site.com/wp-json/woocommerce-analytics/v1/track \
  -H "Content-Type: application/json" \
  -d '{
    "event_name": "page_view"
  }'
  1. Confirm that the test_add_rest_api function is not called.

@chihsuan chihsuan self-assigned this Sep 19, 2025
@chihsuan chihsuan added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. labels Sep 19, 2025
Copy link
Contributor

github-actions bot commented Sep 19, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/wca-proxy-speed-module branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/wca-proxy-speed-module

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Feature] WooCommerce Analytics [Package] WooCommerce Analytics Enhanced analytics for WooCommerce users [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Sep 19, 2025
Copy link
Contributor

github-actions bot commented Sep 19, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 7, 2025
    • Code freeze: October 6, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Sep 19, 2025
@chihsuan chihsuan added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Sep 19, 2025
@chihsuan chihsuan requested review from a team September 19, 2025 06:38
Copy link

jp-launch-control bot commented Sep 19, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/woocommerce-analytics/src/class-woocommerce-analytics.php 0/59 (0.00%) 0.00% 20 💔
projects/plugins/jetpack/class.jetpack.php 715/2265 (31.57%) 0.12% 0 💚

1 file is newly checked for coverage.

File Coverage
projects/packages/woocommerce-analytics/src/mu-plugin/woocommerce-analytics-proxy-speed-module.php 0/13 (0.00%) 💔

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

Base automatically changed from wooa7s-489-implement-on-site-pixel-api-endpoint-with-post-support to trunk September 22, 2025 02:24
- Introduced a new class `WooCommerceAnalyticsProxySpeed` to handle proxy requests and optimize performance.
- Added methods to manage the installation and removal of the proxy speed module.
- Implemented functionality to filter active plugins based on proxy requests.
- Created a new MU plugin file for the proxy speed module.
- Added a constant for the proxy speed module version.
- Updated methods to manage the addition and removal of the proxy speed module, removing unnecessary user capability checks.
- Changed the installation process to copy the proxy speed module file instead of a directory.
- Integrated calls to add and remove the proxy speed module in Jetpack plugin initialization and deactivation processes.
@chihsuan chihsuan force-pushed the add/wca-proxy-speed-module branch from 66873bc to 3e2273b Compare September 24, 2025 06:21
@chihsuan chihsuan requested a review from Copilot September 24, 2025 06:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a proxy speed module for WooCommerce Analytics to enhance proxy API performance by selectively loading only necessary plugins during proxy requests. The module is inspired by Plausible's implementation and is placed in the mu-plugins directory to prevent unnecessary plugins from being loaded.

Key changes:

  • Adds a proxy speed module that filters active plugins for WooCommerce Analytics proxy requests
  • Integrates module installation/removal with Jetpack plugin activation/deactivation lifecycle
  • Implements file management methods to copy the module to mu-plugins directory and clean up on deactivation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

File Description
class.jetpack.php Integrates proxy speed module lifecycle with Jetpack activation/deactivation
woocommerce-analytics-proxy-speed-module.php Core proxy speed module that filters active plugins for performance
class-woocommerce-analytics.php Adds methods to manage proxy speed module installation and removal
changelog files Documents the feature addition

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and tested well!
Would appreciate a review from @kangzj still given it was his original suggestion, and he said in the P2 comment "We’ll need input and assistance from the ops team for this approach", meaning we should loop in ops for this review as well? or is that a follow up?

@chihsuan
Copy link
Member Author

Would appreciate a review from @kangzj still given it was his original suggestion, and he said in the P2 comment "We’ll need input and assistance from the ops team for this approach", meaning we should loop in ops for this review as well? or is that a follow up?

If I understand correctly, @kangzj suggested that for "CIAB sites," we could work with the ops team to set up a direct proxy at the web server level for optimal performance. This remains a viable option, though it would require some additional effort to implement. However, I think it's nice to have a choice, especially now that we've also added the proxy API with the proxy speed module.

I'd also appreciate a review or feedback from @kangzj. 🙏

Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! You rock 🎸

@chihsuan chihsuan merged commit 4aa8d2d into trunk Sep 25, 2025
66 of 67 checks passed
@chihsuan chihsuan deleted the add/wca-proxy-speed-module branch September 25, 2025 06:14
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Sep 25, 2025
@github-actions github-actions bot added this to the jetpack/15.1 milestone Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] WooCommerce Analytics [Package] WooCommerce Analytics Enhanced analytics for WooCommerce users [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants