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(workflows): Wire up wait-until-event handler and UI (#59299)

Daniel Marchuk60e1fe1d4377
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 4107f46d9733..632c06d4e8ef 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -523,6 +523,7 @@ export const FEATURE_FLAGS = {
WORKFLOWS_PERSON_TIMEZONE: 'workflows-person-timezone', // owner: #team-workflows
WORKFLOWS_PUSH_NOTIFICATIONS: 'workflows-push-notifications', // owner: @Odin #team-workflows
WORKFLOWS_RECURRING_SCHEDULES: 'workflows-recurring-schedules', // owner: #team-workflows
+ WORKFLOWS_WAIT_UNTIL_EVENT: 'workflows-wait-until-event', // owner: #team-workflows
} as const
export type FeatureFlagLookupKey = keyof typeof FEATURE_FLAGS
export type FeatureFlagKey = (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS]
diff --git a/nodejs/src/cdp/services/hogflows/actions/conditional_branch.test.ts b/nodejs/src/cdp/services/hogflows/actions/conditional_branch.test.ts
index c9731b752432..82b83b4316a9 100644
--- a/nodejs/src/cdp/services/hogflows/actions/conditional_branch.test.ts
+++ b/nodejs/src/cdp/services/hogflows/actions/conditional_branch.test.ts
@@ -4,10 +4,11 @@ import { FixtureHogFlowBuilder } from '~/cdp/_tests/builders/hogflow.builder'
import { HOG_FILTERS_EXAMPLES } from '~/cdp/_tests/examples'
import { createExampleHogFlowInvocation } from '~/cdp/_tests/fixtures-hogflows'
import { CyclotronJobInvocationHogFlow } from '~/cdp/types'
+import { createInvocationResult } from '~/cdp/utils/invocation-utils'
import { HogFlow, HogFlowAction } from '~/schema/hogflow'
import { findActionById, findActionByType } from '../hogflow-utils'
-import { checkConditions } from './conditional_branch'
+import { ConditionalBranchHandler, checkConditions } from './conditional_branch'
describe('action.conditional_branch', () => {
let invocation: CyclotronJobInvocationHogFlow
@@ -158,4 +159,79 @@ describe('action.conditional_branch', () => {
})
})
})
+
+ describe('wait_until_condition eventMatched short-circuit', () => {
+ let waitInvocation: CyclotronJobInvocationHogFlow
+ let waitAction: Extract<HogFlowAction, { type: 'wait_until_condition' }>
+ let handler: ConditionalBranchHandler
+
+ beforeEach(() => {
+ const waitFlow = new FixtureHogFlowBuilder()
+ .withWorkflow({
+ actions: {
+ wait_until_condition: {
+ type: 'wait_until_condition',
+ config: {
+ condition: {
+ filters: HOG_FILTERS_EXAMPLES.elements_text_filter.filters, // no match
+ },
+ max_wait_duration: '10m',
+ },
+ },
+ matched_target: {
+ type: 'delay',
+ config: { delay_duration: '2h' },
+ },
+ },
+ edges: [
+ {
+ from: 'wait_until_condition',
+ to: 'matched_target',
+ type: 'branch',
+ index: 0,
+ },
+ ],
+ })
+ .build()
+
+ waitAction = findActionByType(waitFlow, 'wait_until_condition')!
+ waitInvocation = createExampleHogFlowInvocation(waitFlow)
+ waitInvocation.state.currentAction = {
+ id: waitAction.id,
+ startedAtTimestamp: DateTime.utc().toMillis(),
+ }
+ handler = new ConditionalBranchHandler()
+ })
+
+ it('advances to the matched branch and clears eventMatched', async () => {
+ waitInvocation.state.currentAction!.eventMatched = true
+ waitInvocation.state.currentAction!.eventMatchedEvent = 'subscription created'
+ waitInvocation.state.currentAction!.eventMatchedEventUuid = 'evt-uuid'
+
+ const result = await handler.execute({
+ invocation: waitInvocation,
+ action: waitAction,
+ result: createInvocationResult(waitInvocation),
+ })
+
+ expect(result.nextAction).toEqual(findActionById(waitInvocation.hogFlow, 'matched_target'))
+ expect(result.result).toEqual({ eventMatched: true })
+ // All wake markers are cleared so a later timeout fire isn't misread as an event wake.
+ expect(waitInvocation.state.currentAction!.eventMatched).toBe(false)
+ expect(waitInvocation.state.currentAction!.eventMatchedEvent).toBeUndefined()
+ expect(waitInvocation.state.currentAction!.eventMatchedEventUuid).toBeUndefined()
+ })
+
+ it('falls through to condition evaluation when eventMatched is not set', async () => {
+ const result = await handler.execute({
+ invocation: waitInvocation,
+ action: waitAction,
+ result: createInvocationResult(waitInvocation),
+ })
+
+ // Condition does not match, so the step reschedules itself rather than advancing.
+ expect(result.scheduledAt).toBeDefined()
+ expect(result.nextAction).toBeUndefined()
+ })
+ })
})
diff --git a/nodejs/src/cdp/services/hogflows/actions/conditional_branch.ts b/nodejs/src/cdp/services/hogflows/actions/conditional_branch.ts
index 8a3183d8d784..d715f301cbbb 100644
--- a/nodejs/src/cdp/services/hogflows/actions/conditional_branch.ts
+++ b/nodejs/src/cdp/services/hogflows/actions/conditional_branch.ts
@@ -17,6 +17,19 @@ export class ConditionalBranchHandler implements ActionHandler {
}: ActionHandlerOptions<
Extract<HogFlowAction, { type: 'conditional_branch' | 'wait_until_condition' }>
>): Promise<ActionHandlerResult> {
+ // The subscription matcher sets eventMatched when an incoming event matched this
+ // step's wait condition. Honor it as a forced match and advance immediately,
+ // rather than re-evaluating the stored condition against the original event.
+ if (action.type === 'wait_until_condition' && invocation.state?.currentAction?.eventMatched === true) {
+ invocation.state.currentAction.eventMatched = false
+ invocation.state.currentAction.eventMatchedEvent = undefined
+ invocation.state.currentAction.eventMatchedEventUuid = undefined
+ return {
+ nextAction: findNextAction(invocation.hogFlow, action.id, 0),
+ result: { eventMatched: true },
+ }
+ }
+
const conditionResult = await checkConditions(
invocation,
action.type === 'conditional_branch'
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
index f334cc510f19..7765110f31c0 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
@@ -474,6 +474,32 @@ describe('Hogflow Executor', () => {
'Workflow completed',
])
})
+
+ it('surfaces the matcher wake event in the resume log', async () => {
+ const invocation = createExampleHogFlowInvocation(hogFlow, {
+ event: {
+ ...createHogExecutionGlobals().event,
+ properties: { name: 'Debug User' },
+ timestamp: '2026-01-30T20:20:20.200Z',
+ },
+ })
+ // The subscription matcher woke this job: it set eventMatched plus the name and
+ // uuid of the matching event. The resume log must surface that exact event as a
+ // linkable [Event:uuid|name] token, not just echo the original trigger event.
+ invocation.state.currentAction = {
+ id: 'function_id_1',
+ startedAtTimestamp: DateTime.now().toMillis(),
+ eventMatched: true,
+ eventMatchedEvent: 'subscription created',
+ eventMatchedEventUuid: 'wake-uuid-123',
+ }
+
+ const result = await executor.execute(invocation)
+
+ expect(result.logs[0].message).toBe(
+ 'Resuming workflow execution at [Action:function_id_1] on [Event:uuid|test|2026-01-30T20:20:20.200Z] (woken by [Event:wake-uuid-123|subscription created])'
+ )
+ })
})
})
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts
index 53b15f1f162c..b1cfeb49da9e 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts
@@ -633,10 +633,22 @@ export class HogFlowExecutorService {
: ''
}
- const triggeredByEvent = hasAssociatedEvent
+ let triggeredByEvent = hasAssociatedEvent
? ` on [Event:${invocation.state.event?.uuid}|${invocation.state.event?.event?.replaceAll('|', '')}|${invocation.state.event?.timestamp}]`
: ''
+ // When the subscription matcher woke this job, surface the wake event rather
+ // than only echoing the trigger event - they are usually different. Use the same
+ // [Event:uuid|name] token as the trigger line so the logs view can link to the
+ // exact event; fall back to the bare name for jobs parked before the uuid was stored.
+ const wakeEvent = invocation.state.currentAction?.eventMatchedEvent
+ const wakeEventUuid = invocation.state.currentAction?.eventMatchedEventUuid
+ if (hasCurrentAction && invocation.state.currentAction?.eventMatched && wakeEvent) {
+ triggeredByEvent += wakeEventUuid
+ ? ` (woken by [Event:${wakeEventUuid}|${wakeEvent.replaceAll('|', '')}])`
+ : ` (woken by event: ${wakeEvent.replaceAll('|', '')})`
+ }
+
return {
level: 'info',
message: `${hasCurrentAction ? 'Resuming' : 'Starting'} ${isBatchWorkflow ? 'batch ' : ''}workflow execution at ${currentAction}${triggeredForActor}${triggeredByEvent}`,
diff --git a/nodejs/src/cdp/workflows-e2e.test.ts b/nodejs/src/cdp/workflows-e2e.test.ts
index 2578594287ad..1539070807aa 100644
--- a/nodejs/src/cdp/workflows-e2e.test.ts
+++ b/nodejs/src/cdp/workflows-e2e.test.ts
@@ -37,6 +37,7 @@ import { createHogExecutionGlobals, insertHogFunctionTemplate } from './_tests/f
import { insertHogFlow } from './_tests/fixtures-hogflows'
import { CdpCyclotronWorkerHogFlow } from './consumers/cdp-cyclotron-worker-hogflow.consumer'
import { CdpEventsConsumer } from './consumers/cdp-events.consumer'
+import { CdpHogflowSubscriptionMatcherConsumer } from './consumers/cdp-hogflow-subscription-matcher.consumer'
import { CyclotronJobQueueKafka } from './services/job-queue/job-queue-kafka'
import { CyclotronJobQueuePostgres } from './services/job-queue/job-queue-postgres'
import { CyclotronJobQueuePostgresV2 } from './services/job-queue/job-queue-postgres-v2'
@@ -66,6 +67,7 @@ describe.each(['postgres-v2' as const, 'postgres' as const])('Workflows E2E (%s)
let team: Team
let globals: HogFunctionInvocationGlobals
let cyclotronPool: Pool
+ let deps: ReturnType<typeof createCdpConsumerDeps>
beforeAll(() => {
cyclotronPool = new Pool({
@@ -113,7 +115,7 @@ describe.each(['postgres-v2' as const, 'postgres' as const])('Workflows E2E (%s)
],
})
- const deps = createCdpConsumerDeps(hub, kafkaProducer)
+ deps = createCdpConsumerDeps(hub, kafkaProducer)
const kafkaQueue = new CyclotronJobQueueKafka(hub.KAFKA_CLIENT_RACK, hub, hub.CONSUMER_BATCH_SIZE)
@@ -267,6 +269,14 @@ describe.each(['postgres-v2' as const, 'postgres' as const])('Workflows E2E (%s)
const exitAction = () => ({ type: 'exit' as const, config: {} })
+ // Mirrors what HogFlowSerializer compiles for {events: [{id: <name>}]}: a single
+ // equality check on the `event` global. The matcher is fail-closed when bytecode
+ // is absent, so fixtures must supply it the same way Django would on save.
+ const eventNameBytecode = (eventName: string): any[] => ['_H', 1, 32, eventName, 32, 'event', 1, 1, 11]
+ const eventNameFilter = (eventName: string) => ({
+ filters: { events: [{ id: eventName }], bytecode: eventNameBytecode(eventName) },
+ })
+
describe('simple workflow: trigger → function → exit', () => {
beforeEach(async () => {
await createWorkflow({
@@ -589,6 +599,128 @@ describe.each(['postgres-v2' as const, 'postgres' as const])('Workflows E2E (%s)
})
})
+ // The matcher reads parked jobs via `CYCLOTRON_NODE_DATABASE_URL` (the postgres-v2 backend).
+ // In legacy `postgres` mode the worker parks the job in a different DB the matcher cannot see,
+ // so wakes are postgres-v2-only.
+ const describeMatcher = mode === 'postgres-v2' ? describe : describe.skip
+ describeMatcher('wait_until_condition: subscription matcher wakes parked jobs', () => {
+ let matcher: CdpHogflowSubscriptionMatcherConsumer
+
+ // trigger → wait_condition → (matched branch | timeout continue) → exit
+ const createWaitUntilWorkflow = (waitConfig: Record<string, any>): Promise<string> =>
+ createWorkflow({
+ actions: {
+ trigger: trigger(),
+ wait_condition: { type: 'wait_until_condition', config: waitConfig },
+ function_matched: fetchAction('https://example.com/condition-matched'),
+ function_timeout: fetchAction('https://example.com/timed-out'),
+ exit: exitAction(),
+ },
+ edges: [
+ { from: 'trigger', to: 'wait_condition', type: 'continue' },
+ { from: 'wait_condition', to: 'function_matched', type: 'branch', index: 0 },
+ { from: 'wait_condition', to: 'function_timeout', type: 'continue' },
+ { from: 'function_matched', to: 'exit', type: 'continue' },
+ { from: 'function_timeout', to: 'exit', type: 'continue' },
+ ],
+ })
+
+ // The job is parked when it is available with a scheduled time in the future.
+ const expectParked = async (): Promise<void> => {
+ await waitForExpect(async () => {
+ const jobs = await queryCyclotronJobs()
+ expect(jobs.some((j: any) => j.status === 'available' && new Date(j.scheduled) > new Date())).toBe(true)
+ }, 5000)
+ expect(mockFetch).not.toHaveBeenCalled()
+ }
+
+ beforeEach(() => {
+ matcher = new CdpHogflowSubscriptionMatcherConsumer({ ...hub }, deps)
+ })
+
+ afterEach(async () => {
+ await matcher?.stop().catch(() => {})
+ })
+
+ it('wakes a parked job and takes the matched branch when a subscribed event fires', async () => {
+ await createWaitUntilWorkflow({
+ // Property condition never matches the trigger event, so the job parks.
+ condition: { filters: HOG_FILTERS_EXAMPLES.elements_text_filter.filters },
+ events: [eventNameFilter('wakeup_event')],
+ max_wait_duration: '5m',
+ })
+ await triggerWorkflow(createGlobals())
+ await expectParked()
+
+ // A subscribed event fires for this person — the matcher wakes the job.
+ await matcher.processBatch([createGlobals({ event: 'wakeup_event' })])
+
+ await waitForExpect(() => {
+ expect(mockFetch).toHaveBeenCalledTimes(1)
+ }, 10000)
+ expect(mockFetch).toHaveBeenCalledWith('https://example.com/condition-matched', expect.anything())
+ })
+
+ it('wakes a parked job when a later event satisfies the property condition', async () => {
+ await createWaitUntilWorkflow({
+ // No events list — only a property-based condition. The matcher evaluates the
+ // condition against every incoming event, making property waits event-driven.
+ condition: { filters: HOG_FILTERS_EXAMPLES.pageview_or_autocapture_filter.filters },
+ max_wait_duration: '5m',
+ })
+ // Trigger with an event that does not satisfy the condition, so the job parks.
+ await triggerWorkflow(createGlobals({ event: 'custom_trigger', properties: {} }))
+ await expectParked()
+
+ // A later $pageview with a posthog URL satisfies the property condition.
+ await matcher.processBatch([
+ createGlobals({ event: '$pageview', properties: { $current_url: 'https://posthog.com' } }),
+ ])
+
+ await waitForExpect(() => {
+ expect(mockFetch).toHaveBeenCalledTimes(1)
+ }, 10000)
+ expect(mockFetch).toHaveBeenCalledWith('https://example.com/condition-matched', expect.anything())
+ })
+
+ it('takes the timeout branch when neither events nor the condition match before max_wait', async () => {
+ await createWaitUntilWorkflow({
+ condition: { filters: HOG_FILTERS_EXAMPLES.elements_text_filter.filters },
+ events: [eventNameFilter('never_fires')],
+ max_wait_duration: '2s',
+ })
+ await triggerWorkflow(createGlobals())
+
+ // An unrelated event passes through the matcher but must not wake the job.
+ await matcher.processBatch([createGlobals({ event: 'some_other_event' })])
+
+ // After max_wait expires the job advances down the continue (timeout) branch.
+ await waitForExpect(() => {
+ expect(mockFetch).toHaveBeenCalledTimes(1)
+ }, 15000)
+ expect(mockFetch).toHaveBeenCalledWith('https://example.com/timed-out', expect.anything())
+ })
+
+ it('leaves the job parked when an event matches neither the events nor the condition', async () => {
+ await createWaitUntilWorkflow({
+ condition: { filters: HOG_FILTERS_EXAMPLES.elements_text_filter.filters },
+ events: [eventNameFilter('wakeup_event')],
+ max_wait_duration: '5m',
+ })
+ await triggerWorkflow(createGlobals())
+ await expectParked()
+
+ // An unrelated event must not wake the job.
+ await matcher.processBatch([createGlobals({ event: 'some_other_event' })])
+
+ // Give the worker room to (incorrectly) pick the job up — it must not.
+ await new Promise((resolve) => setTimeout(resolve, 1000))
+ const jobs = await queryCyclotronJobs()
+ expect(jobs.every((j: any) => j.status === 'available' && new Date(j.scheduled) > new Date())).toBe(true)
+ expect(mockFetch).not.toHaveBeenCalled()
+ })
+ })
+
describe('wait_until_time_window: window in the future', () => {
beforeEach(async () => {
await createWorkflow({
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx
index bc53ed583cd4..499b88d373f7 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanelBuild.tsx
@@ -62,8 +62,8 @@ export const DELAY_NODES_TO_SHOW: CreateActionType[] = [
},
{
type: 'wait_until_time_window',
- name: 'Wait until window',
- description: 'Wait until a specified time window.',
+ name: 'Time window',
+ description: 'Wait for the next allowed time window before continuing.',
config: {
timezone: null,
day: 'any',
@@ -72,8 +72,8 @@ export const DELAY_NODES_TO_SHOW: CreateActionType[] = [
},
{
type: 'wait_until_condition',
- name: 'Wait until condition',
- description: 'Wait until a condition is met or a duration has passed.',
+ name: 'Wait until',
+ description: 'Wait until a matching event fires or a condition is met, up to a maximum duration.',
branchEdges: 1,
config: {
condition: { filters: null },
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx b/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx
index bff2e996306d..aef0e49fe7b6 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx
@@ -31,6 +31,7 @@ import {
import { CodeSnippet } from 'lib/components/CodeSnippet'
import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import { FEATURE_FLAGS } from 'lib/constants'
import { IconAdsClick } from 'lib/lemon-ui/icons'
import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonRadio } from 'lib/lemon-ui/LemonRadio'
@@ -781,6 +782,10 @@ function FrequencySection(): JSX.Element {
function ConversionGoalSection(): JSX.Element {
const { setWorkflowValue } = useActions(workflowLogic)
const { workflow } = useValues(workflowLogic)
+ const { featureFlags } = useValues(featureFlagLogic)
+
+ const waitUntilEventEnabled = !!featureFlags[FEATURE_FLAGS.WORKFLOWS_WAIT_UNTIL_EVENT]
+ const conversionEventFilters = workflow.conversion?.events?.[0]?.filters ?? {}
return (
<div className="flex flex-col py-2 w-full">
@@ -812,21 +817,36 @@ function ConversionGoalSection(): JSX.Element {
/>
</div>
- <div className="flex flex-col gap-1 items-start">
+ <div className="flex flex-col gap-1 items-start w-full">
<LemonLabel>
Detect conversion from events
- <LemonTag>Coming soon</LemonTag>
+ {!waitUntilEventEnabled && <LemonTag>Coming soon</LemonTag>}
</LemonLabel>
- <LemonButton
- type="secondary"
- icon={<IconPlusSmall />}
- onClick={() => {
- posthog.capture('workflows workflow event conversion clicked')
- lemonToast.info('Event targeting coming soon!')
- }}
- >
- Add event conversion
- </LemonButton>
+ {waitUntilEventEnabled ? (
+ <HogFlowEventFilters
+ filtersKey="workflow-conversion-events"
+ filters={conversionEventFilters}
+ setFilters={(newFilters) =>
+ setWorkflowValue('conversion', {
+ ...workflow.conversion,
+ events: newFilters ? [{ filters: newFilters }] : undefined,
+ })
+ }
+ typeKey="workflow-conversion-event"
+ buttonCopy="Add event"
+ />
+ ) : (
+ <LemonButton
+ type="secondary"
+ icon={<IconPlusSmall />}
+ onClick={() => {
+ posthog.capture('workflows workflow event conversion clicked')
+ lemonToast.info('Event targeting coming soon!')
+ }}
+ >
+ Add event conversion
+ </LemonButton>
+ )}
</div>
</div>
</div>
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/StepWaitUntilCondition.tsx b/products/workflows/frontend/Workflows/hogflows/steps/StepWaitUntilCondition.tsx
index 33855ea1d335..6243a6247d1f 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/StepWaitUntilCondition.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/StepWaitUntilCondition.tsx
@@ -1,12 +1,15 @@
import { Node } from '@xyflow/react'
-import { useActions } from 'kea'
+import { useActions, useValues } from 'kea'
-import { LemonLabel } from '@posthog/lemon-ui'
+import { IconCursor, IconPerson } from '@posthog/icons'
+import { LemonDivider, LemonLabel } from '@posthog/lemon-ui'
+import { FEATURE_FLAGS } from 'lib/constants'
import { LemonInput } from 'lib/lemon-ui/LemonInput'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { workflowLogic } from '../../workflowLogic'
-import { HogFlowPropertyFilters } from '../filters/HogFlowFilters'
+import { HogFlowEventFilters, HogFlowPropertyFilters } from '../filters/HogFlowFilters'
import { HogFlowAction } from '../types'
import { HogFlowDuration } from './components/HogFlowDuration'
import { StepSchemaErrors } from './components/StepSchemaErrors'
@@ -18,20 +21,68 @@ export function StepWaitUntilConditionConfiguration({
node: Node<Extract<HogFlowAction, { type: 'wait_until_condition' }>>
}): JSX.Element {
const action = node.data
- const { condition, max_wait_duration } = action.config
+ const { condition, events, max_wait_duration } = action.config
const { partialSetWorkflowActionConfig } = useActions(workflowLogic)
+ const { featureFlags } = useValues(featureFlagLogic)
+
+ const waitUntilEventEnabled = !!featureFlags[FEATURE_FLAGS.WORKFLOWS_WAIT_UNTIL_EVENT]
const { localName: localConditionName, handleNameChange } = useDebouncedNameInput(condition, (updatedCondition) =>
partialSetWorkflowActionConfig(action.id, { condition: updatedCondition })
)
+ const eventFilters = events?.[0]?.filters ?? {}
+
return (
<>
<StepSchemaErrors />
- <div className="flex flex-col gap-1">
- <LemonLabel>Conditions to wait for</LemonLabel>
+ {waitUntilEventEnabled && (
+ <>
+ <div className="flex flex-col gap-3">
+ <span className="flex gap-1">
+ <IconCursor className="text-lg" />
+ <span className="text-md font-semibold">Events to wait for</span>
+ </span>
+ <span className="text-xs text-muted">
+ The workflow continues on the matched path when any of these events fire.
+ </span>
+ <HogFlowEventFilters
+ filtersKey={`wait-until-events-${action.id}`}
+ filters={eventFilters}
+ setFilters={(newFilters) =>
+ partialSetWorkflowActionConfig(action.id, {
+ events: newFilters ? [{ filters: newFilters }] : undefined,
+ })
+ }
+ typeKey="workflow-wait-until-event"
+ buttonCopy="Add event"
+ />
+ </div>
+
+ <div className="flex items-center gap-4 my-2">
+ <div className="flex-1 border-t border-border" />
+ <span className="text-xs text-tertiary uppercase tracking-wide">or</span>
+ <div className="flex-1 border-t border-border" />
+ </div>
+ </>
+ )}
+
+ <div className="flex flex-col gap-3">
+ {waitUntilEventEnabled ? (
+ <>
+ <span className="flex gap-1">
+ <IconPerson className="text-lg" />
+ <span className="text-md font-semibold">Property conditions</span>
+ </span>
+ <span className="text-xs text-muted">
+ The workflow continues when the person matches these properties.
+ </span>
+ </>
+ ) : (
+ <LemonLabel>Conditions to wait for</LemonLabel>
+ )}
<LemonInput
value={localConditionName || ''}
onChange={handleNameChange}
@@ -48,8 +99,10 @@ export function StepWaitUntilConditionConfiguration({
/>
</div>
+ <LemonDivider />
+
<div className="flex flex-col gap-1">
- <LemonLabel>Max time to wait for condition</LemonLabel>
+ <LemonLabel>Max time to wait</LemonLabel>
<HogFlowDuration
value={max_wait_duration}
onChange={(value) => {
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/types.ts b/products/workflows/frontend/Workflows/hogflows/steps/types.ts
index 6ffe2bae8104..390992c7d652 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/types.ts
+++ b/products/workflows/frontend/Workflows/hogflows/steps/types.ts
@@ -199,6 +199,14 @@ export const HogFlowActionSchema = z.discriminatedUnion('type', [
filters: ActionFiltersSchema.optional().nullable(),
name: z.string().optional(), // Custom name for the condition
}),
+ events: z
+ .array(
+ z.object({
+ filters: ActionFiltersSchema.optional().nullable(),
+ name: z.string().optional(),
+ })
+ )
+ .optional(),
max_wait_duration: z.string(),
}),
}),
diff --git a/products/workflows/frontend/Workflows/hogflows/types.ts b/products/workflows/frontend/Workflows/hogflows/types.ts
index 733d5c917c4e..a6f315e5ab29 100644
--- a/products/workflows/frontend/Workflows/hogflows/types.ts
+++ b/products/workflows/frontend/Workflows/hogflows/types.ts
@@ -36,6 +36,14 @@ export const HogFlowSchema = z.object({
.object({
window_minutes: z.number().nullable(),
filters: z.any(),
+ events: z
+ .array(
+ z.object({
+ filters: z.any().optional().nullable(),
+ name: z.string().optional(),
+ })
+ )
+ .optional(),
bytecode: z.array(z.union([z.string(), z.number()])).optional(), // Bytecode only present after save
})
.optional(),