google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.23k stars 286 forks source link

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

Closed kuasha420 closed 1 month ago

kuasha420 commented 4 months ago

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

Implementation Brief

Test Coverage

QA Brief

Changelog entry

techanvil commented 3 months ago

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).

kuasha420 commented 2 months ago

@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:

techanvil commented 2 months ago

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:

kuasha420 commented 2 months ago

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.

techanvil commented 2 months ago

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 commented 2 months ago

IB :white_check_mark:

eugene-manuilov commented 1 month ago

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

mohitwp commented 1 month ago

QA Update ✅

![image](https://github.com/user-attachments/assets/bdff2e8d-df42-4ee9-9d18-f4485b4b0922) ![image](https://github.com/user-attachments/assets/f989b38e-a5dd-4fea-b3d9-5adbc5c3a97e) ![image](https://github.com/user-attachments/assets/0b30f54f-eb9d-43fd-9ac9-59f54be4bd45)
aaemnnosttv commented 1 month ago

@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?

techanvil commented 3 weeks ago

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.