-
Notifications
You must be signed in to change notification settings - Fork 328
Description
Feature Description
Notifications have an optional single checkRequirements function which is used to gate whether the notification qualifies for being active. In practice, this function is often used to check several things, some of which are frequently repeated across a number of instances (e.g. module connection check).
This makes each notification's checkRequirements function unique and unable to be shared with others. It also often uses the pattern of resolving data dependencies at the very beginning, some which may not even be needed, or even appropriate to invoke (such as settings when not connected – see #10259). By splitting monolithic requirements checks into their composite pieces, they can become both sharable and avoid invoking side-effects until truly required for the check they are needed for. This also allows for encapsulating dependencies in the individual checks which often makes then difficult to understand the relationship when mixed with other data and conditions.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- A new utility should be added to allow for composing a series of asynchronous requirements check functions
function ( ...requirements: Function[] ) : () => Promise<bool>
- The utility takes any number of functions are returns a new function that calls them in sequence, stopping as soon as the first check returns
false - If none return false, return
true
- The utility takes any number of functions are returns a new function that calls them in sequence, stopping as soon as the first check returns
- Reusable general purpose (core) checks should be added as relevant
- The notifications for the
analytics-4module should be refactored to use the new infrastructure to help drive out the implementation and establish patterns to follow for remaining implementations
Implementation Brief
- Define new pipeline function in
assets/js/util/async.js - Refactor notifications in
assets/js/modules/analytics-4/index.js, to use new pipeline function to compose eachcheckRequirements, splitting distinct conditions into discreet checks- Extract reusable checks where applicable across modules or for sharing within GA notifications
E.g.
requiresModuleConnection( slug ) requiresScope( scope ) requiresCapability( cap )
- Extract reusable checks where applicable across modules or for sharing within GA notifications
Test Coverage
- Add coverage for new pipeline utility
- Add coverage for shared checks
QA Brief
- This issue introduces new infrastructure that will be used to determine if a notification should be shown or not.
- All Analytics 4 notification display logic has been refactored, so only the conditions for displaying GA4 notifications should be checked for regressions (no behavior about the notifications themselves was touched)
- Audience segmentation setup CTA
- Web data stream not available
- Google tag mismatch
- Enhanced measurement setup CTA
- Audience segmentation introductory overlay
- Enhanced conversions (Analytics variant)
Changelog entry
- N/A