Filter out closed AdSense accounts based on new API capabilities
See original GitHub issueBased 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 astate: CLOSED
, as they can be ignored from our perspective.- See the new account state documentation for background on the possible values.
Implementation Brief
- Using
includes/Modules/AdSense.php
,- Add a new public static function
is_account_not_closed
which should have theaccount
array as parameter. The function should return a boolean, whetheraccount.state
is different fromCLOSED
. - Within
GET:accounts
inparse_data_response
, instead of returning the result of$response->getAccounts
(with the filtered account IDs), store the accounts in a variable ($accounts
) and then usearray_filter
to filter the array, passing the array ($accounts
) as first parameter and the functionfilter_account_with_state_closed
as second parameter. Return the updated array.
- Add a new public static function
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:
- Created a year ago
- Comments:10 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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 itis_account_open
oris_account_not_closed
or something like that? Other than that the IB looks good.@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.