Conversation
| readonly name = 'posthog'; | ||
|
|
||
| send(_event: StreamEvent, _payload: TaskStreamUpdate): Promise<void> { | ||
| // TODO: implement when the PostHog API surface is defined. |
There was a problem hiding this comment.
Wire this up to send to where ever in the heavens (posthog app)
| try { | ||
| appendFileSync( | ||
| TASK_STREAM_LOG, | ||
| `[${event}] ${JSON.stringify(payload)}\n`, |
There was a problem hiding this comment.
This will print to /tmp/posthog-task-stream.log for easy debugging and for us to tweak what this looks like
| started_at: this.startedAt, | ||
| run_phase: session.runPhase, | ||
| tasks: buildTasks(tasks), | ||
| event_plan: eventPlan.length > 0 ? eventPlan : undefined, |
There was a problem hiding this comment.
We will also send the event plan up so we can display them
There was a problem hiding this comment.
[CREATE] {
"session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
"workflow_id": "onboarding",
"skill_id": "posthog_integration",
"started_at": "2026-04-23T15:16:21.919Z",
"run_phase": "idle",
"tasks": [],
"timestamp": "2026-04-23T15:16:21.920Z"
}
[UPDATE] {
"session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
"workflow_id": "onboarding",
"skill_id": "posthog_integration",
"started_at": "2026-04-23T15:16:21.919Z",
"run_phase": "running",
"tasks": [
{
"id": "0",
"title": "Analyze project structure and plan event tracking",
"status": "in_progress"
},
{
"id": "1",
"title": "Set up PostHog dependencies and environment variables",
"status": "pending"
},
{
"id": "2",
"title": "Insert event tracking code",
"status": "pending"
},
{
"id": "3",
"title": "Revise and validate tracking implementation",
"status": "pending"
},
{
"id": "4",
"title": "Wrap up integration",
"status": "pending"
}
],
"timestamp": "2026-04-23T15:17:12.484Z"
}
[UPDATE] {
"session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
"workflow_id": "onboarding",
"skill_id": "posthog_integration",
"started_at": "2026-04-23T15:16:21.919Z",
"run_phase": "running",
"tasks": [
{
"id": "0",
"title": "Analyze project structure and plan event tracking",
"status": "in_progress"
},
{
"id": "1",
"title": "Set up PostHog dependencies and environment variables",
"status": "pending"
},
{
"id": "2",
"title": "Insert event tracking code",
"status": "pending"
},
{
"id": "3",
"title": "Revise and validate tracking implementation",
"status": "pending"
},
{
"id": "4",
"title": "Wrap up integration",
"status": "pending"
}
],
"event_plan": [
{
"name": "start_free_trial_clicked",
"description": "User clicks a 'Start Free Trial' CTA button"
},
{
"name": "contact_sales_clicked",
"description": "User clicks the 'Contact Sales' button on the homepage hero"
},
{
"name": "pricing_plan_clicked",
"description": "User clicks a CTA on the pricing page (Starter, Pro, or Enterprise)"
},
{
"name": "contact_form_submitted",
"description": "User successfully submits the contact form (client-side success)"
},
{
"name": "contact_form_errored",
"description": "Contact form submission fails with a validation or network error (client-side)"
},
{
"name": "contact_form_submission_received",
"description": "Server successfully processes a contact form submission (server-side)"
}
],
"timestamp": "2026-04-23T15:18:01.764Z"
}
...
[UPDATE] {
"session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
"workflow_id": "onboarding",
"skill_id": "posthog_integration",
"started_at": "2026-04-23T15:16:21.919Z",
"run_phase": "running",
"tasks": [
{
"id": "0",
"title": "Analyze project structure and plan event tracking",
"status": "completed"
},
{
"id": "1",
"title": "Set up PostHog dependencies and environment variables",
"status": "completed"
},
{
"id": "2",
"title": "Insert event tracking code",
"status": "completed"
},
{
"id": "3",
"title": "Revise and validate tracking implementation",
"status": "completed"
},
{
"id": "4",
"title": "Wrap up integration",
"status": "in_progress"
}
],
"event_plan": [
{
"name": "start_free_trial_clicked",
"description": "User clicks a 'Start Free Trial' CTA button"
},
{
"name": "contact_sales_clicked",
"description": "User clicks the 'Contact Sales' button on the homepage hero"
},
{
"name": "pricing_plan_clicked",
"description": "User clicks a CTA on the pricing page (Starter, Pro, or Enterprise)"
},
{
"name": "contact_form_submitted",
"description": "User successfully submits the contact form (client-side success)"
},
{
"name": "contact_form_errored",
"description": "Contact form submission fails with a validation or network error (client-side)"
},
{
"name": "contact_form_submission_received",
"description": "Server successfully processes a contact form submission (server-side)"
}
],
"timestamp": "2026-04-23T15:19:58.268Z"
}
[UPDATE] {
"session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
"workflow_id": "onboarding",
"skill_id": "posthog_integration",
"started_at": "2026-04-23T15:16:21.919Z",
"run_phase": "running",
"tasks": [
{
"id": "0",
"title": "Analyze project structure and plan event tracking",
"status": "completed"
},
{
"id": "1",
"title": "Set up PostHog dependencies and environment variables",
"status": "completed"
},
{
"id": "2",
"title": "Insert event tracking code",
"status": "completed"
},
{
"id": "3",
"title": "Revise and validate tracking implementation",
"status": "completed"
},
{
"id": "4",
"title": "Wrap up integration",
"status": "completed"
}
],
"event_plan": [
{
"name": "start_free_trial_clicked",
"description": "User clicks a 'Start Free Trial' CTA button"
},
{
"name": "contact_sales_clicked",
"description": "User clicks the 'Contact Sales' button on the homepage hero"
},
{
"name": "pricing_plan_clicked",
"description": "User clicks a CTA on the pricing page (Starter, Pro, or Enterprise)"
},
{
"name": "contact_form_submitted",
"description": "User successfully submits the contact form (client-side success)"
},
{
"name": "contact_form_errored",
"description": "Contact form submission fails with a validation or network error (client-side)"
},
{
"name": "contact_form_submission_received",
"description": "Server successfully processes a contact form submission (server-side)"
}
],
"timestamp": "2026-04-23T15:21:25.405Z"
}
MattBro
left a comment
There was a problem hiding this comment.
A few things worth looking at before this lands. The big one is that COMPLETE events don't actually fire - details inline.
| StreamEvent, | ||
| } from '../types'; | ||
|
|
||
| const TASK_STREAM_LOG = '/tmp/posthog-task-stream.log'; |
There was a problem hiding this comment.
/tmp doesn't exist on Windows, and the log grows unbounded across runs. Use os.tmpdir() and either truncate on construction or include a timestamp in the filename so concurrent/repeat runs don't collide.
There was a problem hiding this comment.
This is a generally good piece of advice for all of our logging! Thanks :D
There was a problem hiding this comment.
Oh this actually explains why our skills don't install properly on windows 😬 we unzip in tmp!
There was a problem hiding this comment.
This should fix both for windows
|
Oooo this is a great review @MattBro! On it |
MattBro
left a comment
There was a problem hiding this comment.
Looks good - everything substantive got handled, tests cover the lifecycle, and dispose in bin.ts closes the COMPLETE gap cleanly. Nice work.
Two small non-blockers:
- Typo in the test describe block:
Coorect order of events. onTasksChangedonly fires fromsyncTodos, so mid-runsetEventPlan/setRunPhasechanges won't push until the next todo sync. Terminal phase is caught bydispose()so it's fine in practice, but worth a thought if the plan gets edited independently.
Windows /tmp is tracked in #417, good to split.
|
Thanks for the review @MattBro <3 I learned a lot. Looking forward to working together on this. |

Problem
We want to send messages to the heavens (posthog cloud). See our game plan
Changes
Adds a interface to hook into event plan updates made by the agent.
See comments in this PR <3
Test plan