Skip to content

: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.

feat(insights): flag-gated performed event filter UI on insight filter groups (#83740)

Sam Pennington34bfbe29ece4
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 8099bc42834c..ee809866fc07 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2388,6 +2388,22 @@ snapshots:
hash: v1.k794b7964.01e1b40b4a0ab0c328958e94bc0e3b05150e30c3ec182818ef1d9b8475a0c91a.nt0Ok0V7e9_x1rGNVajbWZ-iZ5LMriFrYCI0m_M740o
filters-action-filter--trends-group-default-name--light:
hash: v1.k794b7964.0ae44b0f25e02c062e985b302f4563d1736ca6b1b01f2ecd15bd1cd563d1cc78.-5AoeartLEtxntcPowA-5fjRJ04EoSdMhI1_lfYbj_M
+ filters-behavioral-property-filter-row--action--dark:
+ hash: v1.k794b7964.64be13cd28775723861e4f207be903912d920a6c3fc07b0642fcf5b649ece71b.-g0cCMVhx80qaSirvtkcIWNXCCuDqQQFBw3s2S75JUk
+ filters-behavioral-property-filter-row--action--light:
+ hash: v1.k794b7964.3879bd7d908474b51cd37254eedab66fe23ab852a9736568d12cc985dcd55c34.8y4ho1W8dxU0Spoy39HHvf2O590lt5AkOvv6M8kfCtI
+ filters-behavioral-property-filter-row--default--dark:
+ hash: v1.k794b7964.6c098c9d07b3fa2c86fe538ce7945c965a098a002ec6b0e56481f167e16b4ba4.6d-IwX4pVq2svuxGFXT1cCAVjKQ4Zv_cJ0cau6rXiXs
+ filters-behavioral-property-filter-row--default--light:
+ hash: v1.k794b7964.a487c6f8a0f019c2a8e8e390a384e50fb5ad829d3e3bc5bf1e44f65cf89779c2.pwncW6m1jZuhyuW-_EQFilUiLjOSA86CW3Z1cOokGGk
+ filters-behavioral-property-filter-row--read-only--dark:
+ hash: v1.k794b7964.14387613fce7c7a7c5ba8bd849a0171880ad4fa50e82fc3df4a9ccd0659ed0cd.MbDp30kp-57hPNOb6VqaZutKy4arkZbmSf2rzcPd_sc
+ filters-behavioral-property-filter-row--read-only--light:
+ hash: v1.k794b7964.6540a4f27b02c725a923fd645f0e38d665fda7cc8f9e99d040492ac8ec2d7980.ou5SmbjfPDp7D24CMMp4aXfvdvEVju3ylLjXfp1Wq0A
+ filters-behavioral-property-filter-row--read-only-with-count--dark:
+ hash: v1.k794b7964.8b0d6d3f9b613d643790d6afeb7d9fbd6fd37fc92c2a909ae1a6171b53693221.c982c9VZHohS7BM8Ypec9GmEhe7m-T1RUAmbf0FCAJo
+ filters-behavioral-property-filter-row--read-only-with-count--light:
+ hash: v1.k794b7964.b791a9c5ce7c345a68c8528ad5ab4097671704b92e7f749c114fdc8eb7f10f54.VufLlD1J093-NdMoyYxIz4FPQwkCCweZfKnA3I2eBV4
filters-breakdown-tag--breakdown-tag--dark:
hash: v1.k794b7964.e6cbdc3a3393ecc4000ad415cc5ab5d834207538c4114398f2f55c2823e797cb.wQxm2Qz-ltdbkXWgwNfBwgF5-uZnsGK4y3eNDQTol1c
filters-breakdown-tag--breakdown-tag--light:
diff --git a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
index 9c6f6c6c6aed..79c0670b7f71 100644
--- a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
+++ b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
@@ -3,7 +3,9 @@ import './PropertyFilters.scss'
import { BindLogic, useActions, useValues } from 'kea'
import React, { useState } from 'react'
+import { BehavioralPropertyFilterRow } from 'lib/components/PropertyFilters/components/BehavioralPropertyFilterRow'
import { TaxonomicPropertyFilter } from 'lib/components/PropertyFilters/components/TaxonomicPropertyFilter'
+import { isBehavioralPropertyFilter } from 'lib/components/PropertyFilters/utils'
import {
AllowedProperties,
ExcludedOperators,
@@ -13,6 +15,7 @@ import {
TaxonomicFilterProps,
} from 'lib/components/TaxonomicFilter/types'
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
+import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
import { LogicalRowDivider } from 'scenes/cohorts/CohortFilters/CohortCriteriaRowBuilder'
import { AnyDataNode, DatabaseSchemaField } from '~/queries/schema/schema-general'
@@ -73,6 +76,10 @@ export interface PropertyFiltersProps {
propertyKeyEditable?: boolean
singleLine?: boolean
showRemoveButton?: boolean
+ /** Rendered after the last row. Receives a callback that appends to this filter's own bound
+ * logic, so the caller doesn't have to rebuild the list from possibly-stale props. */
+ addFilterSuffix?: ((addFilter: (property: AnyPropertyFilter) => void) => JSX.Element) | null
+ addFilterDivider?: boolean
}
export function PropertyFilters({
@@ -117,14 +124,17 @@ export function PropertyFilters({
propertyKeyEditable,
singleLine,
showRemoveButton = true,
+ addFilterSuffix,
+ addFilterDivider = false,
}: PropertyFiltersProps): JSX.Element {
const logicProps = { propertyFilters, onChange, pageKey, sendAllKeyUpdates }
const { filters, filtersWithNew, filterIds, filterIdsWithNew } = useValues(propertyFilterLogic(logicProps))
const { remove, setFilter } = useActions(propertyFilterLogic(logicProps))
const [allowOpenOnInsert, setAllowOpenOnInsert] = useState<boolean>(false)
- const displayedFilters = allowNew && editable ? filtersWithNew : filters
- const displayedFilterIds = allowNew && editable ? filterIdsWithNew : filterIds
+ const showNewFilterRow = allowNew && editable
+ const displayedFilters = showNewFilterRow ? filtersWithNew : filters
+ const displayedFilterIds = showNewFilterRow ? filterIdsWithNew : filterIds
// do not open on initial render, only open if newly inserted
useOnMountEffect(() => setAllowOpenOnInsert(true))
@@ -142,8 +152,14 @@ export function PropertyFilters({
return (
<React.Fragment key={displayedFilterIds[index]}>
{logicalRowDivider && index > 0 && index !== displayedFilters.length - 1 && (
- <LogicalRowDivider logicalOperator={FilterLogicalOperator.And} />
+ <LogicalRowDivider
+ logicalOperator={propertyGroupType ?? FilterLogicalOperator.And}
+ />
)}
+ {addFilterDivider &&
+ showNewFilterRow &&
+ index === displayedFilters.length - 1 &&
+ filters.length > 0 && <LemonDivider className="my-1 w-full" />}
<FilterRow
item={item}
index={index}
@@ -159,45 +175,59 @@ export function PropertyFilters({
showRemoveButton={showRemoveButton}
orFiltering={orFiltering}
editable={editable}
- filterComponent={(onComplete) => (
- <TaxonomicPropertyFilter
- pageKey={pageKey}
- index={index}
- filters={filters}
- setFilter={setFilter}
- onComplete={onComplete}
- orFiltering={orFiltering}
- taxonomicGroupTypes={taxonomicGroupTypes}
- metadataSource={metadataSource}
- eventNames={eventNames}
- schemaColumns={schemaColumns}
- dataWarehouseTableName={dataWarehouseTableName}
- propertyGroupType={propertyGroupType}
- disablePopover={disablePopover || orFiltering}
- addText={addText}
- hasRowOperator={hasRowOperator}
- propertyAllowList={propertyAllowList}
- excludedProperties={excludedProperties}
- taxonomicFilterOptionsFromProp={taxonomicFilterOptionsFromProp}
- allowRelativeDateOptions={allowRelativeDateOptions}
- excludedOperators={excludedOperators}
- selectingKeyOnly={selectingKeyOnly}
- hideBehavioralCohorts={hideBehavioralCohorts}
- size={buttonSize}
- addFilterDocLink={addFilterDocLink}
- editable={editable}
- operatorAllowlist={operatorAllowlist}
- hogQLGlobals={hogQLGlobals}
- triggerVariant={triggerVariant}
- staticValueOptions={staticValueOptions}
- propertyDefinitionsOverride={propertyDefinitionsOverride}
- propertyKeyEditable={propertyKeyEditable}
- singleLine={singleLine}
- />
- )}
+ filterComponent={(onComplete) =>
+ isBehavioralPropertyFilter(item) ? (
+ <BehavioralPropertyFilterRow
+ filter={item}
+ onChange={(filter) => setFilter(index, filter)}
+ editable={editable}
+ size={buttonSize}
+ />
+ ) : (
+ <TaxonomicPropertyFilter
+ pageKey={pageKey}
+ index={index}
+ filters={filters}
+ setFilter={setFilter}
+ onComplete={onComplete}
+ orFiltering={orFiltering}
+ taxonomicGroupTypes={taxonomicGroupTypes}
+ metadataSource={metadataSource}
+ eventNames={eventNames}
+ schemaColumns={schemaColumns}
+ dataWarehouseTableName={dataWarehouseTableName}
+ propertyGroupType={propertyGroupType}
+ disablePopover={disablePopover || orFiltering}
+ addText={addText}
+ hasRowOperator={hasRowOperator}
+ propertyAllowList={propertyAllowList}
+ excludedProperties={excludedProperties}
+ taxonomicFilterOptionsFromProp={taxonomicFilterOptionsFromProp}
+ allowRelativeDateOptions={allowRelativeDateOptions}
+ excludedOperators={excludedOperators}
+ selectingKeyOnly={selectingKeyOnly}
+ hideBehavioralCohorts={hideBehavioralCohorts}
+ size={buttonSize}
+ addFilterDocLink={addFilterDocLink}
+ editable={editable}
+ operatorAllowlist={operatorAllowlist}
+ hogQLGlobals={hogQLGlobals}
+ triggerVariant={triggerVariant}
+ staticValueOptions={staticValueOptions}
+ propertyDefinitionsOverride={propertyDefinitionsOverride}
+ propertyKeyEditable={propertyKeyEditable}
+ singleLine={singleLine}
+ />
+ )
+ }
errorMessage={errorMessages && errorMessages[index]}
openOnInsert={allowOpenOnInsert && openOnInsert}
disabledReason={disabledReason}
+ suffix={
+ showNewFilterRow && index === displayedFilters.length - 1 && addFilterSuffix
+ ? addFilterSuffix((property) => setFilter(filters.length, property))
+ : null
+ }
/>
</React.Fragment>
)
diff --git a/frontend/src/lib/components/PropertyFilters/components/BehavioralPropertyFilterRow.stories.tsx b/frontend/src/lib/components/PropertyFilters/components/BehavioralPropertyFilterRow.stories.tsx
new file mode 100644
index 000000000000..5029e506b74e
--- /dev/null
+++ b/frontend/src/lib/components/PropertyFilters/components/BehavioralPropertyFilterRow.stories.tsx
@@ -0,0 +1,87 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import { useState } from 'react'
+
+import { mswDecorator } from '~/mocks/browser'
+import {
+ BehavioralEventType,
+ BehavioralPropertyFilter,
+ PropertyFilterType,
+ PropertyOperator,
+ TimeUnitType,
+} from '~/types'
+
+import { BehavioralPropertyFilterRow } from './BehavioralPropertyFilterRow'
+
+const CHECKOUT_ACTION = { id: 42, name: 'Completed checkout' }
+
+type Story = StoryObj<typeof BehavioralPropertyFilterRow>
+const meta: Meta<typeof BehavioralPropertyFilterRow> = {
+ title: 'Filters/Behavioral Property Filter Row',
+ component: BehavioralPropertyFilterRow,
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/actions/': { count: 1, next: null, previous: null, results: [CHECKOUT_ACTION] },
+ },
+ }),
+ ],
+ args: {
+ editable: true,
+ },
+ render: (props) => {
+ const [filter, setFilter] = useState<BehavioralPropertyFilter>({
+ type: PropertyFilterType.Behavioral,
+ value: BehavioralEventType.PerformEvent,
+ key: '$pageview',
+ event_type: 'events',
+ time_value: 30,
+ time_interval: TimeUnitType.Day,
+ })
+
+ return <BehavioralPropertyFilterRow {...props} filter={filter} onChange={setFilter} />
+ },
+}
+export default meta
+
+export const Default: Story = {}
+
+export const ReadOnly: Story = {
+ args: { editable: false },
+}
+
+export const Action: Story = {
+ render: (props) => (
+ <BehavioralPropertyFilterRow
+ {...props}
+ filter={{
+ type: PropertyFilterType.Behavioral,
+ value: BehavioralEventType.PerformEvent,
+ key: String(CHECKOUT_ACTION.id),
+ event_type: 'actions',
+ time_value: 30,
+ time_interval: TimeUnitType.Day,
+ }}
+ onChange={() => {}}
+ />
+ ),
+}
+
+export const ReadOnlyWithCount: Story = {
+ args: { editable: false },
+ render: (props) => (
+ <BehavioralPropertyFilterRow
+ {...props}
+ filter={{
+ type: PropertyFilterType.Behavioral,
+ value: BehavioralEventType.PerformMultipleEvents,
+ key: '$pageview',
+ event_type: 'events',
+ operator: PropertyOperator.GreaterThanOrEqual,
+ operator_value: 3,
+ time_value: 30,
+ time_interval: TimeUnitType.Day,
+ }}
+ onChange={() => {}}
+ />
+ ),
+}
diff --git a/frontend/src/lib/components/PropertyFilters/components/BehavioralPropertyFilterRow.test.ts b/frontend/src/lib/components/PropertyFilters/components/BehavioralPropertyFilterRow.test.ts
new file mode 100644
index 000000000000..3a42946009ce
--- /dev/null
+++ b/frontend/src/lib/components/PropertyFilters/components/BehavioralPropertyFilterRow.test.ts
@@ -0,0 +1,73 @@
+import {
+ withBehavioralCount,
+ withBehavioralNegation,
+} from 'lib/components/PropertyFilters/components/BehavioralPropertyFilterRow'
+
+import {
+ BehavioralEventType,
+ BehavioralPropertyFilter,
+ PropertyFilterType,
+ PropertyOperator,
+ TimeUnitType,
+} from '~/types'
+
+describe('BehavioralPropertyFilterRow value mapping', () => {
+ const counted: BehavioralPropertyFilter = {
+ type: PropertyFilterType.Behavioral,
+ key: 'signed_up',
+ event_type: 'events',
+ value: BehavioralEventType.PerformMultipleEvents,
+ operator: PropertyOperator.GreaterThanOrEqual,
+ operator_value: 3,
+ time_value: 30,
+ time_interval: TimeUnitType.Day,
+ }
+
+ test.each<[string, PropertyOperator, number, Partial<BehavioralPropertyFilter>]>([
+ [
+ 'at least 1 collapses to the plain criterion',
+ PropertyOperator.GreaterThanOrEqual,
+ 1,
+ { value: BehavioralEventType.PerformEvent, operator: undefined, operator_value: undefined },
+ ],
+ [
+ 'at least 3 keeps the count',
+ PropertyOperator.GreaterThanOrEqual,
+ 3,
+ {
+ value: BehavioralEventType.PerformMultipleEvents,
+ operator: PropertyOperator.GreaterThanOrEqual,
+ operator_value: 3,
+ },
+ ],
+ [
+ 'at most 1 is a count, not the plain criterion',
+ PropertyOperator.LessThanOrEqual,
+ 1,
+ {
+ value: BehavioralEventType.PerformMultipleEvents,
+ operator: PropertyOperator.LessThanOrEqual,
+ operator_value: 1,
+ },
+ ],
+ ])('%s', (_name, operator, operatorValue, expected) => {
+ expect(withBehavioralCount(counted, operator, operatorValue)).toEqual({ ...counted, ...expected })
+ })
+
+ it('clears the count when switching to "did not perform"', () => {
+ expect(withBehavioralNegation(counted, true)).toEqual({
+ ...counted,
+ negation: true,
+ value: BehavioralEventType.PerformEvent,
+ operator: undefined,
+ operator_value: undefined,
+ })
+ })
+
+ it('drops the negation when switching back to "performed"', () => {
+ expect(withBehavioralNegation({ ...counted, negation: true }, false)).toEqual({
+ ...counted,
+ negation: undefined,
+ })
+ })
+})
diff --git a/frontend/src/lib/components/PropertyFilters/components/BehavioralPropertyFilterRow.tsx b/frontend/src/lib/components/PropertyFilters/components/BehavioralPropertyFilterRow.tsx
new file mode 100644
index 000000000000..aaacafb7663c
--- /dev/null
+++ b/frontend/src/lib/components/PropertyFilters/components/BehavioralPropertyFilterRow.tsx
@@ -0,0 +1,173 @@
+import { useValues } from 'kea'
+
+import { LemonInput, LemonSelect } from '@posthog/lemon-ui'
+
+import {
+ BEHAVIORAL_COUNT_OPERATOR_LABELS,
+ behavioralEntityLabel,
+ formatPropertyLabel,
+} from 'lib/components/PropertyFilters/utils'
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import { TaxonomicPopover } from 'lib/components/TaxonomicPopover/TaxonomicPopover'
+
+import { actionsModel } from '~/models/actionsModel'
+import { BehavioralEventType, BehavioralPropertyFilter, PropertyOperator, TimeUnitType } from '~/types'
+
+import { PropertyFilterButton } from './PropertyFilterButton'
+
+export interface BehavioralPropertyFilterRowProps {
+ filter: BehavioralPropertyFilter
+ onChange: (filter: BehavioralPropertyFilter) => void
+ editable: boolean
+ size?: 'xsmall' | 'small' | 'medium'
+}
+
+const COUNT_OPERATOR_OPTIONS = [
+ PropertyOperator.GreaterThanOrEqual,
+ PropertyOperator.LessThanOrEqual,
+ PropertyOperator.Exact,
+].map((value) => ({ value, label: BEHAVIORAL_COUNT_OPERATOR_LABELS[value] || 'exactly' }))
+
+// A cleared number LemonInput reports NaN, which `??` doesn't catch
+const positiveOr = (value: number | undefined, fallback: number): number =>
+ typeof value === 'number' && Number.isFinite(value) && value >= 1 ? value : fallback
+
+const TIME_INTERVAL_OPTIONS = [
+ { value: TimeUnitType.Day, label: 'days' },
+ { value: TimeUnitType.Week, label: 'weeks' },
+ { value: TimeUnitType.Month, label: 'months' },
+ { value: TimeUnitType.Year, label: 'years' },
+]
+
+export function withBehavioralCount(
+ filter: BehavioralPropertyFilter,
+ operator: PropertyOperator,
+ operatorValue: number
+): BehavioralPropertyFilter {
+ // "at least once" is the plain performed_event criterion; anything else needs a count
+ return operator === PropertyOperator.GreaterThanOrEqual && operatorValue === 1
+ ? { ...filter, value: BehavioralEventType.PerformEvent, operator: undefined, operator_value: undefined }
+ : { ...filter, value: BehavioralEventType.PerformMultipleEvents, operator, operator_value: operatorValue }
+}
+
+export function withBehavioralNegation(filter: BehavioralPropertyFilter, negation: boolean): BehavioralPropertyFilter {
+ // "Did not perform" means not at all, so a count no longer applies
+ return negation
+ ? {
+ ...filter,
+ negation: true,
+ value: BehavioralEventType.PerformEvent,
+ operator: undefined,
+ operator_value: undefined,
+ }
+ : { ...filter, negation: undefined }
+}
+
+export function BehavioralPropertyFilterRow({
+ filter,
+ onChange,
+ editable,
+ size = 'medium',
+}: BehavioralPropertyFilterRowProps): JSX.Element {
+ // Only mounted for behavioral filters, so surfaces without one never pay for the actions fetch
+ const { actionsById } = useValues(actionsModel)
+
+ // Filters created via the API with explicit date bounds have no window controls to map onto
+ if (!editable || filter.explicit_datetime) {
+ return (
+ <PropertyFilterButton item={filter}>
+ {formatPropertyLabel(filter, {}, undefined, actionsById)}
+ </PropertyFilterButton>
+ )
+ }
+
+ const countOperator = filter.operator ?? PropertyOperator.GreaterThanOrEqual
+ const countValue = filter.operator_value ?? 1
+
+ const setCount = (operator: PropertyOperator, operatorValue: number): void => {
+ onChange(withBehavioralCount(filter, operator, operatorValue))
+ }
+
+ return (
+ <div className="flex min-w-0 grow" data-attr="behavioral-property-filter-row">
+ <div className="flex min-w-0 grow flex-wrap items-center gap-x-1 gap-y-2">
+ <div className="flex w-full min-w-0 flex-wrap items-center gap-2">
+ <LemonSelect
+ size={size}
+ value={!!filter.negation}
+ onChange={(negation) => onChange(withBehavioralNegation(filter, negation))}
+ options={[
+ { value: false, label: 'Performed' },
+ { value: true, label: 'Did not perform' },
+ ]}
+ data-attr="behavioral-filter-negation"
+ />
+ <div className="min-w-32 flex-1">
+ <TaxonomicPopover
+ size={size}
+ groupType={
+ filter.event_type === 'actions'
+ ? TaxonomicFilterGroupType.Actions
+ : TaxonomicFilterGroupType.Events
+ }
+ groupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
+ value={filter.event_type === 'actions' ? Number(filter.key) : filter.key}
+ onChange={(value, groupType) =>
+ onChange({
+ ...filter,
+ key: String(value),
+ event_type: groupType === TaxonomicFilterGroupType.Actions ? 'actions' : 'events',
+ })
+ }
+ renderValue={() => <span>{behavioralEntityLabel(filter, actionsById)}</span>}
+ placeholder="Select an event or action"
+ fullWidth
+ truncate
+ data-attr="behavioral-filter-event"
+ />
+ </div>
+ </div>
+ {!filter.negation && (
+ <div className="flex items-center gap-2">
+ <LemonSelect
+ size={size}
+ value={countOperator}
+ onChange={(operator) => setCount(operator, countValue)}
+ options={COUNT_OPERATOR_OPTIONS}
+ data-attr="behavioral-filter-count-operator"
+ />
+ <LemonInput
+ type="number"
+ size={size}
+ min={1}
+ className="w-14"
+ value={countValue}
+ onChange={(operatorValue) => setCount(countOperator, positiveOr(operatorValue, 1))}
+ data-attr="behavioral-filter-count-value"
+ />
+ <span className="whitespace-nowrap">{countValue === 1 ? 'time' : 'times'}</span>
+ </div>
+ )}
+ <div className="flex items-center gap-2">
+ <span className="whitespace-nowrap">in the last</span>
+ <LemonInput
+ type="number"
+ size={size}
+ min={1}
+ className="w-14"
+ value={filter.time_value ?? 30}
+ onChange={(timeValue) => onChange({ ...filter, time_value: positiveOr(timeValue, 30) })}
+ data-attr="behavioral-filter-time-value"
+ />
+ <LemonSelect
+ size={size}
+ value={filter.time_interval ?? TimeUnitType.Day}
+ onChange={(timeInterval) => onChange({ ...filter, time_interval: timeInterval })}
+ options={TIME_INTERVAL_OPTIONS}
+ data-attr="behavioral-filter-time-interval"
+ />
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/frontend/src/lib/components/PropertyFilters/components/FilterRow.tsx b/frontend/src/lib/components/PropertyFilters/components/FilterRow.tsx
index f3a8887b2340..003aa800c875 100644
--- a/frontend/src/lib/components/PropertyFilters/components/FilterRow.tsx
+++ b/frontend/src/lib/components/PropertyFilters/components/FilterRow.tsx
@@ -33,6 +33,7 @@ interface FilterRowProps {
disabledReason?: string
editable: boolean
size?: 'xsmall' | 'small' | 'medium'
+ suffix?: JSX.Element | null
}
export const FilterRow = React.memo(function FilterRow({
@@ -54,6 +55,7 @@ export const FilterRow = React.memo(function FilterRow({
disabledReason,
editable,
size = 'small',
+ suffix,
}: FilterRowProps) {
const [open, setOpen] = useState(() => openOnInsert)
@@ -75,6 +77,7 @@ export const FilterRow = React.memo(function FilterRow({
'grow sm:grow-0': isValid,
'grow-0': !isValid,
'wrap-filters': !disablePopover,
+ 'property-filter-row--with-suffix': !!suffix,
})}
data-attr={'property-filter-' + index}
>
@@ -121,6 +124,7 @@ export const FilterRow = React.memo(function FilterRow({
</Popover>
)}
{key && showConditionBadge && index + 1 < totalCount && <OperandTag operand="and" />}
+ {suffix}
</div>
{errorMessage}
</>
diff --git a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.scss b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.scss
index b7b07aef7710..7440bc5d6998 100644
--- a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.scss
+++ b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.scss
@@ -36,6 +36,25 @@
padding-right: 0.5rem;
}
+ // Sentence-length labels wrap instead of being ellipsised, so the pill grows into a block
+ &.PropertyFilterButton--wraps {
+ align-items: flex-start;
+ height: auto;
+ min-height: 2rem;
+ padding: 0.3125rem 0.625rem;
+ white-space: normal;
+ border-radius: var(--radius);
+
+ > .LemonIcon {
+ margin-top: 0.125rem;
+ }
+
+ .PropertyFilterButton-content {
+ overflow: visible;
+ text-overflow: clip;
+ }
+ }
+
&.PropertyFilterButton--compact {
height: unset;
padding: 0.25rem;
diff --git a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.tsx b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.tsx
index b7f64bd6ea88..d26c913cca43 100644
--- a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.tsx
+++ b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterButton.tsx
@@ -14,7 +14,12 @@ import { cohortsModel } from '~/models/cohortsModel'
import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'
import { AnyPropertyFilter, GroupPropertyFilter, GroupTypeIndex } from '~/types'
-import { formatPropertyLabel, isGroupCardFilterKey, propertyFilterTypeToPropertyDefinitionType } from '../utils'
+import {
+ formatPropertyLabel,
+ isBehavioralPropertyFilter,
+ isGroupCardFilterKey,
+ propertyFilterTypeToPropertyDefinitionType,
+} from '../utils'
import { GroupKeyFilterTooltip } from './GroupKeyFilterTooltip'
export interface PropertyFilterButtonProps {
@@ -36,6 +41,9 @@ export const PropertyFilterButton = React.forwardRef<HTMLElement, PropertyFilter
const propertyDefinitionType = propertyFilterTypeToPropertyDefinitionType(item.type)
+ // A behavioral label is a whole sentence, which mid-ellipsis would turn into nonsense
+ const wraps = isBehavioralPropertyFilter(item)
+
const label =
children ||
formatPropertyLabel(
@@ -101,6 +109,7 @@ export const PropertyFilterButton = React.forwardRef<HTMLElement, PropertyFilter
'PropertyFilterButton--closeable': closable,
'PropertyFilterButton--clickable': clickable,
'PropertyFilterButton--compact': compact,
+ 'PropertyFilterButton--wraps': wraps,
})}
aria-disabled={!!disabledReason}
type={ButtonComponent === 'button' ? 'button' : undefined}
@@ -108,7 +117,7 @@ export const PropertyFilterButton = React.forwardRef<HTMLElement, PropertyFilter
>
<PropertyFilterIcon type={item.type} />
<span className="PropertyFilterButton-content" title={showGroupCard ? undefined : label}>
- {midEllipsis(label, 32)}
+ {wraps ? label : midEllipsis(label, 32)}
</span>
{closable &&
!disabledReason && (
diff --git a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterIcon.tsx b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterIcon.tsx
index 0285f3ad314f..ed6c571d4f4c 100644
--- a/frontend/src/lib/components/PropertyFilters/components/PropertyFilterIcon.tsx
+++ b/frontend/src/lib/components/PropertyFilters/components/PropertyFilterIcon.tsx
@@ -1,4 +1,4 @@
-import { IconBuilding, IconPeople, IconPerson, IconPiggyBank } from '@posthog/icons'
+import { IconBuilding, IconCursorClick, IconPeople, IconPerson, IconPiggyBank } from '@posthog/icons'
import { IconUnverifiedEvent } from 'lib/lemon-ui/icons'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
@@ -31,6 +31,12 @@ export function PropertyFilterIcon({ type }: { type?: PropertyFilterType }): JSX
<IconBuilding />
</Tooltip>
)
+ case 'behavioral':
+ return (
+ <Tooltip title="Performed event or action filter">
+ <IconCursorClick />
+ </Tooltip>
+ )
case 'revenue_analytics':
return (
<Tooltip title="Revenue analytics filter">
diff --git a/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts b/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
index e1ab16f64dbd..9361b69a8ee6 100644
--- a/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
+++ b/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
@@ -3,6 +3,7 @@ import { MakeLogicType, actions, kea, key, listeners, path, props, propsChanged,
import { PropertyFilterLogicProps } from 'lib/components/PropertyFilters/types'
import {
+ isBehavioralPropertyFilter,
isValidPropertyFilter,
parseProperties,
PROPERTY_FILTER_TYPE_TO_TAXONOMIC_FILTER_GROUP_TYPE,
@@ -190,7 +191,7 @@ export const propertyFilterLogic = kea<propertyFilterLogicType>([
actions.update()
}
- if (isComplete && property?.key && property?.type) {
+ if (isComplete && property?.key && property?.type && !isBehavioralPropertyFilter(property)) {
const groupType = PROPERTY_FILTER_TYPE_TO_TAXONOMIC_FILTER_GROUP_TYPE[property.type]
if (groupType && recentTaxonomicFiltersLogic.isMounted()) {
const groupName = TAXONOMIC_GROUP_TYPE_TO_DISPLAY_NAME[groupType] ?? groupType
diff --git a/frontend/src/lib/components/PropertyFilters/utils.test.ts b/frontend/src/lib/components/PropertyFilters/utils.test.ts
index 7f273ee49b6e..d08db4108f4c 100644
--- a/frontend/src/lib/components/PropertyFilters/utils.test.ts
+++ b/frontend/src/lib/components/PropertyFilters/utils.test.ts
@@ -3,6 +3,7 @@ import {
convertPropertiesToPropertyGroup,
convertPropertyGroupToProperties,
createDefaultPropertyFilter,
+ formatPropertyLabel,
isAnyPropertyfilter,
isGroupCardFilterKey,
isValidPropertyFilter,
@@ -16,7 +17,10 @@ import type { propertyDefinitionsModelType } from '~/models/propertyDefinitionsM
import { BreakdownFilter } from '~/queries/schema/schema-general'
import {
+ ActionType,
AnyPropertyFilter,
+ BehavioralEventType,
+ BehavioralPropertyFilter,
CohortPropertyFilter,
ElementPropertyFilter,
EmptyPropertyFilter,
@@ -27,6 +31,7 @@ import {
PropertyGroupFilter,
PropertyOperator,
SessionPropertyFilter,
+ TimeUnitType,
} from '../../../types'
import { TaxonomicFilterGroup, TaxonomicFilterGroupType } from '../TaxonomicFilter/types'
@@ -66,6 +71,68 @@ describe('isValidPropertyFilter()', () => {
})
})
+describe('formatPropertyLabel() for behavioral filters', () => {
+ const base: BehavioralPropertyFilter = {
+ type: PropertyFilterType.Behavioral,
+ value: BehavioralEventType.PerformEvent,
+ key: 'signed_up',
+ event_type: 'events',
+ time_value: 30,
+ time_interval: TimeUnitType.Day,
+ }
+
+ // pluralize() glues the count to its unit with a non-breaking space
+ // Every row spells out actionsById: a shorter row makes jest-each hand the callback a `done`
+ const noActions: Partial<Record<string | number, ActionType>> = {}
+
+ test.each<[string, Partial<BehavioralPropertyFilter>, string, Partial<Record<string | number, ActionType>>]>([
+ ['performed', {}, 'Performed signed_up in the last 30\u00a0days', noActions],
+ ['did not perform', { negation: true }, 'Did not perform signed_up in the last 30\u00a0days', noActions],
+ [
+ 'count',
+ {
+ value: BehavioralEventType.PerformMultipleEvents,
+ operator: PropertyOperator.GreaterThanOrEqual,
+ operator_value: 3,
+ },
+ 'Performed signed_up at least 3\u00a0times in the last 30\u00a0days',
+ noActions,
+ ],
+ [
+ 'single unit',
+ { time_value: 1, time_interval: TimeUnitType.Week },
+ 'Performed signed_up in the last 1\u00a0week',
+ noActions,
+ ],
+ [
+ 'explicit date',
+ { explicit_datetime: '-14d', time_value: undefined },
+ 'Performed signed_up since -14d',
+ noActions,
+ ],
+ [
+ 'core event uses its readable label',
+ { key: '$pageview' },
+ 'Performed Pageview in the last 30\u00a0days',
+ noActions,
+ ],
+ [
+ 'action resolves to its name',
+ { key: '42', event_type: 'actions' },
+ 'Performed Completed checkout in the last 30\u00a0days',
+ { 42: { id: 42, name: 'Completed checkout' } as ActionType },
+ ],
+ [
+ 'unresolved action falls back to its id',
+ { key: '42', event_type: 'actions' },
+ 'Performed action 42 in the last 30\u00a0days',
+ noActions,
+ ],
+ ])('%s', (_name, overrides, expected, actionsById) => {
+ expect(formatPropertyLabel({ ...base, ...overrides }, {}, undefined, actionsById)).toEqual(expected)
+ })
+})
+
describe('propertyFilterTypeToTaxonomicFilterType()', () => {
const baseFilter: AnyPropertyFilter = {
type: PropertyFilterType.Event,
diff --git a/frontend/src/lib/components/PropertyFilters/utils.ts b/frontend/src/lib/components/PropertyFilters/utils.ts
index 58663122eae2..40fde6044bd4 100644
--- a/frontend/src/lib/components/PropertyFilters/utils.ts
+++ b/frontend/src/lib/components/PropertyFilters/utils.ts
@@ -7,7 +7,7 @@ import {
isOperatorFlag,
isOperatorMulti,
} from 'lib/utils/operators'
-import { capitalizeFirstLetter } from 'lib/utils/strings'
+import { capitalizeFirstLetter, pluralize } from 'lib/utils/strings'
import type { propertyDefinitionsModelType } from '~/models/propertyDefinitionsModel'
import { extractExpressionComment } from '~/queries/nodes/DataTable/utils'
@@ -15,8 +15,11 @@ import { BreakdownFilter } from '~/queries/schema/schema-general'
import { getCoreFilterDefinition } from '~/taxonomy/helpers'
import {
AccountCustomPropertyFilter,
+ ActionType,
AnyFilterLike,
AnyPropertyFilter,
+ BehavioralEventType,
+ BehavioralPropertyFilter,
BreakdownType,
CohortPropertyFilter,
CohortType,
@@ -48,6 +51,7 @@ import {
RevenueAnalyticsPropertyFilter,
SessionPropertyFilter,
SpanPropertyFilter,
+ TimeUnitType,
WorkflowVariablePropertyFilter,
} from '~/types'
@@ -149,7 +153,8 @@ export const PROPERTY_FILTER_TYPE_TO_TAXONOMIC_FILTER_GROUP_TYPE: Record<Propert
export function formatPropertyLabel(
item: AnyPropertyFilter,
cohortsById: Partial<Record<CohortType['id'], CohortType>>,
- valueFormatter: (value: PropertyFilterValue | undefined) => string | string[] | null = (s) => [String(s)]
+ valueFormatter: (value: PropertyFilterValue | undefined) => string | string[] | null = (s) => [String(s)],
+ actionsById: Partial<Record<string | number, ActionType>> = {}
): string {
if (!isValidPropertyFilter(item)) {
return ''
@@ -159,6 +164,10 @@ export function formatPropertyLabel(
return extractExpressionComment(item.key)
}
+ if (isBehavioralPropertyFilter(item)) {
+ return formatBehavioralPropertyLabel(item, actionsById)
+ }
+
const { value, key, type } = item
const label = 'label' in item ? item.label : undefined
const operator = 'operator' in item ? item.operator : undefined
@@ -237,6 +246,48 @@ export function isCohortPropertyFilter(filter?: AnyFilterLike | null): filter is
return filter?.type === PropertyFilterType.Cohort
}
+export function isBehavioralPropertyFilter(filter?: AnyFilterLike | null): filter is BehavioralPropertyFilter {
+ return filter?.type === PropertyFilterType.Behavioral
+}
+
+export const BEHAVIORAL_COUNT_OPERATOR_LABELS: Partial<Record<PropertyOperator, string>> = {
+ [PropertyOperator.GreaterThanOrEqual]: 'at least',
+ [PropertyOperator.LessThanOrEqual]: 'at most',
+ [PropertyOperator.GreaterThan]: 'more than',
+ [PropertyOperator.LessThan]: 'fewer than',
+ [PropertyOperator.Exact]: 'exactly',
+}
+
+/** Display name for the event or action a behavioral filter targets. An unresolved action falls back
+ * to its id, which is all the filter itself stores. */
+export function behavioralEntityLabel(
+ item: BehavioralPropertyFilter,
+ actionsById: Partial<Record<string | number, ActionType>> = {}
+): string {
+ if (item.event_type === 'actions') {
+ return actionsById[item.key]?.name || `action ${item.key}`
+ }
+ return getCoreFilterDefinition(item.key, TaxonomicFilterGroupType.Events)?.label || item.key
+}
+
+function formatBehavioralPropertyLabel(
+ item: BehavioralPropertyFilter,
+ actionsById: Partial<Record<string | number, ActionType>> = {}
+): string {
+ const eventLabel = behavioralEntityLabel(item, actionsById)
+ const countClause =
+ item.value === BehavioralEventType.PerformMultipleEvents
+ ? ` ${BEHAVIORAL_COUNT_OPERATOR_LABELS[item.operator ?? PropertyOperator.Exact] || 'exactly'} ${pluralize(
+ item.operator_value ?? 0,
+ 'time'
+ )}`
+ : ''
+ const windowClause = item.explicit_datetime
+ ? ` since ${item.explicit_datetime}`
+ : ` in the last ${pluralize(item.time_value ?? 30, item.time_interval ?? TimeUnitType.Day)}`
+ return `${item.negation ? 'Did not perform' : 'Performed'} ${eventLabel}${countClause}${windowClause}`
+}
+
// Filter keys whose value we offer a read-only group-info card for on hover.
// '$group_key' is the group's true identity (always a group key). 'id' is a
// group *property* that conventionally holds the group key (e.g. CRM-imported
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index d3d09762d416..a2812cd6eb0a 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -206,6 +206,7 @@ export const FEATURE_FLAGS = {
// Legacy flags, TBD if they need to be removed
BATCH_EXPORTS_POSTHOG_HTTP: 'posthog-http-batch-exports', // owner: #team-batch-exports
+ BEHAVIORAL_PROPERTY_FILTER: 'behavioral-property-filter', // owner: #team-product-analytics, inline "performed event" filter on insights
BILLING_SKIP_FORECASTING: 'billing-skip-forecasting', // owner: @zach
BOX_PLOT_INSIGHT: 'box-plot-insight', // owner: @pauldambra #team-product-analytics
EXPERIMENT_INTERVAL_TIMESERIES: 'experiments-interval-timeseries', // owner: @jurajmajerik #team-experiments
diff --git a/frontend/src/queries/nodes/InsightViz/InsightViz.scss b/frontend/src/queries/nodes/InsightViz/InsightViz.scss
index 86ca533b9ef0..0e507d3f64f7 100644
--- a/frontend/src/queries/nodes/InsightViz/InsightViz.scss
+++ b/frontend/src/queries/nodes/InsightViz/InsightViz.scss
@@ -39,6 +39,11 @@
min-width: 0;
}
+ // ...but a row with a sibling entry point keeps the two buttons adjacent
+ .property-filter-row--with-suffix .TaxonomicPropertyFilter {
+ flex: 0 0 auto;
+ }
+
// Propagate min-width:0 through the filter chain
.ActionFilterRow,
.ActionFilterRow-filters,
diff --git a/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/AndOrFilterSelect.tsx b/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/AndOrFilterSelect.tsx
index 033167213214..9cf9039c9500 100644
--- a/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/AndOrFilterSelect.tsx
+++ b/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/AndOrFilterSelect.tsx
@@ -8,6 +8,8 @@ export interface AndOrFilterSelectProps {
topLevelFilter?: boolean
prefix?: React.ReactNode
suffix?: [singular: string, plural: string]
+ /** Shown instead of `suffix` in a narrow editor panel. Needs an `editor-panel` container ancestor */
+ shortSuffix?: string
disabledReason?: LemonButtonProps['disabledReason']
size?: LemonButtonProps['size']
}
@@ -18,6 +20,7 @@ export function AndOrFilterSelect({
topLevelFilter,
prefix = 'Match',
suffix = ['filter in this group', 'filters in this group'],
+ shortSuffix,
disabledReason,
size = 'small',
}: AndOrFilterSelectProps): JSX.Element {
@@ -59,7 +62,10 @@ export function AndOrFilterSelect({
optionTooltipPlacement={topLevelFilter ? 'bottom-end' : 'bottom-start'}
dropdownMatchSelectWidth={false}
/>
- {value === FilterLogicalOperator.Or ? suffix[0] : suffix[1]}
+ <span className={shortSuffix ? '@max-[375px]/editor-panel:hidden' : undefined}>
+ {value === FilterLogicalOperator.Or ? suffix[0] : suffix[1]}
+ </span>
+ {shortSuffix && <span className="hidden @max-[375px]/editor-panel:inline">{shortSuffix}</span>}
</div>
)
}
diff --git a/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/PropertyGroupFilters.scss b/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/PropertyGroupFilters.scss
index 77d95838e32b..6a13b2b0cc15 100644
--- a/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/PropertyGroupFilters.scss
+++ b/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/PropertyGroupFilters.scss
@@ -6,6 +6,18 @@
border-radius: var(--radius);
}
+ // Overrides PropertyFilters.scss, which anchors the operator left for the feature-flag
+ // and workflow-trigger usages
+ .property-group--framed .logical-row-divider {
+ align-items: center;
+ margin: 0.625rem 0;
+ color: var(--color-text-tertiary);
+
+ &::before {
+ width: 50%;
+ }
+ }
+
.property-group-and-or-separator {
position: relative;
padding: 0.5rem 0;
diff --git a/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/PropertyGroupFilters.tsx b/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/PropertyGroupFilters.tsx
index 8f9036b00e62..6cd5ce6289f1 100644
--- a/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/PropertyGroupFilters.tsx
+++ b/frontend/src/queries/nodes/InsightViz/PropertyGroupFilters/PropertyGroupFilters.tsx
@@ -1,5 +1,6 @@
import './PropertyGroupFilters.scss'
+import clsx from 'clsx'
import { BindLogic, useActions, useValues } from 'kea'
import React from 'react'
@@ -9,15 +10,36 @@ import { LemonButton, LemonDivider } from '@posthog/lemon-ui'
import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
import { isPropertyGroupFilterLike } from 'lib/components/PropertyFilters/utils'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'
import { InsightQueryNode, ProductAnalyticsInsightQueryNode } from '~/queries/schema/schema-general'
-import { AnyPropertyFilter, InsightLogicProps, PropertyGroupFilterValue } from '~/types'
+import {
+ AnyPropertyFilter,
+ BehavioralEventType,
+ BehavioralPropertyFilter,
+ InsightLogicProps,
+ PropertyFilterType,
+ PropertyGroupFilterValue,
+ TimeUnitType,
+} from '~/types'
import { InsightTestAccountFilter } from '../filters/InsightTestAccountFilter'
import { AndOrFilterSelect } from './AndOrFilterSelect'
import { propertyGroupFilterLogic } from './propertyGroupFilterLogic'
+function newBehavioralFilter(): BehavioralPropertyFilter {
+ return {
+ type: PropertyFilterType.Behavioral,
+ value: BehavioralEventType.PerformEvent,
+ key: '$pageview',
+ event_type: 'events',
+ time_value: 30,
+ time_interval: TimeUnitType.Day,
+ }
+}
+
type PropertyGroupFiltersProps = {
insightProps: InsightLogicProps
query: ProductAnalyticsInsightQueryNode
@@ -38,6 +60,7 @@ export function PropertyGroupFilters({
hasDataWarehouseSeries,
}: PropertyGroupFiltersProps): JSX.Element {
const logicProps = { query, setQuery, pageKey }
+ const { featureFlags } = useValues(featureFlagLogic)
const { propertyGroupFilter } = useValues(propertyGroupFilterLogic(logicProps))
const {
addFilterGroup,
@@ -48,6 +71,7 @@ export function PropertyGroupFilters({
setPropertyFilters,
} = useActions(propertyGroupFilterLogic(logicProps))
+ const behavioralFiltersEnabled = !!featureFlags[FEATURE_FLAGS.BEHAVIORAL_PROPERTY_FILTER]
const showHeader = propertyGroupFilter.type && propertyGroupFilter.values.length > 1
const disabledReason = hasDataWarehouseSeries
? 'Filter groups cannot be added to insights with a data warehouse series. Please use individual series filters instead.'
@@ -100,16 +124,37 @@ export function PropertyGroupFilters({
(group: PropertyGroupFilterValue, propertyGroupIndex: number) => {
return (
<React.Fragment key={propertyGroupIndex}>
- <div className="property-group">
- <div className="flex justify-between items-center mb-2">
+ <div
+ className={
+ behavioralFiltersEnabled
+ ? 'property-group--framed flex min-w-0 flex-col overflow-hidden rounded border'
+ : 'property-group'
+ }
+ >
+ <div
+ className={clsx(
+ 'flex items-center',
+ behavioralFiltersEnabled
+ ? 'gap-x-2 border-b px-2.5 py-2'
+ : 'justify-between mb-2'
+ )}
+ >
<AndOrFilterSelect
onChange={(type) =>
setInnerPropertyGroupType(type, propertyGroupIndex)
}
value={group.type}
+ shortSuffix={behavioralFiltersEnabled ? 'in group' : undefined}
/>
- <LemonDivider className="flex-1 mx-2 @max-[410px]/editor-panel:hidden" />
- <div className="flex items-center gap-1 shrink-0">
+ {!behavioralFiltersEnabled && (
+ <LemonDivider className="flex-1 mx-2 @max-[410px]/editor-panel:hidden" />
+ )}
+ <div
+ className={clsx(
+ 'flex shrink-0 items-center gap-1',
+ behavioralFiltersEnabled && 'ml-auto'
+ )}
+ >
<LemonButton
icon={<IconCopy />}
onClick={() => duplicateFilterGroup(propertyGroupIndex)}
@@ -122,24 +167,52 @@ export function PropertyGroupFilters({
/>
</div>
</div>
- <PropertyFilters
- addText="Filter"
- propertyFilters={
- isPropertyGroupFilterLike(group)
- ? (group.values as AnyPropertyFilter[])
- : null
+ <div
+ className={
+ behavioralFiltersEnabled
+ ? 'bg-primary px-2.5 py-2.5'
+ : undefined
}
- onChange={(properties) => {
- setPropertyFilters(properties, propertyGroupIndex)
- }}
- pageKey={`${keyForInsightLogicProps('new')(
- insightProps
- )}-PropertyGroupFilters-${propertyGroupIndex}`}
- taxonomicGroupTypes={taxonomicGroupTypes}
- eventNames={eventNames}
- propertyGroupType={group.type}
- orFiltering
- />
+ >
+ <PropertyFilters
+ addText="Filter"
+ propertyFilters={
+ isPropertyGroupFilterLike(group)
+ ? (group.values as AnyPropertyFilter[])
+ : null
+ }
+ onChange={(properties) => {
+ setPropertyFilters(properties, propertyGroupIndex)
+ }}
+ pageKey={`${keyForInsightLogicProps('new')(
+ insightProps
+ )}-PropertyGroupFilters-${propertyGroupIndex}`}
+ taxonomicGroupTypes={taxonomicGroupTypes}
+ eventNames={eventNames}
+ propertyGroupType={group.type}
+ orFiltering
+ logicalRowDivider={behavioralFiltersEnabled}
+ hasRowOperator={!behavioralFiltersEnabled}
+ addFilterDivider={behavioralFiltersEnabled}
+ addFilterSuffix={
+ behavioralFiltersEnabled
+ ? (addFilter) => (
+ <LemonButton
+ data-attr={`${pageKey}-add-behavioral-filter`}
+ type="secondary"
+ icon={<IconPlusSmall />}
+ sideIcon={null}
+ onClick={() =>
+ addFilter(newBehavioralFilter())
+ }
+ >
+ Performed
+ </LemonButton>
+ )
+ : null
+ }
+ />
+ </div>
</div>
{propertyGroupIndex !== propertyGroupFilter.values.length - 1 && (
<div className="property-group-and-or-separator">