google / google/site-kit-wp

Add a hasZeroData selector for AdSense

Open
#4,674 2 comments 1 reaction 0 assignees View on GitHub
Module: AdSense P1 QA: Eng
Dominant language
JavaScript
Stars
1.4k
Forks
383
Avg merge
4d 14h
Merged PRs (30d)
77

Description

## Feature Description

For the new Zero States features to be properly implemented, we need a way to explicitly check if a module has "zero data" as opposed to "gathering data". Obviously any site that's gathering data will also have "zero data", but we can use logic tailored to each "module" (eg Google Service) that Site Kit uses to check if there's no data available from the Google API because the site is new or if there's data because there's been nothing of note.

Essentially, we want a selector for AdSense that allows us to easily know: "Is this user's (default) report lacking any data and returning all zeros?"

I don't _think_ we need an `isGatheringData()` selector for AdSense here, because if AdSense is still gathering data about your site to create an account, that will be a specific AdSense account state and we won't show widgets/fetch AdSense reports yet. But having a convenient selector for empty reports would still be useful.

Upon reviewing the [Figma Designs](https://www.figma.com/file/lPdnmgVoPqOEO82AMle9gH/Zero-State?node-id=435%3A1677) it's actually possible we won't need this at all, so I'm leaving it in Triage for now.

---------------

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

## Acceptance criteria

* There should be a `hasZeroData()` selector for the AdSense module's datastore that checks to see if there is no data for AdSense available in a representative report.
* This selector should `return false` if any data is found. The selector should `return true` if no data for a "representative" AdSense report request—likely whatever the default dashboard request would be (eg. 28 days)—is found but `isGatheringData() === false`.

## Implementation Brief

*

### Test Coverage

*

## QA Brief

*

## Changelog entry

*

Contributor guide

Open the contributing guide

Research direction

Start at the AdSense module's datastore selectors and identify the representative report request used by the default dashboard. Check existing AdSense account and report-state selectors before defining the zero-data behavior. Done means hasZeroData() returns false when any report data exists and returns true only for an all-zero report when isGatheringData() is false; add coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
analytics, api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.