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(workflows): link the waking event in hogflow resume logs (#62644)

Daniel Marchuk04d12e384209
diff --git a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts
index 8d8b2a742ae0..7543b10fb483 100644
--- a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts
+++ b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.test.ts
@@ -320,17 +320,18 @@ describe('CdpHogflowSubscriptionMatcherConsumer', () => {
matcher.updateRowCount = 1
matcher.setHogFlows({ 'flow-1': makeHogFlow({ id: 'flow-1' }) })
- await matcher.runWake([makeGlobals({})])
+ await matcher.runWake([
+ makeGlobals({ event: { ...makeGlobals({}).event, timestamp: '2026-01-30T21:00:00.000Z' } }),
+ ])
const update = matcher.calls.find((c) => c.sql.startsWith('UPDATE cyclotron_jobs'))
expect(update).not.toBeUndefined()
expect(update!.params[0]).toEqual(['job-1'])
const newState = parseJSON(update!.params[1][0].toString('utf-8')) as any
expect(newState.state.currentAction.eventMatched).toBe(true)
- // The matching event's name and UUID are persisted so the executor log and the
- // logs view can pinpoint exactly which event woke the step.
expect(newState.state.currentAction.eventMatchedEvent).toBe('wuc_subscribed')
expect(newState.state.currentAction.eventMatchedEventUuid).toBe('event-uuid')
+ expect(newState.state.currentAction.eventMatchedEventTimestamp).toBe('2026-01-30T21:00:00.000Z')
expect(newState.state.conversionMatched).toBeUndefined()
})
diff --git a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.ts b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.ts
index 6f4db0905494..4c5fe93c3330 100644
--- a/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.ts
+++ b/nodejs/src/cdp/consumers/cdp-hogflow-subscription-matcher.consumer.ts
@@ -60,10 +60,10 @@ type WakeRequest = {
id: string
stepMatched: boolean
conversionMatched: boolean
- // Name and UUID of the event that matched, so the executor's resume log can surface the
- // name and the logs view can link to the exact event.
+ // Name, UUID and timestamp of the matched event, so the resume log can name it and link to it.
eventName?: string
eventUuid?: string
+ eventTimestamp?: string
}
type FilterGlobals = ReturnType<typeof convertToHogFunctionFilterGlobal>
@@ -178,6 +178,7 @@ export class CdpHogflowSubscriptionMatcherConsumer<
let stepMatched = false
let stepMatchedEventName: string | undefined
let stepMatchedEventUuid: string | undefined
+ let stepMatchedEventTimestamp: string | undefined
let conversionMatched = false
for (const globals of candidateGlobals) {
const filterGlobals = filterGlobalsFor(globals)
@@ -186,6 +187,7 @@ export class CdpHogflowSubscriptionMatcherConsumer<
stepMatched = true
stepMatchedEventName = globals.event.event
stepMatchedEventUuid = globals.event.uuid
+ stepMatchedEventTimestamp = globals.event.timestamp
}
}
if (!conversionMatched) {
@@ -203,6 +205,7 @@ export class CdpHogflowSubscriptionMatcherConsumer<
conversionMatched,
eventName: stepMatchedEventName,
eventUuid: stepMatchedEventUuid,
+ eventTimestamp: stepMatchedEventTimestamp,
})
}
}
@@ -583,6 +586,7 @@ function applyWakeFlags(stateBuffer: Buffer, req: WakeRequest): Buffer | null {
eventMatched: true,
eventMatchedEvent: req.eventName,
eventMatchedEventUuid: req.eventUuid,
+ eventMatchedEventTimestamp: req.eventTimestamp,
}
applied = true
} else {
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 30ba18420f48..49ad8801c433 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts
@@ -484,21 +484,21 @@ describe('Hogflow Executor', () => {
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.
+ // Woken by the matcher: the resume log should emit a linkable
+ // [Event:uuid|name|timestamp] token, not just echo the trigger event.
invocation.state.currentAction = {
id: 'function_id_1',
startedAtTimestamp: DateTime.now().toMillis(),
eventMatched: true,
eventMatchedEvent: 'subscription created',
eventMatchedEventUuid: 'wake-uuid-123',
+ eventMatchedEventTimestamp: '2026-01-30T21:00:00.000Z',
}
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])'
+ '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|2026-01-30T21:00:00.000Z])'
)
})
})
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts
index b1cfeb49da9e..02940d66c040 100644
--- a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts
+++ b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.ts
@@ -637,16 +637,16 @@ export class HogFlowExecutorService {
? ` 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.
+ // Surface the event that woke the job (not the trigger). The logs view builds the link
+ // from uuid + timestamp, so emit the linkable token only when both are present.
const wakeEvent = invocation.state.currentAction?.eventMatchedEvent
const wakeEventUuid = invocation.state.currentAction?.eventMatchedEventUuid
+ const wakeEventTimestamp = invocation.state.currentAction?.eventMatchedEventTimestamp
if (hasCurrentAction && invocation.state.currentAction?.eventMatched && wakeEvent) {
- triggeredByEvent += wakeEventUuid
- ? ` (woken by [Event:${wakeEventUuid}|${wakeEvent.replaceAll('|', '')}])`
- : ` (woken by event: ${wakeEvent.replaceAll('|', '')})`
+ triggeredByEvent +=
+ wakeEventUuid && wakeEventTimestamp
+ ? ` (woken by [Event:${wakeEventUuid}|${wakeEvent.replaceAll('|', '')}|${wakeEventTimestamp}])`
+ : ` (woken by event: ${wakeEvent.replaceAll('|', '')})`
}
return {
diff --git a/nodejs/src/cdp/types.ts b/nodejs/src/cdp/types.ts
index cf383b3a1944..07931cb45621 100644
--- a/nodejs/src/cdp/types.ts
+++ b/nodejs/src/cdp/types.ts
@@ -342,6 +342,8 @@ export type HogFlowInvocationContext = {
// UUID of the exact event that triggered the wake, so the logs view can link to
// it precisely (the name alone is ambiguous when a person fires it repeatedly).
eventMatchedEventUuid?: string
+ // Paired with the UUID to build the event link in the logs view; never displayed.
+ eventMatchedEventTimestamp?: string
}
// Set by the subscription matcher consumer when an incoming event matched the
// workflow's event-based conversion goals. shouldExitEarly reads and clears it.