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

Remove unused legacy JS code after removal of legacy components and data API #3646

Closed
felixarntz opened this issue Jun 29, 2021 · 8 comments
Closed
Labels
P1 Medium priority QA: Eng Requires specialized QA by an engineer Rollover Issues which role over to the next sprint Type: Enhancement Improvement of an existing feature
Milestone

Comments

@felixarntz
Copy link
Member

felixarntz commented Jun 29, 2021

Now that all legacy widget components have been removed (see #1997 and #2077) and the legacy data API as well (see #2258), we should go through the JS codebase again (after a similar issue earlier, #2418) and look for unused code that can be removed.


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

Acceptance criteria

  • Any code including or only intended for use with legacy dashboard widgets or the legacy dataAPI should be removed (example)

Most of the definition here will be searching through the codebase.

  • Note: all of this will likely not be used anymore, but if it is please note what it is in the IB with suggested replacement (if any)
  • Check through all module components, and review uses of addAction and addFilter to make sure any remaining uses are still valid
  • Ensure references to the old /data REST endpoint are removed (e.g in E2E request interception - search for v1/data)
  • Review all TODO comments to ensure there are none left in the code that are actionable related to the removed legacy widgets and dataAPI

Implementation Brief

(See #3799 for a PR that removes request interception in E2E tests as a starting point for this issue.)

Test Coverage

  • No tests should need removing or changing; existing tests should all pass.

Visual Regression Changes

  • N/A

QA Brief

  • Ensure assets/js/components/SignIn.js is gone.
  • Ensure no calls to 'v1/data' are made.
  • Ensure AC are met.

Changelog entry

  • Remove unused legacy JS code after removal of legacy components and data API
@felixarntz felixarntz added P1 Medium priority Type: Enhancement Improvement of an existing feature QA: Eng Requires specialized QA by an engineer labels Jun 29, 2021
@felixarntz felixarntz self-assigned this Jun 29, 2021
@fhollis fhollis added this to the Sprint 55 milestone Jul 27, 2021
@aaemnnosttv
Copy link
Collaborator

@felixarntz I added ACs here to move this forward as it seems fairly straightforward in its purpose 🙂

Let me know if there's anything else missing when you get back!

@tofumatt
Copy link
Collaborator

tofumatt commented Aug 3, 2021

From what I can see, the entirely of assets/js/components/legacy-notifications/notification-counter is obsolete and can be removed, because it relies on an unused addAction( 'googlesitekit.dataLoaded', 'googlesitekit.dataLoadedGetTotalNotifications' ), neither of which are present elsewhere in the code anymore.

Are all of the legacy notifications set to go? I didn't think they were and couldn't find a ticket saying so, but maybe I missed it. 😅

@tofumatt tofumatt removed their assignment Aug 3, 2021
@aaemnnosttv aaemnnosttv self-assigned this Aug 4, 2021
@aaemnnosttv
Copy link
Collaborator

From what I can see, the entirely of assets/js/components/legacy-notifications/notification-counter is obsolete and can be removed, because it relies on an unused addAction( 'googlesitekit.dataLoaded', 'googlesitekit.dataLoadedGetTotalNotifications' ), neither of which are present elsewhere in the code anymore.

Are all of the legacy notifications set to go? I didn't think they were and couldn't find a ticket saying so, but maybe I missed it. 😅

@tofumatt good catch – this is actually something that seems to have been missed when removing the dataAPI. Legacy notifications are still relevant and don't have a replacement yet so we need to keep these around for now.

Regarding the action you referenced, this can be removed and the total can be fetched right away as there is no longer a collective batch request that is needed to wait for

getTotalNotifications().then( ( count ) => {
this.setState( { count } );
} );

_googlesitekitLegacyData.setup.errorMessage to use select( CORE_SITE ).getInternalServerError()

This error message still needs to come from the server though to map the error code we get in the URL to the error message by the oAuth client

if ( $this->credentials->using_proxy() ) {
$error_code = $this->user_options->get( OAuth_Client::OPTION_ERROR_CODE );
if ( ! empty( $error_code ) ) {
$data['errorMessage'] = $auth_client->get_error_message( $error_code );
}
}

If it was only used in the client, we could maybe move this to the client side but that's a bit out of scope for this issue, although something to potentially consider in the future.

As noted in the TODO comment there, we can't do that without also changing the default returned by the datapoint handler on the server side as it currently defaults to web context only if not provided. This issue is about removing unused JS so I would say this is probably out of scope, but it looks like a safe change to make. @felixarntz ?

Remove assets/js/modules/analytics-4/index.js

Not sure why this was added but I'm guessing due to the use of the googlesitekit.SetupWinNotification-{slug} filter? This filter is still used in DashboardSetupAlerts.

Even if that were removed, we wouldn't remove the index module for a module because it provides important exports (e.g. registerStore) that we expect to be there both in our test utils and in the bundle entrypoint.

Remove assets/js/modules/optimize/index.legacy.js

As mentioned before the googlesitekit.SetupWinNotification-{slug} filter is still in use so we can't remove this yet.

Remove assets/js/components/legacy-notifications/notification-counter

As mentioned above, we should remove the use of the unused action from this component but the counter module and legacy notifications

@aaemnnosttv aaemnnosttv assigned tofumatt and unassigned aaemnnosttv Aug 4, 2021
@tofumatt
Copy link
Collaborator

tofumatt commented Aug 4, 2021

Ah, I thought that controlCallback was a safe change to make but didn't realise the PHP part wasn't already done. I've added that bit to the IB and removed some of the more aggressive changes or changes to files I thought weren't in use but I missed their imports.

Should be ready for another look, thanks! 👍🏻

@aaemnnosttv
Copy link
Collaborator

IB ✅

@aaemnnosttv aaemnnosttv removed their assignment Aug 5, 2021
@felixarntz
Copy link
Member Author

@tofumatt @aaemnnosttv IB also LGTM from my end - I think it's reasonable to make the one Tag Manager API change as well, even though that is technically a breaking change on the server-side since we're changing the default. Should be okay this time though.

@ivankruchkoff ivankruchkoff self-assigned this Aug 9, 2021
@ivankruchkoff ivankruchkoff removed their assignment Aug 11, 2021
@eugene-manuilov eugene-manuilov self-assigned this Aug 11, 2021
@fhollis fhollis added the Rollover Issues which role over to the next sprint label Aug 16, 2021
@fhollis fhollis modified the milestones: Sprint 55, Sprint 56 Aug 16, 2021
@eugene-manuilov
Copy link
Collaborator

@ivankruchkoff, please, add QAB.

@ivankruchkoff ivankruchkoff removed their assignment Aug 19, 2021
@johnPhillips johnPhillips self-assigned this Aug 23, 2021
@johnPhillips
Copy link
Contributor

QA

  • I searched the codebase for v1/data and found no references
  • Verified that assets/js/components/SignIn.js is gone
  • There are no remaining instances of addAction in the codebase that I could find.
  • I also searched the codebases for todo (i.e. for mention of legacy code tasks) and addFilter and I discussed my findings with @tofumatt. We concluded the remaining instances are still valid and not related to this issue.

@johnPhillips johnPhillips removed their assignment Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 Medium priority QA: Eng Requires specialized QA by an engineer Rollover Issues which role over to the next sprint Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

8 participants