:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(replay-vision): show event property filters in scanner config (#78320)
Adam Bowker03d5014fe308
diff --git a/frontend/src/lib/components/UniversalFilters/UniversalFilterButton.component.test.tsx b/frontend/src/lib/components/UniversalFilters/UniversalFilterButton.component.test.tsxnew file mode 100644index 000000000000..906f259a1e75--- /dev/null+++ b/frontend/src/lib/components/UniversalFilters/UniversalFilterButton.component.test.tsx@@ -0,0 +1,56 @@+import '@testing-library/jest-dom'++import { cleanup, render, screen } from '@testing-library/react'+import { Provider } from 'kea'++import { cohortsModel } from '~/models/cohortsModel'+import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'+import { initKeaTests } from '~/test/init'+import { ActionFilter, PropertyFilterType, PropertyOperator } from '~/types'++import { UniversalFilterButton } from './UniversalFilterButton'++describe('UniversalFilterButton', () => {+ beforeEach(() => {+ initKeaTests()+ cohortsModel.mount()+ propertyDefinitionsModel.mount()+ })++ afterEach(() => {+ cleanup()+ })++ const EVENT_WITH_PROPERTIES: ActionFilter = {+ id: '$pageview',+ name: '$pageview',+ type: 'events',+ order: 0,+ properties: [+ {+ key: '$current_url',+ value: ['/checkout'],+ operator: PropertyOperator.Exact,+ type: PropertyFilterType.Event,+ },+ ],+ }++ function renderButton(onClick?: () => void): void {+ render(+ <Provider>+ <UniversalFilterButton filter={EVENT_WITH_PROPERTIES} onClick={onClick} />+ </Provider>+ )+ }++ it('offers the property filter button when there is a handler to open the properties', () => {+ renderButton(() => {})+ expect(screen.getByRole('button')).toBeInTheDocument()+ })++ it('renders no button when read-only, so the property count is not a dead click target', () => {+ renderButton()+ expect(screen.queryByRole('button')).not.toBeInTheDocument()+ })+})diff --git a/frontend/src/lib/components/UniversalFilters/UniversalFilterButton.tsx b/frontend/src/lib/components/UniversalFilters/UniversalFilterButton.tsxindex b8b695d6d055..2d19791421a7 100644--- a/frontend/src/lib/components/UniversalFilters/UniversalFilterButton.tsx+++ b/frontend/src/lib/components/UniversalFilters/UniversalFilterButton.tsx@@ -113,16 +113,20 @@ const EventLabel = ({return (<div className="flex truncate items-center deprecated-space-x-1"><EntityFilterInfo filter={filter} />- <LemonButton- size="xsmall"- icon={- <IconWithCount count={filter.properties?.length || 0} showZero={false}>- <IconFilter />- </IconWithCount>- }- className="p-0.5"- onClick={onClick}- />+ {/* The count button is the only way into an event's property filters, so without a handler to open+ them it would be a dead button — read-only consumers render the properties themselves instead. */}+ {onClick && (+ <LemonButton+ size="xsmall"+ icon={+ <IconWithCount count={filter.properties?.length || 0} showZero={false}>+ <IconFilter />+ </IconWithCount>+ }+ className="p-0.5"+ onClick={onClick}+ />+ )}</div>)}diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerConfigReadonly.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerConfigReadonly.tsxindex f5ab51e71ba7..23060ce64e2a 100644--- a/products/replay_vision/frontend/replay_scanners/components/ScannerConfigReadonly.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerConfigReadonly.tsx@@ -12,8 +12,10 @@ import {} from '@posthog/icons'import { LemonCard, LemonSwitch, LemonTag } from '@posthog/lemon-ui'+import { PropertyFilterButton } from 'lib/components/PropertyFilters/components/PropertyFilterButton'import { TZLabel } from 'lib/components/TZLabel'import { UniversalFilterButton } from 'lib/components/UniversalFilters/UniversalFilterButton'+import { isEntityFilter } from 'lib/components/UniversalFilters/utils'import { dayjs } from 'lib/dayjs'import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'import { humanFriendlyDurationFilter } from 'scenes/session-recordings/filters/DurationFilter'@@ -24,7 +26,7 @@ import {import { filtersFromUniversalFilterGroups } from 'scenes/session-recordings/utils'import { RecordingsQuery } from '~/queries/schema/schema-general'-import { FilterLogicalOperator } from '~/types'+import { FilterLogicalOperator, UniversalFilterValue } from '~/types'import { BooleanTag } from '../../components/BooleanTag'import { CardHeader } from '../../components/CardHeader'@@ -76,6 +78,25 @@ function OptionTags({)}+/** One recording filter, read-only. An event or action filter carries its own property filters, which the+ * editable UI keeps behind a popover — there's nothing to open here, so show them alongside the event. */+function ReadonlyFilter({ filter }: { filter: UniversalFilterValue }): JSX.Element {+ const properties = isEntityFilter(filter) ? (filter.properties ?? []) : []+ return (+ <div className="flex flex-wrap items-center gap-1.5">+ <UniversalFilterButton filter={filter} />+ {properties.length > 0 && (+ <>+ <span className="text-xs">where</span>+ {properties.map((property, i) => (+ <PropertyFilterButton key={i} item={property} compact />+ ))}+ </>+ )}+ </div>+ )+}+function BehaviorCardContent({ scanner }: { scanner: ReplayScanner }): JSX.Element {return (<>@@ -323,7 +344,7 @@ export function ScannerConfigReadonly({ scanner }: { scanner: ReplayScanner }):<span className="text-xs">Match {matchWord} of</span>)}{filters.map((filter, i) => (- <UniversalFilterButton key={i} filter={filter} />+ <ReadonlyFilter key={i} filter={filter} />))}</div>)}