Skip to content

Premium Analytics: Show detail page errors in a notice - #53086

Merged
chihsuan merged 4 commits into
trunkfrom
change/wooa7s-2180-detail-page-notice
Oct 5, 2026
Merged

chihsuan merged 4 commits into
trunkfrom
change/wooa7s-2180-detail-page-notice

Conversation

@chihsuan

@chihsuan chihsuan commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Fixes WOOA7S-2180

Proposed changes

  • Show the "couldn't load" and "not found" messages on author, post, and video details in the same notice the rest of Stats v2 uses.
  • Stop offering Retry on post and video details when access is denied, as author details and the cards already do.
  • Show not found, access denied, and hidden author profiles as an info notice, and load failures as an error notice.
  • Announce the message to screen readers.

The shared error mapping the cards use now also names the notice type, so the detail pages and the cards decide Retry the same way.

Related product discussion/links

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

No.

Testing instructions

Setup

  1. Use a connected site with Stats v2 (Premium Analytics), a post with stats, and a VideoPress video.
  2. Build this branch: jp build plugins/jetpack --deps.
  3. For the access steps, add the snippet below as a mu-plugin. It fails the detail pages' summary request when the page URL carries fake_detail_err.
mu-plugin snippet
<?php
add_filter(
	'rest_pre_dispatch',
	function ( $result, $server, $request ) {
		$route = $request->get_route();
		if ( ! preg_match( '#^/wp/v2/users/\d+$|/stats/video/\d+$#', $route )
			&& ! ( preg_match( '#/stats/post/\d+$#', $route ) && 'post' === $request->get_param( 'fields' ) ) ) {
			return $result;
		}
		parse_str( (string) wp_parse_url( wp_get_raw_referer(), PHP_URL_QUERY ), $args );
		$mode = $args['fake_detail_err'] ?? '';
		if ( '403' === $mode ) {
			return new WP_Error( 'rest_forbidden', 'Forbidden.', array( 'status' => 403 ) );
		}
		if ( '404' === $mode && str_starts_with( $route, '/wp/v2/users/' ) ) {
			return new WP_Error( 'rest_no_route', 'No route.', array( 'status' => 404 ) );
		}
		return $result;
	},
	99,
	3
);

Load failures

  1. In the browser's developer tools, block requests whose URL contains wp/v2/users, then open an author from Top authors. Confirm a red notice reads "We couldn't load this author. Please try again in a moment." with a Retry button.
  2. Unblock the requests and click Retry. Confirm the author's name and cards load.
  3. Repeat with stats/video on a video opened from the Videos report, and with stats/post on a post opened on All time.

Access denied

  1. Open a post's details on All time and append &fake_detail_err=403 to the page URL. Confirm a blue notice reads "You don't have access to this data." with no Retry. On trunk, the same page offers Retry.
  2. Repeat on a video's details.
  3. Open an author's details with &fake_detail_err=404. Confirm a blue notice reads "This site doesn't share author profiles." with no Retry.

Not found

  1. Change the ID in an author details URL to one that doesn't exist, such as /author/99999. Confirm a blue notice reads "We couldn't find this author." with Back to Authors.
  2. Click Back to Authors. Confirm the Authors report opens on the same date range.
  3. Open /video/<id> with an image's attachment ID. Confirm "We couldn't find this video." with Back to Videos, which opens the Videos report on the same range.

Accessibility

  1. With a screen reader on, trigger a load failure. Confirm the message is announced right away, without the Retry label.
  2. Trigger a not-found or access-denied state. Confirm the message is announced politely.

Before / after

Video details with the video request failing. Only the message below the header changes; the header and date button do not.

Before After
before after

Use the @wordpress/ui Notice for the author, post and video detail pages' error and not-found states, and decide Retry through describeError on all three, so access denied no longer offers a Retry that cannot help.
@chihsuan chihsuan self-assigned this Oct 2, 2026
@github-actions github-actions Bot added [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Tests] Includes Tests labels Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 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 commented Oct 2, 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 change/wooa7s-2180-detail-page-notice branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack change/wooa7s-2180-detail-page-notice

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

@jp-launch-control

jp-launch-control Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/routes/author-detail/stage.tsx 31/35 (88.57%) -0.62% 0 💚
projects/packages/premium-analytics/routes/post-detail/hooks/use-post-summary/use-post-summary.ts 24/26 (92.31%) 0.31% 0 💚

2 files are newly checked for coverage.

File Coverage
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/detail-page/describe-detail-page-error.ts 1/1 (100.00%) 💚
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/detail-page/detail-page-notice.tsx 2/2 (100.00%) 💚

Full summary · PHP report · JS report

The post summary passed the raw query error through while gating isError on a missing post, so a failed background refetch left an error beside a loaded post. Also inline the single-use intent alias and note that the notice link must be childless.
@chihsuan
chihsuan marked this pull request as ready for review October 2, 2026 07:45
@chihsuan
chihsuan requested a review from a team as a code owner October 2, 2026 07:45
@chihsuan chihsuan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Oct 2, 2026
Nikschavan
Nikschavan previously approved these changes Oct 5, 2026

@Nikschavan Nikschavan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, the changes look good. I left two questions inline, one about Notice announcements upstream and one about intent in the widget SDK.

What I checked: I opened a video details page on a local site with this branch built, using an image attachment ID for the not-found state. I then made the single-video request fail in the browser, first with a 500 and then with a 403. The 500 shows a red notice with Retry, and the screen reader announces it assertively without the Retry label. Retry recovers once the request succeeds. The 403 shows an info notice with no Retry, announced politely. The layout holds at 1280 and at 390 wide, and the console stays clean.

Not found Load failure Access denied
Not found, with Back to Videos 500, with Retry 403, no Retry

export function DetailPageNotice( { intent, description, actions, link }: DetailPageNoticeProps ) {
return (
// The default announcement (children) would trail the action labels.
<Notice.Root intent={ intent } spokenMessage={ description }>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Notice no longer announces anything on Gutenberg trunk: #82737 removed spokenMessage and politeness, and the announcement guidelines now ask the app to call speak() and to pick the politeness by urgency rather than by intent. It is still unreleased, so this works today, but the next @wordpress/ui bump drops the announcement these three pages now depend on. Calling speak( description, … ) from an effect here would keep the same live regions and the tests as they are. Would it make sense to switch now, since this is the first new caller of the prop?


export interface DescribedError extends WidgetStateError {
/** `error` when something failed; `info` when the request answered and the answer is a fact, such as no access. */
intent: 'error' | 'info';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

describeError is re-exported from the widget SDK (sdk/src/index.ts#L20), so intent becomes part of the widget contract, while the only reader is DetailPageNotice and WIDGET_API_VERSION stays at 1.2.0. Is the plan for SDK widgets to use intent too, or could it stay on the detail-page side?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, no plan for widgets to use it. Moved it to a detail-page helper in c9e1b33.

@chihsuan
chihsuan merged commit 74aadeb into trunk Oct 5, 2026
82 checks passed
@chihsuan
chihsuan deleted the change/wooa7s-2180-detail-page-notice branch October 5, 2026 03:21
@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 Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants