Skip to content

WOOA7S-1495: add Authors widget backed by Jetpack Stats#49570

Draft
Nikschavan wants to merge 10 commits into
update/pa-introduce-customize-dashboardfrom
wooa7s-1495-port-jetpack-stats-module-authors
Draft

WOOA7S-1495: add Authors widget backed by Jetpack Stats#49570
Nikschavan wants to merge 10 commits into
update/pa-introduce-customize-dashboardfrom
wooa7s-1495-port-jetpack-stats-module-authors

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Jun 12, 2026

Copy link
Copy Markdown
Member

Proposed changes

Google Chrome -2026-06-12 at 11 15 10@2x

Ports the Authors widget from the Jetpack Stats module into the Premium Analytics dashboard, backed by the Jetpack Stats API.

  • data package: adds a stats-fetch API client that goes through the stats-admin proxy (/jetpack/v4/stats-app/sites/{blog_id}/stats/{resource}), plus statsQuery/statsTopAuthorsQuery query builders and useStatsTopAuthors/useStatsBlogId hooks. The blog ID is resolved once from /jetpack/v4/connection/data and cached for the page lifetime; queries use skipToken while the blog ID or report date is unresolved.
  • widgets-toolkit: adds AuthorsWidget (leaderboard chart of top authors by views with comparison support) and a buildTopAuthorsData helper, with loading/refetching overlays and empty/error states.
  • premium-analytics plugin: registers the jpa/authors dashboard widget (render entry, widget.json, widget.ts with a configurable max attribute). The render entry defaults to an all-time report range until the host can pass the site launch date.
  • query client provider: adds a withDevtools prop so per-widget providers don't each render React Query devtools.
  • widget-dashboard: insets picker previews with padding instead of scaling, so preview content clears the selection checkbox.

Related product discussion/links

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

No.

Testing instructions

  • Set up a Jetpack-connected site with the Premium Analytics plugin active.
  • Go to the Premium Analytics dashboard and open the widget picker.
  • Verify the picker previews are inset with padding and the content clears the selection checkbox.
  • Add the Authors widget.
  • Verify it renders a leaderboard of top authors by views, sourced from Jetpack Stats (check the network tab for requests to /jetpack/v4/stats-app/sites/{blog_id}/stats/top-authors).
  • Change the Maximum authors attribute and verify the list respects the limit.
  • On a site with no traffic, verify the empty state copy renders instead of the chart.

retrofox and others added 10 commits June 12, 2026 07:47
Private, source-consumed copy of @wordpress/grid until core publishes it.
Private, source-consumed copy of @wordpress/widget-primitives until core publishes it.
Private, source-consumed dashboard engine; depends on jetpack-widget-primitives and jetpack-grid.
Renders the WidgetDashboard engine via wp-build, bundling the grid/primitives/dashboard packages.
useWidgetTypes drives discovery via /wp/v2/widget-modules; hello-world builds as a lazy-loaded script module.
Hook the page boot-dependencies filter so widget modules reach the import map; move the endpoint to the jetpack/v4 namespace.
@wordpress/grid and widget-primitives references in widget-dashboard JSDoc/comments/README, per the faithful-source sync policy.
- data: add stats-fetch API client, stats queries, and useStatsTopAuthors/useStatsBlogId hooks via the /jetpack/v4/stats-app proxy

- widgets-toolkit: add AuthorsWidget and buildTopAuthorsData helper

- query client provider: add withDevtools prop so per-widget providers don't each render React Query devtools

- widget-dashboard: inset picker previews with padding instead of scaling so content clears the selection checkbox
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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 or WordPress.com Site Helper), and enable the wooa7s-1495-port-jetpack-stats-module-authors branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack wooa7s-1495-port-jetpack-stats-module-authors
bin/jetpack-downloader test jetpack-mu-wpcom-plugin wooa7s-1495-port-jetpack-stats-module-authors

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 commented Jun 12, 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!


Premium Analytics plugin:

No scheduled milestone found for this plugin.

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

@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 Jun 12, 2026
/* Inset the live preview inside the tile: extra top padding clears the
selection checkbox, matching the upstream dashboard picker. */
padding: 32px 16px 16px;
box-sizing: border-box;

@Nikschavan Nikschavan Jun 12, 2026

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.

Add spacing around the widget previews in the widget picker

Image

* Constants for API endpoints
*/
export const reportsPath = '/wc/v3/woocommerce-analytics/proxy/reports';
export const statsAppPath = '/jetpack/v4/stats-app';

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.

Temporarily using existing stats endpoint from Jetpack, this can be switched to the proxy endpoint from Premium Analytics once merged

Comment on lines +67 to +73
return {
summary: {
authors: authors.length,
views: authors.reduce( ( total, author ) => total + author.views, 0 ),
},
data: authors,
};

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.

Stats endpoint is converting data to be consumed by the widgets. Question: Should this be handled by the backend or here?

* TODO: Remove the default range once we have a way to pass the launched date to the widget.
*/
const getDefaultReportParams = () => ( {
from: '2000-01-01T00:00:00',

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.

Temporary hardcoded long date range to view the data in the widget, until we have date range picker in the dashboard

@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

No summary data is available for parent commit 909996e, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for 909996e is available.

Full summary · PHP report · JS report

@louwie17 louwie17 force-pushed the update/pa-introduce-customize-dashboard branch from 909996e to d060b2d Compare June 12, 2026 02:39
@nerrad nerrad force-pushed the update/pa-introduce-customize-dashboard branch from d060b2d to 5bb6dd9 Compare June 12, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants