feat(telemetry): instrument CLI run command with lifecycle events

This commit is contained in:
YeonGyu-Kim
2026-04-11 14:14:32 +09:00
parent 4e80a1b1ae
commit 1c27000c37
+5
View File
@@ -53,10 +53,12 @@ export async function run(options: RunOptions): Promise<number> {
const posthog = createCliPostHog() const posthog = createCliPostHog()
const distinctId = getPostHogDistinctId() const distinctId = getPostHogDistinctId()
posthog.trackActive(distinctId, "run_started")
posthog.capture({ posthog.capture({
distinctId, distinctId,
event: "run_started", event: "run_started",
properties: { properties: {
command: "run",
agent: resolvedAgent, agent: resolvedAgent,
has_model: !!options.model, has_model: !!options.model,
has_session_id: !!options.sessionId, has_session_id: !!options.sessionId,
@@ -159,6 +161,7 @@ export async function run(options: RunOptions): Promise<number> {
distinctId, distinctId,
event: "run_completed", event: "run_completed",
properties: { properties: {
command: "run",
agent: resolvedAgent, agent: resolvedAgent,
duration_ms: durationMs, duration_ms: durationMs,
message_count: eventState.messageCount, message_count: eventState.messageCount,
@@ -169,6 +172,7 @@ export async function run(options: RunOptions): Promise<number> {
distinctId, distinctId,
event: "run_failed", event: "run_failed",
properties: { properties: {
command: "run",
agent: resolvedAgent, agent: resolvedAgent,
exit_code: exitCode, exit_code: exitCode,
duration_ms: durationMs, duration_ms: durationMs,
@@ -195,6 +199,7 @@ export async function run(options: RunOptions): Promise<number> {
distinctId, distinctId,
event: "run_failed", event: "run_failed",
properties: { properties: {
command: "run",
agent: resolvedAgent, agent: resolvedAgent,
error: serializeError(err), error: serializeError(err),
duration_ms: Date.now() - startTime, duration_ms: Date.now() - startTime,