site-kit-wp
site-kit-wp copied to clipboard
New error notices in user email reports subscription panel
Feature Description
Implement these notice variants PUE Errors - UX copy in the user email reports subscription panel for admins only
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Admins see error notices in the user email reports subscription panel (notice area) when the latest batch has failed for specific categorized reasons; non-admins do not see these notices.
- Supported error categories match the PUE sheet:
network_errorpermissions_revokedproperty_deletedserver_errorscheduler_errorsending_errorother_error
- Each category renders the specified admin-side notice copy and CTAs (per the provided sheet), including "Email reports are paused" lead where applicable and links to Analytics settings or help URLs as defined per category.
- Notices only appear after all three send attempts for a batch fail and correspond to the latest batch's failure reason; they clear once a subsequent batch succeeds or the error is no longer present.
- Notices support a help/documentation link where defined; categories without CTAs omit them.
Implementation Brief
-
[ ] Update
includes/Core/Email_Reporting/REST_Email_Reporting_Controller.php- Add new
READABLEroute:core/site/data/email-reporting-failure- Compute data from
Email_Log_Batch_Query(latest batch where all logs aregsk_email_failedafterMAX_ATTEMPTS) andMETA_ERROR_DETAILSto extract the category (wp_errorcode). Clear it when a later batch has anygsk_email_sent.
- Compute data from
- Consider a central config (e.g.,
includes/Core/Email_Reporting/Error_Notices_Map.php) keyed by the error reason codes already logged (network_error,permissions_revoked,property_deleted,server_error,scheduler_error,sending_error,other_error), and mapped to their copy and CTA, etc, something like how we handle AdSense server notifications (assets/js/hooks/useAdSenseNotifications.js).Error_Notices_Mapcan expose one method to append content and other details within switch statement like we do inGoogle\Site_Kit\Core\Authentication\Clients\OAuth_Client_Base::get_error_message()
- Add new
-
[ ] Datastore updates in
assets/js/googlesitekit/datastore/site/email-reporting.js- Add selector/resolver
getEmailReportingFailure()returning eitherundefined(loading),null(no terminal failure), or an object like{ category: 'network_error', isTerminal: true, batchID, lastUpdated }. If we do error data mapping on the backend viaError_Notices_Mapinclude the content, CTA, etc to the response as well.- Resolver should invoke the new fetch store eq.
fetchGetEmailReportingFailureStorethat reads a new REST endpointcore/site/data/email-reporting-failure.
- Resolver should invoke the new fetch store eq.
- Optionally add a companion selector
hasEmailReportingFailure()returning a boolean whenisTerminal && category.
- Add selector/resolver
-
[ ] Add
assets/js/components/email-reporting/notices/EmailBatchErrorNotice.js- Use
useSelect( CORE_SITE ).getEmailReportingFailure()and! viewOnlyto gate rendering. - Reuse an existing notice component pattern (e.g., structure of
AnalyticsDisconnectedNoticeor any banner inassets/js/components/email-reporting/UserSettingsSelectionPanel/Notices.js) as the starting point: a heading + body + optional CTAs. - Map
categoryto copy/links via the PUE config, and render only whenfailure && failure.isTerminal - Keep it contained to
assets/js/components/email-reporting/UserSettingsSelectionPanel/Notices.jsso other panels stay unaffected.
- Use
-
[ ] Ensure the notice resets/clears when a batch succeeds (or no terminal failure is present).
Test Coverage
- Update
tests/phpunit/integration/Core/User/REST_Email_Reporting_ControllerTest.php - Update
assets/js/googlesitekit/datastore/site/email-reporting.test.jsto include coverage for new resolver/selector