-
Notifications
You must be signed in to change notification settings - Fork 286
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
Prevent users from connecting GA4 without access to UA #5886
Comments
IB ✅ @nfmohit I made a minor adjustment and fixed a typo which you can see in the edit history, I didn't think these merited the round trip! |
@aaemnnosttv Partially assigned this to you only to get your thoughts on this CR comment. Thanks! |
@aaemnnosttv I've created #6270 to address this. Thank you! |
Thanks @nfmohit 👍 there's a little more to do on that one but not much, I've sent it back with you. More importantly, this issue seems to have introduced a regression (currently in The issue here however is that once GA4 is enabled/toggled-on, the property select remains disabled. Both of these should really be fixed for the release. |
@wpdarren this is ready for review again – please note also that your observation #6271 (comment) should be resolved as well. Just to note for QA as well, the cases we want to ensure are checked here are:
In all cases, if GA4 is connected, there should be no progress bar and it should always show as "Connected" as other modules. We also want to see that the height of the collapsed module settings row does not change between loading and loaded states in each case. This is somewhat less important than all the other functional details but is something we paid attention to addressing in CR. |
QA Update: ✅Verified:
ga-5.mp4 |
Feature Description
Analytics is a bit of a special case when it comes to modules as it is essentially one but technically implemented as two under the hood. In #4825 we added guardrails to the module settings edit views for modules with service entities to prevent an admin without access to the configured entity to change it.
For GA4, we do the same thing – prevent the user from changing the connection without access. Since older configurations could be setup without GA4, we should additionally require that only admins that have access to the current configured UA entity can connect or change the GA4 connection.
At the same time, we should evaluate if it should even be possible for UA and GA4 to have different module owners, which is currently possible.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
The Settings Edit screen for Analytics should be modified to prevent an admin from connecting or changing the connected GA4 property without having access to the connected UA entity
If GA4 is not connected, the toggle to enable GA4 (not the snippet) should be disabled with an added notice explaining that user needs access to UA in order to connect GA4 (exact copy below). The style here should largely follow what is already in place for the insufficient access restrictions in the settings view. The notice should specifically indicate the owner of the main/UA Analytics module as the point of contact for access.
If GA4 is connected, the existing logic in place around insufficient access restrictions for
analytics-4
should be amended to also require the user has access to the current UAanalytics
entity in order to change the connected GA4 entity. In this case, the notice shown should use alternate copy (see below) and have a higher priority over the GA4 notice. E.g. if the user didn't have access to the UA or the GA4 entities, they would only see the notice about UAThe current messages which are shown when a user does not have access to the current configured entity should be amended for consistency
Where
{Analytics}
is eitherAnalytics
orAnalytics 4
respectively.Implementation Brief
assets/js/modules/analytics/components/settings/SettingsForm.js
:<GA4SettingsControls />
component.hasModuleAccess
prop passed to it.hasAnalyticsAccess
andhasAnalytics4Access
props to it.assets/js/modules/analytics/components/common/GA4ActivateSwitch.js
:disabled
.disabled
prop to the<Switch />
component.assets/js/modules/analytics/components/settings/GA4SettingsControls.js
:hasAnalyticsAccess
andhasAnalytics4Access
props to the component instead ofhasModuleAccess
. Do not replace the usages ofhasModuleAccess
because we will create a new variable with the same name.<GA4ActivateSwitch />
component and add thedisabled
prop to it. Thedisabled
prop should be truthy only ifhasAnalyticsAccess
is falsey.analytics-4
module is connected by running theisModuleConnected
selector from thecore/modules
store.hasModuleAccess
. It should betrue
ifanalytics-4
is connected, and bothhasAnalyticsAccess
&hasAnalytics4Access
are truthy.<SettingsNotice />
component:analytics-4
is not connected andhasAnalyticsAccess
is falsey.analytics-4
is connected andhasAnalyticsAccess
is falsey.analytics-4
is connected andhasAnalyticsAccess
is truthy, buthasAnalytics4Access
is falsey.notice
prop depending on the above conditions.Analytics 4
replacing{Analytics}
.assets/js/components/settings/SettingsActiveModule/Header.js
:Connect Google Analytics 4
CTA only if the current user has access to Analytics (UA).useSelect
hook usage similar tohasAnalyticsAccess
fromassets/js/modules/analytics/components/settings/SettingsEdit.js
can be used.assets/js/modules/analytics/components/settings/SettingsControls.js
:notice
prop of the<SettingsNotice />
component to match the third message quoted in the ACs withAnalytics
replacing{Analytics}
.assets/js/modules/analytics/components/settings/SettingsForm.stories.js
:Settings w/o module access
story with two distinct stories, one with no access to Analytics and the other with no access to Analytics 4.Test Coverage
should render a button to connect GA4 if Analytics is connected but GA4 is not
test case inassets/js/components/settings/SettingsActiveModule/Header.test.js
.QA Brief
googlesitekit_analytics-4_settings
from thewp_options
table.Connect Google Analytics 4
CTA is visible on the Module header for the Admin1.Connect Google Analytics 4
CTA is not visible since the Admin1 initially set up Analytics.Analytics
header and click on theEdit
link to go to the/edit
page. This is the same page that will be navigated when we click theConnect Google Analytics 4
CTA.Activate Google Analytics 4 and place code on your site.
toggle switch is disabled when the user doesn't have access to theAnalytics
(UA).Modules -> Analytics -> Settings -> SettingsEdit
storybook, ensure the following newly added stories are as expected:Settings w/o UA and GA4 access, GA4 not connected
Settings w/o UA and GA4 access, GA4 connected
Settings w/o Analytics access, GA4 connected
Settings w/o Analytics-4 access, GA4 connected
Settings w/o UA and GA4 access, fallback owner name
Update
Connect Google Analytics 4
CTA is still visible for the second admin who doesn’t have access to Analytics.Update
Connect Google Analytics 4
CTA is hidden for the users who don't have Analytics access; instead shows a statusGoogle Analytics 4 is not connected
. Please refer to this comment for more details.Update
Changelog entry
The text was updated successfully, but these errors were encountered: