PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
21.22k stars 1.26k forks source link

Improve UX for formulas in trends #3375

Open macobo opened 3 years ago

macobo commented 3 years ago

Is your feature request related to a problem?

We recently added a formulas feature to trends. There's no real explanation of what A/B/C are in the UI, causing users to enter invalid formulas which end up as errors.

Describe the solution you'd like

Here's how mixp@nel solves this:

2021-02-19_14-31

Note also that formulas section is collapsable and by default collapsed.

Describe alternatives you've considered

Additional context

Sentry errors related to this: https://sentry.io/organizations/posthog/issues/2219619895/?project=1899813&query=is%3Aunassigned+is%3Aunresolved

Thank you for your feature request – we love each and every one!

samwinslow commented 3 years ago

Worth mentioning that #3620 partially addresses this, and there are no more Sentry errors after Feb 24. It seems to be rolled out to 30% of real users (and some misc others) via this feature flag.

Perhaps @paolodamico can give context as to whether we can roll this out further or if further iteration is needed?

macobo commented 3 years ago

cc @clarkus @paolodamico worth adding to core experience backlog? Regularly seeing errors in sentry relating to this, indicating users are struggling.

clarkus commented 3 years ago

Sure I can spend some design time on this issue this week. It's related to other ongoing validation work, so it's a good time to think about it.

clarkus commented 3 years ago

From the related https://github.com/PostHog/posthog/issues/4475

Formulas, some types of property aggregation, and other visualization options (e.g. cumulative) are advanced features that the majority of queries won't require. Should we hide these behind an advanced mode to make the experience easier for those times when you don't need it?

clarkus commented 3 years ago

Here's a 2-part solution that uses a workflow similar to the one documented in https://github.com/PostHog/posthog/issues/4680. When a user clicks add formula, show a modal that allows the user to enter a formula name and a formula. This concept has a variable reference built into the control. When you click a variable, it inserts it into the formula textarea at the current cursor position. If there isn't a cursor position, append the variable to the end of the current value (if one exists).

This update allows for multiple formulas to be specified. As each formula is specified, they are listed left-to-right in a sentence-like flow. Clicking a formula will trigger the modal for editing. Clicking the x icon will remove the formula.

Screen Shot 2021-08-17 at 2 55 55 PM Screen Shot 2021-08-17 at 3 45 59 PM

I know we're limited on our ability for format text in a form element, so I can adjust this design to adapt to whatever technical constraints we encounter. Thoughts on this idea? Is there anything else we could add in to make creating formulas easier?

paolodamico commented 3 years ago

Thanks @clarkus! Here's some feedback,

  1. I think this process could be simplified. The modal can it feel clunkier and then editing can be more cumbersome. The way I imagine this is just the inline text field where simply when you type we show the input as your design above (which adds clarity to the way everything is displayed) and we give immediate error feedback there too. We could also add the "graph series variable" helper and even include supported math operators too. We could give an "edit" option (as an alternative) to users where this modal pops up and you have more space to create your formula and rename it. Thoughts?
  2. @Twixes as you provided all the context on #4680, perhaps you'd like to weigh in here? Or @mariusandra ?
clarkus commented 3 years ago

Sure I'm up for trying to simplify. This was mostly a concept to drive feedback, so it's very much in the idea-phase. I think the case for the modal could be debated a bit... it really depends on how complex formulas will be and what the typical character lengths might be. There was also another idea of introducing some utility control to insert a formula based on some list of presets... having a modal here would give us a bit more space to allow for that. The modal also separates editing from summarization - if we allow for multiple formulas and we tile them left-to-right, editing might be more cumbersome if it happens inline.

Much like #4680, the core change here is clearer validation. We could start with that, watch usage and queue up another iteration once we think we have a better understanding of the problems to be solved.

clarkus commented 3 years ago

Here's a rework to focus on inline editing. This is availilbe in figma at https://www.figma.com/file/9yWtngNb1AIuf6KmXaEPJA/App-doodles?node-id=1070%3A135500.

formula-inline-states

paolodamico commented 3 years ago

Really like this! I think this can make it super clear and also quite straightforward to change. FYI checked some numbers and almost all the time formulas are quite simple (see below, source).

Some additional feedback:

clarkus commented 3 years ago

Here's that feedback illustrated. I feel kind of torn about the operators and the variables. I think having a reference of the options available is good, but at some point this layout won't scale to account for everything. I feel like we should simplify it, and see how that performs. Thoughts?

Formulas

samwinslow commented 3 years ago

FWIW, I really like the way Google Sheets color-codes these references in formulas. Since we already have colors assigned to series, think it makes sense to use them here?

Screen Shot 2021-08-18 at 7 44 33 PM
paolodamico commented 3 years ago

Thanks for exploring this @clarkus. I almost feel it's more useful to have the reference operations instead of the letters, these are also static, while we can have n letters. Absolutely love everything else! The colors idea from @samwinslow sounds super interesting too!

clarkus commented 3 years ago

Color coding could work, but we would need to adjust color values to have sufficient contrast for smaller text. Those colors work for graphs for the most part, but some of them just won't have enough contrast for text over a white background. I'm not against the idea, I just need to put in some time to create those colors and make sure they work everywhere we would use them.

This update drops the graph series key and instead focuses on operators. Let me know what you think.

Formulas

paolodamico commented 3 years ago

Great point on the colors contrast! I actually don't think it's worth spending time on that right now, we have a ton of constraints on the series colors and adding another one might make it even more complex, we've been trying to rethink colors for as long as I can remember. Let's keep it this way.

I think this is ready to implement, I'll do so as soon as I can, if someone else from the Core Experience Team wants to pick it up go ahead too.

pjeziorowski commented 3 years ago

We recently added a formulas feature to trends.

Could you tell me in which release it was added?

paolodamico commented 3 years ago

Hi @pjeziorowski! I'm just realizing we haven't officially included this in a release, even if we don't implement the improvements outlined here, we're including in the next release (1.28).

posthog-bot commented 6 months ago

This issue hasn't seen activity in two years! If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in two weeks.