WOOA7S-1501: Port Stats Comments widget#50149
Draft
kangzj wants to merge 3 commits into
Draft
Conversation
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.
Contributor
|
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. 🤷 |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Proposed changes
Ports the Jetpack Stats Comments module into a registered Premium Analytics dashboard widget (
jpa/comments).widgets/comments/(package.json,widget.json,widget.ts,render.tsx,comments.module.css, story).<button type="button">tablist with localuseState) over aLeaderboardChartfromwidgets-toolkit.useStatsCommentshook inpackages/data; the widget reaches the normalized authors/posts groups (report.data[0].items→ groupchildren). No new data-layer or toolkit code.max=0⇒ all rows;WidgetLoadingOverlayonly 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 withuseMultipliers; picker-preview aspect-ratio block in the CSS Module.Default,WithComparison,WidgetDashboardWithWidget) at titlePackages/Premium Analytics/Widgets/Comments,tags: [ 'autodocs' ], withregisterReportMocks()plus a localstats/commentsmock and an Authors/Posts view control wired into the render.No comparison period: the Stats
commentsendpoint is date-range agnostic and returns no comparison rows, soWithComparisonrenders identically (no fabricated deltas), documented in the story.Note on
MetricTabsChart: the port brief mentionedMetricTabsChartfor 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 (thelocations/widget pattern) overLeaderboardChart— 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.Default,WithComparison, andWidgetDashboardWithWidgetstories render, and that the view control switches between Authors and Posts leaderboards.