From 3760baeef51e0a4d4416f7e06a81f0a1e9c82b2f Mon Sep 17 00:00:00 2001 From: James Date: Thu, 23 Apr 2026 18:47:11 +0000 Subject: [PATCH] feat(cli): forward perf breakdown + tmpPeakBytes to PostHog telemetry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CLI already ships `render_complete` events to PostHog but only carries a subset of `RenderPerfSummary` (duration_ms, capture_avg_ms, etc.). With #444 adding per-phase breakdown and #446 adding cache counters, the data is sitting in `job.perfSummary.videoExtractBreakdown` and `job.perfSummary.tmpPeakBytes` but never reaching PostHog. This forwards the new fields as flat properties (flat is easier to query with PostHog insights than nested objects): - tmp_peak_bytes - stage_compile_ms, stage_video_extract_ms, stage_audio_process_ms, stage_capture_ms, stage_encode_ms, stage_assemble_ms - extract_resolve_ms, extract_hdr_probe_ms, extract_hdr_preflight_ms, extract_hdr_preflight_count, extract_vfr_probe_ms, extract_vfr_preflight_ms, extract_vfr_preflight_count, extract_phase3_ms, extract_cache_hits, extract_cache_misses `extract_phase3_ms` disambiguates from `stage_video_extract_ms`: the former is just the parallel ffmpeg extract inside Phase 3, the latter is the full stage (resolve + probe + preflight + extract). All fields optional — the Docker subprocess call site (no perfSummary available) still compiles and ships events without them. --- packages/cli/src/commands/render.ts | 20 ++++++++++++++++ packages/cli/src/telemetry/events.ts | 36 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/packages/cli/src/commands/render.ts b/packages/cli/src/commands/render.ts index 7c3f9d5e..b123c397 100644 --- a/packages/cli/src/commands/render.ts +++ b/packages/cli/src/commands/render.ts @@ -597,6 +597,9 @@ function trackRenderMetrics( ? Math.round((compositionDurationMs / elapsedMs) * 100) / 100 : undefined; + const stages = perf?.stages ?? {}; + const extract = perf?.videoExtractBreakdown; + trackRenderComplete({ durationMs: elapsedMs, fps: options.fps, @@ -611,6 +614,23 @@ function trackRenderMetrics( speedRatio, captureAvgMs: perf?.captureAvgMs, capturePeakMs: perf?.capturePeakMs, + tmpPeakBytes: perf?.tmpPeakBytes, + stageCompileMs: stages.compileMs, + stageVideoExtractMs: stages.videoExtractMs, + stageAudioProcessMs: stages.audioProcessMs, + stageCaptureMs: stages.captureMs, + stageEncodeMs: stages.encodeMs, + stageAssembleMs: stages.assembleMs, + extractResolveMs: extract?.resolveMs, + extractHdrProbeMs: extract?.hdrProbeMs, + extractHdrPreflightMs: extract?.hdrPreflightMs, + extractHdrPreflightCount: extract?.hdrPreflightCount, + extractVfrProbeMs: extract?.vfrProbeMs, + extractVfrPreflightMs: extract?.vfrPreflightMs, + extractVfrPreflightCount: extract?.vfrPreflightCount, + extractPhase3Ms: extract?.extractMs, + extractCacheHits: extract?.cacheHits, + extractCacheMisses: extract?.cacheMisses, ...getMemorySnapshot(), }); } diff --git a/packages/cli/src/telemetry/events.ts b/packages/cli/src/telemetry/events.ts index f7db477e..c89016a0 100644 --- a/packages/cli/src/telemetry/events.ts +++ b/packages/cli/src/telemetry/events.ts @@ -23,6 +23,25 @@ export function trackRenderComplete(props: { // Resource usage peakMemoryMb?: number; memoryFreeMb?: number; + tmpPeakBytes?: number; + // Per-stage timings (subset of RenderPerfSummary.stages) + stageCompileMs?: number; + stageVideoExtractMs?: number; + stageAudioProcessMs?: number; + stageCaptureMs?: number; + stageEncodeMs?: number; + stageAssembleMs?: number; + // Video-extraction breakdown (from RenderPerfSummary.videoExtractBreakdown) + extractResolveMs?: number; + extractHdrProbeMs?: number; + extractHdrPreflightMs?: number; + extractHdrPreflightCount?: number; + extractVfrProbeMs?: number; + extractVfrPreflightMs?: number; + extractVfrPreflightCount?: number; + extractPhase3Ms?: number; + extractCacheHits?: number; + extractCacheMisses?: number; }): void { trackEvent("render_complete", { duration_ms: props.durationMs, @@ -40,6 +59,23 @@ export function trackRenderComplete(props: { capture_peak_ms: props.capturePeakMs, peak_memory_mb: props.peakMemoryMb, memory_free_mb: props.memoryFreeMb, + tmp_peak_bytes: props.tmpPeakBytes, + stage_compile_ms: props.stageCompileMs, + stage_video_extract_ms: props.stageVideoExtractMs, + stage_audio_process_ms: props.stageAudioProcessMs, + stage_capture_ms: props.stageCaptureMs, + stage_encode_ms: props.stageEncodeMs, + stage_assemble_ms: props.stageAssembleMs, + extract_resolve_ms: props.extractResolveMs, + extract_hdr_probe_ms: props.extractHdrProbeMs, + extract_hdr_preflight_ms: props.extractHdrPreflightMs, + extract_hdr_preflight_count: props.extractHdrPreflightCount, + extract_vfr_probe_ms: props.extractVfrProbeMs, + extract_vfr_preflight_ms: props.extractVfrPreflightMs, + extract_vfr_preflight_count: props.extractVfrPreflightCount, + extract_phase3_ms: props.extractPhase3Ms, + extract_cache_hits: props.extractCacheHits, + extract_cache_misses: props.extractCacheMisses, }); }