Sponsored Content
The Wayback Machine - https://web.archive.org/web/20210817024716/https://github.com/google/site-kit-wp/issues/1995
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading state logic ignoring errors in components #1995

Closed
felixarntz opened this issue Sep 8, 2020 · 7 comments
Closed

Fix loading state logic ignoring errors in components #1995

felixarntz opened this issue Sep 8, 2020 · 7 comments

Comments

@felixarntz
Copy link
Member

@felixarntz felixarntz commented Sep 8, 2020 •

This started as part of #1859, but was since separated out to keep issue scope more manageable. Some module components (mostly setup/settings-related) currently have the problem that the logic for displaying the overall ProgressBar depends on data being returned from an API - however, if an error occurs during an API request, that data will never be populated, keeping the component in an infinite loading state.

Instead of relying on selector-based data to exist, it should be relied upon whether the respective resolver has finished, which will work for both the success and error case.


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

Acceptance criteria

  • For the condition whether to display a progress bar, JS components that are used in module setup or module settings must not rely on selectors returning undefined which have a resolver. Whenever a selector has a resolver, such logic should rely on hasFinishedResolution for the selector instead.

Implementation Brief

  • Update conditionals used for early return with <ProgressBar> when data selected from the datastore === undefined to use ! hasFinishedResolution selector instead (only for selectors with a resolver).
    Note, not all selectors have a dedicated selector but use a parent selector which has a resolver. In this case, the "closest" resolver in the selector chain should be checked.
    Also, special care should be taken to ensure bugs are not introduced by changing the conditional to return when something is undefined. It will now be possible for these selected values to be undefined (such as in the event of an error) beyond the progress bar conditional, so we should pay extra attention to ensure potential type errors are handled.
    • assets/js/modules/adsense/components/common/AccountSelect.js
    • assets/js/modules/adsense/components/common/SiteSteps.js
    • assets/js/modules/adsense/components/common/UserProfile.js
    • assets/js/modules/adsense/components/settings/SettingsEdit.js
    • assets/js/modules/adsense/components/setup/SetupMain.js
    • assets/js/modules/analytics/components/common/AccountSelect.js
    • assets/js/modules/analytics/components/common/AccountCreate/index.js
    • assets/js/modules/tagmanager/components/common/AccountCreate.js
    • assets/js/modules/tagmanager/components/common/AccountSelect.js
    • assets/js/modules/tagmanager/components/common/ContainerSelect.js
  • Similar to the last bullet, some conditionals used in the same way are missing this check and are not checking undefined so they only need the same resolver check added
    You can see an example of this done correctly in assets/js/modules/analytics/components/settings/SettingsEdit.js
    • assets/js/modules/analytics/components/common/AccountCreateLegacy.js
    • assets/js/modules/analytics/components/common/ProfileSelect.js
    • assets/js/modules/analytics/components/common/PropertySelect.js

QA Brief

  • Set up Site Kit on your site;
  • Activate and connect AdSense, Analytics, and Tag Manager modules;
  • Make sure that setup and settings forms of these modules work as it worked before:
    • when data is being fetched, the progress bar is shown;
    • when data has been loaded, the progress bar is hidden, and the actual form elements appear.

Changelog entry

  • Fix several UI loading state issues across module setup flows.
@felixarntz
Copy link
Member Author

@felixarntz felixarntz commented Sep 8, 2020

@aaemnnosttv I've copied the relevant piece of the IB from #1859, assigning to you for double-checking and providing an estimate.

@eclarke1 eclarke1 removed this from the Sprint 32 milestone Sep 10, 2020
@eclarke1 eclarke1 added this to the Sprint 33 milestone Sep 22, 2020
@felixarntz
Copy link
Member Author

@felixarntz felixarntz commented Sep 22, 2020

IB ✅

@felixarntz felixarntz removed their assignment Sep 22, 2020
@eugene-manuilov eugene-manuilov self-assigned this Sep 28, 2020
@eclarke1 eclarke1 removed this from the Sprint 33 milestone Oct 12, 2020
@eclarke1 eclarke1 added this to the Sprint 34 milestone Oct 12, 2020
@eugene-manuilov eugene-manuilov removed their assignment Oct 13, 2020
@fhollis fhollis removed this from the Sprint 34 milestone Oct 26, 2020
@fhollis fhollis added this to the Sprint 35 milestone Oct 26, 2020
@eugene-manuilov eugene-manuilov removed their assignment Oct 27, 2020
@felixarntz
Copy link
Member Author

@felixarntz felixarntz commented Oct 27, 2020

@eugene-manuilov Can you add QA Brief for this one?

@eugene-manuilov eugene-manuilov removed their assignment Oct 28, 2020
@eugene-manuilov
Copy link
Collaborator

@eugene-manuilov eugene-manuilov commented Oct 28, 2020

QA Brief is added.

@cole10up cole10up self-assigned this Oct 29, 2020
@felixarntz
Copy link
Member Author

@felixarntz felixarntz commented Oct 30, 2020

QA ⚠️

@eugene-manuilov While testing something else, I ran into a problem which is likely a regression caused by the changes here. What I did was the following:

  1. Go to Analytics setup.
  2. Choose an Analytics account and property, or rely on the preselected ones if there are.
  3. Choose another account.
  4. Now I get an error web property: UA-xxxxxx-x not found.. For some reason, after updating the account, the plugin makes a request to the profiles datapoint with the previously selected property. That property of course is not part of the newly selected account though (you can already tell that because the xxxxxx out of the UA-xxxxxx-x ID must match the account ID), therefore it isn't found. I assume there is some out of sync inconsistency introduced here: When selecting another account, we need to update both the account ID and property ID (the latter needs to be immediately set to its "empty" value) to avoid such a request.

Screenshot:
Screenshot 2020-10-30 at 06 33 34

@eugene-manuilov
Copy link
Collaborator

@eugene-manuilov eugene-manuilov commented Oct 30, 2020

@felixarntz i have created a PR that fixes this issue: #2300.

@felixarntz felixarntz removed their assignment Nov 3, 2020
@cole10up cole10up self-assigned this Nov 4, 2020
@cole10up
Copy link
Collaborator

@cole10up cole10up commented Nov 4, 2020

Tested

Installed, activated and setup latest SK.

Confirmed functionality specifically around data loading for:

Adsense - Pass
Analytics - Pass
Tag Manager - Pass

One thing to note:
When switching date ranges, we're not showing a loading bar for Analytics and Adsense.

This is unrelated but noting that the loading bars are displayed on refresh.

Passed QA ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants