Skip to content

STATS-505: Premium Analytics: Show day totals for Visitors, Likes, and Comments on the hourly Traffic summary - #52858

Merged
Nikschavan merged 4 commits into
trunkfrom
stats-505-daily-visitors-hourly
Sep 29, 2026
Merged

Nikschavan merged 4 commits into
trunkfrom
stats-505-daily-visitors-hourly

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Fixes STATS-505

Proposed changes

  • On a single-day range (Today, Yesterday, or one custom day), the Traffic summary showed a dash for Visitors, Likes, and Comments, while the classic Stats page shows the real numbers for the same day. The chart is hourly there, and stats/visits fills only views at unit=hour, so the widget marked the other three metrics unavailable and had no total to show. Classic Stats has the same hourly limit, but its cards read a separate unit=day request for those three fields (Stats: Add/day data for hourly view tabs wp-calypso#96656).
  • At the hourly interval, the second stats/visits request now asks for visitors,likes,comments in daily buckets, and the cards show those totals with the change against the comparison period. The chart for those three metrics still says "Hourly data isn't available for this metric.", and Views does not change.
  • The day request is only sent when the range starts and ends on day boundaries. "Last 24 hours" keeps the dash, because daily buckets would count up to two whole days there.
  • MetricTab gets a seriesUnavailable field for this case: the card shows its value and the chart shows the reason. unavailable still hides both, which is what WordAds CPM uses.

Related product discussion/links

  • STATS-505
  • p1790252652318109-slack-C0CMN0V97
  • 11709921-zen

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

No.

Testing instructions

Get the branch onto a site with some traffic today or yesterday: a Jurassic Ninja site with the Jetpack Beta Tester plugin pointed at this branch, or a Jurassic Ninja site with the branch synced.

  • Open Jetpack → Stats v2 (the Premium Analytics dashboard) and choose "Yesterday" in the date picker.
  • In the Traffic summary, the Visitors, Likes, and Comments cards show numbers instead of a dash. Compare Visitors with the classic Stats page for the same day, hourly view: the two numbers match.
  • Select the Visitors tab. The chart shows "Hourly data isn't available for this metric." instead of a line.
  • Turn on comparison. The three cards show a change against the previous day.
  • Choose "Last 24 hours". Visitors, Likes, and Comments show a dash, as before.
  • Choose "Last 7 days". All four cards and charts behave as on trunk.

I checked it on my local site on "Today": the cards match classic Stats (764 views, 18 visitors). I did not check comparison or "Last 24 hours" in the browser.

Before (trunk) After (this branch)
Visitors, Comments and Likes cards show a dash on the hourly Traffic summary Visitors 18, Comments 0 and Likes 0, the same day totals as classic Stats
The hourly Traffic summary on "Today" shows only Views. Visitors, Comments and Likes show the day totals. Views and its chart do not change.

With the Visitors tab selected, the card shows the day total and the chart still says hourly data is not available

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the stats-505-daily-visitors-hourly branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack stats-505-daily-visitors-hourly

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

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

jp-launch-control Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.tsx 78/99 (78.79%) 0.22% 0 💚
projects/packages/premium-analytics/widgets/traffic-chart/use-traffic-chart.ts 41/41 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Updates the Premium Analytics Traffic summary to show daily Visitors, Likes, and Comments totals when displaying hourly charts.

Changes:

  • Adds daily totals requests for whole-day hourly ranges.
  • Supports card-only values with unavailable chart series.
  • Expands widget/toolkit tests and documentation.
File Description
projects/​packages/​premium-analytics/​widgets/​traffic-chart/​use-traffic-chart.ts Updated as part of this pull request.
projects/​packages/​premium-analytics/​widgets/​traffic-chart/​stories/​traffic-chart-widget.stories.tsx Updated as part of this pull request.
projects/​packages/​premium-analytics/​widgets/​traffic-chart/​render.tsx Updated as part of this pull request.
projects/​packages/​premium-analytics/​widgets/​traffic-chart/​__tests__/​use-traffic-chart.test.tsx Updated as part of this pull request.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​components/​metric-tabs-chart/​metric-tabs-chart.tsx Updated as part of this pull request.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​components/​metric-tabs-chart/​__tests__/​metric-tabs-chart.test.tsx Updated as part of this pull request.
projects/​packages/​premium-analytics/​changelog/​stats-505-daily-visitors-hourly Updated as part of this pull request.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

At the hourly grain stats/visits fills only views, so the Visitors, Likes and Comments cards showed a dash. For ranges covering whole days, fetch those metrics in daily buckets for the card totals, as Calypso does, and keep their chart marked unavailable.
getDateRangeSpan() reports a partial-day range longer than 48 hours as days, so a URL range such as 13:00 to 12:59 three days later fetched daily totals for four whole calendar days.
The daily request only fills the Visitors, Likes and Comments cards at the hourly grain, so its failure now drops those tabs back to unavailable instead of replacing the whole summary, including the Views chart that loaded, with the error state.
The package requires fake timers for tests that wait on React Query, so a stalled CI runner cannot push an update past the waitFor deadline.
@Nikschavan
Nikschavan force-pushed the stats-505-daily-visitors-hourly branch from b487dbb to 9f0d48d Compare September 28, 2026 10:42
@Nikschavan
Nikschavan marked this pull request as ready for review September 28, 2026 10:47
@Nikschavan
Nikschavan requested a review from a team as a code owner September 28, 2026 10:47
@Nikschavan Nikschavan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Sep 28, 2026

@louwie17 louwie17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Nikschavan, this tested well and the code looks good! I tested it on a local Docker site with Today, Yesterday, a single custom day, a 3-day custom range on hourly, and Last 24 hours. The Visitors, Comments and Likes cards matched the daily stats/visits totals, and comparison showed the right change against the previous day.

LGTM 🚀

@Nikschavan
Nikschavan merged commit 37acb7c into trunk Sep 29, 2026
85 checks passed
@Nikschavan
Nikschavan deleted the stats-505-daily-visitors-hourly branch September 29, 2026 03:56
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants