Skip to content

Create <EmailReportingSettingsAnalyticsDisconnectedNotice> settings analytics disconnected inline notice component #11435

@benbowler

Description

@benbowler

Feature Description

This component will be rendered within the Site Kit admin settings area when the Analytics module is not connected to encourage admins to connect this module in order to add additional datapoints to report emails. This is a warning notice rather than a requirement for the feature activation because Search Console data can still be included if the Analytics module is connected.

Figma designs.


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

Acceptance criteria

  • A new notice is created within the admin settings area when the Analytics module is disconnected - this is distinct to when Analytics was never set up in the first place - updates to module data tracking may be required to detect this state.
    • The notice can be dismissed
    • The Connect Analytics CTA takes the user to the Analytics setup form
  • New flag is introduced in the DB to distinguish if Analytics module has been already activated

Implementation Brief

  • Introduce a lightweight tracker setting Core\Email_Reporting\Analytics_Activation_State that sets the googlesitekit_analytics_ever_connected option
    • You can omit get_default method, as it will return false by default, inheriting it from base Setting class
  • Update includes/Core/Email_Reporting/REST_Email_Reporting_Controller.php
    • Instantiate Analytics_Activation_State setting in constructor and set it to the class property
    • In get_rest_routes add new route GET:analytics-activation-state which returns the value of the Analytics_Activation_State setting
  • In Google\Site_Kit\Core\Email_Reporting\Email_Reporting::register()
    • Invoke on_change method on Analytics_Activation_State setting instance and when propertyID, accountID, webDataStreamID and measurementID keys of $new_value array are not empty - update the setting googlesitekit_analytics_ever_connected to true if not already set.
  • Update assets/js/googlesitekit/datastore/site/email-reporting.js
    • Add a fetch store to retrieve the value from GET:analytics-activation-state
    • Add selector/resolver hasEverActivatedAnalytics to resolve/read the value from the fetch store
  • Add assets/js/components/email-reporting/AnalyticsDisconnectedSettingsNotice.js
    • Render Notice when:
      • Analytics module is not connected (use isModuleConnected selector from CORE_MODULES datastore)
      • hasEverActivatedAnalytics selector returns true
      • Notice was not dismissed (eq select( CORE_USER ).isItemDismissed( 'analytics-email-reporting-notice' ) === false)
    • Match the copy and design with the one in Figma and CTA's behaviour describe in the AC
      • Use useActivateModuleCallback for Connect CTA to trigger the module activation and navigation to the setup screen
  • Include the new notice to the assets/js/components/settings/SettingsEmailReporting.js after Manage email reports subscription link

Test Coverage

  • Add test coverage for the new settings notice and hasEverActivatedAnalytics resolver/selector within existing datastore tests

QA Brief

  • On a site where analytics is not connected, turn the proactiveUserEngagement feature flag on, then turn on the Email Reporting feature in the Admin Settings.
  • Verify that there is no notice.
  • Now connect Analytics and verify that there is still no notice in the Admin Settings within the Email Reporting card.
  • Now disconnect Analytics and verify that the notice appears. Verify that it is dismissed as per the AC.
  • To make it appear again, remove the dismissed-items row in user_meta in the DB and refresh the Admin Settings panel. Verify that the Connect analytics CTA works as per the AC.

Changelog entry

  • Detect if Analytics has previously been connected when displaying certain notices in the Email Reporting notices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0High priorityTeam SIssues for Squad 1Type: 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