Skip to content

Premium Analytics: Add Post highlights widget - #50351

Closed
dognose24 wants to merge 4 commits into
trunkfrom
codex/wooa7s-1526-post-detail-highlights
Closed

Premium Analytics: Add Post highlights widget#50351
dognose24 wants to merge 4 commits into
trunkfrom
codex/wooa7s-1526-post-detail-highlights

Conversation

@dognose24

Copy link
Copy Markdown
Contributor

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

  • New jpa/post-detail-highlights widget: three lifetime metric tiles (Views / Likes / Comments) fetched from the proxied stats/post/{id} endpoint via the existing useStatsPost hook.
  • The widget is the first consumer of the post scope plumbing: it reads reportParams.post_id (seeded from the detail page URL through WidgetRoot) 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.
  • Scope note vs the Calypso original: the Calypso card also shows the post's title, date, and thumbnail, but on the Premium Analytics detail page those are owned by the page's summary header (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.
  • Storybook: Default, NoPostScope (the scopeless empty state), and WidgetDashboardWithWidget stories, with a local stats/post mock and a hasPostScope control.
  • Not included: a default-layout seed for the post-detail page. No seeding mechanism exists yet for that page (tab layouts are client-side preferences that start empty) — building one is parent-issue scope (WOOA7S-1622), so for now the widget is added via the widget picker.

Related product discussion/links

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

No. The widget reads the existing stats/post endpoint 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
packages-premium-analytics-widgets-postdetailhighlights--docs
packages-premium-analytics-widgets-postdetailhighlights--default
packages-premium-analytics-widgets-postdetailhighlights--no-post-scope
packages-premium-analytics-widgets-postdetailhighlights--widget-dashboard-with-widget

Testing instructions

  • From projects/packages/premium-analytics: pnpm run typecheck, pnpm run build (or jetpack build --deps packages/premium-analytics).
  • Storybook (pnpm run storybook:dev from projects/js-packages/storybook): open Packages/Premium Analytics/Widgets/PostDetailHighlightsDefault shows the three metric tiles with mock totals; NoPostScope shows the scopeless empty state; the dashboard story renders the framed card.
  • On a Jetpack-connected site with the dashboard: open a post detail page (?page=jetpack-premium-analytics#/post/<post-id>), enter edit mode, and add the "Post highlights" widget from the picker.
  • Confirm the tiles show the post's all-time views, likes, and comments (cross-check against the same post on the legacy Stats post detail page).
  • Add the widget to the main (site-level) dashboard and confirm it renders the "Open a post or page report…" empty state instead of erroring.

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>
@dognose24

This comment has been minimized.

@claude

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 9, 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!

@jp-launch-control

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

@dognose24

This comment has been minimized.

@dognose24

This comment has been minimized.

@claude

This comment has been minimized.

@dognose24

Copy link
Copy Markdown
Contributor Author

🤖 Review-cycle summary — 36c1bb6dc2698951

3 rounds; CI green; claude[bot] LGTM on re-review; no human comments pending.

What changed during the cycle

Commits added:

  • c2698951f5 — Address review: drop obsolete picker-preview aspect-ratio rule

Review threads addressed:

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.

@dognose24 dognose24 added [Status] Needs Team Review Obsolete. Use Needs Review instead. and removed [Status] In Progress labels Jul 9, 2026
Nikschavan
Nikschavan previously approved these changes Jul 9, 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 for the changes, added two comments.

Comment thread projects/packages/premium-analytics/widgets/post-detail-highlights/render.tsx Outdated
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
@dognose24
dognose24 marked this pull request as draft July 13, 2026 13:24
@dognose24

Copy link
Copy Markdown
Contributor Author

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.

@dognose24

Copy link
Copy Markdown
Contributor Author

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.

@dognose24 dognose24 closed this Jul 13, 2026
@github-actions github-actions Bot removed the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Jul 13, 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