Skip to content

Update all authentication flows (including View-Only) to allow redirect parameters to be persisted to take user to subscribe panel #11890

@benbowler

Description

@benbowler

Feature Description

Update the SetupUsingProxyViewOnly component (and related admin view-only sign-in flow) to support a redirect_url query parameter. When present, clicking "Go to dashboard" redirects to the dashboard URL with the original query params preserved. This enables email reporting links to be proxied through the splash screen while still opening the email reporting panel automatically after the user proceeds.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • notification and panel query parameters are persisted through all splash screen and authentication flows.
  • When a user arrives at the dashboard with notification=X, the corresponding notification is displayed.
  • When a user arrives at the dashboard with panel=email-reporting, the email reporting panel opens.
  • Without these parameters, all existing behaviour is unchanged.

Implementation Brief

Migrate email-reporting-panel to panel=email-reporting

The existing email-reporting-panel=1 query parameter is replaced with the more general panel=email-reporting. This allows the panel parameter to open different panels (one at a time) without requiring feature-specific query keys.

  • Update file includes/Core/Email_Reporting/Email_Reporting.php:

    • Change register_link( 'manage-subscription', array( 'email-reporting-panel' => 1 ) ) to array( 'panel' => 'email-reporting' )
    • Change register_link( 'unsubscribe', array( 'email-reporting-panel' => 1 ) ) to array( 'panel' => 'email-reporting' )
  • Update file includes/Core/Email_Reporting/Email_Reporting_Pointer.php:

    • Change admin_url( 'dashboard', array( 'email-reporting-panel' => 1 ) ) to array( 'panel' => 'email-reporting' )
  • Update file assets/js/hooks/useOpenEmailReportingSelectionPanelEffect.js:

    • Read the panel query arg instead of email-reporting-panel
    • Open the email reporting selection panel when panel === 'email-reporting' (instead of checking for presence of email-reporting-panel)

Backend (PHP) - splash param preservation

  • Update file includes/Core/Admin/Screens.php:
    • no_access_redirect_dashboard_to_splash() (line ~285):
      • Read notification and panel from $this->context->input()->filter( INPUT_GET, ... ) (do not read from $_GET directly)
      • Pass them as query args to $this->context->admin_url( 'splash', [ 'notification' => ..., 'panel' => ... ] )
      • This preserves supported params when any user without dashboard access is redirected to the splash
    • Splash initialize_callback (line ~516):
      • Pass panel through alongside the existing notification pass-through so both params survive the splash → dashboard redirect for users who already have access

Frontend (JavaScript) - splash param preservation

  • Create file assets/js/util/getForwardableParams.js:

    • Export a function that reads notification and panel from global.location.href using getQueryArg and returns an object with the non-empty values
    • This avoids duplicating the param extraction logic across multiple components
  • Update file assets/js/components/setup/SetupUsingProxyViewOnly.js:

    • Import the new utility
    • Use the utility to get forwardable params and pass them to getAdminURL( 'googlesitekit-dashboard', { ...params } ) for the "Go to dashboard" navigation
  • Update file assets/js/components/setup/SetupUsingProxyWithSignIn/Actions.js:

    • Import the new utility
    • Use the utility to get forwardable params and pass them to getAdminURL for the "Skip sign-in" navigation
  • Update file assets/js/components/setup/SetupUsingProxyWithSignIn/index.js:

    • Import the new utility
    • Use the utility to get forwardable params and build a post-auth dashboard URL via getAdminURL( 'googlesitekit-dashboard', { ...params } )
    • In onButtonClick, pass this URL as redirect to proxySetupURL so the params survive the OAuth round-trip via the existing redirect > OPTION_REDIRECT_URL > OAuth_Client::get_authorize_user_redirect_url() mechanism
    • moduleReauthURL branch remains first (takes priority)

Test Coverage

  • Jest tests in assets/js/components/setup/SetupUsingProxyViewOnly.test.js (new file):

    • "Go to dashboard" navigates to base dashboard URL when no params are present
    • "Go to dashboard" navigates to dashboard with panel=email-reporting when present in splash URL
    • "Go to dashboard" navigates to dashboard with notification=X when present in splash URL
  • Jest tests in assets/js/components/setup/SetupUsingProxyWithSignIn/Actions.test.js (update existing):

    • "Skip sign-in" with panel param navigates to dashboard with param preserved
    • "Skip sign-in" without params navigates to base dashboard
  • Jest tests in assets/js/components/setup/SetupUsingProxyWithSignIn/index.test.js (update existing):

    • "Sign in with Google" with panel param passes dashboard URL with param as redirect to proxy setup URL
    • "Sign in with Google" without params navigates to bare proxy setup URL

QA Brief

Site Kit should not have been setup, for each test it should be blank installation with splash screen only visible. Ensure proactiveEngagement feature flag is enabled (for seeing the email reporting panel, but URL params should still be preserved in URL regardless of feature flag)

Email reporting panel/param

  • Admin test
    • Add this path to the base website URL: /wp-admin/admin.php?page=googlesitekit-dashboard&panel=email-reporting And /wp-admin/admin.php?page=googlesitekit-splash&panel=email-reporting both should land on splash screen
    • Setup Site Kit, and verify that after successful OAuth when redirected back to SK dashboard - email reporting side panel is opened
  • View only users
    • Use the same path as above, you should land on dashboard with email reporting side panel opened
  • Secondary Admins
    • Paste same URL as before, after landing on splash screen, whether you authenticate the admin or choose skip sign in and view limited dashbaord, when landing on dashboard - email reporting side panel should open

Notification parameter

  • Repeat steps above, only use this path /wp-admin/admin.php?page=googlesitekit-splash&notification=test_notice
  • Verify that when redirected to the dashboard, the otification=test_notice URL param is preserved

With SK being setup

  • Setup SK with proactiveEngagement feature flag enabled
  • Include this path: /wp-admin/admin.php?page=googlesitekit-dashboard&panel=email-reporting
    • Verify it lands on SK dashboard and opens email reporting panel
  • Go to WP dashboard - when email reporting pointer shows, click on Setup CTA, verify it still correctly redirects you to the dashboard with email reporting panel opened

Changelog entry

  • Ensure query params persist during email subscription flow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0High priorityTeam SIssues for Squad 1Type: EnhancementImprovement of an existing featurejavascriptPull requests that update Javascript code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions