Open techanvil opened 3 weeks ago
Hi @benbowler, thanks for drafting this IB. A couple of points:
... selectors to monitor
syncAvailableCustomDimensions
selector/resolver like so:
fetchSyncAvailableCustomDimensions()
action, this doesn't seem right. We'll probably want to use isFetchingSyncAvailableCustomDimensions()
, e.g.:Hi @benbowler, thanks for updating the IB. A few more points:
For the view-only context:
isSyncingAvailableCustomDimensions
in the AudienceTile
component because the AudienceTileLoading
component will be rendered instead due to including this value in the loading condition.individualTileErrors
value, in order to avoid showing the whole tile in the error state, but still need to flag that there was an invalid custom dimension error to the AudienceTile
so it can avoid rendering the "Top content" metric area.More fundamentally, though - I've noticed the googlesitekit_post_type
custom dimension is actually missing from the "Top content" report options:
It needs to be added as a dimension filter, like we do here, but with value: 'post'
:
This will be needed for this issue to be complete and testable, so we should include the fix here too. There's likely to be a number of tests that need updating as a result which we should factor into the estimate.
I chose to use the getErrorForSelector
selector within the AudienceTile
component instead of adding another new prop to this component, we could instead create a new prop such as hasTopContentCustomDimensionError
instead if prefered.
I've increased the estimate a couple of bands because the scope has expanded slightly as we've discussed required fixes/additions to be able to work on this ticket.
Feature Description
The Audience Tile's "Top content" metric area has a CTA for creating the
googlesitekit_post_type
custom dimension if it doesn't exist.However, it doesn't have logic in place to determine if the custom dimension doesn't exist when requesting the report for the metric. At present it's reliant on the list of available custom dimensions being synced somewhere, which only happens during Audience Segmentation setup, or in the Key Metrics feature.
We should ensure that, if the report for the "Top content" metric returns an error because the custom dimension doesn't exist, the list of custom dimensions is resynced so the tile will immediately know that the dimension is missing and show the CTA to create it.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
googlesitekit_post_type
present in the "Top content" metric area (already implemented via https://github.com/google/site-kit-wp/issues/8153).Implementation Brief
Add Missing Custom Dimension to Top Content Report
googlesitekit_post_type
dimension filter to the top content report options:https://github.com/google/site-kit-wp/blob/119747b9e3be9bb8310faec37b7ea41c6b4ea89f/assets/js/modules/analytics-4/hooks/useAudienceTilesReports.js#L322-L329 https://github.com/google/site-kit-wp/blob/119747b9e3be9bb8310faec37b7ea41c6b4ea89f/assets/js/modules/analytics-4/hooks/useAudienceTilesReports.js#L346-L353
Authenticated User Context
assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceTilesWidget/AudienceTiles.js
(note the newuseAudienceTilesReports
custom hook merged in #8144):useEffect
withtopContentReportErrors
as a dependency.topContentReportErrors
contains any invalid custom dimension errors using the.find
prototype, and use theisInvalidCustomDimensionError
util to identify this error type.fetchSyncAvailableCustomDimensions
.isSyncingAvailableCustomDimensions
containing the value of theisFetchingSyncAvailableCustomDimensions
selector: https://github.com/google/site-kit-wp/blob/56feb1f6ca227cc9fc6da3511a96fb2f4bf9d3b0/assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceTilesWidget/AudienceTile/AudienceTilePagesMetric.js#L94-L96isSyncingAvailableCustomDimensions
: https://github.com/google/site-kit-wp/blob/41f0bbaec9736ba334cccc7b469ce1a5e2cdfc71/assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceTilesWidget/AudienceTiles.js#L419-L427topCitiesReportErrors
here, using theisInvalidCustomDimensionError
util, so that the Top Cities Audience Tile will be rendered if there is only an invalid custom dimension error: https://github.com/google/site-kit-wp/blob/b2d47c854a1c23eaba82690c88812972ba730bed/assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceTilesWidget/AudienceTiles.js#L320View-Only Context
assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceTilesWidget/AudienceTile/index.js
, use thegetErrorForSelector
selector to get any errors for the top content report for the audienceResourceName of the current tile.Test Coverage
QA Brief
Changelog entry