Premium Analytics: Add Post highlights widget - #50351
Conversation
Ports the Jetpack Stats post detail Highlights all-time stats card as a post-scoped widget: lifetime views, likes, and comments from stats/post, scoped by the detail page's reportParams.post_id. The post's title, date, and featured image stay with the page's summary header. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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! |
Code Coverage SummaryThis 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. 🤷 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🤖 Review-cycle summary —
|
| Source | Comment | Resolution |
|---|---|---|
| claude[bot] | Unexplained [inert] aspect-ratio rule with a selector no sibling uses |
Removed entirely — it was the obsolete picker-preview hack #50294 dropped package-wide; written here from a stale copy of the old AGENTS.md guidance (c2698951f5). Re-review confirmed no regression (this widget has no images, so no inert image-sizing rule is needed either). |
| claude[bot] | MetricTile/METRIC_FORMAT duplicated with latest-post |
Acknowledged — promote to widgets-toolkit when a third consumer appears; the upcoming post-detail widgets (table, likes) are list-shaped. |
| claude[bot] | Hand-rolled loading/error/empty states | Conscious choice matching the latest-post metric-card precedent; zero tiles for a post with no engagement is intended. |
Unaddressed (flagged for owner):
None.
CI: all required checks passing.
Nikschavan
left a comment
There was a problem hiding this comment.
Thank you for the changes, added two comments.
Render loading/error/empty through WidgetState per the current widget guidance (scopeless post_id maps to the empty state, with Retry on errors), and move the stats/post story mock into the shared report mocks as a stats-post fixture so the upcoming post likes widget can reuse it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…st-detail-highlights # Conflicts: # projects/packages/premium-analytics/packages/widgets-toolkit/src/stories/mocks/register-report-mocks.ts
|
Parking this as a draft: the new design spec for the post detail Traffic view folds the highlights metrics (Views / Comments / Likes) into a single Performance card (metric header + comparative trend chart + granularity control) rather than a standalone tiles card, so this widget as designed here is superseded. The reusable pieces — the shared stats-post fixture and the reportParams.post_id scope plumbing — will carry over to the Performance widget. Not closing yet pending the Linear ticket's disposition. |
|
Closing in favor of #50457: the new design spec folds these highlights metrics into the post detail Performance card (metric tabs + comparative view-trend chart), which that PR delivers. The reusable pieces from this PR — the shared stats-post fixture, the reportParams.post_id scope plumbing, and the WidgetState handling — were carried over there. |
Fixes WOOA7S-1526. Part of WOOA7S-1622.
Why
The post/page detail page (shipped in #50096) has no widget showing how a post performed over its lifetime. This adds the "Post highlights" widget — all-time views, likes, and comments for the post being viewed — porting the Jetpack Stats post detail Highlights card into Premium Analytics.
Proposed changes
jpa/post-detail-highlightswidget: three lifetime metric tiles (Views / Likes / Comments) fetched from the proxiedstats/post/{id}endpoint via the existinguseStatsPosthook.reportParams.post_id(seeded from the detail page URL throughWidgetRoot) inside the inner component. Without a post scope — e.g. added to the main dashboard — it renders a scopeless empty state without firing a request.post-summary-card), so the widget renders only the metric tiles to avoid duplicating the header. The likes-list card next to it in Calypso is WOOA7S-1528's separate widget.Default,NoPostScope(the scopeless empty state), andWidgetDashboardWithWidgetstories, with a localstats/postmock and ahasPostScopecontrol.Related product discussion/links
Does this pull request change what data or activity we track or use?
No. The widget reads the existing
stats/postendpoint through the established proxy.Verification
Storybook registers and renders all stories for the widget (
Default,NoPostScope,WidgetDashboardWithWidget);pnpm run typecheck, eslint, and the widget-audit checklist (shape/contract/chrome/tokens/i18n/JSDoc) all pass. Not yet exercised against a live post-detail page — the testing instructions below cover that pass.Storybook story index
Testing instructions
projects/packages/premium-analytics:pnpm run typecheck,pnpm run build(orjetpack build --deps packages/premium-analytics).pnpm run storybook:devfromprojects/js-packages/storybook): openPackages/Premium Analytics/Widgets/PostDetailHighlights—Defaultshows the three metric tiles with mock totals;NoPostScopeshows the scopeless empty state; the dashboard story renders the framed card.?page=jetpack-premium-analytics#/post/<post-id>), enter edit mode, and add the "Post highlights" widget from the picker.