Skip to content

Analytics is disconnected CTA appears for view-only user #12454

@kelvinballoo

Description

@kelvinballoo

Bug Description

Here's the scenario

  • I set up analytics and allow key metrics
  • I disconnect analytics
  • The 'Analytics is disconnected' CTA appears for admin. This is fine.
  • However, it also appears for editors with view-only access, which is not expected. They don't have the ability to connect analytics and thus, the CTA should not appear.
    Screenshot attached below.

Screenshots

Details Image

Additional Context

  • PHP Version:
  • OS: [e.g. iOS]
  • Browser: [e.g. chrome, safari]
  • Plugin Version: [e.g. 22]
  • Device: [e.g. iPhone6]

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

Acceptance criteria

  • When Analytics has been connected and then disconnected, view-only users should see the "Analytics is disconnected" banner and tile without the "Connect Analytics" CTA or "Maybe later" link, replaced with the message: "Metrics cannot be displayed without Analytics. To fix the issue, contact your administrator."
  • Admin users continue to see the existing "Connect Analytics" CTA and "Maybe later" link unchanged.

Implementation Brief

  • In assets/js/modules/analytics-4/components/widgets/ConnectGA4CTAWidget.js, when useViewOnly() returns true:
    • Replace the description with a message that directs the user to contact their administrator (e.g. "Metrics cannot be displayed without Analytics. To fix the issue, contact your administrator.").
    • Set ctaButton to undefined (hide the "Connect Analytics" button).
    • Set footer to undefined (hide the "Maybe later" link).
    • Follow the existing pattern in AnalyticsDisconnectedNotice.js (assets/js/components/email-reporting/notices/AnalyticsDisconnectedNotice.js) which already handles view-only correctly.
  • In assets/js/components/KeyMetrics/ConnectModuleCTATile.js, when useViewOnly() returns true:
    • Do not render the "Connect [module]" <Link> element (the handleConnectModule callback from useActivateModuleCallback already returns null for non-admin users, but the link itself still renders with a non-functional click handler — it should be hidden entirely).
  • Storybook: Add a view-only story variant to ConnectGA4CTAWidget.stories.js.

Test Coverage

  • Add a test case in ConnectGA4CTAWidget.test.js for the view-only context.

QA Brief

  • Set up Site Kit with Google Analytics.
  • Set up Key Metrics and ensure a handful of GA KM widgets are added to the dashboard.
  • Now disconnect Analytics.
  • Verify that the "Analytics is disconnected" notification appears with the CTA as expected.
  • Log in as a view-only user.
  • Verify that the "Analytics is disconnected" notification appears, but without the CTA, according to the ACs.
  • Verify that any tile showing the Analytics disconnected notice does not show the CTA.

Changelog entry

  • Fixed the "Analytics is disconnected" CTA banner and tile to hide actionable connect buttons for view-only users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0High priorityTeam MIssues for Squad 2Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions