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.

fix(actions): show correct operator in action tooltip for legacy steps (#66033)

Vasco de Krijgera1a19bb43bd6
diff --git a/frontend/src/lib/components/DefinitionPopover/utils.test.ts b/frontend/src/lib/components/DefinitionPopover/utils.test.ts
index 97c11882010b..d0a273b944f5 100644
--- a/frontend/src/lib/components/DefinitionPopover/utils.test.ts
+++ b/frontend/src/lib/components/DefinitionPopover/utils.test.ts
@@ -1,20 +1,49 @@
-import { PropertyOperator } from '~/types'
+import { AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
-import { allOperatorsToHumanName } from './utils'
+import { allOperatorsToHumanName, genericOperatorToHumanName } from './utils'
-describe('allOperatorsToHumanName', () => {
- it.each([
- // Cohort operators have no symbol prefix and must not be sliced
- [PropertyOperator.In, 'in'],
- [PropertyOperator.NotIn, 'not in'],
- // Regular operators drop their 2-char symbol prefix
- [PropertyOperator.Exact, 'equals'],
- [PropertyOperator.IsNot, "doesn't equal"],
- [PropertyOperator.GreaterThan, 'greater than'],
- // Unknown / missing operator falls back to 'equals'
- [undefined, 'equals'],
- [null, 'equals'],
- ])('maps %s to "%s"', (operator, expected) => {
- expect(allOperatorsToHumanName(operator)).toBe(expected)
+describe('DefinitionPopover operator helpers', () => {
+ describe('genericOperatorToHumanName', () => {
+ it.each([
+ [PropertyOperator.Exact, 'equals'],
+ [PropertyOperator.GreaterThanOrEqual, 'greater than or equal'],
+ [PropertyOperator.LessThanOrEqual, 'less than or equal'],
+ [PropertyOperator.GreaterThan, 'greater than'],
+ [PropertyOperator.IContains, 'contains'],
+ ])('maps a typed property with operator %s to "%s"', (operator, expected) => {
+ const property = { type: PropertyFilterType.Event, key: 'amount', value: 5, operator } as AnyPropertyFilter
+ expect(genericOperatorToHumanName(property)).toBe(expected)
+ })
+
+ it('reads the operator from a legacy action step property that has no type', () => {
+ // Legacy action step properties are stored without a `type` field
+ const property = {
+ key: 'amount',
+ value: 5,
+ operator: PropertyOperator.GreaterThanOrEqual,
+ } as AnyPropertyFilter
+ expect(genericOperatorToHumanName(property)).toBe('greater than or equal')
+ })
+
+ it.each([null, undefined, {} as AnyPropertyFilter])('falls back to "equals" for %s', (property) => {
+ expect(genericOperatorToHumanName(property)).toBe('equals')
+ })
+ })
+
+ describe('allOperatorsToHumanName', () => {
+ it.each([
+ // Cohort operators have no symbol prefix and must not be sliced
+ [PropertyOperator.In, 'in'],
+ [PropertyOperator.NotIn, 'not in'],
+ // Regular operators drop their 2-char symbol prefix
+ [PropertyOperator.Exact, 'equals'],
+ [PropertyOperator.IsNot, "doesn't equal"],
+ [PropertyOperator.GreaterThan, 'greater than'],
+ // Unknown / missing operator falls back to 'equals'
+ [undefined, 'equals'],
+ [null, 'equals'],
+ ])('maps %s to "%s"', (operator, expected) => {
+ expect(allOperatorsToHumanName(operator)).toBe(expected)
+ })
})
})
diff --git a/frontend/src/lib/components/DefinitionPopover/utils.ts b/frontend/src/lib/components/DefinitionPopover/utils.ts
index 56b202fbe23a..0929f068b728 100644
--- a/frontend/src/lib/components/DefinitionPopover/utils.ts
+++ b/frontend/src/lib/components/DefinitionPopover/utils.ts
@@ -1,4 +1,3 @@
-import { isPropertyFilterWithOperator } from 'lib/components/PropertyFilters/utils'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { allOperatorsMapping, genericOperatorMap } from 'lib/utils/operators'
@@ -15,8 +14,11 @@ export function operatorToHumanName(operator?: string): string {
}
export function genericOperatorToHumanName(property?: AnyPropertyFilter | null): string {
- if (isPropertyFilterWithOperator(property) && property.operator && genericOperatorMap[property.operator]) {
- return genericOperatorMap[property.operator].slice(2)
+ // Legacy action step properties have no `type`, so isPropertyFilterWithOperator would reject them
+ // and collapse every operator to "equals" — read the operator directly instead.
+ const operator = property && 'operator' in property ? property.operator : undefined
+ if (operator && genericOperatorMap[operator]) {
+ return genericOperatorMap[operator].slice(2)
}
return 'equals'
}