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(surveys): remove gte and lte from event trigger filters (#113357)

Ben Leae7890d1a86d3
diff --git a/docs/published/docs/surveys/sdk-feature-support.mdx b/docs/published/docs/surveys/sdk-feature-support.mdx
index 255b92f1a7ef..f5af5abe0e3a 100644
--- a/docs/published/docs/surveys/sdk-feature-support.mdx
+++ b/docs/published/docs/surveys/sdk-feature-support.mdx
@@ -24,6 +24,7 @@ For setup instructions, see the [installation guides](/docs/surveys/installation
| Auto-submit on selection | <IconCheck className="w-4 h-4 inline text-green" /> 1.244.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 4.26.0+ | <a href="https://github.com/PostHog/posthog-ios/issues/448"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-android/issues/391"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-flutter/issues/262"><IconWrench className="w-4 h-4 inline text-muted" /></a> |
| Link to specific feature flag variant | <IconCheck className="w-4 h-4 inline text-green" /> 1.259.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 4.4.0+ | <a href="https://github.com/PostHog/posthog-ios/issues/445"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-android/issues/388"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-flutter/issues/259"><IconWrench className="w-4 h-4 inline text-muted" /></a> |
| Event trigger property filters | <IconCheck className="w-4 h-4 inline text-green" /> 1.268.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 4.16.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 3.47.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 3.38.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 5.20.0+ |
+| Event filters using ≥ or ≤ | <IconX className="w-4 h-4 inline text-red" /> | <IconX className="w-4 h-4 inline text-red" /> | <IconX className="w-4 h-4 inline text-red" /> | <IconX className="w-4 h-4 inline text-red" /> | <IconX className="w-4 h-4 inline text-red" /> |
| Cancellation events | <IconCheck className="w-4 h-4 inline text-green" /> 1.299.0+ | <a href="https://github.com/PostHog/posthog-js/issues/2964"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-ios/issues/450"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-android/issues/393"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-flutter/issues/264"><IconWrench className="w-4 h-4 inline text-muted" /></a> |
| Targeting with actions | <IconCheck className="w-4 h-4 inline text-green" /> 1.301.0+ | <a href="https://github.com/PostHog/posthog-js/issues/2965"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-ios/issues/451"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-android/issues/394"><IconWrench className="w-4 h-4 inline text-muted" /></a> | <a href="https://github.com/PostHog/posthog-flutter/issues/265"><IconWrench className="w-4 h-4 inline text-muted" /></a> |
| Styling input appearance | <IconCheck className="w-4 h-4 inline text-green" /> 1.300.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 4.15.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 3.38.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 3.49.0+ | <IconCheck className="w-4 h-4 inline text-green" /> 5.13.0+ |
diff --git a/frontend/src/scenes/surveys/SurveyEventTrigger.tsx b/frontend/src/scenes/surveys/SurveyEventTrigger.tsx
index 320cd70a63c1..e444149975f4 100644
--- a/frontend/src/scenes/surveys/SurveyEventTrigger.tsx
+++ b/frontend/src/scenes/surveys/SurveyEventTrigger.tsx
@@ -22,8 +22,8 @@ import {
import { AddEventButton } from './AddEventButton'
import { surveyLogic } from './surveyLogic'
-// Only include operators supported by the SDK's property matching system
-// Exclude is_set and is_not_set as they're not supported
+// Only include operators that the survey property matcher supports in every SDK. The SDKs treat any other
+// operator (for example gte, lte, is_set, or is_not_set) as a filter that never matches, so the survey never shows.
export const SUPPORTED_OPERATORS: PropertyOperator[] = [
'exact',
'is_not',
@@ -32,9 +32,7 @@ export const SUPPORTED_OPERATORS: PropertyOperator[] = [
'regex',
'not_regex',
'gt',
- 'gte',
'lt',
- 'lte',
] as PropertyOperator[]
export function convertPropertyFiltersToArray(
diff --git a/frontend/src/scenes/surveys/surveyVersionRequirements.test.ts b/frontend/src/scenes/surveys/surveyVersionRequirements.test.ts
index 00550a50787e..ebd156aab662 100644
--- a/frontend/src/scenes/surveys/surveyVersionRequirements.test.ts
+++ b/frontend/src/scenes/surveys/surveyVersionRequirements.test.ts
@@ -1,6 +1,6 @@
-import { Survey } from '~/types'
+import { Survey, SurveyEventsWithProperties } from '~/types'
-import { SURVEY_SDK_REQUIREMENTS, SurveySdkType } from './surveyVersionRequirements'
+import { SURVEY_SDK_REQUIREMENTS, SurveySdkType, getSurveyWarnings } from './surveyVersionRequirements'
const ALL_SDK_TYPES: SurveySdkType[] = [
'posthog-js',
@@ -24,6 +24,22 @@ describe('SURVEY_SDK_REQUIREMENTS', () => {
}
)
+ it.each([
+ { field: 'events', operator: 'gte', warns: true },
+ { field: 'cancelEvents', operator: 'lte', warns: true },
+ { field: 'events', operator: 'gt', warns: false },
+ ] as const)('warns about $operator filters on $field: $warns', ({ field, operator, warns }) => {
+ const triggerEvent = {
+ name: 'checkout completed',
+ propertyFilters: { order_total: { values: ['100'], operator } },
+ } as unknown as SurveyEventsWithProperties
+ const survey = { questions: [], conditions: { [field]: { values: [triggerEvent] } } } as unknown as Survey
+
+ const features = getSurveyWarnings(survey, { 'posthog-js': '1.400.0' }).map((w) => w.feature)
+
+ expect(features.includes('Event filters using ≥ or ≤')).toBe(warns)
+ })
+
it.each([
['an intro that renders', { displayIntroScreen: true, introScreenHeader: 'Welcome' }, true],
['an intro with no header or description', { displayIntroScreen: true }, false],
diff --git a/frontend/src/scenes/surveys/surveyVersionRequirements.ts b/frontend/src/scenes/surveys/surveyVersionRequirements.ts
index 4a2a7031e863..8ef46059b79d 100644
--- a/frontend/src/scenes/surveys/surveyVersionRequirements.ts
+++ b/frontend/src/scenes/surveys/surveyVersionRequirements.ts
@@ -218,6 +218,24 @@ export const SURVEY_SDK_REQUIREMENTS: SurveyFeatureRequirement[] = [
(s.conditions?.events?.values?.length ?? 0) > 0 &&
!!s.conditions?.events?.values?.some((e) => Object.keys(e.propertyFilters ?? {}).length > 0),
},
+ {
+ // No SDK survey matcher implements gte or lte, so a stored filter with either operator never matches.
+ feature: 'Event filters using ≥ or ≤',
+ sdkVersions: {},
+ unsupportedSdks: [
+ { sdk: 'posthog-js', issue: false },
+ { sdk: 'posthog-react-native', issue: false },
+ { sdk: 'posthog-ios', issue: false },
+ { sdk: 'posthog-android', issue: false },
+ { sdk: 'posthog_flutter', issue: false },
+ ],
+ check: (s) =>
+ [...(s.conditions?.events?.values ?? []), ...(s.conditions?.cancelEvents?.values ?? [])].some((e) =>
+ Object.values(e.propertyFilters ?? {}).some((filter) =>
+ (['gte', 'lte'] as string[]).includes(filter.operator)
+ )
+ ),
+ },
{
feature: 'Cancellation events',
sdkVersions: { 'posthog-js': '1.299.0' },