: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
feat(actions): support multiple screen names for matches exactly (#68983)
Matt Pua3d1a08e4c841
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 08c5e6c7cb92..94a18623fc02 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5261,9 +5261,9 @@ snapshots:scenes-app-data-management-actions--new-action--light:hash: v1.k794b7964.63452e5f18d10890adc95905388cc73a7139ebeb10c19eeace75a7da0e2debec.qpdIi0uow-kdQvBB0FNLFB-yXrl-xNgCWFuohl_l3z0scenes-app-data-management-actions--screen-action--dark:- hash: v1.k794b7964.5a59039eb5a488be53ba421b3f3c4c27e898f7072b6cedd5c7beaa8a238694c8.zA1HLvprSld1TbMs_m-mxq7sbNicWq2aygPklmdrw8Q+ hash: v1.k794b7964.a7d45c674c8c2c5b4a953da0a6edc035c483190477dae0d543c1b6b2b1a6cf85.eslQPw_7Y7zBCu9G7OoVbBuAzSA-bqUoje0pbZUki6Qscenes-app-data-management-actions--screen-action--light:- hash: v1.k794b7964.1c99389ca59324c16f66666552d5e80ec1d4e90d483399d3e05a433ef0426d0d.baRzYMczFsgzl7QcNhMSmI76jh8Dem5j7Jc4kIiulCc+ hash: v1.k794b7964.39d810c27996398aae992eb54ef4e84e23c3f53c4812346e1931563a4c1ee0cf._NpDegv8HN4WQn2IpzgYw9J0f6Lc1kTMckTXMi6llq0scenes-app-data-management-comments--comments--dark:hash: v1.k794b7964.e21cefe38419260e81d5eda7e10656d10d1eff95ee3c0445c8a0b9be07b79086.PePuIy_3nZEV8tVawLvzhj85hMz3DwVUBpP0ggnCqeAscenes-app-data-management-comments--comments--light:diff --git a/products/actions/frontend/components/ActionStep.tsx b/products/actions/frontend/components/ActionStep.tsxindex 0bccc6be913e..7006337f4bea 100644--- a/products/actions/frontend/components/ActionStep.tsx+++ b/products/actions/frontend/components/ActionStep.tsx@@ -1,7 +1,8 @@import { useValues } from 'kea'+import { useState } from 'react'import { IconX } from '@posthog/icons'-import { LemonButton, LemonInput, LemonSegmentedButton, Link } from '@posthog/lemon-ui'+import { LemonButton, LemonInput, LemonInputSelect, LemonSegmentedButton, Link } from '@posthog/lemon-ui'import { AuthorizedUrlList } from 'lib/components/AuthorizedUrlList/AuthorizedUrlList'import { AuthorizedUrlListType } from 'lib/components/AuthorizedUrlList/authorizedUrlListLogic'@@ -407,7 +408,8 @@ function TypeSwitcher({},{value: '$screen',- label: 'Screen',+ label: 'Mobile screen',+ tooltip: 'Screen views from mobile apps ($screen events sent by the mobile SDKs)','data-attr': 'action-type-screen',disabledReason,},@@ -435,21 +437,35 @@ function ScreenNameField({disabledReason?: string}): JSX.Element {const existingFilter = step.properties?.find(isScreenNameFilter)- const screenName = (existingFilter && 'value' in existingFilter ? (existingFilter.value as string) : '') ?? ''- const operator: ScreenNameMatching =- existingFilter && 'operator' in existingFilter- ? (existingFilter.operator as ScreenNameMatching)- : PropertyOperator.IContains+ const rawValue = existingFilter && 'value' in existingFilter ? existingFilter.value : undefined+ const screenNames: string[] =+ rawValue == null || rawValue === '' ? [] : Array.isArray(rawValue) ? rawValue.map(String) : [String(rawValue)]+ const filterOperator: ScreenNameMatching | undefined =+ existingFilter && 'operator' in existingFilter ? (existingFilter.operator as ScreenNameMatching) : undefined- const setFilter = (name: string, op: ScreenNameMatching): void => {+ // Keep the selected operator even when the value is empty (an empty filter isn't persisted, so we can't+ // read it back off the step) — otherwise picking "matches exactly" before typing would snap back to the default.+ // Only seeded once: safe because this component remounts when the step's event type changes away from $screen.+ const [operator, setOperator] = useState<ScreenNameMatching>(filterOperator ?? PropertyOperator.IContains)++ // Only "matches exactly" supports multiple values (translated to an IN() query); the rest take a single string+ const isMulti = operator === PropertyOperator.Exact+ const singleValue = screenNames[0] ?? ''++ const setFilter = (value: string | string[], op: ScreenNameMatching): void => {const otherProperties = (step.properties || []).filter((p) => !isScreenNameFilter(p))+ const isEmpty = Array.isArray(value) ? value.length === 0 : !value+ if (isEmpty) {+ sendStep({ ...step, properties: otherProperties })+ return+ }sendStep({...step,properties: [...otherProperties,{key: SCREEN_NAME_PROPERTY,- value: name,+ value,operator: op as PropertyOperator,type: PropertyFilterType.Event,},@@ -457,17 +473,21 @@ function ScreenNameField({})}- const clearFilter = (): void => {- sendStep({ ...step, properties: (step.properties || []).filter((p) => !isScreenNameFilter(p)) })+ const handleOperatorChange = (op: ScreenNameMatching): void => {+ setOperator(op)+ const nextValue = op === PropertyOperator.Exact ? screenNames : singleValue+ setFilter(nextValue, op)}return (<div className="deprecated-space-y-1"><div className="flex flex-wrap gap-1">- <LemonLabel>Screen name</LemonLabel>+ <LemonLabel info="Matches the $screen_name property on $screen events sent by the mobile SDKs (iOS, Android, React Native, Flutter). This is the mobile equivalent of a pageview URL.">+ Screen name+ </LemonLabel><div className="flex flex-1 justify-end"><LemonSegmentedButton- onChange={(value) => setFilter(screenName, value as ScreenNameMatching)}+ onChange={(value) => handleOperatorChange(value as ScreenNameMatching)}value={operator}options={Object.entries(SCREEN_NAME_MATCHING_LABEL).map(([value, label]) => ({value,@@ -478,14 +498,26 @@ function ScreenNameField({/></div></div>- <LemonInput- data-attr="edit-action-screen-name-input"- allowClear- onChange={(val) => (val ? setFilter(val, operator) : clearFilter())}- value={screenName}- placeholder="e.g. HomeScreen, Settings"- disabledReason={disabledReason}- />+ {isMulti ? (+ <LemonInputSelect+ data-attr="edit-action-screen-name-input"+ mode="multiple"+ allowCustomValues+ value={screenNames}+ onChange={(vals) => setFilter(vals, operator)}+ placeholder="e.g. HomeScreen, Settings"+ disabled={!!disabledReason}+ />+ ) : (+ <LemonInput+ data-attr="edit-action-screen-name-input"+ allowClear+ onChange={(val) => setFilter(val, operator)}+ value={singleValue}+ placeholder="e.g. HomeScreen"+ disabledReason={disabledReason}+ />+ )}</div>)}diff --git a/products/actions/frontend/components/ActionsTable.tsx b/products/actions/frontend/components/ActionsTable.tsxindex 3c98365671eb..c8e025a66d43 100644--- a/products/actions/frontend/components/ActionsTable.tsx+++ b/products/actions/frontend/components/ActionsTable.tsx@@ -150,11 +150,15 @@ export function ActionsTable(): JSX.Element {return (<>Screen name {SCREEN_NAME_MATCHING_LABEL[operator]}{' '}- <strong>{String(screenFilter.value)}</strong>+ <strong>+ {Array.isArray(screenFilter.value)+ ? screenFilter.value.join(', ')+ : String(screenFilter.value)}+ </strong></>)}- return 'Screen'+ return 'Mobile screen'}case '':case null: