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

Relocate the per user Audience Settings out of analytics module settings so it can be accessed when the module is disconnected

Open kuasha420 opened this issue 1 year ago • 1 comments

Feature Description

While working on #8156 it was discovered that the audience settings needs to be accessed when Analytics is disconnected. This issue will handle the refactor of the settings and enhancing the isActive requirement of the Widget introduced in the aforementioned issue.

More logical place for the settings is the user store, In the short term, we can move the selectors and rest endpoint to facilitate that. However as @aaemnnosttv pointed out in our private conversation, maybe it's time we introduced user preference infrastructure, so instead of having separate rest endpoint and store partial for Audience, Key metrics, user input etc, we can have a single class, rest endpoint and store partial for all of them. We can use WordPress filters to modify this from within module or other place when necessary and migrate the existing settings on the fly in future. Something to consider while working on the definition of the issue!


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

Acceptance criteria

  • Infrastructure for common user preference should be introduced.
    • This includes User_Setting class, REST controller and necessary store partial on core/user store.
  • Audience Segmentation related user setting that are currently stored in Audience_Settings should be moved to the newly introduced user preference.
    • The Audience_Settings and related REST and store infrastructure should also be removed from the code base.
    • All usage of the Audience_Settings should be refactored across the code base to use the values stored in user preference.
  • The audienceConnectAnalyticsCTA widget should only be shown if the Audience Segmentation feature has been set up for the current user and Analytics is disconnected.

Implementation Brief

  • [ ]

Test Coverage

QA Brief

Changelog entry

kuasha420 avatar Jun 05 '24 11:06 kuasha420

Hi @kuasha420, thanks for drafting the AC.

My concern is that adding a common user preferences infrastructure is a bit of scope creep that we are trying to cut out for the development of the initial Audience Segmentation release.

I realise it sounds quite simple, but I feel that designing and implementing a generic subsystem like this is inherently going to be more complicated and time consuming than simply moving the current Audience Settings code out of the Analytics module to the core User area of the codebase,

What I'd suggest is that we take this more simple and specific approach for the initial iteration, but create a followup issue - which can be defined outside of the Audience Segmentation epic - to create the common infrastructure, and migrate the Audience, Key Metrics, User Input settings/preferences over to it.

WDYT? If so, please can you amend the AC and also create a followup issue to capture the above? (Just one issue will do for now although we could split it out to multiple issues later).

techanvil avatar Jul 05 '24 10:07 techanvil

@techanvil Thanks for the review and raising this. Yes, I do understand the concern here. However, in the defense of doing the common infra now, I'd like to point one thing.

If we just move the settings to core user area, we will eventually need to create a migration/migrate on the fly the audience segmentation related settings. This will be the case for already launched features like User Input and Key Metrics, of course. But for audience segmentation, this can be prevented.

Also, the User Preference is going to be for simple Key-Value pairs, so I personally don't think it is going to be too difficult compared to just moving the Audience settings, except renaming the keys.

For the above reason, if we can do this right now without a vast investment, (ie. multiple level bump on the estimate), I'd put this forward to you once more for consideration. :pray:

If you don't agree, feel free to send it back my way, and I'll update the ACs and create follow up issue as suggested!

Cheers. :clinking_glasses:

kuasha420 avatar Jul 08 '24 04:07 kuasha420

Thanks @kuasha420, I appreciate your point, it's a fair one and it would indeed be nice to avoid having to migrate the Audience Segmentation settings.

However - with the epic running hot as it is, we are in a position where we really want to minimise any work that is not essential to the delivery of the feature. Also - although it doesn't sound too difficult, I do think it's going to be, within relative terms, significantly more work to implement the new infrastructure compared to simply moving what we've already got.

We'd need to introduce a multi-option version of the User_Setting class (or something along those lines), a new datastore, cover all of this with tests and indeed test it thoroughly to ensure it works for multiple user options. Plus do a smoke test of the existing Audience Segmentation feature to make sure it still works as expected.

This feels like more than a single bump on the estimate compared to mostly moving existing code and performing a smoke test (obviously, in either case we'll also need to also the last point in the AC so this doesn't factor in the comparison). We should also be conscious that things that look simple often have a tendency to be less so than we thought :sweat_smile:.

We'll still need to introduce a new REST controller, but maybe we could even add this in a forward-looking way so that it can be extended later to cover additional settings.

Going back to the point about the settings migration - while it would of course be nice to avoid needing to migrate the Audience Segmentation settings, seeing as we'll have to migrate Key Metrics and User Input anyway, we'll already have the pattern established so migrating AS settings as well should be relatively low impact compared to if we had to migrate the AS settings in isolation. Something else to bear in mind - although we can't bank on it, say if Team S are running a bit low on work they might even be able to pick the infra work up before AS is released and we could potentially avoid the migration anyway.

Sooo, with all this in mind, I do still feel it would be preferable to reduce the scope of this issue and address the rest later. Unless you have any further considerations, please do ahead with that approach. Thanks! :beers:

techanvil avatar Jul 08 '24 10:07 techanvil

Sounds reasonable @techanvil. I've updated the AC for you to review. I'll file a follow up issue about exploring user preferences as you've suggested. Cheers.

kuasha420 avatar Jul 09 '24 07:07 kuasha420

Thanks @kuasha420. That generally LGTM - I have made a couple of minor tweaks to the AC - adding a added a point to clarify the new paths and rewording the final point slightly to make it a bit more user-oriented.

AC :white_check_mark:

techanvil avatar Jul 09 '24 11:07 techanvil

IB :white_check_mark:

techanvil avatar Jul 18 '24 09:07 techanvil

Sending this ticket back to execution. Left one comment to @zutigrm and one comment to @kuasha420 and @techanvil.

eugene-manuilov avatar Aug 06 '24 16:08 eugene-manuilov

QA Update ✅

  • Tested on dev environment.
  • Verified audience segmentation set up.
  • Verified audience segmentation selection and deselection of group.
  • Done smoke testing of audience segmentation functionality.
  • All functionality are same as latest environment.
  • Verified await googlesitekit.data.select('core/user').getAudienceSettings() output an object with groups inside an array

image

image

image

mohitwp avatar Aug 23 '24 12:08 mohitwp

@kuasha420 @techanvil it sounds like this one took a simpler approach for the sake of time at the moment which makes sense. I still think it's worth moving towards a generic API for preferences where this could live rather than replicating this approach for other situations. Do we have an issue to pick this up as a follow-up outside of the epic?

aaemnnosttv avatar Aug 23 '24 19:08 aaemnnosttv

Hey @aaemnnosttv, I've created https://github.com/google/site-kit-wp/issues/9325 an an initial entry point for following up on this. We'll probably want to create more issues to backport existing user settings, but we can figure that out as we get further into the definition of the initial issue.

techanvil avatar Sep 11 '24 09:09 techanvil