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

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { LemonButton, LemonButtonProps, LemonDropdown, Popover } from '@posthog/
import { BindLogic, useActions, useValues } from 'kea'
import { useState } from 'react'

import { AnyDataNode } from '~/queries/schema'
import { UniversalFiltersGroup, UniversalFilterValue } from '~/types'

import { TaxonomicPropertyFilter } from '../PropertyFilters/components/TaxonomicPropertyFilter'
Expand Down Expand Up @@ -75,12 +76,14 @@ const Value = ({
onChange,
onRemove,
initiallyOpen = false,
metadataSource,
}: {
index: number
filter: UniversalFilterValue
onChange: (property: UniversalFilterValue) => void
onRemove: () => void
initiallyOpen?: boolean
metadataSource?: AnyDataNode
}): JSX.Element => {
const { rootKey, taxonomicPropertyFilterGroupTypes } = useValues(universalFiltersLogic)

Expand All @@ -103,6 +106,7 @@ const Value = ({
onChange={(properties) => onChange({ ...filter, properties })}
disablePopover
taxonomicGroupTypes={[TaxonomicFilterGroupType.EventProperties]}
metadataSource={metadataSource}
/>
) : isEditable ? (
<TaxonomicPropertyFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

if (propertyKey && propertyType) {
const newPropertyFilter = createDefaultPropertyFilter(
{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import { actionsModel } from '~/models/actionsModel'
import { cohortsModel } from '~/models/cohortsModel'
import { AndOrFilterSelect } from '~/queries/nodes/InsightViz/PropertyGroupFilters/AndOrFilterSelect'
import { NodeKind } from '~/queries/schema'
import { RecordingUniversalFilters, UniversalFiltersGroup } from '~/types'

import { DurationFilter } from './DurationFilter'
Expand Down Expand Up @@ -109,6 +110,8 @@
TaxonomicFilterGroupType.Cohorts,
TaxonomicFilterGroupType.PersonProperties,
TaxonomicFilterGroupType.SessionProperties,
TaxonomicFilterGroupType.FeatureFlags,
TaxonomicFilterGroupType.HogQLExpression,
]}
onChange={(filterGroup) => setFilters({ filter_group: filterGroup })}
>
Expand Down Expand Up @@ -144,6 +147,7 @@
onRemove={() => removeGroupValue(index)}
onChange={(value) => replaceGroupValue(index, value)}
initiallyOpen={allowInitiallyOpen}
metadataSource={{ kind: NodeKind.RecordingsQuery }}

Check failure on line 150 in frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilters.tsx

View workflow job for this annotation

GitHub Actions / Code quality checks

Type 'NodeKind.RecordingsQuery' is not assignable to type 'NodeKind.ExperimentTrendsQuery'.
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

/>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { loaders } from 'kea-loaders'
import { actionToUrl, router, urlToAction } from 'kea-router'
import { subscriptions } from 'kea-subscriptions'
import api from 'lib/api'
import { isAnyPropertyfilter } from 'lib/components/PropertyFilters/utils'
import { isAnyPropertyfilter, isHogQLPropertyFilter } from 'lib/components/PropertyFilters/utils'
import { DEFAULT_UNIVERSAL_GROUP_FILTER } from 'lib/components/UniversalFilters/universalFiltersLogic'
import {
isActionFilter,
Expand Down Expand Up @@ -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"™

properties.push(f)
} else if (isAnyPropertyfilter(f)) {
if (isRecordingPropertyFilter(f)) {
if (f.key === 'visited_page') {
Expand Down
Loading