Skip to content

Premium Analytics: Describe widget CSV downloads as action objects - #53013

Merged
chihsuan merged 49 commits into
trunkfrom
uni-823-native-widget-action-prep
Oct 2, 2026
Merged

chihsuan merged 49 commits into
trunkfrom
uni-823-native-widget-action-prep

Conversation

@chihsuan

@chihsuan chihsuan commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Part of UNI-823

Proposed changes

Prepare the widgets' Download CSV action for the dashboard's native widget footer. Nothing changes on screen.

The existing download buttons render these actions, so no widget changes. Moving widget footers onto the native one waits for the Gutenberg change to land.

Related product discussion/links

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

No.

Testing instructions

Setup

  1. Check out this branch on a Jetpack site connected to WordPress.com, with Premium Analytics active and recent Stats data. Run jp build plugins/jetpack --deps.
  2. Open wp-admin/admin.php?page=jetpack-premium-analytics-wp-admin.

Card downloads

  1. Click the download button in the Top pages footer. Confirm the CSV saves as on Premium Analytics: Download full reports from six more widgets #52969.
  2. Repeat on Top referrers.
  3. On a site with WooCommerce, repeat on Orders over time. Confirm the server-generated CSV saves.

Failed download

  1. In the browser console, run URL.createObjectURL = () => { throw new Error( 'Test failure' ); };, then click the Top pages download button.
  2. Confirm a dismissible snackbar shows "Test failure" and the button can be clicked again.
  3. Reload the page to restore downloads.

@chihsuan chihsuan self-assigned this Oct 1, 2026
@chihsuan
chihsuan force-pushed the uni-823-download-full-reports-from-more-widgets branch from f0013fe to 6636bb5 Compare October 1, 2026 06:44
@github-actions github-actions Bot added [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics labels Oct 1, 2026
Nikschavan
Nikschavan previously approved these changes Oct 2, 2026

@Nikschavan Nikschavan 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.

Thank you, the changes look good. I left one question inline about keeping the failure snackbar in parity with upstream.

What I checked: the Top pages and Top referrers download buttons still save their CSVs. I also forced a save failure by making URL.createObjectURL throw. The dismissible snackbar showed, and the button became available again. Blocking stats/top-posts in DevTools did not produce a failure for me, because the download reused the data that was already loaded and sent no request.

Failed download shows a dismissible snackbar

id: string;
label: string;
icon: ReactElement;
/** Never rejects: the dashboard's action runner reports no failure, so this shows the snackbar. */

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.

This action copies the shape of the upstream WidgetCallbackAction and goes one step further: useDownloadWithErrorNotice shows a snackbar when the download fails. Upstream does not have that yet: useRunActions only logs a failed action with console.error, and its comment notes that hosts have no notices capability yet. The snackbar is a useful addition, so is there an upstream issue for it, to keep the two in parity?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No dedicated issue yet, but WordPress/gutenberg#83877 lists it as a follow-up. Once hosts get notices, we can drop ours and let the callback reject.

@chihsuan

chihsuan commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

Good catch, I updated the failed-download steps to force the failure from the console instead.

@chihsuan
chihsuan force-pushed the uni-823-download-full-reports-from-more-widgets branch from 001bce1 to dbc8185 Compare October 2, 2026 03:53
…om-more-widgets' into uni-823-native-widget-action-prep

# Conflicts:
#	projects/packages/premium-analytics/packages/data/src/queries/__tests__/fetch-stats-report-rows.test.ts
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/download-csv/exporter-csv-download-button.tsx
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/report-exports/__tests__/hierarchy-reports.test.ts
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/report-exports/clicks.ts
#	projects/packages/premium-analytics/routes/reports/authors/page.test.tsx
#	projects/packages/premium-analytics/routes/reports/videos/page.test.tsx
#	projects/packages/premium-analytics/tests/js/widget-report-csv-parity.test.tsx
#	projects/packages/premium-analytics/widgets/test-utils.tsx
#	projects/packages/premium-analytics/widgets/top-posts/__tests__/top-posts.test.tsx
Base automatically changed from uni-823-download-full-reports-from-more-widgets to trunk October 2, 2026 04:17
@chihsuan
chihsuan dismissed Nikschavan’s stale review October 2, 2026 04:17

The base branch was changed.

…t-action-prep

# Conflicts:
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/download-csv/exporter-csv-download-button.tsx
#	projects/packages/premium-analytics/tests/js/widget-report-csv-parity.test.tsx
#	projects/packages/premium-analytics/widgets/test-utils.tsx
#	projects/packages/premium-analytics/widgets/top-posts/__tests__/top-posts.test.tsx
@chihsuan
chihsuan merged commit 3640c4f into trunk Oct 2, 2026
77 of 78 checks passed
@chihsuan
chihsuan deleted the uni-823-native-widget-action-prep branch October 2, 2026 05:06
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Oct 2, 2026
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.

2 participants