Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(analytics): include error ids in toast events (#18407)

Nikita Kabardinff0ef342ea59
diff --git a/web/src/features/notifications/ErrorNotification.clienttest.tsx b/web/src/features/notifications/ErrorNotification.clienttest.tsx
index f693a1e1a9..a5f3839641 100644
--- a/web/src/features/notifications/ErrorNotification.clienttest.tsx
+++ b/web/src/features/notifications/ErrorNotification.clienttest.tsx
@@ -30,7 +30,7 @@ describe("ErrorNotification", () => {
vi.clearAllMocks();
});
- it("captures one metadata-only shown event for a rendered error toast", async () => {
+ it("captures the displayed error ID without toast content", async () => {
const props = {
error: "Sensitive error title",
description: "Sensitive customer-controlled details",
@@ -50,6 +50,7 @@ describe("ErrorNotification", () => {
source: "trpc",
path: "traces.byId",
hasErrorId: true,
+ errorId: props.traceId,
});
});
@@ -66,9 +67,6 @@ describe("ErrorNotification", () => {
expect(JSON.stringify(mocks.capture.mock.calls[0]?.[1])).not.toContain(
"Sensitive",
);
- expect(JSON.stringify(mocks.capture.mock.calls[0]?.[1])).not.toContain(
- props.traceId,
- );
});
it("classifies a local warning without inventing tRPC metadata", async () => {
@@ -89,6 +87,7 @@ describe("ErrorNotification", () => {
hasErrorId: false,
});
});
+ expect(mocks.capture.mock.calls[0]?.[1]).not.toHaveProperty("errorId");
});
it("classifies a pathless tRPC warning by its explicit source", async () => {
diff --git a/web/src/features/notifications/ErrorNotification.tsx b/web/src/features/notifications/ErrorNotification.tsx
index 0a9b662771..ba2669c658 100644
--- a/web/src/features/notifications/ErrorNotification.tsx
+++ b/web/src/features/notifications/ErrorNotification.tsx
@@ -46,6 +46,7 @@ export const ErrorNotification: React.FC<ErrorNotificationProps> = ({
source,
...(path ? { path } : {}),
hasErrorId: Boolean(traceId),
+ ...(traceId ? { errorId: traceId } : {}),
});
};
diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.ts
index 832cf26e86..7996627f2c 100644
--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts
+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts
@@ -12,6 +12,7 @@ type ToastEventMap = {
source: "trpc" | "application";
path?: string;
hasErrorId: boolean;
+ errorId?: string;
};
};
@@ -378,7 +379,8 @@ const events = {
version_update: ["banner_shown", "reload_clicked", "dismissed"],
notification: ["click_link", "dismiss_notification"],
// User-visible error-frustration denominator. Metadata only: `path` is the
- // static tRPC procedure name; never send toast text or the raw Error ID.
+ // static tRPC procedure name and `errorId` is the opaque ID shown in the
+ // toast; never send toast text or error payloads.
toast: ["shown", "report_issue", "dismiss"],
tag: [
"add_existing_tag",