Connect Analytics CTA does not appear when Analytics is disconnected, and Settings section disappears
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 383
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 77
Description
## Bug Description
## Steps to reproduce
1. Setup the Audience Segmentation feature.
2. Disconnect Analytics and navigate to the dashboard.
3. The Audiences Widget Area will not be shown at all, while it should display the Connect Analytics CTA.
4. Navigate to the **Settings > Admin Settings** screen.
5. The "Visitor groups" section will not be visible, while it's expected to be showing the "Display visitor groups in dashboard" toggle.
## Additional Context
- PHP Version: any
- OS: any
- Browser: any
- Plugin Version: 1.137.0 pre release, in development
- Device: any
---------------
_Do not alter or remove anything below. The following sections will be managed by moderators only._
## Acceptance criteria
- When the Audience Segmentation feature has been set up, and Analytics is subsequently disconnected:
- The Connect Analytics CTA should be displayed in the Audiences Widget Area.
- The "Visitor groups" section should be displayed on the Settings screen with the "Display visitor groups in dashboard" toggle present.
- When Analytics is reconnected:
- If it's reconnected with the same property, the previous state of the Audience Segmentation feature should be restored.
- If it's reconnected with a different property, the feature should be reset as per https://github.com/google/site-kit-wp/issues/8180.
## Implementation Brief
* [ ] Add a new Analytics setting, `previousPropertyID`, to track the previously connected Analytics property ID.
* [ ] Ensure the Analytics settings `availableAudiences`, `audienceSegmentationSetupCompletedBy`, `availableAudiencesLastSyncedAt`, and `previousPropertyID` are retained when Analytics is deactivated. Additionally, don't call `Reset_Audiences::reset_audience_data()` when Analytics is deactivated.
* [ ] Ensure the above settings are only reset when a different property is connected, comparing `propertyID` to `previousPropertyID` in the `pre_update_option_googlesitekit_analytics-4_settings` hook.
* Finish off PR: https://github.com/google/site-kit-wp/pull/9450
### Test Coverage
* Update/fix test coverage to accommodate the above changes.
## QA Brief
*
## Changelog entry
*
Contributor guide
Research direction
Start with PR #9450, then inspect the pre_update_option_googlesitekit_analytics-4_settings hook and Reset_Audiences::reset_audience_data(). Verify the Audiences Widget Area and Settings > Admin Settings behavior after disconnecting and reconnecting Analytics, including same- and different-property cases. Update or add the test coverage described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100