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

Combine events and actions into select box #2394

Merged
merged 10 commits into from
Nov 24, 2020
Merged

Conversation

timgl
Copy link
Collaborator

@timgl timgl commented Nov 16, 2020

Changes

  • Create a new 'Select Box' component that's much more intuitive and faster to use
  • Apply that components for selecting actions/events
    image

Checklist

  • All querysets/queries filter by Organization, Team, and User (if this PR affects ANY querysets/queries).
  • Django backend tests (if this PR affects the backend).
  • Cypress end-to-end tests (if this PR affects the frontend).

@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 16, 2020 12:43 Inactive
@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 16, 2020 14:52 Inactive
@macobo
Copy link
Contributor

macobo commented Nov 16, 2020

This solves #2274 right? :)

Copy link
Contributor

@paolodamico paolodamico left a comment

Choose a reason for hiding this comment

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

Comments on UX,

  • It'd be amazing if you could interact with the box with the keyboard (as we do with the command palette) to significantly speed up usage.
  • Maybe consider changing to fuzzy searching as we do in the command palette? Probably it should just be a bit stricter, just to help with typos.
  • I would maybe bold the event matches when you have a search term, in case you have a section collapsed that matches the event you're searching for.
  • The "step" language seems confusing, "match group" or "matching conditions" could be better. We should definitely keep consistency on this too in the rest of the app.
  • We can improve the hierarchy of elements in the action/event detail view to match the standardized components (e.g. the event name, would probably be the Level 3 subtitle element, as right now it's a bit confusing to have a mix of different sizes.
    • Related to the above, I think it might be worth adding the events & actions icon to the details page, particularly now that we're using them to show the distinction more clearly.
  • For events maybe add the "PostHog" indicator to autocapture/default events?

On the code side a minor thing, SelectBox seems a bit ambiguous / confusing. Did not deep dive into the code, but there doesn't seem to be any glaring issues.

@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 18, 2020 12:14 Inactive
@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 18, 2020 18:46 Inactive
@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 18, 2020 19:08 Inactive
@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 18, 2020 19:39 Inactive
@timgl
Copy link
Collaborator Author

timgl commented Nov 18, 2020

Have solved most of the issues above. Haven't done the 'posthog logo' for posthog events yet as i don't want to balloon this PR. Also not sure what the subtitle 3 element is or how I get it, it's an h3, maybe we should style all h3's to be the same?

cc @macobo would you mind giving this another look as Paolo is out?

Copy link
Contributor

@macobo macobo left a comment

Choose a reason for hiding this comment

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

Couple of css issues

  1. When height of the lists is smaller than box height, scrollbars still appears:

Screenshot from 2020-11-19 11-46-23

  1. The border around focused search box doesn't really fit with the rest of the component:

Screenshot from 2020-11-19 11-49-50

frontend/src/lib/components/SelectBox.tsx Outdated Show resolved Hide resolved
export function SelectUnit({
name,
dataSource,
dropdownLogic,
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: Why is this a prop? Could find no other instances where we pass logics around this way besides this PR but I didn't look super hard.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm take a look at PropertyFilter.js for example. It's a way of making sure the props for the logic are passed through correctly everywhere.


const getSuggestions = (events: EventUsageType[]): EventUsageType[] => {
return events
.filter((event) => event.usage_count > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: Should we even return these to the frontend?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean the usage_count?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, events with usage_count == 0

useEffect(() => {
if (selectedItemKey) {
const allSources = items.map((item) => item.dataSource).flat()
setSelectedItem(allSources.filter((item) => item.key === selectedItemKey)[0] || false)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is the || false needed here?

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 actually not sure it is. I ran into this while developing but can't reproduce it anymore. I do still think it's safer, as the alternative is having a complete white-out

frontend/src/lib/components/SelectBox.tsx Outdated Show resolved Hide resolved
frontend/src/lib/components/SelectBox.tsx Outdated Show resolved Hide resolved
frontend/src/lib/components/SelectBox.tsx Show resolved Hide resolved
frontend/src/scenes/insights/ActionSelectInfo.tsx Outdated Show resolved Hide resolved
frontend/src/lib/components/SelectBox.tsx Show resolved Hide resolved
@macobo
Copy link
Contributor

macobo commented Nov 19, 2020

Note/thought for the future: We could have used feature flags here to develop this - put the new version behind a feature flag, roll it out and delete the old code afterwards.

I think this has several upsides:

  1. Derisks things significantly as the UI doesn't need to be perfect + any major bugs can be rolled back without a deploy.
  2. Reviewing PRs after iteration 2-3 gets kind of messy. We could merge in the current state and e.g. deal with layout issues in a follow-up.

It does introduce the need to later come back and clean up the effectively dead code and make sure to turn the flag on - but this is a pain our users feel as well.

All that said - no action required for this PR, just food for thought for future.

@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 20, 2020 09:56 Inactive
@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 23, 2020 11:59 Inactive
@macobo
Copy link
Contributor

macobo commented Nov 23, 2020

Codewise this looks good. However missed a comment: #2394 (review) + the build failure might be relevant here.

@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 23, 2020 20:23 Inactive
@timgl timgl temporarily deployed to posthog-combine-events--fqdec8 November 24, 2020 16:30 Inactive
@timgl
Copy link
Collaborator Author

timgl commented Nov 24, 2020

I had already fixed the toolbar issue (unless you're still seeing it?) and fixed build.

@timgl timgl merged commit f47e8b9 into master Nov 24, 2020
@timgl timgl deleted the combine-events-actions branch November 24, 2020 17:28
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.

None yet

3 participants