Skip to content

WOOA7S-1501: Port Stats Comments widget#50149

Draft
kangzj wants to merge 3 commits into
trunkfrom
add/wooa7s-1501-comments
Draft

WOOA7S-1501: Port Stats Comments widget#50149
kangzj wants to merge 3 commits into
trunkfrom
add/wooa7s-1501-comments

Conversation

@kangzj

@kangzj kangzj commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

Ports the Jetpack Stats Comments module into a registered Premium Analytics dashboard widget (jpa/comments).

  • New self-contained widget under widgets/comments/ (package.json, widget.json, widget.ts, render.tsx, comments.module.css, story).
  • Composite layout: a local Authors / Posts tab toggle (<button type="button"> tablist with local useState) over a LeaderboardChart from widgets-toolkit.
    • Authors view: comment authors ranked by comment count, with avatars.
    • Posts view: most commented posts, each linking to the published post.
  • Data comes from the existing useStatsComments hook in packages/data; the widget reaches the normalized authors/posts groups (report.data[0].items → group children). No new data-layer or toolkit code.
  • Honors the Stats-widget contract: max=0 ⇒ all rows; WidgetLoadingOverlay only when loading with no data (tab chrome stays visible, only the content area shows the state); no self-rendered heading; strings via __( …, 'jetpack-premium-analytics' ); counts formatted with useMultipliers; picker-preview aspect-ratio block in the CSS Module.
  • Three Storybook stories per the package template (Default, WithComparison, WidgetDashboardWithWidget) at title Packages/Premium Analytics/Widgets/Comments, tags: [ 'autodocs' ], with registerReportMocks() plus a local stats/comments mock and an Authors/Posts view control wired into the render.

No comparison period: the Stats comments endpoint is date-range agnostic and returns no comparison rows, so WithComparison renders identically (no fabricated deltas), documented in the story.

Note on MetricTabsChart: the port brief mentioned MetricTabsChart for the toggle, but that primitive is a metric switcher over a line chart and cannot host a leaderboard; the Comments module is two leaderboards behind a toggle. The toggle is therefore built with local tab state (the locations/ widget pattern) over LeaderboardChart — no upstream (widgets-toolkit / packages/data / @automattic/charts) changes were needed.

Related product discussion/links

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

No. It renders existing Jetpack Stats comments data already available through the Premium Analytics proxy.

Testing instructions

  • pnpm exec eslint projects/packages/premium-analytics/widgets/comments/**/*.{ts,tsx} — clean.
  • pnpm exec stylelint projects/packages/premium-analytics/widgets/comments/comments.module.css — clean.
  • jetpack build packages/premium-analytics --deps — succeeds.
  • In Storybook, open Packages / Premium Analytics / Widgets / Comments; verify the Default, WithComparison, and WidgetDashboardWithWidget stories render, and that the view control switches between Authors and Posts leaderboards.
  • Live-dashboard verification pending — handled centrally; Storybook + audit + eslint pass locally.

Add the Comments widget to the Premium Analytics dashboard, porting the
Jetpack Stats Comments module. Shows the most active comment authors and
most commented posts behind a local Authors/Posts tab toggle, built on the
widgets-toolkit LeaderboardChart. The Stats comments endpoint is date-range
agnostic and has no comparison period, so the widget renders consistently
regardless of the dashboard date picker.
@github-actions

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

@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 Jul 2, 2026
@jp-launch-control

jp-launch-control Bot commented Jul 2, 2026

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

@kangzj

kangzj commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Live dashboard verification — Comments

Rendered on the connected Premium Analytics dashboard (Insights tab, raven env, blog 254382195) with real data and zero console errors.

Comments

@kangzj kangzj marked this pull request as ready for review July 2, 2026 07:33
@kangzj kangzj requested review from a team as code owners July 2, 2026 07:33
@kangzj kangzj marked this pull request as draft July 2, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Premium Analytics [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant