Closed
Description
Feature Description
The analytics
module should be replaced with analytics-4
completely. This should notably include:
- For components and datastore infrastructure still retrieving settings from the
analytics
module, update them so that they retrieve such module settings from theanalytics-4
module instead. - Replace all references to any user-facing string
Analytics 4
withAnalytics
. - Remove any special handling for the
analytics-4
module. - Remove module and datastore registration for
analytics
. - Turn off the
internal
flag for theanalytics-4
module.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Any remaining usage of the
analytics
datastore infrastructure should be used with their respective counterpart fromanalytics-4
. - Any user-facing reference to
Analytics 4
should be replaced withAnalytics
. - Any special handling for the
analytics-4
module should be removed (notably in regards to module activation/connection logic & dashboard sharing). - Module & datastore registration for the
analytics
module should be removed. - The
internal
flag should be removed for theanalytics-4
module.
Implementation Brief
Datastore and frontend changes
- Replace selectors using
MODULES_ANALYTICS
store to useMODULES_ANALYTICS_4
store in relevant components. You can run a search for( MODULES_ANALYTICS )
in your IDE - In
assets/js/modules/analytics/components/settings/OptionalSettingsView.js
:- Remove
isUAConnected
andanonymizeIP
variables and their usage. - Remove current
useSnippet
selector and renameuseGA4Snippet
touseSnippet
- Update current selectors using
MODULES_ANALYTICS
to use Analytics 4 store - Remove
showIPAnonymizationSettings
variable and it's usage
- Remove
- Move
getServiceURL
selector fromassets/js/modules/analytics/datastore/service.js
to theassets/js/modules/analytics-4/datastore/service.js
and update the usage, so it is selected from Analytics 4 store - Copy any remaining files (not already migrated) to the analytics-4 counterpart folder:
assets/js/modules/analytics/components/settings/
.assets/js/modules/analytics/components/common/
assets/js/modules/analytics/components/setup/
assets/js/modules/analytics/components/dashboard
assets/js/modules/analytics/components/module
- Move the
assets/js/modules/analytics/util/countries-data.js
andassets/js/modules/analytics/util/countries-timezones.js
in case it is not migrated as part of #7928 - Also move
assets/js/modules/analytics/util/parseDimensionStringToDate.js
and it's test to the analytics 4 module utils folder - Move
assets/js/modules/analytics/datastore/__factories__
to the analytics 4 module datastore, and update it's imports - Rename, by excluding
GA4
from their name -isGA4Connected
,ga4Connected
,ga4SnippetEnabled
anduseGA4Snippet
selectors and re-visit their usage - Search through the codebase for
Analytics 4
string, and replace it withAnalytics
in relevant user facing places - Search for filename in IDE, and look for files ending in
GA4.js
, remove old analytics widget that have analytics 4 counterpart and removeGA4
from analytics 4 widgets name - Remove usage, of old analytics, or replace it with
analytics-4
, where it is not needed across the remaining files. You can search forslug: 'analytics'
,moduleSlug="analytics"
,isModuleConnected( 'analytics' )
,moduleName: 'analytics'
,modules: [ 'analytics' ]
and lastlyanalytics
. - From
assets/js/modules/analytics/index.js
, move theGA4
widgets registration to theassets/js/modules/analytics-4/index.js
- Remove
assets/js/googlesitekit-modules-analytics.js
file and remove it's use from webpackentry
- Remove
assets/js/modules/analytics/
Backend changes
- In
includes/Modules/Tag_Manager.php
- Remove conditional dependency for
analytics
- Remove conditional dependency for
- In
includes/Core/Modules/Modules.php
- Replace
Analytics
withAnalytics_4
in$core_modules
variable, and remove it fromconstruct
- Replace the use of
Analytics
class withAnalytics_4
throughout the file- And in
is_module_connected
,activate_module
,set_active_modules_option
methods- Remove the inline to-do comments where applicable and modify condition to account for
Analytics_4
being the only module
- Remove the inline to-do comments where applicable and modify condition to account for
- And in
- Replace
- Edit
includes/Core/Modules/REST_Modules_Controller.php
- In
get_rest_routes
method- Remove this
Analytics_4
check, as owner settings are transferred to analytics 4 in #7923
- Remove this
- In
- In
includes/Modules/Analytics_4.php
- Update
setup_info
method:- Set
internal
tofalse
- Remove
depends_on
- Set
- In
replicate_analytics_sharing_settings
method- Replace
Analytics
class withAnalytics_4
- Replace
- Search throughout the file for
Analytics::
and replace withAnalytics_4
- Modify
is_connected
method- Uncomment
accountID
, and remove comment andadsConversionID
property
- Uncomment
- Update
- Remove
includes/Modules/Analytics.php
- Remove
includes/Modules/Analytics/
Test Coverage
- Remove any remaining irrelevant UA related stories and tests that have
GA4
counterpart - Replace
analytics
module slug withanalytics-4
in tests and stories e.g. inprovideModules
- Replace
analytics
withanalytics-4
in fixtures for module slug, where applicable, and setinternal
to true inassets/js/googlesitekit/modules/datastore/__fixtures__/list.json
- Migrate any remaining relevant php tests revolving around old
Analytics
class to theAnalytics_4Test
and updateAnalytics_4Test
- replaceAnalytics::
usage, etc - Fix any failing tests
QA Brief
- Go through the whole Analytics flow, and verify everything is still working as intended
Changelog entry
- Replace the legacy
analytics
module withanalytics-4
.