Skip to content

WOOA7S-2210: Premium Analytics: Handle zero-data periods in charts and highlights - #52795

Merged
Nikschavan merged 8 commits into
trunkfrom
update/pa-zero-data-charts-highlights
Sep 28, 2026
Merged

Nikschavan merged 8 commits into
trunkfrom
update/pa-zero-data-charts-highlights

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Fixes WOOA7S-2210

Proposed changes

  • The Stats API answers a period with no traffic with a zero for every day (stats/visits, the email opens timeline) or a null for every bucket (stats/subscribers), not an empty list. Total views, total visitors, the subscribers chart and the email timeline only checked for an empty list, so they never reached their empty state and drew a flat line at zero instead. They now treat all-zero or all-null data as empty.
  • Every chart built on MetricTabsChart (Traffic summary, the subscribers chart, the email timeline and the WordAds chart) keeps its tabs at zero and shows the no-results message inside the chart area, instead of replacing the whole widget. MetricTabsChart gets an optional empty prop for this, rendered in the same slot it already uses for a metric that is unavailable, and it decides emptiness with the shared isEmptyChartData helper. The check runs per metric: a tab whose metric is all zero shows the message even when another tab has data, unless the chart reads every metric out on hover (WordAds), where the graph stays while any metric has data, and with Compare on, a zero period against a previous period with data still draws both lines. The email timeline keeps a widget-level state only for its prompt to open an email report.
  • Highlights and the Insights components never show an empty state; zero values are fine there. Site overview, Year in review and All-time stats show zeros where the API has no value, the posting activity calendar draws with every day empty, and Views over years shows the current month at zero for a site with no views. Subscriber highlights shows zero for current counts and keeps the placeholder for the 30, 60 and 90 days ago counts it has no data for, so it never claims a site had no subscribers before it existed. Its change since 30 days ago still only shows when that older count is known.
  • Error and loading states are unchanged in all of these widgets.

Related product discussion/links

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

No.

Testing instructions

  • Get this branch onto a site with Stats data and the Premium Analytics dashboard enabled, either a Jurassic Ninja site with the branch synced or the Jetpack Beta Tester plugin pointed at update/pa-zero-data-charts-highlights.
  • Open the Stats v2 dashboard on the Traffic tab and set a custom period from before the site had any traffic, for example January 2005.
  • Traffic summary should keep its four tabs at 0 and show the magnifier with "We couldn’t find results for this time period." in the chart area. Switch between the tabs and between the line and bar chart types; the message should stay.
  • Switch to a period with data and check that the chart draws again. Turn on Compare and check that both periods draw.
  • If Total views or Total visitors is on your dashboard, it should show its empty state for the same empty period instead of a flat line.
  • Open the Insights tab and check that Year in review, All-time stats and the posting activity calendar render with numbers or an empty calendar, never an empty-state message.
Before After
Traffic summary for January 2005 with the tabs at 0 and a flat line along the bottom of a 0 to 80 axis Traffic summary for January 2005 with the tabs at 0 and the magnifier with "We couldn’t find results for this time period." in the chart area
The chart draws a flat line at zero. The tabs stay and the chart area says there are no results.

I checked Traffic summary on my local site with an empty period and with data. The highlight widgets only reach their no-value case on a site the API has nothing for, which my site does not reproduce; unit tests cover those cases with the empty responses the API returns.

@github-actions

github-actions Bot commented Sep 25, 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 update/pa-zero-data-charts-highlights branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/pa-zero-data-charts-highlights

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

github-actions Bot commented Sep 25, 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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Premium Analytics plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions Bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh labels Sep 25, 2026
@jp-launch-control

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

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 11 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/metric-tabs-chart/metric-tabs-chart.tsx 77/98 (78.57%) 0.45% 0 💚
projects/packages/premium-analytics/widgets/all-time-stats/render.tsx 8/8 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/widgets/email-time-series/render.tsx 34/35 (97.14%) -0.08% 0 💚
projects/packages/premium-analytics/widgets/posting-activity/render.tsx 13/13 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/widgets/site-overview/render.tsx 21/21 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

@Nikschavan
Nikschavan marked this pull request as ready for review September 25, 2026 10:38
@Nikschavan
Nikschavan requested a review from a team as a code owner September 25, 2026 10:38
Copilot AI lite review requested due to automatic review settings September 25, 2026 10:38
@Nikschavan Nikschavan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Sep 25, 2026

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

🔵 Needs a closer look

Posting activity can suppress request errors when stale placeholder data is present; current-range error handling should be restored.

Review effort: Lite
Findings: None

What changed in this PR

Updates Premium Analytics widgets to correctly handle zero/null Stats API data.

Changes:

  • Adds chart-level empty states while preserving tabs and zero values.
  • Updates highlights and Insights widgets to display appropriate zeros/placeholders.
  • Adds tests, stories, toolkit support, and changelog entries.
