Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/cli/src/commands/check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,9 @@ describe("check pipeline", () => {
expect(reached?.message).toMatch(
/^Check reached its --budget of 70 s while running the overlap pass .*Seconds per phase: /,
);
expect(trackCheckReport).toHaveBeenCalledWith(
expect.objectContaining({ ok: false, stopCode: "check_budget_reached" }),
);
expect(report.ok).toBe(false);
expect(report.layout.findings.some((finding) => finding.code === "container_overflow")).toBe(
true,
Expand Down Expand Up @@ -3626,6 +3629,7 @@ describe("check report telemetry", () => {
}),
);
expect(report.contrast.errorCount).toBe(1);
expect(trackCheckReport.mock.calls[0]?.[0].stopCode).toBeUndefined();
});

it("reports zero browser samples and timings after a lint short circuit", async () => {
Expand Down
40 changes: 40 additions & 0 deletions packages/cli/src/telemetry/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,46 @@ describe("trackCheckReport", () => {
});
});

it("names the finding that stopped the check, and omits it when none did", () => {
const props = {
contrastGate: false,
motionGate: false,
captionZoneGate: false,
frameCheckGate: false,
snapshotsGate: false,
lintErrors: 0,
lintWarnings: 0,
runtimeErrors: 1,
runtimeWarnings: 0,
layoutErrors: 0,
layoutWarnings: 0,
motionErrors: 0,
motionWarnings: 0,
contrastErrors: 0,
contrastWarnings: 0,
craftWarnings: 0,
launchSettleMs: 0,
renderReadyTimedOut: false,
seekLoopMs: 0,
contrastMs: 0,
gridMs: 0,
craftMs: 0,
overlapMs: 0,
durationSec: 0,
gridPoints: 0,
contrastPoints: 0,
ok: false,
exitCode: 1,
};
trackCheckReport({ ...props, stopCode: "media_copies_unfinished" });
expect(trackEvent).toHaveBeenLastCalledWith(
"check_report",
expect.objectContaining({ stop_code: "media_copies_unfinished" }),
);
trackCheckReport(props);
expect(trackEvent.mock.calls.at(-1)?.[1]).not.toHaveProperty("stop_code");
});

it("omits run_id when no run ID is provided", () => {
trackCheckReport({
contrastGate: false,
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/telemetry/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { BrowserInstallFacts } from "../browser/installFacts.js";
import type { StopCode } from "../utils/checkPipeline.js";
import type { OutputResolutionIssueKind } from "@hyperframes/core";
import { redactTelemetryString } from "@hyperframes/core/telemetry-redaction";
import type { SubTimelineWaitOutcome } from "@hyperframes/engine";
Expand Down Expand Up @@ -1193,6 +1194,7 @@ export function trackCheckReport(props: {
contrastPoints: number;
ok: boolean;
exitCode: number;
stopCode?: StopCode;
runId?: string;
}): void {
trackEvent("check_report", {
Expand Down Expand Up @@ -1224,6 +1226,7 @@ export function trackCheckReport(props: {
contrast_points: props.contrastPoints,
ok: props.ok,
exit_code: props.exitCode,
...(props.stopCode && { stop_code: props.stopCode }),
...runIdField(props.runId),
});
}
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/src/utils/checkPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,9 @@ function buildReport(
contrastPoints: browser.contrastChecked,
ok: report.ok,
exitCode: checkExitCode(report),
stopCode: browser.runtimeFindings
.map((finding) => finding.code)
.find((code): code is StopCode => (STOP_CODES as readonly string[]).includes(code)),
runId: getRunId(),
});
return filterComponentReport(report, options);
Expand Down Expand Up @@ -2264,6 +2267,13 @@ function emptyBrowserResult(): CheckBrowserResult {
};
}

export const STOP_CODES = [
"media_copies_unfinished",
"check_budget_reached",
"check_runtime_failure",
] as const;
export type StopCode = (typeof STOP_CODES)[number];

function runtimeFailure(error: unknown, code?: string): CheckFinding {
return findingAtRoot(
code ??
Expand Down
Loading