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

feat(insights): hide "other" breakdown #19359

Merged
merged 34 commits into from
Dec 19, 2023
Merged

Conversation

mariusandra
Copy link
Collaborator

@mariusandra mariusandra commented Dec 15, 2023

Problem

Not everyone is happy with the "Other" column.

Changes

Adds a way to remove the column when you edit the chart.

2023-12-18 14 41 51

I had to make NULL / None handling for breakdowns very explicit as well. Because of our column materialization, we must also treat "" as None.

How did you test this code?

Backend tests

@mariusandra mariusandra changed the title Breakdown hide other feat(insights): hide "other" breakdown Dec 15, 2023
@mariusandra mariusandra requested a review from Twixes December 15, 2023 15:09
@mariusandra mariusandra marked this pull request as ready for review December 15, 2023 15:09
@webjunkie
Copy link
Contributor

Reminds me of Kibana:

image

Maybe we'll also do a toggle?

Copy link
Contributor

github-actions bot commented Dec 15, 2023

Size Change: 0 B

Total Size: 2 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 2 MB

compressed-size-action

@@ -98,7 +98,6 @@
"""

TOP_ELEMENTS_ARRAY_OF_KEY_SQL = """
SELECT groupArray(value) FROM (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running through groupArray() removes the rows where this field is None. We however do want to know if None is part of the returned fields or not.

Comment on lines +236 to +241
)

if filter.using_histogram:
return response[0][0]
else:
return [row[0] for row in response]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two queries here: 1) integer histogram breakdown, 2) string top results breakdown.

The response of the second query changed in order to also return nulls. More on it below.

Comment on lines +87 to +88
BREAKDOWN_NULL_STRING_LABEL = "$$_posthog_breakdown_null_$$"
BREAKDOWN_NULL_NUMERIC_LABEL = 9007199254740990 # pow(2, 53) - 2, for JS compatibility
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a giant fan of magic strings, but for now I consider this to be good enough... Or at least "helps us today and doesn't block us from adding a proper fix in the future".

@mariusandra
Copy link
Collaborator Author

Finally ready for a review

@mariusandra mariusandra removed the request for review from Twixes December 18, 2023 16:49
@webjunkie
Copy link
Contributor

Tried to test this, but no matter what I do, I don't get the "for readability, not all breakdown values are displayed. Click below to load them." thing locally 🤔

What I still wanted to suggest is, if it wouldn't be better to put the new toggle under options at the top?

Copy link
Contributor

@webjunkie webjunkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I found it, but only with HogQL trends turned off. Is that as intended?

Otherwise, seems to work alright.

!breakdown.breakdown_hide_other_aggregation,
})
}
label='Group renaming values under "Other"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label='Group renaming values under "Other"'
label='Group remaining values under "Other"'

@mariusandra
Copy link
Collaborator Author

Thanks for the review!

Yes, for now this is only implemented for the non-HogQL trends. I have added "Breakdown controls" as one of the things to fix for the rewrite.

I also put an end to the frontend innovation, and moved the button into the sidebar with the other editor filters:

2023-12-19 09 33 18

There will likely be some changed snapshots because of this.

One of the next things we can add here is the option to toggle exactly how many breakdown values are displayed, and which ones, but that's for future PRs.

@thmsobrmlr
Copy link
Contributor

thmsobrmlr commented Dec 19, 2023

Fly-by suggestion: We already have some options relating to breakdowns in the ...-menu. Should we put the toggle there? I'd also like to add a breakdown limit there.

Screenshot 2023-12-19 at 09 43 16

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

15 snapshot changes in total. 0 added, 15 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@mariusandra
Copy link
Collaborator Author

Something like this?
2023-12-19 10 05 46

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

14 snapshot changes in total. 0 added, 14 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@thmsobrmlr
Copy link
Contributor

Something like this? 2023-12-19 10 05 46

Exactly this.

@mariusandra mariusandra merged commit 3037124 into master Dec 19, 2023
78 checks passed
@mariusandra mariusandra deleted the breakdown-hide-other branch December 19, 2023 09:42
Copy link

sentry-io bot commented Dec 19, 2023

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ CHQueryErrorQueryWasCancelled: Code: 394. /api/projects/{parent_lookup_team_id}/insights/... View Issue
  • ‼️ CHQueryErrorQueryWasCancelled: Code: 394. /api/projects/{parent_lookup_team_id}/insights/... View Issue
  • ‼️ CHQueryErrorQueryWasCancelled: Code: 394. /api/projects/{parent_lookup_team_id}/insights/... View Issue
  • ‼️ CHQueryErrorQueryWasCancelled: Code: 394. /api/projects/{parent_lookup_team_id}/insights/... View Issue
  • ‼️ CHQueryErrorNotAnAggregate: Column properties is not under aggregate function and not in GROUP BY. Have columns: ['pmat_ema... /api/projects/{parent_lookup_team_id}/insights/... View Issue

Did you find this useful? React with a 👍 or 👎

min={1}
value={breakdownLimit}
onChange={(newValue) => {
setBreakdownLimit(newValue ?? 25)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What doesn't work here for me is typing a value and then focusing somewhere else, thereby closing the menu. That doesn't seem to trigger onChange.

Copy link
Collaborator Author

@mariusandra mariusandra Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the UX here is poor. I'll improve it in the next PR as it seems I made the breakdown pills huge now with the new design I didn't have enabled locally
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants