Improve new stats error states: centering and unavailable sites - #23081
Merged
Conversation
Add textAlign = TextAlign.Center to the error Text in the Authors, Emails, Subscribers list, UTM and Year in review detail screens so a wrapping message stays centered instead of left-aligning, matching the existing NoConnectionContent/TagsAndCategories convention. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The WordPress.com stats API returns an 'invalid_blog' error (e.g. file download stats on a Jetpack site) as a WpRequestResult.UnknownError with a 404, which fell through to the generic 'An unexpected error occurred' message and left the API's reason unread. Add a lightweight, dependency-free parser for the API error code, a new StatsErrorType.NOT_AVAILABLE mapped to a meaningful string, and classify the 'invalid_blog' code (in both the UnknownError and WpError branches) as NOT_AVAILABLE. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Retrying a NOT_AVAILABLE error never succeeds, so thread an isNotAvailable flag through the card error chain (repository results, card ViewModels, StatsCardFetchResult, card/detail UI states) and, when set, render only the message with no Retry or WP Admin button on both the stats card and the detail screen. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #23081 +/- ##
=======================================
Coverage 37.37% 37.37%
=======================================
Files 2339 2340 +1
Lines 126952 126991 +39
Branches 17499 17507 +8
=======================================
+ Hits 47452 47469 +17
- Misses 75618 75639 +21
- Partials 3882 3883 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Detail screens are only reachable via a card's "Show all" action, which is absent when a card's stats are unavailable. The NOT_AVAILABLE state can therefore never render on a detail screen, making the isNotAvailable retry-hiding logic there dead code. Revert the detail path (MostViewedDetailActivity showRetry param/logic, MostViewedDetailViewModel Error field/threading, and the four MostViewedDetailFetcher error mappings) while keeping the error-message centering and all card/repository/data-source NOT_AVAILABLE handling. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
adalpari
marked this pull request as ready for review
July 9, 2026 11:14
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.


Description
Improves error handling and presentation across the new stats screens. Three related changes:
Center error messages in detail screens — the error
Textin the Authors, Emails, Subscribers list, UTM, Year in review, and Most viewed detail screens (and the stats card) had notextAlign, so a message that wraps to multiple lines left-aligned instead of centering. AddedtextAlign = TextAlign.Center, matching the existingNoConnectionContent/TagsAndCategoriesconvention.Surface a clear message when stats are unavailable for the site — the WordPress.com stats API returns an
invalid_blogerror (e.g. file download stats on a Jetpack site) as aWpRequestResult.UnknownErrorwith a 404. This was unhandled and fell through to the generic "An unexpected error occurred", discarding the API's reason. Added a lightweight, dependency-free parser for the API error code, a newStatsErrorType.NOT_AVAILABLEmapped to a meaningful string ("These stats aren't available for this site"), and classification of theinvalid_blogcode in both theUnknownErrorandWpErrorbranches.Hide the Retry button for unavailable stats — retrying a
NOT_AVAILABLEerror never succeeds, so anisNotAvailableflag is threaded through the card error chain (repository results, card ViewModels,StatsCardFetchResult, and the card/detail UI states). When set, only the message is shown — no Retry or WP Admin button — on both the stats card and the detail screen.Unit tests added for the error-code parser and the
NOT_AVAILABLEmapping.Testing instructions
Error message centering:
Unavailable stats message + no Retry (requires a Jetpack/self-hosted site):
Verify it shows "These stats aren't available for this site" (centered).
Verify there is no Retry button on the card.
Verify other stats work as expected