Sponsored Content
The Wayback Machine - https://web.archive.org/web/20210817024836/https://github.com/google/site-kit-wp/issues/167
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

Check whether a post has Analytics data to determine whether to show admin bar menu #167

Closed
bjackson27 opened this issue Jul 10, 2019 · 4 comments

Comments

@bjackson27
Copy link

@bjackson27 bjackson27 commented Jul 10, 2019 •

Current: Admin bar does not display if search console doesn't have stats.

66bc86d899d7a2e54f5a2f02ccb0c080

66bc7836cc0ffb1836cbe77b9fcdb154

Expected: G logo should appear in the admin bar and expand upon hover if there are stats from any modules (eg. Analytics). This should appear on the Front end and in the admin.


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

Acceptance criteria

  • In order to determine whether to display the Admin bar:
    • check that there are GA stats available for that specific post
    • check that both these stats are not zero

If we have a situation where SC is "gathering data", GA stats are both zero, but we still show the Admin bar, that would be rather underwhelming for users.

Screenshot 2019-07-18 at 18 12 38
(this screenshot is from the main dashboard, but the stats would look similar in the Admin bar)

Implementation Brief

Analytics specific

Add action googlesitekit_show_admin_bar_menu in analytics module to check if analytics has data for the post, the same way search console calls has_data_for_post() https://github.com/google/site-kit-wp/blob/develop/includes/Modules/Search_Console.php#L578 in this hook,
add similar method in Analytics module by requesting overview datapoint with permalink argument and save result in transient.

Update delete_all_transients() in Reset.php to remove added transient when reseting Site Kit.

Opportunity for abstraction (possibly separate ticket?)

Modules could be Admin bar aware, and able to inform the Admin Bar whether or not it is active for the current URL and thus better inform the Site Kit admin bar item if it should render or not.

  • Add a new Module_With_Admin_Bar interface
    • Defines a public is_active_in_admin_bar( $url ) : bool method
    • Each module displayed in the admin bar could implement its own logic for whether or not it should be active in the admin bar
  • Add a new with_admin_bar() : Module[] method to Modules
    • Returns an array of all active Module instances that are filtered to only those that implement the Module_With_Admin_Bar interface
  • Add a new set_modules( $modules ) : void method on Admin_Bar where $modules : Module_With_Admin_Bar[]
    • After instantiating Admin_Bar in Plugin, pass the active modules to the instance
    $admin_bar = ( new Core\Admin_Bar\Admin_Bar( $this->context, $assets ) )->register();
    $admin_bar->set_modules( $modules->with_admin_bar() )
  • In \Google\Site_Kit\Core\Admin_Bar\Admin_Bar::is_active, check if any of the provided modules is_active_in_admin_bar( $url )
  • No change would likely be necessary on the front yet, but this could be exposed in each module's JS info array if useful

Changelog entry

  • Ensure admin bar displays when at least Search Console or Analytics have stats for the current URL.
@felixarntz
Copy link
Member

@felixarntz felixarntz commented Aug 12, 2019

@lucymtc The implementation brief should contain information on how the filter in the Analytics module behaves in relation to the Search_Console module, in regards to the following:

  • If both modules have data for the post, the overall filter result should be true.
  • If none of the two modules have data for the post > result false.
  • If only Search Console has data for the post > result true.
  • If only Analytics has data for the post > result true.

In order to properly handle that while still keeping the filters in isolation, potentially a single centralized filter in the core Modules class would be better suited, calling the respective has_data_for_post() methods of each active module and making the necessary logic concatenation.

The implementation brief will furthermore need some adjustments after #312. We should consider this issue blocked by #312, and revisit the implementation brief once the work on that has been completed.

@felixarntz felixarntz assigned lucymtc and unassigned felixarntz Aug 12, 2019
@felixarntz felixarntz added P0 and removed P2 labels Aug 27, 2019
@lucymtc lucymtc removed their assignment Aug 29, 2019
@tofumatt tofumatt assigned tofumatt and unassigned tofumatt Sep 2, 2019
@tofumatt
Copy link
Collaborator

@tofumatt tofumatt commented Sep 2, 2019

Moving this to "Revisit Later" as it's currently blocked by #312; since we'll want to revise the IB after #312 is completed, we should hold off on this IB so we don't write it 1.5 times 😉

@felixarntz felixarntz added P1 and removed P0 labels Oct 1, 2019
@felixarntz
Copy link
Member

@felixarntz felixarntz commented Nov 27, 2019 •

@aaemnnosttv I really like the suggested abstraction, let's put that in place as part of this issue (this will clearly increase the size of this issue, but that's okay). IB ✅

This issue doesn't have super-high priority, let's just tackle it whenever we find some time for it after the critical bugs have been fixed.

@felixarntz felixarntz assigned aaemnnosttv and unassigned felixarntz Nov 27, 2019
@aaemnnosttv aaemnnosttv removed their assignment Nov 27, 2019
@ThierryA ThierryA removed the Size: S label Feb 3, 2020
@aaemnnosttv aaemnnosttv self-assigned this Feb 7, 2020
@eclarke1 eclarke1 added this to the Sprint 16 milestone Feb 7, 2020
@aaemnnosttv aaemnnosttv removed their assignment Feb 7, 2020
@felixarntz felixarntz assigned aaemnnosttv and unassigned felixarntz Feb 14, 2020
@felixarntz felixarntz removed their assignment Feb 19, 2020
@cole10up cole10up self-assigned this Feb 26, 2020
@cole10up
Copy link
Collaborator

@cole10up cole10up commented Feb 27, 2020

Tested

Confirmed on pages without analytics data and no search console info the admin bar menu isn't displayed

image

Confirmed alternate scenario of no SC data but with Analytics during testing of #314

image

Passed QA ✅

@cole10up cole10up removed their assignment Feb 27, 2020
@eclarke1 eclarke1 removed this from the Sprint 16 milestone Feb 27, 2020
@eclarke1 eclarke1 added this to the Sprint 17 milestone Feb 27, 2020
@felixarntz felixarntz closed this Feb 28, 2020
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
9 participants