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
8 changes: 6 additions & 2 deletions frontend/src/renderer/components/NotificationCenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,24 @@ export function NotificationCenter({ style }: NotificationCenterProps) {

const markOneRead = async (id: string) => {
setActionError(null);
void captureRendererEvent("ao.renderer.notification_marked_read", { scope: "single" });
void captureRendererEvent("ao.renderer.notification_mark_read_requested", { scope: "single" });
try {
await markRead.mutateAsync(id);
void captureRendererEvent("ao.renderer.notification_mark_read_succeeded", { scope: "single" });
} catch (error) {
void captureRendererEvent("ao.renderer.notification_mark_read_failed", { scope: "single" });
setActionError(error instanceof Error ? error.message : "Could not mark notification read");
}
};

const markAll = async () => {
setActionError(null);
void captureRendererEvent("ao.renderer.notification_marked_read", { scope: "all" });
void captureRendererEvent("ao.renderer.notification_mark_read_requested", { scope: "all" });
try {
await markAllRead.mutateAsync();
void captureRendererEvent("ao.renderer.notification_mark_read_succeeded", { scope: "all" });
} catch (error) {
void captureRendererEvent("ao.renderer.notification_mark_read_failed", { scope: "all" });
setActionError(error instanceof Error ? error.message : "Could not mark notifications read");
}
};
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/renderer/lib/daemon-telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ describe("daemon failure telemetry", () => {
expect(captureMock).not.toHaveBeenCalled();
});

it("does not count ready-state daemon warnings as failures", () => {
stop = startDaemonFailureTelemetry();

pushStatus({ state: "ready", code: "port_unconfirmed" });

expect(captureMock).not.toHaveBeenCalled();
});

it("dedupes identical consecutive failures and resets on recovery", () => {
stop = startDaemonFailureTelemetry();

Expand Down
1 change: 1 addition & 0 deletions frontend/src/renderer/lib/daemon-telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let started = false;
let lastFailureKey: string | null = null;

function failureKey(status: DaemonStatus): string | null {
if (status.state === "ready") return null;
if (!status.code) return null;
return [status.state, status.code, status.exitCode ?? "", status.signal ?? ""].join("|");
}
Expand Down
14 changes: 10 additions & 4 deletions frontend/src/renderer/lib/telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,18 @@ describe("telemetry sanitizers", () => {
target: "pr",
});
expect(await sanitizeRendererProperties("ao.renderer.notification_opened", { target: "http://x" })).toEqual({});
expect(await sanitizeRendererProperties("ao.renderer.notification_marked_read", { scope: "all" })).toEqual({
expect(await sanitizeRendererProperties("ao.renderer.notification_mark_read_requested", { scope: "all" })).toEqual({
scope: "all",
});
expect(await sanitizeRendererProperties("ao.renderer.notification_marked_read", { scope: "everything" })).toEqual(
{},
);
expect(await sanitizeRendererProperties("ao.renderer.notification_mark_read_succeeded", { scope: "all" })).toEqual({
scope: "all",
});
expect(await sanitizeRendererProperties("ao.renderer.notification_mark_read_failed", { scope: "all" })).toEqual({
scope: "all",
});
expect(
await sanitizeRendererProperties("ao.renderer.notification_mark_read_requested", { scope: "everything" }),
).toEqual({});
});

it("whitelists coarse daemon failure fields and drops messages", async () => {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/renderer/lib/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ export async function sanitizeRendererProperties(
case "ao.renderer.notification_opened":
if (properties?.target === "pr" || properties?.target === "session") safe.target = properties.target;
break;
case "ao.renderer.notification_marked_read":
case "ao.renderer.notification_mark_read_requested":
case "ao.renderer.notification_mark_read_succeeded":
case "ao.renderer.notification_mark_read_failed":
if (properties?.scope === "single" || properties?.scope === "all") safe.scope = properties.scope;
break;
case "ao.renderer.daemon_failure":
Expand Down
Loading