Skip to content

Premium Analytics: Add post detail Post highlights widget - #50457

Merged
dognose24 merged 15 commits into
trunkfrom
codex/wooa7s-post-performance-widget
Jul 14, 2026
Merged

dognose24 merged 15 commits into
trunkfrom
codex/wooa7s-post-performance-widget

Conversation

@dognose24

@dognose24 dognose24 commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Part of WOOA7S-1622 / WOOA7S-1526 (supersedes the parked #50351). The fixed page composition that places this card lives in #50488, stacked on this PR (split back out per review).

Design note: this PR originally shipped a "Performance" card — Views/Comments/Likes metric tabs over a comparative view-trend chart. The current design drops the trend chart from the post detail Traffic view and leads with plain metric tiles, so the widget was reworked into the Post highlights tiles card (ce8ba60871). The earlier review rounds on the chart card (window bucketing, MetricTabsChart layout/colors) were reverted with it; the data-layer and icon work they produced remains.

Why

The post/page detail page has no card showing how the post performed. This adds the Traffic view's highlights card per the current design: views, comments, and likes at a glance. (#50488, stacked on this PR, makes the page a fixed composition that renders it out of the box.)

Proposed changes

  • New jpa/post-detail-highlights widget: the scoped post's Views / Comments / Likes as metric tiles through the shared MetricTileGrid, scoped to the post via reportParams.post_id.
    • Views is period-scoped to the dashboard date range, with a period-over-period delta when the picker's comparison is on. Both windows are summed client-side from one stats/post response — comparison costs no second request.
    • Comments / Likes are lifetime totals (the API has no per-post history for them): their tiles carry an "All-time total" note, and previousValue: null keeps the comparison layout aligned without a fabricated delta.
  • Data layer: expose the stats/post/{id} endpoint's data field — the post's full daily view history as [date, views] tuples — through StatsPostField, the response types, and the sanitizer (normalized oldest-first, with a normalizer test).
  • Icons: redraw the reports icon as a 48px two-tone illustration matching the rest of the icon set (it was the one remaining 24px solid glyph, rendering dark and heavy in 48px empty-state slots; orders-fulfillment's empty state picks up the fix too).
  • Storybook: shared stats-post fixture (deterministic daily series ending today) routed in routeStatsReport(), with Default / WithComparison / NoPostScope / WidgetDashboardWithWidget stories and a hasPostScope control.

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; data is an already-served response field.

Verification

pnpm run typecheck, eslint, the data-layer normalizer test, and the post-detail route tests pass; the widget-audit checklist (shape/contract/chrome/tokens/i18n/JSDoc) holds. Exercised against a live post-detail page on a local docker env.

Testing instructions

  • From projects/packages/premium-analytics: pnpm run typecheck, pnpm run test packages/data/src/processing/stats/__tests__/post.test.ts routes/post-detail.
  • Storybook (pnpm run storybook:dev from projects/js-packages/storybook): open Packages/Premium Analytics/Widgets/PostDetailHighlights — Default shows the three tiles; WithComparison adds a delta to Views only; NoPostScope shows the scopeless empty state.
  • On a Jetpack-connected site: open a post detail page (admin.php?page=jetpack-premium-analytics-wp-admin&p=%2Fpost%2F<post-id>), enter edit mode, add the "Post highlights" widget (with Premium Analytics: make the post detail page a fixed composition #50488 applied it renders by default instead).
  • Confirm the Views total matches the same post and range on the legacy Stats post detail page, and the delta follows the dashboard compare range; Comments and Likes show lifetime totals with an "All-time total" tooltip and no delta.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Feature [Package] Premium Analytics [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants