'Add Metric' placeholder not appears on 'View only dashboard' until user make changes to selection.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 383
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 77
Description
## Bug Description
If only the Analytics module is shared, and not the Search Console, three tiles will initially appear on the view-only dashboard when a user accesses it for the first time. These tiles are stretched to the full width of the page, with no additional "Add Metric" placeholder tile. The "Add Metric" placeholder tile only appears after the user modifies the metric selection.
## Steps to reproduce
1. Activate 2 or 3 key metric tiles and ensure all is working as expected.
2. Via dashboard sharing, grant access to GA for other users BUT NOT search console.
3. Login to the site from another user account (ie. An editor role), and access the view only SK dashboard
4. Notice there is no "Add a metric" tile.
5. Make changes to selection (Remove selection of 1 metric).
6. Now 'Add a metric' placeholder tile will appear.
## Screenshots

https://github.com/user-attachments/assets/ad1eb35f-7437-4dcf-87e0-c6481df09ac3
## 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
* The "Add a metric" tile(s) should be visible at all times when there are less than 4 metrics available on the "View Only" dashboard for a user. This should be the case even when only analytics is shared but not search console.
* If the `conversionReporting` feature flag is on, then the "Add a metric" tile(s) should be visible at all times when there are less than 8 metrics (ie. so 5, 6 or 7 metrics selected) available on the "View Only" dashboard for a user.
## Implementation Brief
CHECK THE STATUS and and updates in #9645 which could change where the below code is moved.
Explanation for the current issue:
- The `isActive()` check when registering the `AddMetricCTATile`s uses the `getKeyMetrics()` selector. When there are no `userPickedMetrics`, this selector returns the `answerBasedMetrics` or the [default set](https://github.com/google/site-kit-wp/blob/848e73481535cb9a2a787dab006df306b607e6d5/assets/js/googlesitekit/datastore/user/key-metrics.js#L280-L285) of `tailored metrics`.
* [ ] In `assets/js/googlesitekit/datastore/user/key-metrics.js`, move the [`displayInWidgetArea` callback check](https://github.com/google/site-kit-wp/blob/848e73481535cb9a2a787dab006df306b607e6d5/assets/js/googlesitekit/datastore/user/key-metrics.js#L495-L527) from the `getUserPickedMetrics` to the end of the `getKeyMetrics` selector before returning the final set of metrics.
* [ ] So the `getKeyMetrics` selector will first compute the set of key metrics (either `userPicked` or `answerBased` or default set) and then further filter them by calling the `displayInWidgetArea`
* [ ] Also move the condition that returns an empty array if the final number of key metrics is 1.
### Test Coverage
*
## QA Brief
*
## Changelog entry
*
Contributor guide
Assessment
This issue has not been assessed yet.