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

When you don't have enough data, and switch to 7 days and then back to larger data it shows an error that the data isn't available #184

Closed bjackson27 closed 4 years ago

bjackson27 commented 5 years ago

Noticed this on my site. I don't have any data from the last 7 days so when I switch to the last 7 days it rightly shows and error. When I switch back to 14, 28 or 90 days the error still displays.

Steps to recreate: 1) View dashboard (or module page) as normal 2) Switch to 7 day view - receive gathering stats message 3) Switch to 14, 28 or 90 day view - receive gathering stats message above the graph

Currently I get:

5e154a77a53dc159dd71b39ea1991787

I expect to get:

5e212abcb4c5fb8e7c92dff5cbfcc85a

Currently I get:

5e239c58c61eb62b904436db7d275509

I expect

5e2c4a6691ce5336456560b70247c020

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

Acceptance criteria

Implementation Brief

Changelog entry

QA Brief

felixarntz commented 5 years ago

Related: #447

Potentially this will already fix it.

ThierryA commented 4 years ago

Moving this to IB as it doesn't have an estimate

felixarntz commented 4 years ago

Let's check if this is still relevant after the latest changes to the date range selector. I prioritized this for the upcoming release since we should fix it if still a problem, but it could be that it already got fixed by now - in that case this should be closed.

tofumatt commented 4 years ago

This does still happen with the new datepicker, at least on legacy pages that are using withData:

2020-08-04 20 24 03

tofumatt commented 4 years ago

Just posting here to document what I'm finding, as this wasn't very intuitive to me. It looks like this setState call:

https://github.com/google/site-kit-wp/blob/897c92e479c3577ceceb3355b8c58c5c7287c4e3/assets/js/components/higherorder/withdata.js#L196

Isn't properly "reset" when the date range changes, meaning the empty "Last 7 Days" request sets a zeroData state in the component, which isn't reset when switching back to "Last 28 Days". Resetting that when the date range changes should fix things, just need to figure out where to do that appropriately here.

tofumatt commented 4 years ago

This one was much tougher to track down than implement, so PR is ready and the IB is set to review. Turns out: it was still happening! 😄

aaemnnosttv commented 4 years ago

IB ✅ but the fix needs tweaking - will follow-up in code review.

cole10up commented 4 years ago

Tested

Installed latest SK release candidate, activated and setup.

Activated Analytics with on a site with not enough data:

image image

Dashboard: image image image

image

Adjusted the duration of the data for an existing site:

image image image image

Passed QA ✅