Integrate OpenHandoff factory workspace (#212)

This commit is contained in:
Nathan Flurry 2026-03-09 14:00:20 -07:00 committed by GitHub
parent 3d9476ed0b
commit bf282199b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
251 changed files with 42824 additions and 692 deletions

View file

@ -0,0 +1,41 @@
import type { FrontendErrorContext } from "./types.js";
interface FrontendErrorCollectorGlobal {
setContext: (context: FrontendErrorContext) => void;
}
declare global {
interface Window {
__OPENHANDOFF_FRONTEND_ERROR_COLLECTOR__?: FrontendErrorCollectorGlobal;
__OPENHANDOFF_FRONTEND_ERROR_CONTEXT__?: FrontendErrorContext;
}
}
export function setFrontendErrorContext(context: FrontendErrorContext): void {
if (typeof window === "undefined") {
return;
}
const nextContext = sanitizeContext(context);
window.__OPENHANDOFF_FRONTEND_ERROR_CONTEXT__ = {
...(window.__OPENHANDOFF_FRONTEND_ERROR_CONTEXT__ ?? {}),
...nextContext,
};
window.__OPENHANDOFF_FRONTEND_ERROR_COLLECTOR__?.setContext(nextContext);
}
function sanitizeContext(input: FrontendErrorContext): FrontendErrorContext {
const output: FrontendErrorContext = {};
for (const [key, value] of Object.entries(input)) {
if (
value === null ||
value === undefined ||
typeof value === "string" ||
typeof value === "number" ||
typeof value === "boolean"
) {
output[key] = value;
}
}
return output;
}