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
Copy over analytics
module settings to analytics-4
#7923
Comments
ACs here are good, moving to IB 👍🏻 |
Update: After a discussion with @aaemnnosttv, I have updated the ACs of this issue so that instead of doing a once-off migration of the module settings, we fallback to the data stored in CC: @tofumatt |
IB ✔️ |
QA Update: ✅Verified:
|
Hi @wpdarren. I was just working on reviewing some of the SAM work that is going out as part of this release, and I think this issue isn't working fully as expected. The new GA4 settings are being correctly migrated if Analytics was set up before the PR for this issue was merged. However, if the Analytics module is connected after the PR is merged, the GA4 settings are not migrated. See: The idea behind this issue was for the new CC: @aaemnnosttv |
@nfmohit, thanks for finding and sharing this issue. I left my thoughts on Slack about this. In short, I feel that we will rely a lot on the QAB for this epic because the changes are in the background. I'll bring it up in our retro to see what lessons we (I) can learn from this. |
We have taken a deeper look into this and found out that there isn't a simple way for this to work for new Analytics module setups. As a result, I have opened a new issue to perform a DB migration of the settings just when we ship the singular Analytics module - #8082. |
Thanks @nfmohit! |
Feature Description
Module settings in the
analytics
module that are still relevant after the removal of UA should be copied over to theanalytics-4
module. Namely:accountID
adsConversionID
canUseSnippet
ownerID
trackingDisabled
useSnippet
A runtime process migration should be introduced in the Analytics_4 class that migrates the settings data from
analytics
toanalytics-4
. For example,accountID
setting data ingooglesitekit_analytics_settings
should be migrated over togooglesitekit_analytics-4_settings
.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
analytics
module should be copied over to theanalytics-4
module:accountID
adsConversionID
canUseSnippet
trackingDisabled
adsenseLinked
googlesitekit_analytics-4_settings
option, it should fallback to the data stored in thegooglesitekit_analytics_settings
option (if it exists there).ownerID
setting should also be treated in the same way, instead of how it is currently always synced between the two modules.Implementation Brief
includes/Modules/Analytics_4/Settings.php
:get_owned_keys
method to include theaccountID
module setting.get_default
method to include defaults for the module settings mentioned in the ACs. The default values can be copied from theModules\Analytics\Settings
class.get_sanitize_callback
method to add sanitization for thecanUseSnippet
,trackingDisabled
, andadsenseLinked
module settings. These sanitization rules can be copied from theModules\Analytics\Settings
class.merge_initial_owner_id
method.update_owner_id_in_settings
method.get
method:analytics
module setting value for theownerID
setting.analytics-4
module but does exist in thegooglesitekit_analytics_settings
option, the value from thegooglesitekit_analytics_settings
option is served.Analytics_Settings
class as a way to access thegooglesitekit_analytics_settings
option, use the always availableget_option
WordPress function. This will ensure that this fallback works even after theModules\Analytics
class is removed in the future (currently planned as a part of #7932).assets/js/modules/analytics-4/datastore/base.js
:accountID
in theownedSettingsSlugs
array.settingSlugs
array.Test Coverage
tests/phpunit/integration/Modules/Analytics_4/SettingsTest.php
:get
method to verify the fallback behaviour for the copied settings.QA Brief
googlesitekit.data.select('modules/analytics-4').getSettings()
, hit enter. Expand the array, verify that keys listed in AC are present and have correct dataChangelog entry
The text was updated successfully, but these errors were encountered: