Skip to content

Fix Key Metrics hidden state for existing users #12872

Description

@techanvil

Feature Description

As part of the Setup Flow Refresh epic, we've decided that the Key Metrics and Audience Segmentation widgets are now integral parts of the dashboard and are set up by default when connecting Analytics.

We've also updated the Key Metrics section of the Settings screen, removing the toggle to hide the widget in the process.

However, as a result of this, existing users who have chosen to hide Key Metrics will no longer be able to toggle it on again when this feature is released.

Given that KM is now considered to be integral, we should re-show it for any users who've hidden it - and for consistency we should apply the same logic to the Audience Segmentation widget, i.e. remove its toggle from the Settings screen and re-show the widget to users who had hidden it.

We should also show a notice to affected users to inform them of the change.

This was raised in the bug bash, see this Asana task.


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

Acceptance criteria

  • Existing users who've hidden the Key Metrics widgets are re-shown the widgets on the dashboard when the setupFlowRefresh feature flag is enabled.
  • A notice is shown to affected users to inform them of the change (see Figma, and the screenshot below).
    • As per the Figma design, the copy for the notice is:
      • Title: Key metrics are back on your dashboard
      • Description: This section is now an integral part of the dashboard. You can customize which metrics are shown to focus on the ones most relevant to you.
      • Dismiss button: Got it
      • CTA button: Select metrics
    • Clicking the CTA button opens the Key Metrics selection panel and dismisses the notice.
    • Clicking the dismiss button dismisses the notice.
  • The existing "Change metrics" CTA for the widget area is updated to read "Select metrics" to align with the new design.
  • This change is gated behind the setupFlowRefresh feature flag.
Image

Implementation Brief

  • In assets/js/googlesitekit/datastore/user/key-metrics.js:

    • Override the isKeyMetricsWidgetHidden selector to return false when the setupFlowRefresh flag is enabled, regardless of the stored value, so the widget area is always visible under the flag.
    • Add a new raw selector (e.g. getRawKeyMetricsWidgetHidden) that returns the actual stored isKeyMetricsWidgetHidden setting without the flag override. This exposes the original user preference for use by the notice component.
  • Create new file: assets/js/components/KeyMetrics/KeyMetricsBackNotice.js.

    • Use the dismissed items store pattern only for notice visibility state: when user interacts (dismiss or CTA), call dismissItem( 'key-metrics-back-notice' ).
    • When CTA button is clicked:
      • Dismiss the notice by calling dismissItem( 'key-metrics-back-notice' ).
      • Open the Key Metrics selection panel by dispatching setValue( KEY_METRICS_SELECTION_PANEL_OPENED_KEY, true ) to CORE_UI.
    • When dismiss button is clicked:
      • Dismiss the notice by calling dismissItem( 'key-metrics-back-notice' ).
  • Register and integrate the notice widget into the dashboard widget area:

    • In assets/js/googlesitekit/widgets/register-defaults.js, register new widget: keyMetricsBackNotice.
    • Register it in AREA_MAIN_DASHBOARD_KEY_METRICS_PRIMARY so it renders inside the Key Metrics area (under the title/subtitle block and above metric tiles, per design).
    • Use full-width widget sizing and priority so the notice appears before the existing Key Metrics tiles/CTAs in that area.
    • Only register this widget when setupFlowRefresh is enabled (skip registration entirely when the flag is disabled).
    • Put notice visibility conditions in the widget isActive callback:
      • raw stored key metrics hidden setting is true (getRawKeyMetricsWidgetHidden).
      • notice slug key-metrics-back-notice is not dismissed.
  • Update the "Change metrics" CTA text to "Select metrics":

    • Locate the "Change metrics" link component and update the link text from 'Change metrics' to 'Select metrics'.
    • Apply consistent text casing and punctuation.
    • This change should be gated behind setupFlowRefresh flag.

Test Coverage

  • Add tests for isKeyMetricsWidgetHidden selector: verify it returns false when setupFlowRefresh is enabled regardless of stored value; verify it returns the stored value when flag is disabled.
  • Add tests for getRawKeyMetricsWidgetHidden selector: verify it always returns the actual stored value regardless of flag state.
  • Add tests for KeyMetricsBackNotice: verify UI copy and actions (dismiss + CTA) and CTA opens key metrics selection panel.
  • Add tests for widget registration/placement: verify keyMetricsBackNotice is only registered when setupFlowRefresh is enabled, is registered in AREA_MAIN_DASHBOARD_KEY_METRICS_PRIMARY, and appears before the metric tiles in the rendered area.
  • Add tests for widget isActive: verify it returns true only when raw stored hidden setting is true and slug key-metrics-back-notice is not dismissed.
  • Add tests for notice dismissal state: verify dismissed item (key-metrics-back-notice) is persisted and notice doesn't reappear after dismissal.
  • Add tests for notice CTA action: verify Key Metrics selection panel opens and notice dismiss state is persisted.
  • Add tests for link text update: verify text is updated to "Select metrics" and still opens the selection panel when setupFlowRefresh is enabled.
  • Update any relevant stories.

QA Brief

  • With the setupFlowRefresh flag disabled, set up Site Kit with Analytics and hide the Key Metrics widget so it is hidden for your user (via the Settings -> Admin Settings -> Key Metrics Settings toggle).
  • Enable the setupFlowRefresh feature flag.
  • On the dashboard, confirm the Key Metrics widget area is shown again, with the "Key metrics are back on your dashboard" notice above the metric tiles, matching the Figma design (title, description, "Got it", and "Select metrics").
  • Click "Select metrics": confirm the Key Metrics selection panel opens and the notice is dismissed. Reload and confirm the notice does not reappear.
  • Repeat the setup and this time click "Got it": confirm the notice is dismissed and does not reappear on reload.
  • Confirm the widget area CTA link reads "Select metrics" (instead of "Change metrics") and opens the selection panel.
  • With the flag disabled, confirm the behavior is unchanged: a user who hid Key Metrics still sees it hidden, the notice is not shown, and the CTA link still reads "Change metrics".

Changelog entry

  • Re-show hidden Key Metrics widgets, with an explanatory notice.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Fields

    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