Skip to content

[WIP] Premium Analytics: port WooCommerce Analytics CSV report export (test)#50094

Draft
layoutd wants to merge 3 commits into
trunkfrom
add/pa-report-export-test
Draft

[WIP] Premium Analytics: port WooCommerce Analytics CSV report export (test)#50094
layoutd wants to merge 3 commits into
trunkfrom
add/pa-report-export-test

Conversation

@layoutd

@layoutd layoutd commented Jun 30, 2026

Copy link
Copy Markdown

Foundation for WOOA7S-1581

Proposed changes

  • Port the WooCommerce Analytics CSV report export subsystem into the jetpack-premium-analytics package, under src/Reports/Export/.
  • Registered only when WooCommerce is active and Jetpack is connected (gated on woocommerce_init + Manager::is_connected()), so it is inert on a plain Jetpack site.
  • Data source re-pointed from WA's own proxy to Premium Analytics' existing data proxy: /jetpack-premium-analytics/v1/proxy/v2/analytics/{endpoint}.
  • Starts with 3 report controllers (Orders, Products, Visitors) to validate the pipeline end to end.
  • Route preserved as /wc/v3/woocommerce-analytics/reports/csv-export so the existing frontend export hook works unchanged.

This is a WIP / test port, not for merge. The goal is to exercise the generation endpoints on a Premium Analytics + WooCommerce store. Known follow-ups before a real PR (all part of decoupling from WooCommerce):

  • Untangle the email layer from WC_Email + WC templates onto generic / Jetpack / Premium Analytics branding.
  • Normalize file and class naming and the text domain to Premium Analytics conventions (class-*.php, Snake_Case, jetpack-premium-analytics); the ported files keep WA's PSR-4 names and woocommerce-analytics domain for now.
  • Replace the WC-backed logger (DebugLogger wrapping WC_Logger) with a non-WC implementation for a Jetpack-only path.
  • Add the remaining 12 report controllers once the pipeline is validated.

Related product discussion/links

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

No new tracking. It exposes existing WordPress.com analytics report data as a CSV (download or email) to authorized users (manage_options / the connected blog). The email delivery path sends report data via wp_mail; worth a privacy review before the email path is productionized.

Testing instructions

Requires WooCommerce active, Jetpack connected, and the store provisioned on WordPress.com analytics.

  • Check out add/pa-report-export-test and run jetpack build plugins/premium-analytics.
  • Activate Premium Analytics and WooCommerce; confirm the Jetpack connection.
  • Confirm the route registers, then exercise it (as a user with manage_options):
    • POST /wp-json/wc/v3/woocommerce-analytics/reports/csv-export with report_type[]=orders, from, to, interval=day, delivery_method=download -> expect a CSV stream.
    • Repeat with report_type[]=products and report_type[]=visitors.
    • With delivery_method=email -> expect a 202 and an "export ready" email with the CSV attached (locally, catch it in Mailpit at http://localhost:1080).
  • Without WooCommerce active: confirm the route is absent and the site loads normally (the gating no-ops).

@github-actions

Copy link
Copy Markdown
Contributor

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 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!

@jp-launch-control

jp-launch-control Bot commented Jun 30, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/src/class-analytics.php 4/57 (7.02%) -0.13% 1 ❤️‍🩹

19 files are newly checked for coverage. Only the first 5 are listed here.

File Coverage
projects/packages/premium-analytics/src/Reports/Export/AbstractCSVReportController.php 0/42 (0.00%) 💔
projects/packages/premium-analytics/src/Reports/Export/CSVExportController.php 0/250 (0.00%) 💔
projects/packages/premium-analytics/src/Reports/Export/CSVExportEmail.php 0/96 (0.00%) 💔
projects/packages/premium-analytics/src/Reports/Export/CSVExportScheduler.php 0/143 (0.00%) 💔
projects/packages/premium-analytics/src/Reports/Export/CSVReportControllerInterface.php 0/1 (0.00%) 💔

Full summary · PHP 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant