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

Add the Settings Section toggle switch variant and hook up the setting to toggle the Audiences Widget Area on/off

Open techanvil opened this issue 1 year ago • 5 comments

Feature Description

Add the Settings Section toggle switch variant and hook up the setting to toggle the Audiences Widget Area on/off.

See Settings section in the design doc.


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

Acceptance criteria

  • A toggle switch is implemented in the Settings Section under the Admin Settings tab, below the Key Metrics section.
  • The toggle switch controls the visibility of the Audiences Widget Area.
  • The setting is persistent through the POST audience-settings endpoint and reflects the current state of the Audiences Widget Area visibility.
  • The feature aligns with the guidelines in the design doc and the Figma design.

Implementation Brief

  • [x] Add assets/js/modules/analytics-4/components/settings/AudienceSegmentation/SettingsVisitorGroups.js
    • Use assets/js/components/settings/SettingsPlugin.js as a starting point
    • Replace Checkbox component with Switch component
    • Apply styling and text as outlined in design doc and figma linked in AC
    • In the onChange callback, save the settings using the setAudienceSegmentationWidgetHidden action and check for the value using isAudienceSegmentationWidgetHidden action, implemented in 7176,
  • [x] Update assets/js/components/settings/SettingsAdmin.js
    • After https://github.com/google/site-kit-wp/blob/c173f6c206ce0b7f2eb0777b0acfe3bfe649c385/assets/js/components/settings/SettingsAdmin.js#L50-L54 Check if analytics-4 module is active, using isModuleActive selector on CORE_MODULES datastore, and if audienceSegmentation feature flag is enabled to render SettingsVisitorGroups component wrapped with <Cell size={ 12 }> component

Test Coverage

  • Add tests for SettingsVisitorGroups component, ensuring the switch's actions send the events mentioned in the description/ACs

QA Brief

  • Ensure the Analytics module is connected.
  • Ensure the Audience Segmentation feature flag is enabled via the tester plugin.
  • Navigate to the Settings page -> Admin Settings and verify the Visitor groups section with the toggle switch is displayed under the Key Metrics section.
  • Verify the toggle switch is functional and toggles the visibility of the Audiences Widget Area.
  • Verify the setting is persistent through the POST audience-settings endpoint.
  • Go to the browser's Network tab and check the POST request for audience-settings when toggling the switch.
  • Once merged, verify this story.

Changelog entry

  • Add a settings toggle for Audience Segmentation.

techanvil avatar Jan 25 '24 12:01 techanvil

AC ✔️

eugene-manuilov avatar Jan 30 '24 13:01 eugene-manuilov

IB ✅

tofumatt avatar Jan 31 '24 19:01 tofumatt

Hey @zutigrm, as mentioned on Slack I've added a code organization section to the design doc to help keep us aligned.

The upshot is that we should create this new SettingsVisitorGroups in the assets/js/modules/analytics-4/components/settings/AudienceSegmentation/ folder.

It's also worth noting that the audience settings will only be available if analytics-4 is active so we should make that a condition for displaying the settings section.

Please can you update the IB accordingly?

techanvil avatar Feb 05 '24 11:02 techanvil

Thanks for the update @zutigrm, IB LGTM! :white_check_mark:

techanvil avatar Feb 05 '24 12:02 techanvil

QA Update: ✅

Verified:

  • On the Settings page, the Visitor groups section with the toggle switch is displayed under the Key Metrics section.
  • The toggle switch is functional and toggles the visibility of the Audiences Widget Area.
  • The setting is persistent through the POST audience-settings endpoint.
  • The POST request for audience-settings when toggling the switch.
  • This story loads and behaves correctly.
Screenshots

image image

wpdarren avatar Mar 29 '24 12:03 wpdarren

⚠️ I noticed a misspelling which should be fixed but can happen in a follow-up https://github.com/google/site-kit-wp/pull/8424#pullrequestreview-1983969282

aaemnnosttv avatar Apr 05 '24 18:04 aaemnnosttv