Skip to content

Handle Analytics activation errors on the splash screen. #12373

Description

@techanvil

Feature Description

Handle Analytics activation errors on the splash screen.

For reference, see the Analytics activation failure section in the design doc, and the Figma design.


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

Acceptance criteria

  • When the user clicks the Sign in with Google button on the splash screen with Analytics selected:
    • Errors from the following requests are handled:
      • POST core/modules/data/activation
      • POST core/user/data/initial-setup-settings
    • The GET core/user/data/initial-setup-settings request is not made (this requires an update to the saveInitialSetupSettings() action as discussed in the design doc).
  • When an error is returned from a request, the AnalyticsActivationErrorNotification component is shown (see Add the splash screen Analytics activation error notification to Storybook. #12372).
  • Clicking the Retry plugin setup button retries the setup process.
  • These changes are gated by the setupFlowRefreshPhase4 feature flag.

Implementation Brief

See the implementation guide in the design doc.

  • In assets/js/components/setup/SetupUsingProxyWithSignIn/index.js:

    • Add setupFlowRefreshPhase4-gated error handling for both of these requests in the Analytics opt-in path:
      • POST core/modules/data/activation
      • POST core/user/data/initial-setup-settings
    • On either error, register and display analytics-activation-error-notification with:
      • Component: AnalyticsActivationErrorNotification
      • priority: PRIORITY.ERROR_HIGH
      • areaSlug: NOTIFICATION_AREAS.HEADER
      • viewContexts: [ VIEW_CONTEXT_SPLASH ]
      • isDismissible: false
      • featureFlag: setupFlowRefreshPhase4
    • Ensure the setup flow returns early after error notification registration so OAuth/navigation does not continue.
    • Wire the notification CTA onRetry to re-run the onButtonClick callback.
    • Dispatch setIsAnalyticsSetupComplete( false ) before persisting splash setup state.
  • In assets/js/googlesitekit/datastore/user/initial-setup-settings.js:

    • Refactor saveInitialSetupSettings() to stop resolving getInitialSetupSettings() before save.
    • Update saveInitialSetupSettings() to simply persist the current in-store initialSetupSettings state, rather than accepting per-call override data.
    • Remove the need to pass a settings object into saveInitialSetupSettings() for this flow.
    • This removes the explicit pre-save dependency on GET core/user/data/initial-setup-settings in the save action path.
  • In assets/js/components/key-metrics-setup/KeyMetricsSetupApp.js:

    • Dispatch setIsAnalyticsSetupComplete( true ) before calling saveInitialSetupSettings().
    • Update the saveInitialSetupSettings call to use the argument-less form.
    • Update any isFetchingSaveInitialSetupSettings(), getErrorForAction( 'saveInitialSetupSettings', ... ), and clearActionError( 'saveInitialSetupSettings', ... ) usage to match the new action signature.
  • In assets/js/modules/analytics-4/components/common/AccountCreate/index.js

    • In the Continue without Analytics flow, dispatch setIsAnalyticsSetupComplete( true ) before calling saveInitialSetupSettings().
    • Update saveInitialSetupSettings usage to the argument-less form (do not pass { isAnalyticsSetupComplete: true }).
    • Update the CORE_USER dispatch destructuring to include setIsAnalyticsSetupComplete.

Test Coverage

  • Update assets/js/components/setup/SetupUsingProxyWithSignIn/index.test.js:
    • Add coverage for activation failure showing the Analytics activation error notification and preventing navigation.
    • Add coverage for initial setup settings save failure showing the same notification and preventing navigation.
    • Add coverage for Retry plugin setup invoking the same setup callback and successfully continuing when retry succeeds.
    • Add assertion in analytics opt-in success path that initial setup settings endpoint is called via POST in this flow.
  • Update assets/js/googlesitekit/datastore/user/initial-setup-settings.test.js as per changes.
  • Update any impacted KeyMetricsSetupApp tests to reflect the setIsAnalyticsSetupComplete() plus argument-less saveInitialSetupSettings() flow.
  • Add the story for error notification on splash screen.
  • Make sure all tests are passing.

QA Brief

  1. Ensure setupFlowRefresh and setupFlowRefreshPhase4 flags are enabled.
  2. Set up tweak to intercept activation endpoint:
    • Endpoint: .*/wp-json/google-site-kit/v1/core/modules/data/activation.*
    • Method: POST
    • Status: 500
  3. On a fresh/reset install open the Site Kit dashboard, the splash screen should be shown.
  4. On the splash screen, check the Get visitor insights… box and click the Sign in with Google button.
  5. You should not be navigated away from the splash screen, and a Connecting Site Kit failed error should appear.
  6. Remove the intercept from tweak and click the Retry plugin setup button.
  7. You should be taken through to the Google sign-in flow with no errors.
  8. Reset the plugin.
  9. Set up tweak to intercept the initial setup settings endpoint:
    • Endpoint: .*/wp-json/google-site-kit/v1/core/user/data/initial-setup-settings.*
    • Method: POST
    • Status: 500
  10. Repeat steps 3-7. The results should be the same.
  11. Remove tweak intercept an repeat setup with Get visitor insights… checked. Setup should proceed as normal with no errors.

Changelog entry

  • Handle Analytics activation errors on the new splash screen.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions