Skip to content

WOOA7S-1508: Port Stats Most popular time widget#50154

Draft
kangzj wants to merge 2 commits into
trunkfrom
add/wooa7s-1508-most-popular-time
Draft

WOOA7S-1508: Port Stats Most popular time widget#50154
kangzj wants to merge 2 commits into
trunkfrom
add/wooa7s-1508-most-popular-time

Conversation

@kangzj

@kangzj kangzj commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes WOOA7S-1508

Proposed changes

  • Ports the Jetpack Stats "Most popular time" highlight into a registered Premium Analytics widget (jpa/most-popular-time, category stats, framed presentation).
  • Shows the peak hour for views and its share of the total (hour rendered via <Text>, share via MetricWithComparison value-only), above a bar chart of views across the day rendered with the toolkit BarChart.
  • Data comes from the existing useStatsInsights hook (stats/insights proxy). The insights endpoint reports across the whole lifetime of the site, so there is no date range and no comparison periodWithComparison renders identically to Default, which the story documents.
  • Follows the Stats-widget contract: two-component split with WidgetRoot, WidgetLoadingOverlay only when loading with no data, host-owned chrome (no body heading), all strings through __( …, 'jetpack-premium-analytics' ), CSS Modules with --wpds-* tokens only, and the picker-preview aspect-ratio block.
  • Adds three Storybook stories (Default, WithComparison, WidgetDashboardWithWidget) per the AGENTS.md template. Central mocks don't cover stats/insights, so a story-scoped apiFetch middleware mocks it inside the story file (the shared register-report-mocks is untouched).

Scope is additive only: the new widgets/most-popular-time/** folder plus a changelog entry. The Storybook widgets root is already registered in projects.js.

Related product discussion/links

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

No. It reuses the existing stats/insights proxy endpoint via the existing useStatsInsights data hook; no new tracking.

Testing instructions

  • Live-dashboard verification pending — handled centrally; Storybook + audit + eslint + build pass locally.
  • In Storybook, open Packages / Premium Analytics / Widgets / MostPopularTime and confirm:
    • Default shows the peak-hour highlight, its share of views, and the hourly bar chart.
    • WithComparison renders identically (insights has no comparison period).
    • WidgetDashboardWithWidget renders the widget in the real dashboard chrome (framed card).
  • Local checks that pass: pnpm exec eslint (clean), stylelint (clean), tsc --noEmit (clean), jetpack build packages/premium-analytics --deps (succeeds), and /widget-audit most-popular-time (no violations).

Ports the Jetpack Stats "Most popular time" highlight into a registered
jpa/most-popular-time widget: the peak hour for views and its share, above a
bar chart of views across the day. Data comes from the useStatsInsights hook;
the insights endpoint has no date range or comparison period.
@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 — Most popular time

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

Most popular time

@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