Repository navigation
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
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! |
aee027d to
90dc22e
Compare
layoutd
left a comment
There was a problem hiding this comment.
LGTM! Manually tested the error states and retry recovery; everything works as expected, left one non-blocking comment about storybook.
| error: unknown, | ||
| { retryDescription, onRetry }: DescribeErrorOptions | ||
| ): WidgetStateError { | ||
| if ( getApiErrorStatus( error ) === 403 && getApiErrorCode( error ) !== 'no_connection' ) { |
There was a problem hiding this comment.
Non-blocking: The Storybook error mocks return a 403, so these stories no longer show Retry as their descriptions claim. Maybe update the descriptions and add a retryable 500/no_connection story?
There was a problem hiding this comment.
Good catch — confirmed. Both mock helpers reject with a 403 whose code isn't no_connection, so those four stories were rendering the neutral no-access copy while their descriptions still promised a Retry.
Fixed in edc2563
64bc152
into
worktree-wooa7s-1770-api-error-status
* Premium Analytics: keep HTTP status on failed Stats API requests * Premium Analytics: parse error Responses that apiFetch rejects, keep status on invalid JSON * Premium Analytics: cover register guard, non-object bodies, url unbounded queries * Premium Analytics: share Stats widget error descriptions (#50729) * refactor: share Stats widget error descriptions * fix: keep no_connection 403 retryable, gate hook errors, use full-sentence retry copy * test: add retryable error stories for the shared Stats error mapper * Update projects/packages/premium-analytics/changelog/fix-stats-api-error-status Co-authored-by: Justin P <228780+layoutd@users.noreply.github.com> * fix: register Stats error-status middleware from the data package WP 7.0's Core boot ignores initModules in initSinglePage(), so the app's init() module never runs there and the middleware was not installed. Register it next to the retry policy that reads the status instead. --------- Co-authored-by: Justin P <228780+layoutd@users.noreply.github.com>
Fixes WOOA7S-1649
Proposed changes
Stats widgets currently build their error-state descriptors independently, which duplicates policy and has allowed details such as missing actions to drift. Now that WOOA7S-1770 preserves the HTTP status on failed Stats requests, this PR centralizes the UI decision in the widgets toolkit.
describeErrormapper and unit tests.no_connection403 stays retryable — a broken Jetpack connection can heal, unlike a permission gate.errorwith the same predicate asisErrorso the two fields can't disagree.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
pnpm jetpack build plugins/premium-analytics --deps) and open the Premium Analytics dashboard in wp-admin.wp-content/mu-plugins/. It reads afake_errflag off the dashboard URL (via the request referer), so you can switch modes per page load without touching stored site state:mu-plugin: force
stats/devices/*errors&fake_err=403appended to the URL. Confirm Devices and Top Platforms show “You don't have access to this data.” with no Retry button. 403s are not auto-retried, so the error shows immediately.&fake_err=403nc. Confirm the widgets show the retryable copy with a Retry button instead — the proxy'sno_connection403 stays retryable.&fake_err=500. Confirm Devices shows “We couldn't load device data. Please try again in a moment.” with a Retry button (Top Platforms says “platform data”). Non-403 failures go through React Query's three auto-retries first, so expect ~8 seconds of skeleton before the error appears — and keep the window focused, since React Query pauses retries while the tab is hidden.history.replaceState(null, '', location.href.replace(/&fake_err=\w+/, ''))in the DevTools console — then click Retry. Confirm the request runs again, succeeds, and the widget recovers to its chart.