site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

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

Open bjackson27 opened this issue 7 years ago • 8 comments

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

  • "Gathering data" message should only be displayed for views where there's no data returned from the API.

Implementation Brief

  • Set zeroData in state any time new data is loaded.
  • Merge #1876

Changelog entry

  • Fix bug where state of not having sufficient data for a Site Kit widget would sometimes incorrectly persist when switching the date range.

QA Brief

  • Test that switching between an empty view and a populated view does not display the error as pictured in https://github.com/google/site-kit-wp/issues/184#issuecomment-668780740
  • This state can be hard to reproduce; if you want a copy of cached sessionStorage data to test it, ping me and I can send you some privately. The data I have been testing with needs to be anonymised so I don't want to post it here 😄

bjackson27 avatar Jul 10 '19 20:07 bjackson27

Related: #447

Potentially this will already fix it.

felixarntz avatar Aug 26 '19 16:08 felixarntz

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

ThierryA avatar Feb 11 '20 14:02 ThierryA

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.

felixarntz avatar Jul 27 '20 17:07 felixarntz

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

2020-08-04 20 24 03

tofumatt avatar Aug 04 '20 19:08 tofumatt

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 avatar Aug 04 '20 20:08 tofumatt

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! 😄

tofumatt avatar Aug 04 '20 23:08 tofumatt

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

aaemnnosttv avatar Aug 05 '20 08:08 aaemnnosttv

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 ✅

cole10up avatar Aug 13 '20 08:08 cole10up