Integrate the GA4 submit changes store functionality into the UA submit changes store
#3244 implemented the canSubmitChanges (plus __dangerousCanSubmitChanges) selector and the submitChanges action for the modules/analytics-4 store.
For the first milestone of adding GA4 support, the GA4 module only exists internally, while the only user-facing touch points are exposed via the existing Analytics module, which primarily is for UA but now allows for some GA4 support. As such, since all GA4 data is controlled via UI in the existing Analytics module, some parts of the modules/analytics-4 store need to be integrated into the modules/analytics store so that calls to the latter from the UI are sufficient to cover both.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The
submitChangesaction of themodules/analyticsstore should after successful execution of its own functionality also trigger thesubmitChangesaction of themodules/analytics-4store if that store is loaded (which depends on the feature flag being enabled, via the server side).- This should be trivial by calling the
submitChangesaction ofmodules/analytics-4in thesubmitChangesfunction frommodules/analytics.
- This should be trivial by calling the
- Similarly, the
canSubmitChangesselector (plus its "dangerous" companion selector) of themodules/analyticsstore should also require the corresponding functionality of themodules/analytics-4store to pass if that store is loaded (as above).- This should be possible to achieve simply by relying on the
modules/analytics-4store's__dangerousCanSubmitChangesselector within thevalidateCanSubmitChangescode frommodules/analytics.
- This should be possible to achieve simply by relying on the
Implementation Brief
- Inside the
submitChangesaction of the Analytics store, after successfully completing its own functionality:
- Ascertain that the Analytics-4 feature (
ga4setup) is enabled viaisFeatureEnabled- If it is enabled, call the
submitChangesaction of the Analytics-4 module (see #3244)
- If it is enabled, call the
- Inside the
validateCanSubmitChangesselector of the Analytics store,
- Ascertain that the Analytics-4 feature (
ga4setup) is enabled viaisFeatureEnabled- If it is enabled, call the
__dangerousCanSubmitChangesselector in the Analytics-4 store (important to use this version of thecanSubmitChangesselector because it will throw if it fails).
- If it is enabled, call the
Test Coverage
- Add test coverage for the new functionality; existing tests should pass.
Visual Regression Changes
- None anticipated.
QA Brief
- With the
ga4setupfeature flag disabled, submitting the Analytics setup form or saving changed Analytics settings via the module's settings panel should still work as expected. - With the
ga4setupfeature flag enabled, submitting the Analytics setup form or saving changed Analytics settings via the module's settings panel should no longer work. This is an expected temporary stage for the GA4 implementation, and the breakage here is irrelevant since it's not user-facing, as the feature flag is not enabled in production.
Changelog entry
- Update Analytics data store settings
submitChangesinfrastructure to include GA4 when enabled.
@johnPhillips IB mostly looks good. There is one thing that we need to update before approval:
- Ascertain that the Analytics-4 feature (ga4setup) is enabled via isFeatureEnabled
- If it is enabled, call the canSubmitChanges selector in the Analytics-4 store (see #3244)
- The function should only return true if both its own functionality passes AND the canSubmitChanges call from the Analytics-4 module returns true
We need to call the __dangerousCanSubmitChanges selector instead of canSubmitChanges because the validateCanSubmitChanges is expected to throw exceptions if something is wrong. That's what the dangerous version of the canSubmitChanges selector does whilst the canSubmitChanges selector itself just returns true or false and doesn't throw.
Thanks @eugene-manuilov, I've added this to the IB.
The function should only return true if both its own functionality passes AND the __dangerousCanSubmitChanges call from the Analytics-4 module returns true
@johnPhillips validateCanSubmitChanges and __dangerousCanSubmitChanges return nothing. They throw if something is wrong. If they don't throw then everything is good. No need to return true here. So we can delete the last point.
Thanks @eugene-manuilov, updated 👍
Thanks, @johnPhillips. IB :heavy_check_mark:
QA Update: Pass ✅
Verified:
-
With the
ga4setupfeature flag disabled, submitting the Analytics setup form and saving changed Analytics settings via the module's settings panel still works as expected. I tested this with a site that already had a Analytics account and one site that had a new Analytics created. Both work as expected. -
With the
ga4setupfeature flag enabled, submitting the Analytics setup form and saving changed Analytics settings via the module's settings panel no longer works.