File Reviewed change
projects/​plugins/​wpcomsh/​changelog/​update-pa-zero-data-charts-highlights Changelog entry.
projects/​plugins/​premium-analytics/​changelog/​update-pa-zero-data-charts-highlights Changelog entry.
projects/​plugins/​jetpack/​changelog/​update-pa-zero-data-charts-highlights Changelog entry.
projects/​packages/​premium-analytics/​widgets/​wordads-chart-tabs/​use-wordads-chart.ts Removes widget-level empty-state handling.
projects/​packages/​premium-analytics/​widgets/​wordads-chart-tabs/​render.tsx Adds chart-level empty state.
projects/​packages/​premium-analytics/​widgets/​wordads-chart-tabs/​__tests__/​wordads-chart-tabs.test.tsx Updates WordAds coverage.
projects/​packages/​premium-analytics/​widgets/​views-over-years/​use-views-over-years.ts Handles no-view responses.
projects/​packages/​premium-analytics/​widgets/​views-over-years/​stories/​views-over-years-widget.stories.tsx Updates story coverage.
projects/​packages/​premium-analytics/​widgets/​views-over-years/​render.tsx Renders zero-view data.
projects/​packages/​premium-analytics/​widgets/​views-over-years/​build-views-over-years.ts Builds a zero-valued current month.
projects/​packages/​premium-analytics/​widgets/​views-over-years/​__tests__/​views-over-years.test.tsx Tests zero-view rendering.
projects/​packages/​premium-analytics/​widgets/​views-over-years/​__tests__/​use-views-over-years.test.tsx Tests hook states.
projects/​packages/​premium-analytics/​widgets/​views-over-years/​__tests__/​build-views-over-years.test.ts Tests zero-row construction.
projects/​packages/​premium-analytics/​widgets/​traffic-chart/​stories/​traffic-chart-widget.stories.tsx Updates empty-period story.
projects/​packages/​premium-analytics/​widgets/​traffic-chart/​render.tsx Moves empty state into the chart.
projects/​packages/​premium-analytics/​widgets/​traffic-chart/​__tests__/​render.test.tsx Tests zero-filled charts.
projects/​packages/​premium-analytics/​widgets/​total-visitors/​render.tsx Detects zero visitor data.
projects/​packages/​premium-analytics/​widgets/​total-visitors/​__tests__/​total-visitors.test.tsx Tests zero visitor ranges.
projects/​packages/​premium-analytics/​widgets/​total-views/​render.tsx Detects zero view data.
projects/​packages/​premium-analytics/​widgets/​total-views/​__tests__/​total-views.test.tsx Tests zero view ranges.
projects/​packages/​premium-analytics/​widgets/​subscribers-chart/​render.tsx Handles null subscriber data in-chart.
projects/​packages/​premium-analytics/​widgets/​subscribers-chart/​__tests__/​subscribers-chart.test.tsx Tests null subscriber periods.
projects/​packages/​premium-analytics/​widgets/​subscriber-highlights/​stories/​subscriber-highlights-widget.stories.tsx Updates highlights story.
projects/​packages/​premium-analytics/​widgets/​subscriber-highlights/​render.tsx Shows zero counts and placeholders.
projects/​packages/​premium-analytics/​widgets/​subscriber-highlights/​__tests__/​subscriber-highlights.test.tsx Tests zero and placeholder values.
projects/​packages/​premium-analytics/​widgets/​site-overview/​stories/​site-overview-widget.stories.tsx Updates zero-metric story.
projects/​packages/​premium-analytics/​widgets/​site-overview/​render.tsx Shows zero-valued metrics.
projects/​packages/​premium-analytics/​widgets/​site-overview/​__tests__/​site-overview.test.tsx Tests zero metrics.
projects/​packages/​premium-analytics/​widgets/​posting-activity/​stories/​posting-activity-widget.stories.tsx Updates empty-calendar story.
projects/​packages/​premium-analytics/​widgets/​posting-activity/​render.tsx Renders empty calendars; stale responses can suppress errors.
projects/​packages/​premium-analytics/​widgets/​posting-activity/​__tests__/​posting-activity.test.tsx Tests empty calendars and refetches.
projects/​packages/​premium-analytics/​widgets/​email-time-series/​render.tsx Adds chart-level empty handling.
projects/​packages/​premium-analytics/​widgets/​email-time-series/​__tests__/​email-time-series.test.tsx Tests empty and zero timelines.
projects/​packages/​premium-analytics/​widgets/​annual-highlights/​stories/​annual-highlights-widget.stories.tsx Updates zero-year story.
projects/​packages/​premium-analytics/​widgets/​annual-highlights/​render.tsx Shows zero-valued missing-year tiles.
projects/​packages/​premium-analytics/​widgets/​annual-highlights/​__tests__/​annual-highlights.test.tsx Tests missing-year zeros.
projects/​packages/​premium-analytics/​widgets/​all-time-stats/​stories/​all-time-stats-widget.stories.tsx Updates missing-summary story.
projects/​packages/​premium-analytics/​widgets/​all-time-stats/​render.tsx Shows zero-valued missing totals.
projects/​packages/​premium-analytics/​widgets/​all-time-stats/​__tests__/​all-time-stats.test.tsx Tests missing-summary zeros.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​index.ts Exports shared empty-data support.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​components/​metric-tabs-chart/​stories/​metric-tabs-chart.stories.tsx Adds zero-data chart story.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​components/​metric-tabs-chart/​metric-tabs-chart.tsx Supports per-metric chart empty content.
projects/​packages/​premium-analytics/​packages/​widgets-toolkit/​src/​components/​metric-tabs-chart/​__tests__/​metric-tabs-chart.test.tsx Tests empty and comparison behavior.
projects/​packages/​premium-analytics/​changelog/​update-pa-zero-data-charts-highlights Package changelog entry.

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

