WOOA7S-1495: add Authors widget backed by Jetpack Stats#49570
WOOA7S-1495: add Authors widget backed by Jetpack Stats#49570Nikschavan wants to merge 10 commits into
Conversation
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
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
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. |
| /* 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; |
| * Constants for API endpoints | ||
| */ | ||
| export const reportsPath = '/wc/v3/woocommerce-analytics/proxy/reports'; | ||
| export const statsAppPath = '/jetpack/v4/stats-app'; |
There was a problem hiding this comment.
Temporarily using existing stats endpoint from Jetpack, this can be switched to the proxy endpoint from Premium Analytics once merged
| return { | ||
| summary: { | ||
| authors: authors.length, | ||
| views: authors.reduce( ( total, author ) => total + author.views, 0 ), | ||
| }, | ||
| data: authors, | ||
| }; |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
Temporary hardcoded long date range to view the data in the widget, until we have date range picker in the dashboard
909996e to
d060b2d
Compare
d060b2d to
5bb6dd9
Compare

Proposed changes
Ports the Authors widget from the Jetpack Stats module into the Premium Analytics dashboard, backed by the Jetpack Stats API.
stats-fetchAPI client that goes through the stats-admin proxy (/jetpack/v4/stats-app/sites/{blog_id}/stats/{resource}), plusstatsQuery/statsTopAuthorsQueryquery builders anduseStatsTopAuthors/useStatsBlogIdhooks. The blog ID is resolved once from/jetpack/v4/connection/dataand cached for the page lifetime; queries useskipTokenwhile the blog ID or report date is unresolved.AuthorsWidget(leaderboard chart of top authors by views with comparison support) and abuildTopAuthorsDatahelper, with loading/refetching overlays and empty/error states.jpa/authorsdashboard widget (render entry,widget.json,widget.tswith a configurablemaxattribute). The render entry defaults to an all-time report range until the host can pass the site launch date.withDevtoolsprop so per-widget providers don't each render React Query devtools.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
/jetpack/v4/stats-app/sites/{blog_id}/stats/top-authors).Maximum authorsattribute and verify the list respects the limit.