-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Key Metric display logic for selection panel, widget area and view only dashboard #9548
Comments
ACs here are good, and thanks for the great explanation/context for the issue 👍🏻 Moving to IB 🙂 |
IB ✅ |
QA Update ✅
Top earning pages KM tile related scenarios Top earning pages KM tile when AdSense is disconnected Top earning pages KM tile when both Analytics and AdSense are disconnected Top earning pages KM tile when Analytics is disconnected If AdSense or Analytics module gets disconnect later and 'Top earning pages' KM tile is already selected Recording.1581.mp4Key metric complete flow when 'conversionInfra' feature flag is not enabled Recording.1580.mp4Recording.1581.mp4Recording.1583.mp4Key metric complete flow when 'conversionInfra' feature flag is enabled Recording.1584.mp4Recording.1585.mp4Recording.1586.mp4View only dashboard when user selects 'Most popular products by pageviews' KM tile Recording.1582.mp4 |
Bug Description
In #7741, we introduced logic for view only users that filters out key metrics which require custom dimensions, but now those custom dimensions are unavailable (since view only users can't do much about this).
We are now directly calling
displayInList()
in thegetKeyMetricSettings
selector for view-only users which has side-effects when thedisplayInList
implementation contains calls to check ifisKeyMetricActive()
, like in the case of Most Popular Products and for widgets that useshouldDisplayWidgetWithConversionEvent()
. It causes a infinite recursion as seen with the calls below:However, this logic was introduced in a central
getKeyMetricsSettings()
selector even though the main purpose here was to filter out onlyuserPickedMetrics
, i.e. metrics the user had once saved but they no longer can benefit from since the custom dimensions required have been deleted or modified. So this should be thoughtfully refactored into thegetUserPickedMetrics
selector or somewhere more suitable.site-kit-wp/assets/js/googlesitekit/datastore/user/key-metrics.js
Lines 467 to 501 in 8a891c4
We do have a clear separation of concerns when it comes to logic:
But we have created a slight overlap in some places to hack things a certain way which makes things redundant and confusing. This can be re-visited and cleaned up.
Steps to reproduce
Pick your own metrics
.Most popular products by pageviews
widget is in the list.Screen recording
Screen.Recording.2024-10-23.at.20.32.57.mov
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Most popular products by pageviews
widget tile, widget tiles that require Custom Dimensions and the new ACR metric tiles.displayInList()
callback function is not used for purposes other than displaying a key metric widget tile in the Metrics Selection panel.Once completed, review #8703 which appears to be an earlier report of the same issue.
Implementation Brief
Fixing the bug
In
assets/js/components/KeyMetrics/key-metrics-widgets.js
:displayInWidgetArea
callback property for all the key metrics that have arequiredCustomDimension
. Set this property to call theshouldDisplayWidgetWithCustomDimensions()
function. In the future, this callback can be used by other tiles to add any additional requirements for widgets to be rendered in the widget area which would further override the "user picked" or "answer based" selection.In
assets/js/googlesitekit/datastore/user/key-metrics.js
, :getKeyMetricSettings()
selector: Remove the wholeisViewOnly
check and snippet to filter out metrics. This will now be handled within thegetUserPickedMetrics
below.getUserPickedMetrics()
selector: Filter thewidgetSlugs
result. Using theKEY_METRICS_WIDGETS
data, check if the widget has adisplayInWidgetArea
property and use the boolean function for filtering. Pass theisViewOnlyDashboard
value.Generic Refactoring
Rename the
displayInList
property todisplayInSelectionPanel
for more clarity as "list" is too generic.In
getAnswerBasedMetrics
selector: Use a new selector for fetching theshowConversionTailoredMetrics
:site-kit-wp/assets/js/googlesitekit/datastore/user/key-metrics.js
Lines 287 to 292 in e1ecae0
In
getKeyMetrics
selector: Remove unnecessary filtering of answer based metrics for ACR feature flag as this is already done within thegetAnswerBasedMetrics
selector.site-kit-wp/assets/js/googlesitekit/datastore/user/key-metrics.js
Lines 242 to 250 in e1ecae0
In
getKeyMetrics
selector: Move the filtering ofuserPickedMetrics
for the ACR feature flag to a callback function that can be added to the newdisplayInWidgetArea
property of all the new ACR metrics inkey-metrics-widgets
. Remove thekeyMetricsGA4WidgetsNonACR
constant if not used.site-kit-wp/assets/js/googlesitekit/datastore/user/key-metrics.js
Lines 227 to 231 in e1ecae0
Test Coverage
No new tests needed.
QA Brief
conversionReporting
feature flag.Changelog entry
The text was updated successfully, but these errors were encountered: