google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 291 forks source link

Minus figure appearing in AdSense chart when no earnings made #6479

Closed wpdarren closed 8 months ago

wpdarren commented 1 year ago

Bug Description

When AdSense is connected and the account and site has been approved. The AdSense Performance over the last X days displays minus figures in the y-axis section of the chart, when no earnings have been made in the period.

What's unusual is that the issue only occurs on 28 days. The chart looks fine for 7, 14 days. I am unsure about 90 days because the site did generate a huge £0.01 within this period.

image.png

Please note: I have a site where you can see this in action without the tester plugin, if this helps.


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

Acceptance criteria

Implementation Brief

Test Coverage

QA Brief

Changelog entry

aaemnnosttv commented 1 year ago

Related issues

@wpdarren I wasn't able to reproduce this on a site that appears to have no data, so you may need to help provide details as to how to reproduce this.

image
mxbclang commented 11 months ago

@wpdarren Reassigning this to you, can you please see if this is still occurring? TY!

wpdarren commented 11 months ago

@aaemnnosttv There's nothing more to share about how to recreate this other than that I set up AdSense, and within 90 days, there is a small amount of money, now $0.05. No issue occurs on 7 and 14 days, but on 28 days on the Earnings and Page CTR tabs it displays as per the screenshot. I also noticed that in 90 days, the same happened on Page CTR

I tested this again on the latest release, and the issue still occurs.

It's possible that it's an edge case.

Can I give you access to the Search Console AdSense account to test it yourself?

https://github.com/google/site-kit-wp/assets/73545194/bb8231c9-cbe6-4017-8ce1-7159919ebf89

nfmohit commented 10 months ago

Update: I tried various variations of AdSense reporting simulation using the tester plugin but wasn't able to reproduce this. I also looked into the related similar issues and verified that the fix there is applied in the AdSense chart. It would be helpful to take a look at a site where the error can be seen. @wpdarren (when you're back from the holiday break), could you share access details to the site internally? Thanks!

mxbclang commented 10 months ago

@wpdarren Reassigned to you to help with the site detail info, thanks!

wpdarren commented 10 months ago

@bethanylang, apologies. I should have updated this ticket with a comment. I have already provided @nfmohit with details for the site where this issue can be re-created on 2 January. I'll assign the ticket to Nahid.

nfmohit commented 9 months ago

💡 Investigation update 💡

Thank you for sharing access to the account, @wpdarren. I was able to reproduce the issue and I have been able to find the root cause.

For curious minds, here's what I have found so far. In order for the chart's V-axis to start at 0 (non-negative), the vAxis.viewWindow.min and vAxis.viewWindow.max values need to be defined. While we set vAxis.viewWindow.min to 0 in the default configuration:

https://github.com/google/site-kit-wp/blob/1bdb01fb8007d6b39200ab5cd925db583cc64100/assets/js/modules/adsense/components/module/ModuleOverviewWidget/Stats.js#L107-L109

We only set vAxis.viewWindow.max to a ceiling of 100 when we have a zero report:

https://github.com/google/site-kit-wp/blob/1bdb01fb8007d6b39200ab5cd925db583cc64100/assets/js/modules/adsense/components/module/ModuleOverviewWidget/Stats.js#L136-L143

However, in the case of this specific site, the previous range data is not zero, it actually has data: image

Which is why, the vAxis.viewWindow.max ceiling is set to undefined, causing the V-axis to go negative.

Even though the previous range has some data, it doesn't show up in the chart:

image

I'll continue my investigation to find out why that is the case.

eugene-manuilov commented 9 months ago

IB ✔️

eugene-manuilov commented 9 months ago

@zutigrm could you please add the estimate please?

zutigrm commented 9 months ago

@eugene-manuilov Added, sorry about that.

tofumatt commented 8 months ago

Assigning @wpdarren as he has a site to test this behaviour on (and will know which site it is 😄).

wpdarren commented 8 months ago

QA Update: ✅

https://github.com/google/site-kit-wp/assets/73545194/72be99b2-9522-4a19-a0f2-ea004b0fcc02