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
20.59k stars 1.23k forks source link

redo/undo when editing HogQL #17300

Open pauldambra opened 1 year ago

pauldambra commented 1 year ago

Particularly when writing complex HogQL it would be amazing to have the ability to skip between versions of the written query.

We could use the existing logic to store versions of the query as they're written so you can have a "live undo" of unsaved changes (but there's a good chance that monaco does this anyway since its a text editor)

We're also storing saved versions of a query to the activity log. So we could use them e.g. http://127.0.0.1:8000/api/projects/1/insights/18/activity?page=1&limit=20 to let users step through versions and decide if they want to resave a previous version as the current.

This would let you undo other users changes to your queries too

We'd need to (at least):

stuti90 commented 1 year ago

Is it possible to store history for "Run" queries in addition to saved queries? I actually care less for undo-ing while i'm typing. I usually run my query like 10 times before I finally find a version I want to save - so just having a history for the multiple runs would be good enough.

pauldambra commented 1 year ago

Is it possible to store history for "Run" queries in addition to saved queries?

(not without changes but definitely possible)

Would you need that history on more than one computer? Would you need it to survive between sessions?

stuti90 commented 1 year ago

Would you need that history on more than one computer?

This would be a nice-to-have feature. Since I mostly do all my analysis work only on a single work laptop, i'd rarely encounter the need for having it available on multiple computers.

Would you need it to survive between sessions?

Yes please! I can definitely see myself wanting to look up queries I ran in a few days ago

Ideally I'd actually break the "SQL editor" as an app(?) or tab of its own rather than being tied to an insight you're creating. For an insight, it makes sense that we only have versions of every save. But for a query editor, I'd like a history of each run. And you can always give a user the option of saving a query they ran as an insight.