You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current assets/js/components/setup/ModuleSetup.js hard-codes the entire setup screen, i.e., the header, progress indicator, content wrapper, intro title, the module's SetupComponent, and footer, and already carries module-specific conditionals for the Analytics initial-setup flow.
The planned upcoming work for Reader Revenue Manager Express Setup is set to add further complexity and module-specific logic to this component, which is not intended.
#12974 decomposes this component into smaller, independently composable, and reusable primitives. The intention behind this refactor is for a module to optionally own its entire setup screen when required, and when it does, it can import any of the above primitives to retain the default behavior for areas that do not require customization.
This issue is intended to extract shared behavior currently inlined in ModuleSetup, i.e., the finishSetup routine (cache clear, event tracking, redirect) and view tracking into custom hooks (e.g. useFinishSetup, useModuleSetupTracking). This allows module-specific screens to reuse core logic without duplication.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Shared hooks encapsulate the module setup behaviors currently inlined in ModuleSetup: completing setup (cache clear, completion tracking, redirect) and view tracking on mount.
A module that owns its own setup screen can import and use those hooks to get the same completion and view-tracking behavior as the default flow, without duplicating that logic.
ModuleSetup consumes the shared hooks and no longer inlines the finishSetup routine or mount-time view tracking.
Existing module setup behavior is unchanged:
Completing setup still clears the module_setup cache, fires the correct completion tracking event, and navigates to the Site Kit dashboard or an optional custom redirect URL.
Viewing a module setup screen still fires the correct view tracking event once on load.
Canceling setup from the default footer still fires the correct cancel tracking event.
Add shared setup hooks under assets/js/components/setup/hooks/:
useFinishSetup: Extract the finishSetup callback from ModuleSetup.
Accept moduleSlug and any inputs needed to preserve current completion-tracking behavior (including the initial Analytics setup-flow variant for now).
Return an async finishSetup( redirectURL? ) function that:
Clears the module_setup cache.
Tracks the appropriate completion event.
Navigates to the provided redirect URL (with forwardable params merged in) or to the default Site Kit dashboard URL with the existing success notification params.
useModuleSetupTracking: Extract mount-time view tracking (and optionally the cancel-setup tracking callback used by the default footer).
Accept moduleSlug and any inputs needed to preserve current view-tracking behavior (including the initial Analytics setup-flow variant for now).
Fire the correct view event on mount.
Expose a reusable cancel-tracking callback if that keeps ModuleSetup free of inline tracking logic.
Update assets/js/components/setup/ModuleSetup.js to use the new hooks instead of its inline implementations. Behavior and public props should remain the same.
Feature Description
The current
assets/js/components/setup/ModuleSetup.jshard-codes the entire setup screen, i.e., the header, progress indicator, content wrapper, intro title, the module'sSetupComponent, and footer, and already carries module-specific conditionals for the Analytics initial-setup flow.The planned upcoming work for Reader Revenue Manager Express Setup is set to add further complexity and module-specific logic to this component, which is not intended.
#12974 decomposes this component into smaller, independently composable, and reusable primitives. The intention behind this refactor is for a module to optionally own its entire setup screen when required, and when it does, it can import any of the above primitives to retain the default behavior for areas that do not require customization.
This issue is intended to extract shared behavior currently inlined in
ModuleSetup, i.e., thefinishSetuproutine (cache clear, event tracking, redirect) and view tracking into custom hooks (e.g.useFinishSetup,useModuleSetupTracking). This allows module-specific screens to reuse core logic without duplication.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
ModuleSetup: completing setup (cache clear, completion tracking, redirect) and view tracking on mount.ModuleSetupconsumes the shared hooks and no longer inlines thefinishSetuproutine or mount-time view tracking.module_setupcache, fires the correct completion tracking event, and navigates to the Site Kit dashboard or an optional custom redirect URL.setup_flow_v3_view_analytics_step,setup_flow_v3_complete_analytics_step) continue to fire under the same conditions as today, until relocated by Remove Analytics-specific quirks out of the core module setup component #12976.Implementation Brief
assets/js/components/setup/hooks/:useFinishSetup: Extract thefinishSetupcallback fromModuleSetup.moduleSlugand any inputs needed to preserve current completion-tracking behavior (including the initial Analytics setup-flow variant for now).finishSetup( redirectURL? )function that:module_setupcache.useModuleSetupTracking: Extract mount-time view tracking (and optionally the cancel-setup tracking callback used by the default footer).moduleSlugand any inputs needed to preserve current view-tracking behavior (including the initial Analytics setup-flow variant for now).ModuleSetupfree of inline tracking logic.assets/js/components/setup/ModuleSetup.jsto use the new hooks instead of its inline implementations. Behavior and public props should remain the same.Test Coverage
useFinishSetup:module_setupcache.complete_module_setupevent for a normal module setup flow.useModuleSetupTracking:view_module_setupevent on mount for a normal module setup flow.cancel_module_setupevent when the cancel callback is invoked (if extracted into this hook).ModuleSetup.test.jscoverage passing; adjust only if assertions move to hook-level tests.QA Brief
Changelog entry
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