Skip to content

Write HTML. Render video. Built for agents.

feat(cli): render events carry the browser's build and install-path shape (#4180)

Miguel Ángelaa05278b7815
diff --git a/packages/cli/src/browser/installFacts.test.ts b/packages/cli/src/browser/installFacts.test.ts
new file mode 100644
index 0000000000..c26804fd17
--- /dev/null
+++ b/packages/cli/src/browser/installFacts.test.ts
@@ -0,0 +1,53 @@
+import { describe, expect, it } from "vitest";
+import { describeBrowserInstall } from "./installFacts.js";
+
+describe("describeBrowserInstall", () => {
+ it("reads the build and drive from a Windows managed-cache path", () => {
+ const path =
+ "D:\\Users\\a\\.cache\\hyperframes\\chrome-headless-shell\\win64-152.0.7928.2\\chrome-headless-shell.exe";
+ expect(describeBrowserInstall(path)).toEqual({
+ build: "152.0.7928.2",
+ pathAscii: true,
+ pathLength: "under_120",
+ drive: "windows_other",
+ });
+ });
+
+ it("does not mistake an IP-shaped or version-shaped directory for a build", () => {
+ expect(describeBrowserInstall("/home/10.0.0.1/apps/1.2.3.4/chrome").build).toBeUndefined();
+ const cached = "/home/u/.cache/puppeteer/chrome/linux-150.0.7422.0/chrome-linux64/chrome";
+ expect(describeBrowserInstall(cached).build).toBe("150.0.7422.0");
+ });
+
+ it("puts each length bucket edge on the documented side", () => {
+ const at = (n: number) => describeBrowserInstall(`/${"a".repeat(n - 1)}`).pathLength;
+ expect([at(119), at(120), at(199), at(200), at(259), at(260)]).toEqual([
+ "under_120",
+ "120_to_199",
+ "120_to_199",
+ "200_to_259",
+ "200_to_259",
+ "260_plus",
+ ]);
+ });
+
+ it("flags a non-ASCII path and a UNC share", () => {
+ expect(describeBrowserInstall("\\\\host\\share\\Мой\\chrome.exe")).toMatchObject({
+ pathAscii: false,
+ drive: "unc",
+ });
+ });
+
+ it("omits the build for a system Chrome and buckets a long POSIX path", () => {
+ const facts = describeBrowserInstall(`/${"a".repeat(270)}/chrome`);
+ expect(facts).toEqual({ pathAscii: true, pathLength: "260_plus", drive: "posix" });
+ });
+
+ it.each([
+ ["C:\\Program Files\\Google\\Chrome\\chrome.exe", "windows_c"],
+ ["c:/chrome/chrome.exe", "windows_c"],
+ ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "posix"],
+ ] as const)("classifies the drive of %s", (path, drive) => {
+ expect(describeBrowserInstall(path).drive).toBe(drive);
+ });
+});
diff --git a/packages/cli/src/browser/installFacts.ts b/packages/cli/src/browser/installFacts.ts
new file mode 100644
index 0000000000..80362cc996
--- /dev/null
+++ b/packages/cli/src/browser/installFacts.ts
@@ -0,0 +1,34 @@
+export interface BrowserInstallFacts {
+ /** Four-part build from a managed-cache path (`152.0.7928.2`); absent for a system Chrome. */
+ build?: string;
+ pathAscii: boolean;
+ pathLength: "under_120" | "120_to_199" | "200_to_259" | "260_plus";
+ drive: "posix" | "windows_c" | "windows_other" | "unc";
+}
+
+// Puppeteer-style cache layout: `<cache>/chrome[-headless-shell]/<platform>-<build>/`.
+const BUILD_IN_PATH = /[\\/]chrome(?:-headless-shell)?[\\/][a-z0-9_]+-(\d+\.\d+\.\d+\.\d+)[\\/]/i;
+
+function driveOf(path: string): BrowserInstallFacts["drive"] {
+ if (path.startsWith("\\\\") || path.startsWith("//")) return "unc";
+ const letter = /^([A-Za-z]):[\\/]/.exec(path)?.[1];
+ if (!letter) return "posix";
+ return letter.toUpperCase() === "C" ? "windows_c" : "windows_other";
+}
+
+function lengthBucket(length: number): BrowserInstallFacts["pathLength"] {
+ if (length < 120) return "under_120";
+ if (length < 200) return "120_to_199";
+ return length < 260 ? "200_to_259" : "260_plus";
+}
+
+/** Path-shape facts only; the path itself never leaves the machine. */
+export function describeBrowserInstall(executablePath: string): BrowserInstallFacts {
+ const build = BUILD_IN_PATH.exec(executablePath)?.[1];
+ return {
+ ...(build ? { build } : {}),
+ pathAscii: /^\p{ASCII}*$/u.test(executablePath),
+ pathLength: lengthBucket(executablePath.length),
+ drive: driveOf(executablePath),
+ };
+}
diff --git a/packages/cli/src/browser/preflight.test.ts b/packages/cli/src/browser/preflight.test.ts
index 796bd841d4..fa55b8c79d 100644
--- a/packages/cli/src/browser/preflight.test.ts
+++ b/packages/cli/src/browser/preflight.test.ts
@@ -178,6 +178,7 @@ describe("runEnvironmentChecks", () => {
versionMajor: 7,
});
expect(result.browserVersionMajor).toBe(7);
+ expect(result.browserInstall).toMatchObject({ pathAscii: true });
});
it("reports Chrome as not found (no throw) when browser discovery throws on a corrupt cache", async () => {
diff --git a/packages/cli/src/browser/preflight.ts b/packages/cli/src/browser/preflight.ts
index 457c55147d..40afdc2f09 100644
--- a/packages/cli/src/browser/preflight.ts
+++ b/packages/cli/src/browser/preflight.ts
@@ -2,6 +2,7 @@ import { existsSync } from "node:fs";
import { platform } from "node:os";
import { findFfBinary } from "@hyperframes/parsers/ff-binaries";
import { ensureBrowser, findBrowser, type BrowserResult } from "./manager.js";
+import { describeBrowserInstall, type BrowserInstallFacts } from "./installFacts.js";
import { FFMPEG_PATH_ENV, FFPROBE_PATH_ENV, getFFmpegInstallHint } from "./ffmpeg.js";
import {
chromeDepsInstallCommand,
@@ -31,6 +32,7 @@ export interface EnvironmentCheckResult {
ffmpegPath?: string;
ffprobePath?: string;
browser?: BrowserResult;
+ browserInstall?: BrowserInstallFacts;
ffmpegVersionMajor?: number;
browserVersionMajor?: number;
}
@@ -427,7 +429,7 @@ export async function runEnvironmentChecks(
outcomes,
...(ffmpeg.ok && ffmpeg.path ? { ffmpegPath: ffmpeg.path } : {}),
...(ffprobe.path ? { ffprobePath: ffprobe.path } : {}),
- ...(browser ? { browser } : {}),
+ ...(browser ? { browser, browserInstall: describeBrowserInstall(browser.executablePath) } : {}),
...(ffmpeg.versionMajor != null ? { ffmpegVersionMajor: ffmpeg.versionMajor } : {}),
...(browserVersionMajor != null ? { browserVersionMajor } : {}),
};
diff --git a/packages/cli/src/commands/render.ts b/packages/cli/src/commands/render.ts
index c18edff88e..c632cc9fbb 100644
--- a/packages/cli/src/commands/render.ts
+++ b/packages/cli/src/commands/render.ts
@@ -93,6 +93,7 @@ import { VERSION } from "../version.js";
import { isDevMode } from "../utils/env.js";
import { buildDockerRunArgs, resolveDockerPlatform } from "../utils/dockerRunArgs.js";
import { createStderrTail, DockerRenderExitError } from "../utils/dockerStderrTail.js";
+import type { BrowserInstallFacts } from "../browser/installFacts.js";
import { normalizeErrorMessage } from "../utils/errorMessage.js";
import { runEnvironmentChecks } from "../browser/preflight.js";
import {
@@ -470,6 +471,7 @@ export interface RenderOptions {
/** Major FFmpeg/Chrome version from local preflight (telemetry only); absent on Docker renders. */
ffmpegVersionMajor?: number;
browserVersionMajor?: number;
+ browserInstall?: BrowserInstallFacts;
/** HLS target segment length in seconds; ignored unless `format` is `"hls"`. */
hlsSegmentSeconds?: number;
workers?: number;
@@ -946,6 +948,7 @@ async function executeLocalRender(
...options,
ffmpegVersionMajor: preflight.ffmpegVersionMajor,
browserVersionMajor: preflight.browserVersionMajor,
+ browserInstall: preflight.browserInstall,
};
cancellation.checkAncestors();
cancellation.signal.throwIfAborted();
@@ -1211,6 +1214,7 @@ function renderEnvironmentTelemetryPayload(
return {
ffmpegVersionMajor: options.ffmpegVersionMajor,
browserVersionMajor: options.browserVersionMajor,
+ browserInstall: options.browserInstall,
};
}
diff --git a/packages/cli/src/telemetry/events.test.ts b/packages/cli/src/telemetry/events.test.ts
index 41dfdac770..0bf560dae2 100644
--- a/packages/cli/src/telemetry/events.test.ts
+++ b/packages/cli/src/telemetry/events.test.ts
@@ -396,6 +396,34 @@ describe("render telemetry events", () => {
expect(props.browser_version_major).toBe(118);
});
+ it("carries the browser install path facts on both render events, never the path", () => {
+ const browserInstall = {
+ build: "152.0.7928.2",
+ pathAscii: false,
+ pathLength: "200_to_259",
+ drive: "windows_other",
+ } as const;
+ trackRenderComplete({
+ durationMs: 1,
+ fps: 30,
+ quality: "draft",
+ docker: false,
+ gpu: false,
+ browserInstall,
+ });
+ trackRenderError({ fps: 30, quality: "draft", docker: false, browserInstall });
+ for (const call of trackEvent.mock.calls) {
+ const props = call[1] as Record<string, unknown>;
+ expect(props).toMatchObject({
+ browser_build: "152.0.7928.2",
+ browser_path_ascii: false,
+ browser_path_length: "200_to_259",
+ browser_path_drive: "windows_other",
+ });
+ expect(Object.keys(props)).not.toContain("browser_path");
+ }
+ });
+
it("omits toolchain majors on a Docker render", () => {
trackRenderComplete({ durationMs: 1, fps: 30, quality: "draft", docker: true, gpu: false });
const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
diff --git a/packages/cli/src/telemetry/events.ts b/packages/cli/src/telemetry/events.ts
index 38f2dac93d..2a73edddbd 100644
--- a/packages/cli/src/telemetry/events.ts
+++ b/packages/cli/src/telemetry/events.ts
@@ -1,3 +1,4 @@
+import type { BrowserInstallFacts } from "../browser/installFacts.js";
import { redactTelemetryString, type OutputResolutionIssueKind } from "@hyperframes/core";
import type { SubTimelineWaitOutcome } from "@hyperframes/engine";
import { FEEDBACK_RATING_SCALE } from "../utils/feedbackRating.js";
@@ -238,12 +239,17 @@ function renderOutputShapeEventProperties(props: RenderOutputShapeTelemetryPaylo
export interface RenderEnvironmentTelemetryPayload {
ffmpegVersionMajor?: number;
browserVersionMajor?: number;
+ browserInstall?: BrowserInstallFacts;
}
function renderEnvironmentEventProperties(props: RenderEnvironmentTelemetryPayload) {
return {
ffmpeg_version_major: props.ffmpegVersionMajor,
browser_version_major: props.browserVersionMajor,
+ browser_build: props.browserInstall?.build,
+ browser_path_ascii: props.browserInstall?.pathAscii,
+ browser_path_length: props.browserInstall?.pathLength,
+ browser_path_drive: props.browserInstall?.drive,
};
}