-
Notifications
You must be signed in to change notification settings - Fork 328
Description
Feature Description
Implement the logic for returning to the Analytics or Key Metrics step when exiting the setup flow.
For reference, see the Returning to Site Kit after exiting the setup flow section in the Design Doc.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- If the user exits the setup flow by clicking the Exit setup button, or by any other means, e.g., closing the browser window, and the user returns to Site Kit, they are redirected to either the splash screen, or the Analytics or Key Metrics setup screen, depending on the step they were on when they exited the setup flow.
- If the user was on the Analytics setup screen, they are redirected to the Analytics setup screen.
- If the user was on the Key Metrics setup screen, they are redirected to the Key Metrics setup screen.
- In any other case, they are redirected to the splash screen.
- This logic is only active when the
setupFlowRefreshfeature flag is enabled.
Implementation Brief
- In
assets/js/components/setup/SetupUsingProxyWithSignIn/index.js- In the
onButtonClickcallback, ifconnectAnalyticsis set, call thesaveInitialSetupSettingsaction from theCORE_USERstore and setisAnalyticsSetupCompletetofalse. Do this only whensetupFlowRefreshis enabled, using theuseFeaturehook to determine this.
- In the
- In
assets/js/components/key-metrics-setup/KeyMetricsSetupApp.js- In the
submitChangescallback, when there is no error, callsaveInitialSetupSettingsand setisAnalyticsSetupCompletetotruebecause, at this point, the analytics setup is complete.
- In the
- In
includes/Core/Admin/Screens.php, refer to the prototype PR- Add the
initialize_callbackto thedashboardscreen. - Refer to the existing
initialize_callbackand implement similar logic for redirecting the user.
site-kit-wp/includes/Core/Admin/Screens.php
Lines 385 to 431 in c45ae16
'initialize_callback' => function ( Context $context ) { $is_view_only = ! $this->authentication->is_authenticated(); if ( ! $is_view_only ) { $initial_setup_settings = ( new Initial_Setup_Settings( $this->user_options ) )->get(); $is_analytics_setup_complete = $initial_setup_settings['isAnalyticsSetupComplete']; if ( false === $is_analytics_setup_complete ) { $is_analytics_connected = $this->modules->is_module_connected( 'analytics-4' ); if ( $is_analytics_connected ) { wp_safe_redirect( $context->admin_url( 'user-input', array( 'showProgress' => true, ) ) ); exit; } else { $slug = $context->input()->filter( INPUT_GET, 'slug' ); $show_progress = (bool) $context->input()->filter( INPUT_GET, 'showProgress' ); $re_auth = (bool) $context->input()->filter( INPUT_GET, 'reAuth' ); if ( 'analytics-4' === $slug && $re_auth && $show_progress ) { return; } wp_safe_redirect( $context->admin_url( 'dashboard', array( 'slug' => 'analytics-4', 'showProgress' => true, 'reAuth' => true, ) ) ); exit; } } } },
- Add the
Test Coverage
-
Add tests to ensure
saveInitialSetupSettingsis being called on the splash screen and Key Metrics App screen with the correctisAnalyticsSetupCompletevalue. -
Add tests for the
initialize_callbackfunctionality.
QA Brief
- Install and activate the
Site Kit by Google Staging Proxyplugin. - Enable the
setupFlowRefreshfeature.
Case 1: Land on Key Metrics Screen
-
Connect the Analytics and it will redirect to Key metrics screen. Do not setup Key metrics.
-
Move away from this screen by visiting WordPress Dashboard or any other page in WP admin.
-
Revisit the
Site Kit > Dashboard, it should redirect to new Key metrics setup screen.
Case 2: Land on Analytics Screen
-
Setup Site Kit with connect Analytics option checked. Do not configure Analytics module during initial setup flow.
-
Click on
Site Kit > Dashboard, it should redirect again to Analytics setup screen.
Changelog entry
- Ensure the user is returned to the Analytics or Key Metrics setup screen if the new setup flow is interrupted on one of those screens.