@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 on a local Docker site! For a period with no data the Traffic tab keeps the four tabs at 0 with the magnifier in the chart, a period with data draws again, and comparing a period with no data against one with views still draws both series. Year in review, All-time stats and the posting calendar all render with numbers, no empty state.

I did leave two inline comments. The main thing to fix is the new isEmptyChartData export from the widgets toolkit, which isn't used outside the toolkit, so we should drop that. The other one is smaller, around the empty state being decided per tab, which on WordAds hides the hover readout of the other metrics even when those have data. Maybe that's fine, but wanted to flag it.

Also a heads up, as you mentioned #52794 touches the same five render files. The new total views/visitors tests here assert the old "No views in this period." copy, so whichever lands second will need those tests updated too, not only the render hunks.

Let me know what you think.

Comment thread projects/packages/premium-analytics/packages/widgets-toolkit/src/index.ts Outdated
@Nikschavan
Nikschavan requested a review from louwie17 September 28, 2026 01:48
@Nikschavan
Nikschavan force-pushed the update/pa-zero-data-charts-highlights branch from 37ba365 to e1a6aee Compare September 28, 2026 04:44
louwie17
louwie17 previously approved these changes 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 for the updates @Nikschavan, and for dropping the export and keeping the WordAds readout! This tested well again on a local Docker site. I left one small nit, happy if it's a follow up. Good to ship 🚢

Comment thread projects/packages/premium-analytics/widgets/traffic-chart/render.tsx Outdated
The Stats API answers an empty period with zero-filled days, so total views, total visitors, the subscribers chart and the email timeline drew a flat line and never reached their empty state. They now count all-zero or null data as empty. Traffic summary keeps its tabs at zero and shows the no-results message inside the chart, per metric, through a new empty prop on MetricTabsChart.

Highlights and Insights components no longer show an empty state: site overview, Year in review and All-time stats show zeros, the posting activity calendar and Views over years draw empty, and Subscriber highlights shows zero for current counts and a placeholder for past counts it has no data for.

Part of WOOA7S-2210.
Site owners read the plugin changelogs, not the package one, so the entry also goes to each plugin that ships Premium Analytics.
…harts

The subscribers chart, the email timeline and the WordAds chart render MetricTabsChart but replaced the whole widget when a period had no data, while Traffic summary kept its tabs at zero and showed the message in the plot. They now pass the same empty content to MetricTabsChart, so an idle period looks the same in every tab chart. The email timeline keeps a widget-level state only for its missing-email prompt.

MetricTabsChart checks for data with the shared isEmptyChartData helper, now exported from the toolkit root, instead of its own zero check, and the widgets drop theirs. The WordAds hook no longer returns an isEmpty nothing reads.

Part of WOOA7S-2210.
Since #52717, wpcomsh no longer ships the Premium Analytics package; the Jetpack entry covers WoA sites.
… data

A chart that reads every metric out on hover, like WordAds, now shows the no-results message only when those other metrics are empty too, so an all-zero Revenue tab still offers the Ads Served readout. isEmptyChartData stays internal to the widgets toolkit.
…mpty check

The MetricTabsChart mocks always render the empty prop, so these widget tests prove only that the prop is passed; the emptiness check is covered in MetricTabsChart.
…isitors tests

Trunk replaced the per-widget empty copy with the shared "We couldn’t find results for this time period." message in #52794, so the zero-filled range tests now look for that text.
ChartEmptyState already defaults to the search icon and the no-results copy, so the tab charts no longer repeat them.
@Nikschavan
Nikschavan force-pushed the update/pa-zero-data-charts-highlights branch from e1a6aee to 29fb5d1 Compare September 28, 2026 10:09
@Nikschavan
Nikschavan merged commit 1dbcad8 into trunk Sep 28, 2026
82 checks passed
@Nikschavan
Nikschavan deleted the update/pa-zero-data-charts-highlights branch September 28, 2026 10:39
@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 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[JS Package] Premium Analytics Sdk [Package] Ads [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics RNA [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