refactor(telemetry): drop run lifecycle events and captureException from runner
This commit is contained in:
@@ -64,8 +64,6 @@ describe("run telemetry isolation", () => {
|
|||||||
trackActive: () => {
|
trackActive: () => {
|
||||||
throw new Error("telemetry failed")
|
throw new Error("telemetry failed")
|
||||||
},
|
},
|
||||||
capture: mock(() => {}),
|
|
||||||
captureException: mock(() => {}),
|
|
||||||
shutdown: mock(async () => {
|
shutdown: mock(async () => {
|
||||||
throw new Error("shutdown failed")
|
throw new Error("shutdown failed")
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -58,20 +58,6 @@ export async function run(options: RunOptions): Promise<number> {
|
|||||||
} catch {
|
} catch {
|
||||||
// telemetry failure is non-fatal, silently ignore
|
// telemetry failure is non-fatal, silently ignore
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
posthog.capture({
|
|
||||||
distinctId,
|
|
||||||
event: "run_started",
|
|
||||||
properties: {
|
|
||||||
command: "run",
|
|
||||||
agent: resolvedAgent,
|
|
||||||
has_model: !!options.model,
|
|
||||||
has_session_id: !!options.sessionId,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} catch {
|
|
||||||
// telemetry failure is non-fatal, silently ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resolvedModel = resolveRunModel(options.model)
|
const resolvedModel = resolveRunModel(options.model)
|
||||||
@@ -164,38 +150,6 @@ export async function run(options: RunOptions): Promise<number> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exitCode === 0) {
|
|
||||||
try {
|
|
||||||
posthog.capture({
|
|
||||||
distinctId,
|
|
||||||
event: "run_completed",
|
|
||||||
properties: {
|
|
||||||
command: "run",
|
|
||||||
agent: resolvedAgent,
|
|
||||||
duration_ms: durationMs,
|
|
||||||
message_count: eventState.messageCount,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} catch {
|
|
||||||
// telemetry failure is non-fatal, silently ignore
|
|
||||||
}
|
|
||||||
} else if (exitCode === 1) {
|
|
||||||
try {
|
|
||||||
posthog.capture({
|
|
||||||
distinctId,
|
|
||||||
event: "run_failed",
|
|
||||||
properties: {
|
|
||||||
command: "run",
|
|
||||||
agent: resolvedAgent,
|
|
||||||
exit_code: exitCode,
|
|
||||||
duration_ms: durationMs,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} catch {
|
|
||||||
// telemetry failure is non-fatal, silently ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exitCode
|
return exitCode
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
cleanup()
|
cleanup()
|
||||||
@@ -210,25 +164,6 @@ export async function run(options: RunOptions): Promise<number> {
|
|||||||
if (err instanceof Error && err.name === "AbortError") {
|
if (err instanceof Error && err.name === "AbortError") {
|
||||||
return 130
|
return 130
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
posthog.captureException(err, distinctId)
|
|
||||||
} catch {
|
|
||||||
// telemetry failure is non-fatal, silently ignore
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
posthog.capture({
|
|
||||||
distinctId,
|
|
||||||
event: "run_failed",
|
|
||||||
properties: {
|
|
||||||
command: "run",
|
|
||||||
agent: resolvedAgent,
|
|
||||||
error: serializeError(err),
|
|
||||||
duration_ms: Date.now() - startTime,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} catch {
|
|
||||||
// telemetry failure is non-fatal, silently ignore
|
|
||||||
}
|
|
||||||
console.error(pc.red(`Error: ${serializeError(err)}`))
|
console.error(pc.red(`Error: ${serializeError(err)}`))
|
||||||
return 1
|
return 1
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user