Skip to content

Premium Analytics: add CSV downloads to full reports - #50547

Merged
layoutd merged 22 commits into
trunkfrom
add/report-page-csv-downloads
Jul 17, 2026
Merged

Premium Analytics: add CSV downloads to full reports#50547
layoutd merged 22 commits into
trunkfrom
add/report-page-csv-downloads

Conversation

@layoutd

@layoutd layoutd commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

  • Add a solid Download action to the top-right page header of the full Posts & Pages report.
  • Export every loaded row from the active Posts & Pages or Archives tab with Title, Views, and URL columns.
  • Reuse the CSV action's feature flag and delivery-state behavior, while keeping the compact widget presentation as its default.
  • Hide the action while the active report is loading, refetching, or in an error state so stale rows cannot be exported.
image

Related product discussion/links

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

No.

Testing instructions

  • Check out this PR with Premium Analytics: split CSV download components #50569 as its base and build Premium Analytics with dependencies: jp build packages/premium-analytics --deps.
  • Enable the POC with add_filter( 'jetpack_premium_analytics_csv_exports_enabled', '__return_true' ); in a local test plugin.
  • Open Analytics, find the Most viewed widget, and click See report.
  • Confirm a solid Download button appears at the top right of the full Posts & Pages report header.
  • Click Download. Confirm it is unavailable while delivery is in progress, then becomes available again and saves a top-posts-<from>_<to>.csv file containing Title, Views, and URL columns for every table row.
  • Switch to the Archives tab and confirm the action downloads an archives-<from>_<to>.csv file containing the active tab's rows.
  • Disable the POC filter and confirm the Download action is not shown.

@github-actions

github-actions Bot commented Jul 15, 2026

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!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 15, 2026
@jp-launch-control

jp-launch-control Bot commented Jul 15, 2026

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report

@layoutd
layoutd force-pushed the add/report-page-csv-downloads branch from ae39893 to 1218ba2 Compare July 16, 2026 13:31
@layoutd layoutd removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 16, 2026
@layoutd
layoutd force-pushed the add/report-page-csv-downloads branch from 1218ba2 to 1e6c24d Compare July 16, 2026 14:30
@layoutd
layoutd changed the base branch from add/direct-report-download to refactor/csv-download-components July 16, 2026 14:30
@layoutd
layoutd requested a review from Copilot July 16, 2026 15:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds CSV download support to the Premium Analytics full “Posts & Pages” report page, reusing the existing CSV export feature gate and the shared row-serialization download action.

Changes:

  • Adds a solid “Download” page-header action that exports the currently loaded rows (Posts & Pages or Archives tab) as CSV with Title/Views/URL columns.
  • Extends the posts report records hook to expose isFetching/isError so the page can hide exports during refetch/error states.
  • Adds route-level tests for the page action and a changelog entry.

Reviewed changes

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

File Description
projects/packages/premium-analytics/routes/reports/posts/page.tsx Builds CSV columns/rows from active tab records and renders a header Download action gated by feature flag + query state.
projects/packages/premium-analytics/routes/reports/posts/page.test.tsx New tests asserting the header action renders and is gated appropriately.
projects/packages/premium-analytics/routes/reports/posts/config/use-report-records.ts Exposes isFetching and isError for both tabs’ records to support export gating.
projects/packages/premium-analytics/changelog/add-report-page-csv-downloads Adds a user-facing changelog entry for the new report-page CSV downloads.

Comment thread projects/packages/premium-analytics/routes/reports/posts/page.tsx
@layoutd
layoutd force-pushed the add/report-page-csv-downloads branch from 1e6c24d to e5d58d1 Compare July 16, 2026 15:40
@layoutd
layoutd requested a review from Copilot July 16, 2026 15:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@layoutd
layoutd marked this pull request as ready for review July 16, 2026 16:36
@layoutd
layoutd requested review from a team as code owners July 16, 2026 16:36

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @layoutd This looks good overall.

Left a suggestion to reuse getDatePart and one non-blocking thought for future report pages.

Comment thread projects/packages/premium-analytics/routes/reports/posts/page.tsx
Base automatically changed from refactor/csv-download-components to trunk July 17, 2026 23:09
…downloads

# Conflicts:
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/download-csv/__tests__/csv-download-button.test.tsx
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/download-csv/csv-download-button.module.scss
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/download-csv/csv-download-button.tsx
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/helpers/build-csv.ts
@layoutd layoutd added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jul 17, 2026
@layoutd
layoutd merged commit 095f4a9 into trunk Jul 17, 2026
83 checks passed
@layoutd
layoutd deleted the add/report-page-csv-downloads branch July 17, 2026 23:33
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Premium Analytics [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants