Skip to content

Implement the logic for returning to the Analytics or Key Metrics step when exiting the setup flow. #11388

@techanvil

Description

@techanvil

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 setupFlowRefresh feature flag is enabled.

Implementation Brief

  • In assets/js/components/setup/SetupUsingProxyWithSignIn/index.js
    • In the onButtonClick callback, if connectAnalytics is set, call the saveInitialSetupSettings action from the CORE_USER store and set isAnalyticsSetupComplete to false. Do this only when setupFlowRefresh is enabled, using the useFeature hook to determine this.
  • In assets/js/components/key-metrics-setup/KeyMetricsSetupApp.js
    • In the submitChanges callback, when there is no error, call saveInitialSetupSettings and set isAnalyticsSetupComplete to true because, at this point, the analytics setup is complete.
  • In includes/Core/Admin/Screens.php, refer to the prototype PR
    • Add the initialize_callback to the dashboard screen.
    • Refer to the existing initialize_callback and implement similar logic for redirecting the user.
      '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;
      }
      }
      }
      },

Test Coverage

  • Add tests to ensure saveInitialSetupSettings is being called on the splash screen and Key Metrics App screen with the correct isAnalyticsSetupComplete value.

  • Add tests for the initialize_callback functionality.

QA Brief

  • Install and activate the Site Kit by Google Staging Proxy plugin.
  • Enable the setupFlowRefresh feature.

Case 1: Land on Key Metrics Screen

  1. Connect the Analytics and it will redirect to Key metrics screen. Do not setup Key metrics.

  2. Move away from this screen by visiting WordPress Dashboard or any other page in WP admin.

  3. Revisit the Site Kit > Dashboard, it should redirect to new Key metrics setup screen.

Case 2: Land on Analytics Screen

  1. Setup Site Kit with connect Analytics option checked. Do not configure Analytics module during initial setup flow.

  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0High priorityTeam MIssues for Squad 2Type: EnhancementImprovement of an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions