Launch Widget API-based dashboard without feature flag
Potential considerations before we can remove the feature flag and get rid of the legacy components for the dashboard widgets:
- Monitor how many API requests are made by the Widget API widgets. Room for optimization? For example implementing batching in
googlesitekit-api, combining almost similar Analytics requests into one and then splitting out response data, ... - Check all refactored widgets to ensure they include relevant checks for their API response data (defensive coding):
- return if e.g.
! data || ! data.length || ! data[ 0 ].rows || ! data[ 0 ].totalsetc.
- return if e.g.
- Calls to
getDataErrorComponentandgetNoDataComponentshould either use non-legacy components introduced for that purpose, or at least the calls should be updated to also include all the extra parameters, so that it at least works correctly (e.g. currently the fullerrorobject is not passed in the new widgets). - Investigate "Maximum call stack size exceeded" error occasionally happening on refactored All Traffic widget.
- Review legacy data API - does it include any logic not currently replicated by
googlesitekit-api? Like setting global error states etc. - Use new function instead of over-complicated legacy
getDataTableFromDatafunction. - Potentially allow widgets to specify minimum and maximum width as alternative to a single width (relevant e.g. in #2023).
- Potentially modify
quarterwidget width to still display two in one row for mobile view? See last screenshots in https://github.com/google/site-kit-wp/issues/1898#issuecomment-693178796 for context. - Use datastore selectors for URLs instead of legacy
getSiteKitAdminURLfunction. - Modify sparkline component to render a flat zero graph if it doesn't receive any data (relevant e.g. for Analytics Goals widget, see https://github.com/google/site-kit-wp/pull/1938#discussion_r485274499).
- Include bug issues in the sprint that were fixed as part of this refactoring, solely for tracking purposes and changelog:
- #1996
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Note that this is blocked by #3406. The IB can be already written though and even a PR could be started already.
- The
widgets.dashboardandwidgets.pageDashboardfeature flags should be removed:- Everything that was previously only used with those flags active should now be unconditionally active.
- Everything that was previously not used with those flags active should now be entirely removed.
- All usages of the
googlesitekit.DashboardModuleandgooglesitekit.DashboardDetailsModulefilters (including the components that are only used in conjunction with those filters) should be removed. - The legacy widgets and every wrapping UI around it in the Site Kit dashboard and single URL view should be entirely removed, e.g.:
assets/js/modules/*/components/dashboard/Legacy*.jsassets/js/modules/*/components/dashboard-details/Legacy*.js
- All utility functions in
assets/js/modules/*/util/index.jsthat are no longer used should be removed. - Now irrelevant components (e.g. the
DashboardModuleHeaderandPostSearchercomponents) should also be removed. As part of writing the IB, please conduct a more detailed check for which components from the removed widgets are now no longer relevant. - It needs to be ensured that the dashboard details-related Storybook stories still show up as before (without any widgets, just the headers essentially).
- Any now irrelevant Storybook coverage (e.g. legacy-based dashboard search funnel) should also be removed. No replacements need to be implemented as part of this issue. If any of these stories is part of VRT, those should be removed as well. As part of writing the IB, please check which stories are now no longer relevant.
Implementation Brief
See this PR that covers most of the AC https://github.com/google/site-kit-wp/pull/3439
Referring to AC
-
Remove widgets.dashboard and widgets.pageDashboard feature flag usage from these files:
- assets/js/components/dashboard-details/DashboardDetailsApp.js
- assets/js/components/dashboard/DashboardApp.js
-
-
Remove instances from
- assets/js/modules/analytics/index.legacy.js
- assets/js/modules/pagespeed-insights/index.js
- stories/dashboard-details.stories.js
-
Remove whole file
- assets/js/components/dashboard-details/LegacyDashboardDetailsModule.js
-
-
Do as per AC.
-
Remove at least the following Individual functions in these files
-
assets/js/modules/adsense/util/index.js
- isDataZeroAdSense
-
assets/js/modules/analytics/util/index.js
- extractAnalyticsDashboardSparklineData
- getAnalyticsErrorMessageFromData
- isDataZeroForReporting
- analyticsAdsenseReportDataDefaults
- siteAnalyticsReportDataDefaults
- overviewReportDataDefaults
- userReportDataDefaults
- trafficSourcesReportDataDefaults
- getTopPagesReportDataDefaults
- parseTotalUsersData
-
assets/js/modules/search-console/util/index.js
- isDataZeroSearchConsole
And the entire file
- assets/js/modules/analytics/util/calculateOverviewData.js
- assets/js/modules/analytics/util/calculateOverviewData.test.js
-
-
The total list of files to be removed for this step and step 3 are as follows:
- assets/js/components/dashboard-details/LegacyDashboardDetailsModule.js
- assets/js/components/dashboard/DashboardModuleHeader.js
- assets/js/components/dashboard/LegacyDashboardModule.js
- assets/js/modules/adsense/components/dashboard/AdSenseDashboardWidget.js
- assets/js/modules/adsense/components/dashboard/AdSensePerformanceWidget.js
- assets/js/modules/adsense/components/dashboard/LegacyAdSenseDashboardMainSummary.js
- assets/js/modules/adsense/components/dashboard/LegacyAdSenseDashboardWidgetOverview.js
- assets/js/modules/adsense/components/dashboard/LegacyAdSenseDashboardWidgetSiteStats.js
- assets/js/modules/adsense/components/dashboard/LegacyDashboardAdSenseTopEarningPagesSmall.js
- assets/js/modules/adsense/components/dashboard/LegacyDashboardAdSenseTopPages.js
- assets/js/modules/adsense/components/dashboard/LegacyDashboardEarnings.js
- assets/js/modules/analytics/components/dashboard-details/AnalyticsDashboardDetailsWidgetTopAcquisitionSources.js
- assets/js/modules/analytics/components/dashboard-details/index.js
- assets/js/modules/analytics/components/dashboard/AnalyticsAdSenseDashboardWidgetLayout.js
- assets/js/modules/analytics/components/dashboard/DashboardAllTrafficWidget/LegacyDashboardAllTraffic.js
- assets/js/modules/analytics/components/dashboard/LegacyAdSenseDashboardWidgetTopPagesTableSmall.js
- assets/js/modules/analytics/components/dashboard/LegacyAnalyticsAdSenseDashboardWidgetTopPagesTable.js
- assets/js/modules/analytics/components/dashboard/LegacyAnalyticsDashboardWidget.js
- assets/js/modules/analytics/components/dashboard/LegacyAnalyticsDashboardWidgetOverview.js
- assets/js/modules/analytics/components/dashboard/LegacyAnalyticsDashboardWidgetPopularPagesTable.js
- assets/js/modules/analytics/components/dashboard/LegacyAnalyticsDashboardWidgetSiteStats.js
- assets/js/modules/analytics/components/dashboard/LegacyAnalyticsDashboardWidgetTopAcquisitionSources.js
- assets/js/modules/analytics/components/dashboard/LegacyAnalyticsDashboardWidgetTopLevel.js
- assets/js/modules/analytics/components/dashboard/LegacyAnalyticsDashboardWidgetTopPagesTable.js
- assets/js/modules/analytics/components/dashboard/LegacyDashboardAcquisitionPieChart.js
- assets/js/modules/pagespeed-insights/components/dashboard/LegacyDashboardPageSpeedCTA.js
- assets/js/modules/pagespeed-insights/components/dashboard/LegacyDashboardSpeed.js
- assets/js/modules/search-console/components/dashboard-details/DashboardDetailsSearchFunnel.js
- assets/js/modules/search-console/components/dashboard-details/DashboardDetailsWidgetKeywordsTable.js
- assets/js/modules/pagespeed-insights/components/dashboard/LegacyDashboardPageSpeedCTA.js
- assets/js/modules/pagespeed-insights/components/dashboard/LegacyDashboardSpeed.js
- assets/js/modules/search-console/components/dashboard-details/DashboardDetailsSearchFunnel.js
- assets/js/modules/search-console/components/dashboard-details/DashboardDetailsWidgetKeywordsTable.js
- assets/js/modules/search-console/components/dashboard-details/index.js
- assets/js/modules/search-console/components/dashboard/GoogleSitekitSearchConsoleDashboardWidget.js
- assets/js/modules/search-console/components/dashboard/LegacyDashboardPopularity.js
- assets/js/modules/search-console/components/dashboard/LegacyDashboardPopularityInner.js
- assets/js/modules/search-console/components/dashboard/LegacyDashboardSearchFunnel.js
- assets/js/modules/search-console/components/dashboard/LegacyDashboardSearchFunnelInner.js
- assets/js/modules/search-console/components/dashboard/LegacyDashboardWidgetPopularKeywordsTable.js
- assets/js/modules/search-console/components/dashboard/LegacySearchConsoleDashboardWidgetKeywordTable.js
- assets/js/modules/search-console/components/dashboard/LegacySearchConsoleDashboardWidgetOverview.js
- assets/js/modules/search-console/components/dashboard/LegacySearchConsoleDashboardWidgetSiteStats.js
- assets/js/modules/search-console/components/dashboard/LegacySearchConsoleDashboardWidgetTopLevel.js
-
Nothing to be done here
-
Remove VRTs
dashboard--post-searcherdashboard--search-funnel-analytics-inactivedashboard--search-funnelglobal--data-tableadsense-module--performanceanalytics-module--audience-overview-chartanalytics-module--top-acquisition-pie-chartsearch-console-module--overview-chartdashboard--module-header
Also 8. Fix failing e2e tests for Analytics' and Search Console's e2e dashboard-date-range.test
Both dashboards seem to be always empty

However, they work when running locally

Most likely the e2e is missing some mock data
- Investigate and fix
QA Brief
- Test main dashboard page and URL-specific pages (the "Detailed Page Stats" page), ensuring widgets render as-expected and that there are no rendering/other errors when using the new widget-based layout.
Changelog entry
- Update dashboard and details page to display widgets only.
@felixarntz a few ideas here:
- VRT coverage – we could see about adding any missing cases (or even creating new ones) using legacy components, then perhaps we could use a feature flag in storybook to load alternate versions of the same stories using the new refactored components using the same data via the datastore. That way we could confirm that given the same data there would be no visual changes between old and new implementations.
- Update the feature flag in the App to be a switch between widget implementations (rather than adding an additional area).
This way we can run the current E2E tests against the new widgets as if it were already live/swapped before we do that.
Monitor how many API requests are made by the Widget API widgets. Room for optimization? For example implementing batching in
googlesitekit-api, combining almost similar Analytics requests into one and then splitting out response data,
This would make sense to do particularly for API requests which are implemented as batch requests by the endpoint. E.g. The Analytics GET:report datapoint requests Google_Service_AnalyticsReporting->reports->batchGet() but always with a single request. I think this may be the only one that's like this but that might be the best place to start.
The other requests that come to mind to benefit from batching are PSI requests since these take the longest so combining these into a single request might not be any faster for the end user, but it would require allocating less PHP processes for however long the request takes which usually takes several seconds. Not sure if we can request these in parallel on the server though.
@felixarntz per your comment earlier, I found that the Analytics batchGet does require several parameters to be the same across all batched requests, e.g. viewId and dateRanges so perhaps that wouldn't work, but we may still be able to intelligently batch them as those things would likely always be the same. There are a few other parameters that have the same requirement but we don't use all of them.
I've spent a few hours trying to debug failing e2e tests (there are lots with the same error message)
Many fail and most have similar messages. I've isolated the problem down to a one-line change that can be seen here: https://github.com/google/site-kit-wp/pull/3439/files
I can't replicate it in the browser
On the linked PR, I've spent a few hours trying to fix Analytics' and Search Console's failing e2e dashboard-date-range.test https://github.com/google/site-kit-wp/pull/3439
Both dashboards seem to be always empty

However this works for me when running locally! So I'm a bit confused

Maybe the e2e is missing some mock data :thinking:
The AC says to remove DashboardModuleHeader but this is still used in a few components :thinking:
I may have done something wrong though
Regarding <DashboardModuleHeader /> still being used, that usage is ultimately still in legacy components. It's used in files with "legacy" in the name, yes, but also in files exported by index.legacy.js, eg:
- https://github.com/google/site-kit-wp/blob/9c76cb91c324f9f0a22748040de8660dc893dc17/assets/js/modules/analytics/components/dashboard-details/AnalyticsDashboardDetailsWidgetTopAcquisitionSources.js#L40 (exported by
assets/js/modules/analytics/index.legacy.js) - https://github.com/google/site-kit-wp/blob/9c76cb91c324f9f0a22748040de8660dc893dc17/assets/js/modules/search-console/components/dashboard-details/DashboardDetailsSearchFunnel.js#L34 (used in
assets/js/modules/search-console/index.legacy.js) - https://github.com/google/site-kit-wp/blob/9c76cb91c324f9f0a22748040de8660dc893dc17/assets/js/modules/search-console/components/dashboard-details/DashboardDetailsWidgetKeywordsTable.js#L68 (used in
assets/js/modules/search-console/index.legacy.js) - https://github.com/google/site-kit-wp/blob/9c76cb91c324f9f0a22748040de8660dc893dc17/stories/dashboard.stories.js#L50 (A story that can be removed)
So it should be fine to remove everywhere.
The Dashboard not loading could well be because of mock data not being provided for the new components, but I'm not so sure about that because I think the API endpoints were the same for their usage.
When you run the E2E tests in interactive mode—as you're doing—do you see any console errors that would prevent the components from rendering? Usually they'd display loading states rather than nothing if the mock data was missing, I'd think...
For complex changes like this let's not make the IB "merge this PR" 🙂 . As the PRs' content can change that makes it tough to evaluate the IB against the ACs or the PR against the ACs/IBs as the PRs' code changes 😅
It would be helpful for this IB to list out the relevant stories and particularly VRTs that should be removed. Usually using a PR as an IB works well if the change is very straightforward and the PR requires no further effort, but as it's not passing tests yet and it isn't clear why they aren't passing I think the IB needs to be fleshed out more. Let me know if that all makes sense 🙂
@tofumatt Thanks for the feedback
DashboardModuleHeader ah right! :facepalm: Thanks. I'll remove this component then and I'll check those legacy exports again to make sure i haven't left any files out
Dashboard e2e tests -> I didn't see any errors. I'm happy to have a look more into it (although it's hard without the react dev tools being inside the headless browser), but first I wanted to check I wasn't missing something really obvious :smile:
If you're not sure then it warrants investigation (which I could do as part of this IB, although I'm conscious of the time I've spent already!)
"It would be helpful for this IB to list out the relevant stories and particularly VRTs that should be removed." But you do not want me to detail out every file change?
There are so many components that I've removed here that I'm sure I've made some kind of mistake, and the PR is huge. So I'm happy to detail anything else here you think :+1:
The VRTs to remove would be helpful, but in fairness if anything's really excessive you can generalise. It's always nice to provide context in the IBs, but use your judgement and if it turns out I'm just requesting a list of 100 files, please say no 😅
I don't think I see anything really obvious with the E2E tests but I haven't thoroughly reviewed the PR. Feel free to ping someone for another set of eyes if you need it though. But if the IB should be "fix a particular, failing E2E test" then that's fair. But please outline it in the IB rather than the linked comment, as it's just a wee bit easier to follow that way. 🙂
@tofumatt @aaemnnosttv @eugene-manuilov This must not be merged until develop is open for 1.38.0 release issues.
@tofumatt I've fleshed out the IB a lot. That's much better. I was expecting there to be some huge list but now I've written it, it's really not that big.
Thinking about it, I spent a lot of time doing this PR, and documenting what I did in an IB would have helped.
Points 3. and 5. are a bit mixed though. I just know which files I've deleted from the diff but if you want me to go through again I can check which are related to 3. and which to 5. It's very time consuming though
Also, I really want to emphasize that AC steps 4 and 5 should be checked again as part of the Execution. AC steps 1 and 2 are easy to check with find&replace and checking the project builds. Whereas checking orphaned files is a very manual process of course!
@tofumatt I'm a bit unclear on what this step in the AC means though (I've only just realized now I've revisited the AC :upside_down_face: )
6. It needs to be ensured that the dashboard details-related Storybook stories still show up as before (without any widgets, just the headers essentially).
Do you know what this entails? I can ask Felix if not :smile:
@danielgent I believe it's referring to this story in particular, although there is one more there as well.
A bit more context here is that the context renderer here needs to still render the Header and Footer even when there are no widgets. For example, the pageDashboardNotFound slug does not even exist, so it's somewhat intended to render none there. https://github.com/google/site-kit-wp/blob/b168f3ac75ab06a6a46b9aefa32d12f4c3d65416/assets/js/components/dashboard-details/DashboardDetailsApp.js#L58-L63
Cool thanks @aaemnnosttv . So this step looks done to me :+1: https://google.github.io/site-kit-wp/storybook/pull/3439/?path=/story/dashboard-details--not-found-entity
The following IB is mostly a summary of what has been done but to the amount of changes, as part of the execution, the whole code base should be checked again as most likely changes have been missed
Sorry, I don't follow that sentence. but to the amount of changes, as part of the execution, the whole code base should be checked again isn't clear to me—could you rephrase? 😅
Referring to AC
- Change files
I understand you're referencing the ACs here because they contain, essentially, implementation. But writing "Change files" is vague, so much so that I think it actually makes it harder to read this IB. I'd be better to write something like "Remove widgets.dashboard and widgets.pageDashboard feature flag usage from these files:"
- TODO
This needs to be filled in 🙂 Seems like your comment above says it's already done, but let's spell it out 😏
Finally, since this entails E2E tests failing we should raise the estimate on this one a bit, I'd say at least an 11 because they take a long time to run/debug/fix.
Let me know if there's something else here I'm missing/need to review. Thanks! 👍🏻
Thanks @tofumatt
but to the amount of changes, as part of the execution, the whole code base should be checked again
was meant to be
but DUE to the amount of... :see_no_evil:
I've just removed this line for now.
What I meant to say is that there may be more files and utils to be removed. I went through the codebase twice, but it wouldn't hurt to have another set of eyes checking it. Especially 4 and 5, as they involved checking unused imports from the deleted components
Awesome, looks good!
I think this IB covers it, thanks 👍🏻
IB ✅
Noting that #2077 will make fixing the remaining E2E tests and some code removal much easier, especially in the existing branch, so I'm marking it as blocking this issue.
@eugene-manuilov I think this should go to @tofumatt ? (as he did the execution :smile: )
I'm not complaining and (upon reading the feedback) they look like my code changes. I'm just thinking of the Site Kit flow :thinking:
I'll address these on Monday if I don't hear anything otherwise :+1:
eugene-manuilov I think this should go to tofumatt ? (as he did the execution )
@danielgent Ah... i didn't notice Matthew has finished it. I'll re-assign it to him then :smile: