-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow sorting breakdown lists by some metrics #4513
Conversation
39a3872
to
7865bbc
Compare
|
a31cc5b
to
142b585
Compare
7b9dcfa
to
7b3be9f
Compare
7b3be9f
to
b929500
Compare
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.
Looks really good overall, and everything works nicely on staging. Good job! 🙌
We could make some things more consistent and explicit though. Comments inline.
return new Metric({width: 'w-24', sortable: true, ...props, key: "visitors", renderValue, renderLabel}) | ||
} | ||
|
||
export const createGroupConversionRate = (props) => { |
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.
It feels like we're somewhere in the middle of conversion_rate
and group_conversion_rate
here.
The breakdown reports (e.g. /sources
, /browsers
, etc...) are returning the metric under the conversion_rate
key in the API response. And yet the frontend sends order_by
as ["group_conversion_rate", "desc"]
.
We should fix this discrepancy. The new API considers them two different metrics, so we should make the breakdown actions (such as Api.StatsController.sources
) explicitly ask for the conversion rate that makes sense in that report context.
So sources, browsers, pages, etc, would directly ask for group_conversion_rate
from the lower level Breakdown module (rather than let it transform conversion_rate
-> group_conversion_rate
), and also return the metric as group_conversion_rate
in the API response.
Custom Property Breakdown and Goal Conversions would still stick with conversion_rate
.
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.
True! The reason we're somewhere in the middle is because I didn't want to refactor the legacy internal endpoints, CSV exports, and v1 Stats API responses. I expect that they are currently consistent with each other.
What we could do is conditionally remap order_by: [conversion_rate, direction]
to order_by: [group_conversion_rate, direction]
in the legacy backend. I opted to make the dashboard aware of the difference between the two because I anticipate the dashboard on v2 API to keep this awareness.
bf3a453
to
c33d4fa
Compare
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.
Good point about the consistency between Stats API, CSV export and the dashboard. Makes sense to keep the frontend only aware of conversion_rate
, and do the mapping on the backend.
test/plausible_web/controllers/api/stats_controller/countries_test.exs
Outdated
Show resolved
Hide resolved
eb22ee3
to
f13c28b
Compare
Changes
Tests
Changelog
Documentation
Dark mode