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): read the person id the events query returns in the test panel (#121138)

Harley Alexanderbc67ac2c5f63
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.test.ts b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.test.ts
index 0397ea25cb46..76c1a6f2d0e0 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.test.ts
@@ -132,7 +132,7 @@ describe('hogFlowEditorTestLogic', () => {
})
})
- describe('createGlobalsFromResponse groups', () => {
+ describe('createGlobalsFromResponse', () => {
const event = {
uuid: 'e1',
distinct_id: 'd1',
@@ -155,6 +155,26 @@ describe('hogFlowEditorTestLogic', () => {
const globals = createGlobalsFromResponse(event, undefined, 1, 'wf')
expect(globals.groups).toEqual({})
})
+
+ it.each([
+ [
+ 'the events query person column',
+ { uuid: 'p-uuid', properties: { plan: 'pro' }, distinct_id: 'd1' },
+ 'p-uuid',
+ ],
+ ['a person with an id', { id: 'p-id', properties: { plan: 'pro' } }, 'p-id'],
+ ])('reads the person id from %s', (_name, person, expectedId) => {
+ const globals = createGlobalsFromResponse(event, person, 1, 'wf')
+ expect(globals.person).toMatchObject({
+ id: expectedId,
+ properties: { plan: 'pro' },
+ url: expect.stringMatching(new RegExp(`/person/${expectedId}$`)),
+ })
+ })
+
+ it('leaves the person out for an event with no person', () => {
+ expect(createGlobalsFromResponse(event, { distinct_id: 'd1' }, 1, 'wf').person).toBeUndefined()
+ })
})
describe('createExampleEventForTrigger', () => {
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts
index 7684ccfba861..c3147f1f4fbc 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts
+++ b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorTestLogic.ts
@@ -110,6 +110,8 @@ export const createGlobalsFromResponse = (
groups: CyclotronJobInvocationGlobals['groups'] = {}
): CyclotronJobInvocationGlobals => {
const projectUrl = `${window.location.origin}/project/${teamId}`
+ // The events query's `person` column names the id `uuid`, and holds only `distinct_id` for an event with no person.
+ const personId = person?.uuid ?? person?.id
return {
event: {
uuid: event.uuid,
@@ -122,12 +124,12 @@ export const createGlobalsFromResponse = (
event: event.event,
properties: event.properties,
},
- person: person
+ person: personId
? {
- id: person.id,
+ id: personId,
properties: person.properties,
name: person.name || 'Unknown person',
- url: `${window.location.origin}/person/${person.id}`,
+ url: `${window.location.origin}/person/${personId}`,
}
: undefined,
groups,