Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdSense notifications no longer surface alerts #7559

Closed
aaemnnosttv opened this issue Sep 8, 2023 · 7 comments
Closed

AdSense notifications no longer surface alerts #7559

aaemnnosttv opened this issue Sep 8, 2023 · 7 comments
Labels
Module: AdSense Google AdSense module related issues P0 High priority Type: Bug Something isn't working

Comments

@aaemnnosttv
Copy link
Collaborator

aaemnnosttv commented Sep 8, 2023

Bug Description

The AdSense module is the only module which currently implements the notifications datapoint which is used for surfacing module-specific notifications on the dashboard automatically.

This is currently intended to surface any "severe" alerts from AdSense via the API but does not work as expected.

Steps to reproduce

  1. This requires access to an AdSense account that has at least 1 severe alert (we currently have this with one of our test accounts)
  2. Connect AdSense using the aforementioned account (using a URL of an approved site)
  3. Visit dashboard
  4. See no notifications from AdSense

Screenshots

Example severe alert
image

Expected notification
image

Additional Context

This has not worked properly for a long time, so we may want to make some stylistic enhancements while we're at it.

Example response from the AdSense API with various alerts
{
  "alerts": [
    {
      "name": "accounts/pub-1234567890/alerts/1a6602e9",
      "severity": "WARNING",
      "message": "We encourage you to publish your seller information in the Google sellers.json file. Visit the account settings page to review your current visibility status.",
      "type": "sellers-json-consent"
    },
    {
      "name": "accounts/pub-1234567890/alerts/bb58073e",
      "severity": "INFO",
      "message": "You have new labs to try out. Visit the Labs tab to find out more.",
      "type": "new-lab-available"
    },
    {
      "name": "accounts/pub-1234567890/alerts/eb9896eb",
      "severity": "SEVERE",
      "message": "Earnings at risk - You need to fix some ads.txt file issues to avoid severe impact to your revenue.",
      "type": "ads-txt-issues"
    }
  ]
}

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Severe alerts within the connected AdSense account should be surfaced automatically on the Site Kit dashboard

Implementation Brief

The main problem here is that GET:notifications calls GET:alerts internally which needs the accountID. If not provided, it falls back to the accountID in the module's settings which is relied upon in the case of the notifications endpoint.

case 'GET:alerts':
if ( ! isset( $data['accountID'] ) ) {
$option = $this->get_settings()->get();
$data['accountID'] = $option['accountID'];
if ( empty( $data['accountID'] ) ) {
/* translators: %s: Missing parameter name */
return new WP_Error( 'missing_required_param', sprintf( __( 'Request parameter is empty: %s.', 'google-site-kit' ), 'accountID' ), array( 'status' => 400 ) );
}
}

This fails however, even when an accountID is configured in the settings because $data is a Data_Request instance, which is immutable, so the assignment is a no-op. This results in the request failing as a WP_Error which is then silently ignored in the core/modules handler.

$notifications = $modules[ $slug ]->get_data( 'notifications' );
if ( is_wp_error( $notifications ) ) {
// Don't consider it an error if the module does not have a 'notifications' datapoint.
if ( Invalid_Datapoint_Exception::WP_ERROR_CODE === $notifications->get_error_code() ) {
$notifications = array();
}
return $notifications;
}

  • Update GET:alerts to require accountID in all cases by removing the fallback to settings
  • Update GET:notifications to always pass accountID from settings, returning early with an empty array if none is set
    • Also remove format: large from mapping (invalid value anyways)
  • Reduce sizing of NotificationAlertSVG in AdSenseAlerts to better align with other notifications (like module connect success)

Test Coverage

  • Add test coverage for AdSense alerts and notifications datapoints

QA Brief

  • Connect adsense to an account that had critical alert showing in the AdSense Console. ie. oi.ie.
  • See that SK Dashboard also shows the alert.

Changelog entry

  • Fix a bug that prevented severe AdSense alerts from appearing in Site Kit Dashboard.
@aaemnnosttv aaemnnosttv added Type: Bug Something isn't working P0 High priority Module: AdSense Google AdSense module related issues labels Sep 8, 2023
@tofumatt tofumatt self-assigned this Sep 11, 2023
@tofumatt
Copy link
Collaborator

IB ✅

@tofumatt tofumatt removed their assignment Sep 11, 2023
@kuasha420 kuasha420 self-assigned this Sep 18, 2023
@kuasha420 kuasha420 removed their assignment Sep 20, 2023
@tofumatt tofumatt self-assigned this Sep 20, 2023
tofumatt added a commit that referenced this issue Sep 20, 2023
Fix AdSense critical alerts not surfacing on SK Dashboard
@tofumatt tofumatt removed their assignment Sep 20, 2023
@wpdarren wpdarren self-assigned this Sep 25, 2023
@wpdarren
Copy link
Collaborator

wpdarren commented Sep 26, 2023

QA Update: ⚠️

@kuasha420 I have two UX observations that might be out of scope, but thought I would raise.

  1. The graphic does not seem lined up to the text and CTA. See screenshot below.
  2. The AdSense text and logo looks small. Feel that should stand out more.

If you feel these are out of scope, then let me know and I will create a ticket.

@kuasha420
Copy link
Contributor

Hi @wpdarren, those are valid observation. The notice does look a bit out of place and visually inconsistent with the current SK Dashboard, which is not surprising as it was designed for a different time.

However, I'd say those are out of scope for this ticket as it was about getting the alerts back. We can and should definitely open a new issue to improve and polish the AdSense alert further.

Cheers.

@kuasha420 kuasha420 removed their assignment Sep 27, 2023
@wpdarren
Copy link
Collaborator

QA Update: ⚠️

@kuasha420 apologies, I have one other observation. If in AdSense there are more than 1 Severe alerts, then only the first one appears. I closed the first alert down in Site Kit and refreshed the dashboard and no other alerts appear. Is this something we have factored in, and if not, is it an issue we should fix, or, create a new ticket?

@aaemnnosttv
Copy link
Collaborator Author

@wpdarren you're correct, only the first alert is being shown. It looks like it was always this way, but I agree we should fix it so that each alert returned is shown. I gave this a quick test and it seems to work as expected if all the alerts are returned, we just need to ensure they have unique IDs which is what the dismissal references. Since this should be a simple change, I think we can include it as a follow-up here rather than as a separate issue.

@aaemnnosttv
Copy link
Collaborator Author

Moving this back to CR with a quick follow-up PR shown above.

@wpdarren
Copy link
Collaborator

QA Update: ✅

Verified:

  • SK Dashboard also show the alert from AdSense when an error occurs.
  • Tested on desktop and small viewports like mobile and tablet.
  • Tested to make sure that the GDPR message appears
  • Tested to make sure that all alerts appear when there is more than one.

Note: will be creating a ticket to highlight the UX/UI issues reported previously.

alerts.mp4
Screenshots

image
image
image

@wpdarren wpdarren removed their assignment Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: AdSense Google AdSense module related issues P0 High priority Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants