Premium Analytics: Show months with no subscriber data as a gap - #52523
adamwoodnz merged 13 commits into
Conversation
|
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! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Wpcomsh plugin:
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. |
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Code Coverage SummaryCoverage changed in 1 file.
|
9e474a3 to
2b25e41
Compare
2b25e41 to
747fadb
Compare
747fadb to
f068c59
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@claude please review this PR. Get the change set with a single |
|
Claude finished @adamwoodnz's task in 2m 28s —— View job Review
The shape of the change is right, and the runtime half checks out: 1. The nullable contract lives in a cast, not in the type —
|
daeb65a to
63eb0ea
Compare
b3cb37b to
b9a845a
Compare
caebe46 to
47a128c
Compare
The toolkit tooltip typed its value as a number and handed it straight to `MetricValue`, which formats null to an empty string, so a period with no reading printed a row with no value at all. It now prints "No data", as the charts package's own tooltip does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZqouXJVXUJX4ywMC8krzp
The API returns null for the periods before a site existed, and the widget turned each into 0, so a young site drew zero-height stubs across months it had no record for. The bar chart can now draw a null as a gap, so it gets the null. The line chart cannot yet and still gets 0 until CHARTS-284, which is why the choice is made per chart type. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZqouXJVXUJX4ywMC8krzp
The fix is visible wherever the dashboard ships, so the plugins that surface it carry it too, not only the package. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZqouXJVXUJX4ywMC8krzp
This PR only merges once CHARTS-284 teaches the line chart to draw a null, so there is no reason to keep coercing for it here. Line mode shows "Invalid data" until then. Dropping the per-chart-type split also lets the toolkit's chart point accept null directly, so the cast that hid the null from the type is gone, and the changelog entries now describe the whole chart. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZqouXJVXUJX4ywMC8krzp
The gap is the months before the site launched or turned on subscriptions, not the months before its first subscriber. A launched site with subscriptions on and no subscribers still reads a real zero. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DxvpmYsGipgDaUwR3zeVe6
The widget cast the two counts to number | null because the data layer still typed them as numbers. A cast is never checked, so a rename would have left the null branch compiling as dead code. Widen the type where it is declared and read the fields directly. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DxvpmYsGipgDaUwR3zeVe6
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DxvpmYsGipgDaUwR3zeVe6
Pin the three places a null has to survive: the data layer passes it through instead of parsing it to zero, the widget charts it as a gap beside a real zero, and the tooltip reads it as No data while a zero still reads 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DxvpmYsGipgDaUwR3zeVe6
The row rendered "No data" in a plain span at the row's weight 400, so it read as a second label beside the bold values. Give the value class the face MetricValue uses at the sm size. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DxvpmYsGipgDaUwR3zeVe6
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DxvpmYsGipgDaUwR3zeVe6
The comparative line and bar charts moved to the inline layout, which writes the value into the label through getLabel and never renders the row's value. formatMetricValue gives an empty string for null, so a month with no subscriber count read " Subscribers · March 1" with no value at all. The tooltip now hands getLabel "No data" for a missing reading, and the split row reads the same string from one place. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T6rWwVGBVEcNmuR8kkLphs
No ChartTooltip story used the inline layout the comparative charts render, and none carried a null value, so a reviewer could not see how a bucket with no reading reads next to a real zero. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T6rWwVGBVEcNmuR8kkLphs
Spelling "No data" into the value slot of the value-first label read "No data Subscribers · March 1". A missing reading needs its own sentence with the metric as a parameter, so translators can place it. The tooltip now hands getLabel null for a bucket with no reading, and formatTooltipPointLabel turns that into "No data for Subscribers · March 1, 2026". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T6rWwVGBVEcNmuR8kkLphs
d161a40 to
eeb4c66
Compare
Fixes WOOA7S-2181
Why
The Subscriber summary drew a zero for every month before a site launched or turned on subscriptions. A site launched in April, viewed over the last 12 months, showed zero bars or a flat zero line from October to March, as if it had been open to subscribers and gained none. Those months are now empty, and hovering one reads "No data".
Its chart dependencies are all merged: #52522 (CHARTS-281, the bar chart) and #52580 (CHARTS-284, the line chart) teach both charts to draw a
nullas a gap, and #52588 (CHARTS-283) keeps a small whole-number axis from repeating its labels.Proposed changes
null.toPointsno longer turns a missingsubscribersorsubscribers_paidinto0, for bar and line mode alike. The headline figure still reads the latest point, falling back to0.null.MetricTabDatum.valueis nownumber | null. Nothing downstream needed changing: the chart series types already acceptnull.ChartTooltiptyped its value as a number and handed it toMetricValue, andAbbreviatedValueformatsnullto an empty string, so the row printed no value at all. It now prints a translated "No data", as the charts package's own tooltip does. A genuine0still formats as0.ChartTooltipnow handsgetLabelanullfor a missing reading, andformatTooltipPointLabelgives it its own translatable sentence:No data for %1$s · %2$s.Screenshots
A site that launched in April, over the last 12 months. Both modes draw the count on the same
0to1axis.Bar mode: a month before launch reads "No data for Subscribers"
Bar mode: a month after launch keeps its value
Line mode: the line starts at April, and February reads "No data for Subscribers"
Line mode: a month after launch keeps its value
"1 Subscribers" is the value-first label's missing plural, tracked in UNI-813.
To do before ready
toPointskeeps anulland still reads a real0, andTooltipRowprints "No data" fornulland a formatted0for0, and anullin a raw matrix row survivessanitizeStatsSubscribersResponse.Related product discussion/links
1 Subscribers). Not changed here.Does this pull request change what data or activity we track or use?
No.
Testing instructions
On a site that launched or turned on subscriptions inside the selected window (for example, in April):
No data, not0or an empty row.No data.Verified so far:
🤖 Generated with Claude Code
https://claude.ai/code/session_01GZqouXJVXUJX4ywMC8krzp