Skip to content
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

Merged
merged 22 commits into from
Sep 12, 2024
Merged

Conversation

apata
Copy link
Contributor

@apata apata commented Sep 3, 2024

Changes

  • On the dashboard, allow Metrics (aka column configurations) to
    • specify width they need
    • specify if they are sortable
  • Default sort order for breakdown endpoints is hardcoded on the dashboard (needed to show what column the report is sorted by)
  • Unifies Google Keywords modal

Tests

  • Automated tests have been added

Changelog

  • Entry has been added to changelog

Documentation

  • Docs update is not needed

Dark mode

  • The UI has been tested both in dark and light mode

@apata apata marked this pull request as draft September 3, 2024 09:04
@apata apata added the preview label Sep 3, 2024
Copy link

github-actions bot commented Sep 3, 2024

Preview environment👷🏼‍♀️🏗️
PR-4513

@apata apata force-pushed the dashboard-list-sort branch 5 times, most recently from a31cc5b to 142b585 Compare September 4, 2024 11:19
@apata apata force-pushed the dashboard-list-sort branch 7 times, most recently from 7b9dcfa to 7b3be9f Compare September 6, 2024 21:32
@apata apata marked this pull request as ready for review September 9, 2024 06:55
@RobertJoonas RobertJoonas mentioned this pull request Sep 9, 2024
4 tasks
Copy link
Contributor

@RobertJoonas RobertJoonas left a 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.

assets/js/dashboard/hooks/use-order-by.ts Outdated Show resolved Hide resolved
return new Metric({width: 'w-24', sortable: true, ...props, key: "visitors", renderValue, renderLabel})
}

export const createGroupConversionRate = (props) => {
Copy link
Contributor

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.

Copy link
Contributor Author

@apata apata Sep 11, 2024

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.

assets/js/dashboard/stats/reports/metrics.js Show resolved Hide resolved
assets/js/dashboard/stats/reports/metrics.js Outdated Show resolved Hide resolved
lib/plausible/stats/breakdown.ex Outdated Show resolved Hide resolved
assets/js/dashboard/stats/behaviours/conversions.js Outdated Show resolved Hide resolved
@apata apata force-pushed the dashboard-list-sort branch 4 times, most recently from bf3a453 to c33d4fa Compare September 11, 2024 16:36
Copy link
Contributor

@RobertJoonas RobertJoonas left a 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.

@apata apata merged commit 9fcb76d into master Sep 12, 2024
10 checks passed
@apata apata deleted the dashboard-list-sort branch September 12, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants