site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Enhanced Measurement Created Despite Disabled

Open wpdarren opened this issue 1 year ago • 3 comments

Bug Description

While completing testing on the Singular Analytics Module, I noticed that when setting up Analytics, the user creates a new property/web data stream and disables Enhanced Measurement; when the new property is created, the Enhanced Measurement toggle is changed and enabled. This is not a regression, as it occurs on the latest release.

You can see it in action on this screencast.

https://github.com/google/site-kit-wp/assets/73545194/dfdff5f1-b82c-460b-a4e2-24602e958fe5

Steps to reproduce

  1. Activate Analytics Module.
  2. During setup, select and existing account but chose to create a New property.
  3. Toggle the enhanced measurement switch off.
  4. Continue setup.
  5. See that the enhance measurement for the newly created property/data stream is enabled anyways.

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

Acceptance criteria

  • Creating a new property (or new measurement ID) during Analytics setup should honor the "Enable enhanced measurement toggle" and only enable enhanced measurement for the newly created web data stream associated with newly created property when the toggle is "On".

Implementation Brief

It seems we do not have an implementation for passing the enhanced measurement settings when new web data stream is created from settings, unlike how it is done in account create flow.

  • [ ] Go to the assets/js/modules/analytics-4/datastore/webdatastreams.js and update the createWebDataStream action
    • Collect the value from the CORE_FORMS where enhanced measurement switch component will store the current value https://github.com/google/site-kit-wp/blob/d6c58d6d644209b60469061c1b04a3008afc5b7c/assets/js/modules/analytics-4/components/common/EnhancedMeasurementSwitch.js#L55-L57
    • Pass it as a third parameter to the fetchCreateWebDataStream function , as enhancedMeasurementStreamEnabled https://github.com/google/site-kit-wp/blob/d6c58d6d644209b60469061c1b04a3008afc5b7c/assets/js/modules/analytics-4/datastore/webdatastreams.js#L174-L177
      • And include it in https://github.com/google/site-kit-wp/blob/d6c58d6d644209b60469061c1b04a3008afc5b7c/assets/js/modules/analytics-4/datastore/webdatastreams.js#L114-L147
  • [ ] Update Google\Site_Kit\Modules\Analytics_4 class
    • [ ] Modify the POST:create-webdatastream endpoint in create_data_request method https://github.com/google/site-kit-wp/blob/d6c58d6d644209b60469061c1b04a3008afc5b7c/includes/Modules/Analytics_4.php#L1041-L1055 to check for newly added enhancedMeasurementStreamEnabled parameter, and pass it to the create_webdatastream method. Make it as an optional parameter
    • [ ] In create_webdatastream method
      • Instead of returning the response straight, return it to a variable, and if enhancedMeasurementStreamEnabled parameter is available send the request to the enhanced-measurement-settings endpoint https://github.com/google/site-kit-wp/blob/d6c58d6d644209b60469061c1b04a3008afc5b7c/includes/Modules/Analytics_4.php#L838-L849 with the needed parameters. You can acquire web data stream ID from response’s _id property
      • Return the web data stream creation response.

Test Coverage

  • No update needed

QA Brief

Changelog entry

wpdarren avatar Mar 18 '24 15:03 wpdarren

I was doing release testing on main and created new everything (account, property, data steam) and disabled EM. All went well.

Even the EM banner showed up right after.

Screenshot_20240322_110527 Screenshot_20240322_110551

However, I can reproduce this by selecting an existing account and creating a new Property on it. Note that is only happens in setup, and not when creating a new property in Settings.

Moving this forward. :+1:

kuasha420 avatar Mar 22 '24 05:03 kuasha420

AC ✔️

eugene-manuilov avatar Mar 22 '24 16:03 eugene-manuilov

IB ✅

tofumatt avatar Mar 28 '24 15:03 tofumatt

QA Update: ✅

Verified:

Noted the need to grant the additional edit permission to create a new property/datastream to reproduce the issue:

  • Went through OAuth and came back and the automatic creation afterward. See screencast.
  • The enhanced measurement setting keeps the value selected while creating a new property/web data stream.
  • On the setup module screen, the switch is enabled by default, even if on the selected property, you disabled enhanced measurement switch is enabled by default, as well as whenever you switch to different/new property or/and the web data stream switch is reset to on by default
  • On the Settings page, the switch is less pushy. If the enhanced measurement for a selected property is disabled, it shows as off by default or when switching between the account/property/web data stream dropdown.

I ran through some testing of enhanced measurement in its entirety to ensure everything worked as expected. Including testing the banner on the dashboard when the feature is disabled. Enabling and disabling the feature within settings

Note: I did notice a bug, but not a regression related to the banner on the dashboard. I will create a ticket for this.

https://github.com/google/site-kit-wp/assets/73545194/f1d73e21-7b03-405d-95da-602060bdbcda

Screenshots

image image image image

wpdarren avatar Apr 16 '24 12:04 wpdarren