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: allow hogql property queries in replay filtering #26176

Merged

Conversation

pauldambra
Copy link
Member

@pauldambra pauldambra commented Nov 13, 2024

we don't allow people to add hogql property filters in replay but we could

this PR

  • allows hogql property queries

## for this PR

  • convert replay API to not use filters any more behind a flag

to do in follow-up since I want to test the new stuff in prod and everything is behind flags

  • add a QueryRunner for RecordingsQuery
  • add autocomplete for replay hogql

hogql filtering

2024-11-23 09 03 35

@@ -132,7 +132,7 @@ export const universalFiltersLogic = kea<universalFiltersLogicType>([
newValues.push(newFeatureFlagFilter)
} else {
const propertyType =
item.propertyFilterType ?? taxonomicFilterTypeToPropertyFilterType(taxonomicGroup.type)
item?.propertyFilterType ?? taxonomicFilterTypeToPropertyFilterType(taxonomicGroup.type)
Copy link
Member Author

Choose a reason for hiding this comment

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

hogql property filters don't have an item so this needs to be slightly safer

@@ -144,6 +147,7 @@ const RecordingsUniversalFilterGroup = (): JSX.Element => {
onRemove={() => removeGroupValue(index)}
onChange={(value) => replaceGroupValue(index, value)}
initiallyOpen={allowInitiallyOpen}
metadataSource={{ kind: NodeKind.RecordingsQuery }}
Copy link
Member Author

Choose a reason for hiding this comment

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

we need something here to correct the autocomplete

Copy link
Member Author

Choose a reason for hiding this comment

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

I need a query runner in python for the recordings query

@@ -120,6 +120,8 @@ export function convertUniversalFiltersToRecordingsQuery(universalFilters: Recor
actions.push(f)
} else if (isLogEntryPropertyFilter(f)) {
console_log_filters.push(f)
} else if (isHogQLPropertyFilter(f)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this "just works"™

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work for all property types e.g person & event properties? Wondering if the subqueries in the runner affect things here in any way

Copy link
Member Author

Choose a reason for hiding this comment

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

it works for hogql... am going to ignore everything else for now 🤣
(but noted)

Copy link
Contributor

Choose a reason for hiding this comment

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

I would be more worried about it not working for folks without PoE enabled (but maybe that's everyone now)

@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

Copy link
Contributor

github-actions bot commented Nov 23, 2024

Size Change: +110 B (+0.01%)

Total Size: 1.11 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.11 MB +110 B (+0.01%)

compressed-size-action

@pauldambra pauldambra marked this pull request as ready for review November 23, 2024 11:05
filter = SessionRecordingsFilter(request=request, team=self.team)
self._maybe_report_recording_list_filters_changed(request, team=self.team)
return list_recordings_response(filter, request, self.get_serializer_context())
use_query_type = (request.GET.get("as_query", "False")).lower() == "true"
Copy link
Member Author

Choose a reason for hiding this comment

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

let's the API client declare which processing version it accepts so we can test the new mechanism with a slow rollout

@pauldambra pauldambra requested a review from a team November 24, 2024 10:23
@pauldambra pauldambra removed the stale label Nov 24, 2024
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

@daibhin daibhin left a comment

Choose a reason for hiding this comment

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

The test files are a little difficult to review but I'll trust that you've just copied them over and not made any implementational changes.

Left a couple of comments but overall the code / approach looks good. Happy enough that it's behind a FF so I'm sure you'll test it for data accuracy :)

listAPIAsQuery: [
(s) => [s.featureFlags],
(featureFlags) => {
return !!featureFlags[FEATURE_FLAGS.REPLAY_LIST_RECORDINGS_AS_QUERY]
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing that always catches me about the query endpoint is the caching. You might need to disable it so that the list refreshes (or maybe the caching is desirable)

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, i'm slightly wary of moving to the query endpoint tbh 🙈
(just from a "i don't know how this works right now" viewpoint

@@ -120,6 +120,8 @@ export function convertUniversalFiltersToRecordingsQuery(universalFilters: Recor
actions.push(f)
} else if (isLogEntryPropertyFilter(f)) {
console_log_filters.push(f)
} else if (isHogQLPropertyFilter(f)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work for all property types e.g person & event properties? Wondering if the subqueries in the runner affect things here in any way

operand?: FilterLogicalOperator
session_ids?: string[]
person_uuid?: string
/**
* @default "start_time"
* */
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL

Comment on lines +237 to +238
query = RecordingsQuery.model_validate(data_dict)
query.session_ids = playlist_items
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we only doing this validation because it doesn't go through the /query endpoint? Maybe we should just move it to a runner instead. Totally happy if that's the next step in a followup PR

Copy link
Member Author

Choose a reason for hiding this comment

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

am going to create a runner so i get autocomplete for the hogql property box
but want to understand that way more before I move this API over 😨

@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 2)
  • webkit: 0 added, 0 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 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@pauldambra pauldambra merged commit 7da1bd1 into master Dec 4, 2024
96 checks passed
@pauldambra pauldambra deleted the feat/allow-hogql-property-queries-in-replay-filtering branch December 4, 2024 04:24
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