feat: add diagnostics and telemetry runtime

This commit is contained in:
donghyeon-ka
2026-07-26 16:42:27 +09:00
parent 2fa0baa577
commit 5173b6c8d6
43 changed files with 1760 additions and 116 deletions
+27 -2
View File
@@ -36,6 +36,7 @@ describe("application input/output boundary", () => {
it("uses fake output ports for preference, session, and safe diagnostics flows", () => {
const write = vi.fn(() => ({ ok: true as const }));
const emit = vi.fn();
const record = vi.fn();
const ports = {
session: {
getState: () => "authenticated" as const,
@@ -49,7 +50,8 @@ describe("application input/output boundary", () => {
write,
remove: () => ({ ok: true as const }),
},
diagnostics: { emit },
diagnostics: { record },
telemetry: { emit },
releaseInfo: {
getCurrent: async () => ({
buildId: "build-a",
@@ -82,20 +84,43 @@ describe("application input/output boundary", () => {
buildId: "build-a",
boundaryName: "route",
});
expect(record).toHaveBeenCalledWith({
level: "error",
eventId: "ui.render.failed",
context: {
route_id: "APP_HOME",
build_id: "build-a",
component_boundary: "route",
},
});
expect(emit).toHaveBeenCalledWith("ui.render.failed", {
route_id: "APP_HOME",
build_id: "build-a",
component_boundary: "route",
});
application.diagnostics.reportRouteChanged({
routeId: "APP_HOME",
buildId: "build-a",
});
expect(record).toHaveBeenCalledWith({
level: "info",
eventId: "route.changed",
context: { route_id: "APP_HOME", build_id: "build-a" },
});
});
it("does not let a failing diagnostics output escape into presentation", () => {
const application = createTestApplication({
diagnostics: {
emit() {
record() {
throw new Error("sink details");
},
},
telemetry: {
emit() {
throw new Error("telemetry details");
},
},
});
expect(() =>