site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

New error notices in user email reports subscription panel

Open benbowler opened this issue 1 month ago • 2 comments

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_error
    • permissions_revoked
    • property_deleted
    • server_error
    • scheduler_error
    • sending_error
    • other_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 READABLE route: core/site/data/email-reporting-failure
      • Compute data from Email_Log_Batch_Query (latest batch where all logs are gsk_email_failed after MAX_ATTEMPTS) and META_ERROR_DETAILS to extract the category (wp_error code). Clear it when a later batch has any gsk_email_sent.
    • 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_Map can expose one method to append content and other details within switch statement like we do in Google\Site_Kit\Core\Authentication\Clients\OAuth_Client_Base::get_error_message()
  • [ ] Datastore updates in assets/js/googlesitekit/datastore/site/email-reporting.js

    • Add selector/resolver getEmailReportingFailure() returning either undefined (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 via Error_Notices_Map include the content, CTA, etc to the response as well.
      • Resolver should invoke the new fetch store eq. fetchGetEmailReportingFailureStore that reads a new REST endpoint core/site/data/email-reporting-failure.
    • Optionally add a companion selector hasEmailReportingFailure() returning a boolean when isTerminal && category.
  • [ ] Add assets/js/components/email-reporting/notices/EmailBatchErrorNotice.js

    • Use useSelect( CORE_SITE ).getEmailReportingFailure() and ! viewOnly to gate rendering.
    • Reuse an existing notice component pattern (e.g., structure of AnalyticsDisconnectedNotice or any banner in assets/js/components/email-reporting/UserSettingsSelectionPanel/Notices.js) as the starting point: a heading + body + optional CTAs.
    • Map category to copy/links via the PUE config, and render only when failure && failure.isTerminal
    • Keep it contained to assets/js/components/email-reporting/UserSettingsSelectionPanel/Notices.js so other panels stay unaffected.
  • [ ] 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.js to include coverage for new resolver/selector

QA Brief

Changelog entry

benbowler avatar Nov 27 '25 16:11 benbowler