mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
* feat(telemetry): add output-shape request facts to render events output_resolution_preset, output_format, hdr_mode, video_frame_format, and gif_fps_capped join render_complete/render_error, all threaded from already-resolved RenderOptions/RenderPlan fields rather than recomputed: createRenderPlan already computes gifFpsCapped (clamping a requested --fps above 30 to 30 for --format gif) but only used it for a console warning; this threads that same decision into RenderOptions and telemetry. All five are known before the pipeline starts, so both events carry them even when a render fails before a perfSummary exists. Also wires output_format/output_resolution_preset into Studio's separate emitStudioRenderComplete/emitStudioRenderError path, since Studio's request genuinely varies those two per-request. hdr_mode, video_frame_format, and gif_fps_capped stay CLI-only: Studio exposes no HDR-mode, video-frame-format, or GIF output control to users at all, so there is no per-request value to report for those three. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * feat(telemetry): add adapters_used to render events adapters_used lists the runtime deterministic adapters (packages/core/src/runtime/adapters/) a composition exercises. Investigated the actual codebase rather than the ticket's guessed 7-adapter list and found 12 real registered adapters (gsap, css, waapi, animejs, lottie, three, typegpu, d3, leaflet, mapbox, maplibre, google-maps) — the map/data-source adapters share the exact same window.__hf<Name> registration mechanism and are equally real "adapters used" facts, so all 12 are included. Detection unions a live page.evaluate probe (piggybacked on the same probeSession resolveCompositionElementCount already uses) with a static regex fallback over the compiled HTML, since this is purely observational with no gating role (unlike compositionElementCount) — union strictly increases recall rather than needing one source of truth. Threaded through the same plumbing chain as the already-merged composition_element_tags/aroll_video_count/heygen_video_count. Studio's emitStudioRenderComplete/emitStudioRenderError get this field automatically, with no Studio-side code change, via the same shared capture-observability spread heygen_video_count already uses. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * feat(telemetry): add audio/image/sub-composition/color-grading counts audio_count, image_count, sub_composition_count, audio_group_count, color_grading_count, and has_lut join composition_element_tags in the same single scanElementTags pass — audio/image/audio-group counts read from the scan's uncapped tag map so a 50+-distinct-tag composition can't push a named count into the "other" bucket. sub_composition_count counts data-composition-src mounts directly rather than reusing collectSubCompositionSrcs, which dedupes by src and drops placeholder/remote mounts (a different, smaller fact than the mount count this field reports). has_lut decodes the HTML-entity-escaped form of data-color-grading before parsing, since linkedom's serializer re-emits it "-escaped on every compile-pipeline round-trip — without the decode this silently reported false for every LUT-graded composition. The LUT-presence check now mirrors normalizeLut's own definition of "has a LUT" exactly, closing a gap where a blank or empty lut value would have reported true. Threaded through the same plumbing chain as the already-merged per-tag/provenance/adapter fields; Studio's emitter picks these up automatically via the shared capture-observability spread. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * feat(telemetry): add browser_version_major and ffmpeg_version_major Both are already-run subprocess calls whose output was discarded: readToolVersion (checkFFmpeg's preflight) already runs `ffmpeg -version`, and chromeLaunchOutcome already runs `--version` as a Chrome launch sanity probe on every render. A shared extractMajorVersion helper pulls the first X.Y-shaped number from either banner, threaded onto EnvironmentCheckOutcome/ EnvironmentCheckResult, then RenderOptions right after runEnvironmentChecks resolves in the local render path only. Docker renders never populate these two RenderOptions fields (the containerized producer runs its own preflight the host CLI never sees), so both properties come back absent there rather than reporting the host's own toolchain versions for a render that didn't use them. Studio does not call runEnvironmentChecks or this ffmpeg/Chrome preflight at all before creating a render job, so its render_complete/ render_error events will not carry these two properties unless Studio's own startup path is separately instrumented — a genuine parity gap, not an oversight in this change. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * feat(telemetry): add authoring_skill_source and authoring_skill_invalid Both derive from resolution logic createRenderPlan already runs: authoring_skill_source names whichever step actually won attribution (an explicit --skill flag, or the skill persisted in hyperframes.json) using the same flagSkill/projectConfigSkill values already computed for authoringSkill itself, not a second lookup. authoring_skill_invalid surfaces the raw --skill value when it fails slug-shape validation (normalizeSkillSlug rejects malformed input, not unregistered skill names) — this value already exists as RenderPlan.invalidAuthoringSkill and already drives a CLI warning in present.ts; this change threads the same field into telemetry rather than adding a parallel one. Threaded through both RenderOptions builders in execute.ts (single and batch render) and all three telemetry call sites in render.ts, including the Docker path — skill attribution is a request-level fact independent of which backend executes the render. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * feat(telemetry): add root_body_mismatch and root_body_delta_px_bucket Measures the composition root's authored data-width/data-height against the scaffold's own html/body CSS size, straight from the compiled document string scanElementTags already scans — the source-level fact, not runtime DOM state. init.ts's applyCompositionSizing (the #4001 fix) only patches the live DOM after the browser loads this same HTML, so this measurement stays meaningful whether or not that fix ran for a given render. Reuses @hyperframes/parsers' canvasScaffoldPatterns regexes (the same ones packages/lint's root_dimensions_mismatch rule reads) for the CSS side. Root-tag detection here is a lighter first-data-composition-id-match heuristic, not lint's more thorough findRootTag (which also handles a leading decorative <svg> defs block) — that helper isn't part of @hyperframes/lint's public API, and expanding it is out of scope here. The delta is bucketed (0 / 1-10 / 11-50 / 51+ px) rather than reported raw, and both fields come back absent — not a false/"0" default — when the root or the CSS block can't be read at all. Threaded through the same plumbing as every other static-scan field this week, including the live-capture-observability fallback used on a crash that never reaches perfSummary. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * feat(telemetry): add hf_env_overrides (names only, capped at 20) Reports the sorted names of HF_*/HYPERFRAMES_* env vars present when createRenderPlan resolves — never their values, since several of these carry filesystem paths. Snapshotting at plan-resolution time (the very first line of the render command, before any pipeline code runs) matters: this render's own preflight later injects HYPERFRAMES_FFMPEG_PATH/HYPERFRAMES_FFPROBE_PATH into its own process.env, which would otherwise make those two always read back as "operator overrides" whether or not the operator ever set them. Reports an empty array, never an absent key, when nothing is set, matching every other capped/bucketed field added this week. Capped at 20 names, documented alongside the cap constant. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * fix(cli): stop clobbering studio render_complete fields, fix an env leak trackRenderComplete's explicit audio_count/image_count/root_body_mismatch/ adapters_used/etc. keys, sourced from perfSummary.drawElement and only ever populated on the CLI's own render.ts path, always won the object spread over the observability-capture fallback those same keys share with trackRenderError, even when the direct value was undefined. studioRenderTelemetry.ts's emitStudioRenderComplete never populates drawElement, only the capture fallback, so 24 fields silently came back missing from every studio-triggered render_complete event despite Studio having computed and sent the capture value. Each field now falls back to its captureXxx counterpart via a new directOrCapture() helper when the direct field is absent, with regression tests proving both the fallback and that the direct value still wins when both are present. Also excludes HF_SHADER_WORKER_ENTRY from hf_env_overrides: cli.ts sets this on every invocation to point the bundled shader worker pool at its own file, sharing the HF_ prefix by coincidence rather than because an operator set it. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * style: remove em and en dashes from added code comments No behavior change. Rewrites 22 comment lines this PR's own diff introduced, using a comma or a period where the dash separated two clauses. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * test(producer): add a temporary diagnostic for a CI-only rootBodyMismatch failure Not a real fix. The rootBodyMismatch test group fails deterministically in CI (confirmed on two runs of the same head) but will not reproduce locally by any method tried, including an isolated file run, the exact combined producer:test:unit command, a worker-count-constrained run, and a fresh clone with a clean install and build matching CI's own steps. This dumps the intermediate regex-match state for the simplest failing fixture to stderr so the next CI run's log says what actually differs. To be removed once that answer lands. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * test(producer): widen the rootBodyMismatch diagnostic to compare import paths Still not a real fix. The previous diagnostic (ca4e73983) proved the imported HTML_BODY_CSS_WIDTH_FIRST_RE has 4 capture groups in the failing CI run instead of the 2 the source and production code expect, but it used a dynamic import(), which can resolve through a different codepath than renderOrchestrator.ts's static import. This adds a static import of the same binding, a require.resolve() of the resolved file path, and a direct read of that file's own regex line, so the next run can rule in or out a static/dynamic resolution split versus a genuinely different file on disk. Locally both imports agree (2 groups, same object, correct file). To be removed once the CI answer lands. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * fix(producer): read the merged 4-group scaffold-size regex correctly main merged #4012 while this branch was in flight, consolidating HTML_BODY_CSS_WIDTH_FIRST_RE/HEIGHT_FIRST_RE from 2 capture groups (digits only) to 4 (prefix text, digits, suffix text, digits) so cli's applyResolutionPreset could reuse the same regex for its in-place replace. detectRootBodySizeMismatch still read groups 1/2 as the digits, now the prefix/suffix text, so Number() on them was NaN and every render's rootBodyMismatch/rootBodyDeltaPxBucket silently came back undefined. Fixed to read groups 2/4, matching lint's core.ts readHtmlBodyCssSize exactly. Removes the temporary diagnostic test (ca4e73983,e2e384c8e) now that its CI log gave the real answer: both a static and dynamic import of the regex resolved to the same file, and that file's own content had 4 groups because this branch's merge-base predates #4012, not because of any resolution or caching difference. A fresh CI run confirmed no CI-only failure remains after merging main and fixing the indices. Co-Authored-By: Miguel Ángel <miguel.sierra@heygen.com> * chore: nudge CI (no workflow run triggered on previous push) * chore: nudge CI again now that #4017 is out of draft --------- Co-authored-by: Miguel Ángel <miguel.sierra@heygen.com>
355 lines
13 KiB
TypeScript
355 lines
13 KiB
TypeScript
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
import type { RenderJob, RenderPerfSummary } from "@hyperframes/producer";
|
|
|
|
// Mock `../telemetry/events.js` so we can capture trackRenderComplete /
|
|
// trackRenderError calls and verify the payload mapping without firing
|
|
// network requests.
|
|
const trackRenderComplete = vi.fn();
|
|
const trackRenderError = vi.fn();
|
|
vi.mock("../telemetry/events.js", () => ({
|
|
trackRenderComplete: (...args: unknown[]) => trackRenderComplete(...args),
|
|
trackRenderError: (...args: unknown[]) => trackRenderError(...args),
|
|
}));
|
|
|
|
// Imported after the mock is registered so the module picks up the mocked
|
|
// trackRenderComplete / trackRenderError.
|
|
const { emitStudioRenderComplete, emitStudioRenderError } =
|
|
await import("./studioRenderTelemetry.js");
|
|
|
|
const opts = {
|
|
fps: { num: 30, den: 1 } as const,
|
|
quality: "standard",
|
|
};
|
|
|
|
const fullObservability: NonNullable<RenderPerfSummary["observability"]> = {
|
|
renderJobId: "render-123",
|
|
compositionHash: "abc123",
|
|
eventCount: 8,
|
|
lastEvent: {
|
|
phase: "pipeline",
|
|
status: "checkpoint",
|
|
elapsedMs: 5000,
|
|
message: "completed",
|
|
},
|
|
failedPhase: undefined,
|
|
browserDiagnostics: {
|
|
total: 4,
|
|
errors: 1,
|
|
pageErrors: 0,
|
|
requestFailed: 1,
|
|
httpErrors: 1,
|
|
navigationStarts: 1,
|
|
navigationFailures: 0,
|
|
consoleErrors: 0,
|
|
consoleWarnings: 1,
|
|
},
|
|
capture: {
|
|
forceScreenshot: true,
|
|
captureMode: "screenshot",
|
|
workerCount: 1,
|
|
useStreamingEncode: false,
|
|
useLayeredComposite: true,
|
|
usePageSideCompositing: false,
|
|
hasHdrContent: true,
|
|
browserGpuMode: "auto",
|
|
protocolTimeoutMs: 300_000,
|
|
pageNavigationTimeoutMs: 60_000,
|
|
playerReadyTimeoutMs: 45_000,
|
|
adaptersUsed: ["gsap"],
|
|
audioCount: 2,
|
|
imageCount: 3,
|
|
rootBodyMismatch: true,
|
|
rootBodyDeltaPxBucket: "11-50",
|
|
},
|
|
extraction: {
|
|
videoCount: 6,
|
|
extractedVideoCount: 6,
|
|
totalFramesExtracted: 167_400,
|
|
maxFramesPerVideo: 27_900,
|
|
avgFramesPerExtractedVideo: 27_900,
|
|
vfrProbeMs: 120,
|
|
vfrPreflightMs: 2400,
|
|
vfrPreflightCount: 6,
|
|
cacheHits: 0,
|
|
cacheMisses: 6,
|
|
},
|
|
init: {
|
|
initDurationMs: 1234,
|
|
tweenCount: 42,
|
|
},
|
|
events: [],
|
|
};
|
|
|
|
const fullPerf: RenderPerfSummary = {
|
|
renderId: "r-1",
|
|
totalElapsedMs: 5000,
|
|
fps: 30,
|
|
quality: "standard",
|
|
workers: 4,
|
|
chunkedEncode: false,
|
|
chunkSizeFrames: null,
|
|
compositionDurationSeconds: 10,
|
|
totalFrames: 300,
|
|
resolution: { width: 1920, height: 1080 },
|
|
videoCount: 1,
|
|
audioCount: 0,
|
|
stages: {
|
|
compileMs: 100,
|
|
videoExtractMs: 200,
|
|
audioProcessMs: 50,
|
|
captureMs: 4000,
|
|
captureSetupMs: 750,
|
|
captureFrameMs: 3250,
|
|
encodeMs: 500,
|
|
assembleMs: 150,
|
|
},
|
|
videoExtractBreakdown: {
|
|
resolveMs: 10,
|
|
hdrProbeMs: 20,
|
|
hdrPreflightMs: 30,
|
|
hdrPreflightCount: 1,
|
|
vfrProbeMs: 40,
|
|
vfrPreflightMs: 50,
|
|
vfrPreflightCount: 2,
|
|
extractMs: 60,
|
|
cacheHits: 3,
|
|
cacheMisses: 4,
|
|
cachePublishFailures: 0,
|
|
cacheGcEvictions: 0,
|
|
cacheGcBytesFreed: 0,
|
|
cacheAgedPartialsCleared: 0,
|
|
},
|
|
tmpPeakBytes: 1024,
|
|
captureAvgMs: 13,
|
|
capturePeakMs: 25,
|
|
observability: fullObservability,
|
|
};
|
|
|
|
describe("studioRenderTelemetry", () => {
|
|
beforeEach(() => {
|
|
trackRenderComplete.mockClear();
|
|
trackRenderError.mockClear();
|
|
});
|
|
|
|
describe("emitStudioRenderComplete", () => {
|
|
it("tags the event with source: 'studio' and fps as a number", () => {
|
|
emitStudioRenderComplete(opts, 5000, fullPerf);
|
|
expect(trackRenderComplete).toHaveBeenCalledOnce();
|
|
const payload = trackRenderComplete.mock.calls[0]![0];
|
|
expect(payload.source).toBe("studio");
|
|
expect(payload.fps).toBe(30);
|
|
expect(payload.quality).toBe("standard");
|
|
expect(payload.docker).toBe(false);
|
|
expect(payload.gpu).toBe(false);
|
|
});
|
|
|
|
it("forwards the browser user's distinctId so the render funnel is joinable", () => {
|
|
emitStudioRenderComplete({ ...opts, distinctId: "browser-user-123" }, 5000, fullPerf);
|
|
expect(trackRenderComplete.mock.calls[0]![0].distinctId).toBe("browser-user-123");
|
|
});
|
|
|
|
it("leaves distinctId undefined for older clients that don't send one", () => {
|
|
emitStudioRenderComplete(opts, 5000, fullPerf);
|
|
expect(trackRenderComplete.mock.calls[0]![0].distinctId).toBeUndefined();
|
|
});
|
|
|
|
it("maps every RenderPerfSummary field to the expected payload key", () => {
|
|
emitStudioRenderComplete(opts, 5000, fullPerf);
|
|
const p = trackRenderComplete.mock.calls[0]![0];
|
|
expect(p.durationMs).toBe(5000);
|
|
expect(p.workers).toBe(4);
|
|
expect(p.compositionDurationMs).toBe(10_000);
|
|
expect(p.compositionWidth).toBe(1920);
|
|
expect(p.compositionHeight).toBe(1080);
|
|
expect(p.totalFrames).toBe(300);
|
|
// speedRatio = compositionDurationMs / elapsedMs = 10000 / 5000 = 2
|
|
expect(p.speedRatio).toBe(2);
|
|
expect(p.captureAvgMs).toBe(13);
|
|
expect(p.capturePeakMs).toBe(25);
|
|
expect(p.tmpPeakBytes).toBe(1024);
|
|
// stages
|
|
expect(p.stageCompileMs).toBe(100);
|
|
expect(p.stageVideoExtractMs).toBe(200);
|
|
expect(p.stageAudioProcessMs).toBe(50);
|
|
expect(p.stageCaptureMs).toBe(4000);
|
|
expect(p.stageCaptureSetupMs).toBe(750);
|
|
expect(p.stageCaptureFrameMs).toBe(3250);
|
|
expect(p.stageEncodeMs).toBe(500);
|
|
expect(p.stageAssembleMs).toBe(150);
|
|
// video-extract breakdown
|
|
expect(p.extractResolveMs).toBe(10);
|
|
expect(p.extractHdrProbeMs).toBe(20);
|
|
expect(p.extractHdrPreflightMs).toBe(30);
|
|
expect(p.extractHdrPreflightCount).toBe(1);
|
|
expect(p.extractVfrProbeMs).toBe(40);
|
|
expect(p.extractVfrPreflightMs).toBe(50);
|
|
expect(p.extractVfrPreflightCount).toBe(2);
|
|
// `extractMs` on RenderPerfSummary maps to `extractPhase3Ms` on the event
|
|
// (named for legacy reasons — see packages/cli/src/commands/render.ts).
|
|
expect(p.extractPhase3Ms).toBe(60);
|
|
expect(p.extractCacheHits).toBe(3);
|
|
expect(p.extractCacheMisses).toBe(4);
|
|
// observability aggregate
|
|
expect(p.observabilityRenderJobId).toBe("render-123");
|
|
expect(p.observabilityCompositionHash).toBe("abc123");
|
|
expect(p.observabilityEventCount).toBe(8);
|
|
expect(p.observabilityLastPhase).toBe("pipeline");
|
|
expect(p.observabilityLastStatus).toBe("checkpoint");
|
|
expect(p.browserDiagnosticCount).toBe(4);
|
|
expect(p.browserDiagnosticErrors).toBe(1);
|
|
expect(p.browserDiagnosticRequestFailed).toBe(1);
|
|
expect(p.browserDiagnosticHttpErrors).toBe(1);
|
|
expect(p.browserDiagnosticNavigationStarts).toBe(1);
|
|
expect(p.browserDiagnosticConsoleWarnings).toBe(1);
|
|
expect(p.captureMode).toBe("screenshot");
|
|
expect(p.captureForceScreenshot).toBe(true);
|
|
expect(p.captureWorkerCount).toBe(1);
|
|
expect(p.captureUseLayeredComposite).toBe(true);
|
|
expect(p.captureHasHdrContent).toBe(true);
|
|
expect(p.capturePageNavigationTimeoutMs).toBe(60_000);
|
|
expect(p.observabilityExtractVideoCount).toBe(6);
|
|
expect(p.observabilityExtractedVideoCount).toBe(6);
|
|
expect(p.observabilityExtractTotalFrames).toBe(167_400);
|
|
expect(p.observabilityExtractMaxFramesPerVideo).toBe(27_900);
|
|
expect(p.observabilityExtractAvgFramesPerVideo).toBe(27_900);
|
|
expect(p.observabilityExtractVfrPreflightCount).toBe(6);
|
|
expect(p.observabilityExtractCacheMisses).toBe(6);
|
|
expect(p.observabilityInitDurationMs).toBe(1234);
|
|
expect(p.observabilityInitTweenCount).toBe(42);
|
|
// capture.audioCount / imageCount / rootBodyMismatch / adaptersUsed are the
|
|
// only source for these on a studio render, since no drawElement resolves here.
|
|
// events.ts's trackRenderComplete falls back to captureXxx precisely because
|
|
// this path only ever supplies these, never the direct field.
|
|
expect(p.captureAdaptersUsed).toEqual(["gsap"]);
|
|
expect(p.captureAudioCount).toBe(2);
|
|
expect(p.captureImageCount).toBe(3);
|
|
expect(p.captureRootBodyMismatch).toBe(true);
|
|
expect(p.captureRootBodyDeltaPxBucket).toBe("11-50");
|
|
});
|
|
|
|
it("omits all perf-derived fields when perfSummary is undefined", () => {
|
|
emitStudioRenderComplete(opts, 5000, undefined);
|
|
const p = trackRenderComplete.mock.calls[0]![0];
|
|
// Identity fields still present
|
|
expect(p.source).toBe("studio");
|
|
expect(p.fps).toBe(30);
|
|
expect(p.durationMs).toBe(5000);
|
|
// Perf-derived fields all undefined
|
|
expect(p.workers).toBeUndefined();
|
|
expect(p.compositionDurationMs).toBeUndefined();
|
|
expect(p.totalFrames).toBeUndefined();
|
|
expect(p.speedRatio).toBeUndefined();
|
|
expect(p.stageCompileMs).toBeUndefined();
|
|
expect(p.extractResolveMs).toBeUndefined();
|
|
});
|
|
|
|
it("omits videoExtractBreakdown fields when only the breakdown is absent", () => {
|
|
const perfNoExtract: RenderPerfSummary = { ...fullPerf, videoExtractBreakdown: undefined };
|
|
emitStudioRenderComplete(opts, 5000, perfNoExtract);
|
|
const p = trackRenderComplete.mock.calls[0]![0];
|
|
expect(p.workers).toBe(4);
|
|
expect(p.extractResolveMs).toBeUndefined();
|
|
expect(p.extractCacheHits).toBeUndefined();
|
|
});
|
|
|
|
it("leaves speedRatio undefined when elapsedMs is zero", () => {
|
|
emitStudioRenderComplete(opts, 0, fullPerf);
|
|
const p = trackRenderComplete.mock.calls[0]![0];
|
|
expect(p.speedRatio).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("emitStudioRenderError", () => {
|
|
it("tags with source: 'studio' and forwards failedStage + elapsedMs", () => {
|
|
emitStudioRenderError(opts, 1200, "encode", new Error("boom"), undefined);
|
|
expect(trackRenderError).toHaveBeenCalledOnce();
|
|
const p = trackRenderError.mock.calls[0]![0];
|
|
expect(p.source).toBe("studio");
|
|
expect(p.fps).toBe(30);
|
|
expect(p.quality).toBe("standard");
|
|
expect(p.docker).toBe(false);
|
|
expect(p.failedStage).toBe("encode");
|
|
expect(p.elapsedMs).toBe(1200);
|
|
expect(p.errorMessage).toBe("boom");
|
|
});
|
|
|
|
it("stringifies non-Error throwables", () => {
|
|
emitStudioRenderError(opts, 100, undefined, "string error", undefined);
|
|
expect(trackRenderError.mock.calls[0]![0].errorMessage).toBe("string error");
|
|
});
|
|
|
|
it("does not include a workers field on the error event payload", () => {
|
|
// Documented behavior: studio renders don't request a worker count,
|
|
// and the early-failure path doesn't have perfSummary to read it from.
|
|
emitStudioRenderError(opts, 100, undefined, new Error("x"), undefined);
|
|
const p = trackRenderError.mock.calls[0]![0];
|
|
expect(p.workers).toBeUndefined();
|
|
});
|
|
|
|
it("maps observability from a failed producer job", () => {
|
|
const job: RenderJob = {
|
|
id: "r-error",
|
|
config: { fps: opts.fps, quality: "standard" },
|
|
status: "failed",
|
|
progress: 25,
|
|
currentStage: "Starting frame capture",
|
|
createdAt: new Date(),
|
|
warnings: [],
|
|
errorDetails: {
|
|
message: "Navigation timeout of 60000 ms exceeded",
|
|
elapsedMs: 60_001,
|
|
freeMemoryMB: 1024,
|
|
observability: {
|
|
...fullObservability,
|
|
failedPhase: "capture_hdr_layered",
|
|
lastEvent: {
|
|
phase: "capture_hdr_layered",
|
|
status: "error",
|
|
elapsedMs: 60_001,
|
|
durationMs: 60_000,
|
|
message: "Navigation timeout of 60000 ms exceeded",
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
emitStudioRenderError(opts, 60_001, "Starting frame capture", new Error("timeout"), job);
|
|
|
|
const p = trackRenderError.mock.calls[0]![0];
|
|
expect(p.observabilityFailedPhase).toBe("capture_hdr_layered");
|
|
expect(p.observabilityLastPhase).toBe("capture_hdr_layered");
|
|
expect(p.observabilityLastStatus).toBe("error");
|
|
expect(p.browserDiagnosticCount).toBe(4);
|
|
expect(p.captureMode).toBe("screenshot");
|
|
expect(p.capturePageNavigationTimeoutMs).toBe(60_000);
|
|
expect(p.observabilityExtractTotalFrames).toBe(167_400);
|
|
expect(p.observabilityExtractVfrPreflightCount).toBe(6);
|
|
});
|
|
});
|
|
|
|
// The browser profile's opt-out is invisible to the CLI's own policy, so
|
|
// without an explicit signal these fired for an opted-out user — attributed
|
|
// to the install id, which is worse than attributing them correctly.
|
|
describe("browser telemetry opt-out", () => {
|
|
it("emits nothing for a render whose browser opted out", () => {
|
|
emitStudioRenderComplete({ ...opts, telemetryOptOut: true }, 5000, fullPerf);
|
|
emitStudioRenderError(
|
|
{ ...opts, telemetryOptOut: true },
|
|
1200,
|
|
"encode",
|
|
new Error("boom"),
|
|
undefined,
|
|
);
|
|
expect(trackRenderComplete).not.toHaveBeenCalled();
|
|
expect(trackRenderError).not.toHaveBeenCalled();
|
|
});
|
|
|
|
// An older client sends no flag at all. That is not consent withdrawn, and
|
|
// treating it as such would silently drop every pre-upgrade render.
|
|
it.each([undefined, false])("still emits when telemetryOptOut is %s", (flag) => {
|
|
emitStudioRenderComplete({ ...opts, telemetryOptOut: flag }, 5000, fullPerf);
|
|
expect(trackRenderComplete).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|
|
});
|