mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(core,cli): attribute figma REST failures to the endpoint that failed
cli_error had no way to tell which figma REST call (images, files_nodes, variables_local, styles, ...) actually hit RATE_LIMITED/FORBIDDEN/etc, so the dashboard could see failures spike but not which call caused them. FigmaClientError now carries a low-cardinality endpoint label (never the raw fileKey/nodeId), threaded through to cli_error's endpoint property.
This commit is contained in:
@@ -29,6 +29,7 @@ export async function withFigmaErrors(command: string, fn: () => Promise<void>):
|
||||
stack_trace: err.stack,
|
||||
command,
|
||||
kind: "command_error",
|
||||
endpoint: err instanceof FigmaClientError ? err.endpoint : undefined,
|
||||
});
|
||||
await telemetry.flush();
|
||||
} catch {
|
||||
|
||||
@@ -431,6 +431,21 @@ describe("trackCliError", () => {
|
||||
expect(props.error_message).toContain("[path]");
|
||||
expect(props.stack_trace).not.toContain("/Users/alice");
|
||||
});
|
||||
|
||||
it("forwards the figma endpoint label when supplied", () => {
|
||||
trackCliError({
|
||||
error_name: "RATE_LIMITED",
|
||||
error_message: "figma rate limit hit (429)",
|
||||
command: "figma asset",
|
||||
kind: "command_error",
|
||||
endpoint: "images",
|
||||
});
|
||||
|
||||
expect(trackEvent).toHaveBeenCalledWith(
|
||||
"cli_error",
|
||||
expect.objectContaining({ endpoint: "images" }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("trackCommandFailure", () => {
|
||||
|
||||
@@ -490,6 +490,9 @@ export function trackCliError(props: {
|
||||
stack_trace?: string;
|
||||
command?: string;
|
||||
kind: "uncaught_exception" | "unhandled_rejection" | "command_error";
|
||||
/** Low-cardinality figma REST call label (e.g. "images", "files_nodes") —
|
||||
* which endpoint failed, for FigmaClientError-backed failures only. */
|
||||
endpoint?: string;
|
||||
}): void {
|
||||
trackEvent("cli_error", {
|
||||
error_name: props.error_name,
|
||||
@@ -502,6 +505,7 @@ export function trackCliError(props: {
|
||||
: undefined,
|
||||
command: props.command,
|
||||
kind: props.kind,
|
||||
endpoint: props.endpoint,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user