question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filter out closed AdSense accounts based on new API capabilities

See original GitHub issue

Based on the recently released new AdSense API capabilities and the corresponding enhancements to the design doc, we need to ensure closed AdSense accounts are ignored by Site Kit. For example, if a user has only a single closed account, they will need to create a new AdSense account, which is the same as if they had no account at all.


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

Acceptance criteria

  • The AdSense GET:accounts data point should filter out any accounts from the API response that have a state: CLOSED, as they can be ignored from our perspective.

Implementation Brief

  • Using includes/Modules/AdSense.php,
    • Add a new public static function is_account_not_closed which should have the account array as parameter. The function should return a boolean, whether account.state is different from CLOSED.
    • Within GET:accounts in parse_data_response, instead of returning the result of $response->getAccounts (with the filtered account IDs), store the accounts in a variable ($accounts) and then use array_filter to filter the array, passing the array ($accounts) as first parameter and the function filter_account_with_state_closed as second parameter. Return the updated array.

Test Coverage

  • No new tests to be added.

QA Brief

  • Use a Google account where you have a closed AdSense account.
  • Start the AdSense module setup and verify that this account does not show up or that there are no errors due to this account being chosen.
  • Basically, if that closed AdSense account is the only one you have, you should land in the UI to create a new AdSense account.
  • This should be tested both with and without the adsenseSetupV2 flag enabled.
  • This isn’t exactly possible to set up in a reasonable timeframe, but @felixarntz has such an account, so he is going to QA this issue.

Changelog entry

  • Ensure closed AdSense accounts are not considered for the AdSense account to use with the module.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
felixarntzcommented, Apr 10, 2022

@asvinb Just one thing regarding the IB: The filter_account_with_state_closed doesn’t really sound accurate. Since it’s a boolean check for whether the account is not closed, how about we call it is_account_open or is_account_not_closed or something like that? Other than that the IB looks good.

0reactions
felixarntzcommented, May 16, 2022

@wpdarren Since this is something which happens on the server-side, it wouldn’t really be possible to mock this via the tester plugin.

I think this piece is simple enough so that we don’t need to cover this as part of the bug bash.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FAQ - Ad Filters | AdSense Host API - Google Developers
To filter ads from your publishers' pages, you'll need to add those URLs to the AdSense for Content Host tab under AdSense Setup...
Read more >
Close your AdSense account - Google Support
If you no longer want to use AdSense, you can close your AdSense account. This will automatically stop all AdSense ads serving on...
Read more >
Add, remove, or update a payment method | Cloud Billing
The types of payment methods available to you are based on your business address ... If your new payment method is a U.S....
Read more >
Google Merchant Center - Services to Promote Your Products
success story. Aéropostale finds new online customers through free listings.
Read more >
Google Codelabs
... a new feature to an existing application. They cover a wide range of topics such as Android Wear, Google Compute Engine, ARCore,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found