-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Redefine when revenue information is displayed on All Websites Dashboard #22886
Conversation
This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers |
$indexByIdGoal = 1 === count($idSite); | ||
|
||
$cleanedGoals = array(); | ||
foreach ($goals as &$goal) { | ||
$cleanedGoals[$goal['idgoal']] = $this->formatGoal($goal); | ||
if ($indexByIdGoal) { | ||
$cleanedGoals[$goal['idgoal']] = $this->formatGoal($goal); | ||
} else { | ||
$cleanedGoals[] = $this->formatGoal($goal); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't quite understand why you would want this different behavior if there is a single goal or multiple? What's the problem with always setting the array index as the ID goal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@caddoo backward compatibility. It's a public API change, we would need to wait until Matomo 6 ideally, or have a prominent message in the changelog about his. So with this compromise we agreed that's palatable if we keep the behaviour for a all sites and update it for a single site where the list of goals won't change with the index, but it would change if we indexed it in the list for all sites.
All tests are passing 🥳 |
Description:
In the current All Websites Dashboard (AWD), the
revenue
information is always shown, unless theGoals
plugin is disabled.For the redesigned AWD, this condition will be changed to only display
revenue
information if:Goals
plugin is enabledThis check is done on a per-user basis, a user needs at least view access to any site that would quality for displaying revenue information.
The API
Goals.getGoals
was fixed to properly return goals for multiple sites. The goal list was indexed byidgoal
, but that value is not unique across sites, so if two sites hadidgoal = 1
, you would only get one result instead of two. The API was changed to NOT index the return list with any defined keys to work around this limitation. Requesting goals for a single site will still return them indexed byidgoal
.Fetching 40k goals across 10k sites took a varying time between 500ms and 1250ms in my development environment according to XHProf (around 50% of the total runtime), with most of the time spent in
Goals\API::formatGoal()
. The API will not be called if there is at least one ecommerce site available.Without XHProf active, the response times were always hovering between 175ms and 200ms locally (according to
curl
), and around 75ms to 100ms without any of the new checks.If necessary, we can add an (internal?)
Goals.hasAtLeastOneGoalWithRevenue($idSites)
that could take care of that check in a single database query and circumvent the goal formatting. We can also take this approach if the change toGoals.getGoals
qualifies as a breaking change and can not be done in a feature release, even though it is also a fix.Fixes #5045
Refs DEV-15665
Review