Remove unused legacy JS code after removal of legacy components and data API
See original GitHub issueNow 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
andaddFilter
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 forv1/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.)
- Remove all E2E request inceptions for unused
v1/data
API calls - Fix these legacy data TODOs:
- Remove
usageContext
param fromcontrolCallback
inassets/js/modules/tagmanager/datastore/containers.js
. This also involves changing both instances of$usage_context = $data['usageContext'] ?: self::USAGE_CONTEXT_WEB;
in/Users/matt/Projects/site-kit-wp/includes/Modules/Tag_Manager.php
to be$usage_context = $data['usageContext'] ?: array( self::USAGE_CONTEXT_WEB, self::USAGE_CONTEXT_AMP );
- Remove fallback in
includes/Modules/Tag_Manager.php
, routeGET:tag-permission
, always set$container_id = $data['containerID'];
- Remove redundant comment in
tests/e2e/specs/modules/search-console/dashboard-date-range.test.js
(TODO The module pages use the Widget API.
)
- Remove
- Remove the following, unused files:
assets/js/components/SignIn.js
- Remove
addAction
andaddFilter
calls:addFilter( 'googlesitekit.AdSenseDashboardZeroData', 'googlesitekit.AdSenseDashboardZeroDataRefactored'
- Refactor
assets/js/components/legacy-notifications/notification-counter
to callgetTotalNotifications()
immediately oncomponentDidMount()
—remove theaddAction()
andremoveAction()
calls.
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
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Remove legacy data API and legacy higher-order components ...
The legacy data API and the legacy higher-order components withData and addToFilter should be removed once they are no longer used.
Read more >Lighthouse: Reduce unused JavaScript - GTmetrix
Dead code elimination is the process of removing JavaScript code that isn't used by your current page. This code may contain remnants from...
Read more >How to find dead code in a large react project? - Stack Overflow
Solution: For node projects, run the following command in your project root: npx unimported. If you're using flow type annotations, ...
Read more >Legacy Context - React
The legacy context API will be removed in a future major version. ... The following code shows a Button component written as a...
Read more >Deprecated and obsolete features - JavaScript - MDN Web Docs
These features are likely stable because removing them will cause backward compatibility issues and break legacy websites. (JavaScript has ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
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! 👍🏻