Skip to content

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

fix(web): stop unrelated tRPC client errors from grouping into one Sentry issue (#15818)

Nikita Kabardin9a5b18ae7f2a
diff --git a/web/src/components/table/data-table-ai-filters.tsx b/web/src/components/table/data-table-ai-filters.tsx
index 8096fc1627..7f5419784b 100644
--- a/web/src/components/table/data-table-ai-filters.tsx
+++ b/web/src/components/table/data-table-ai-filters.tsx
@@ -11,7 +11,7 @@ import { Info } from "lucide-react";
import { useQueryProject } from "@/src/features/projects/hooks";
import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";
import { AIFeaturesDisabledNotice } from "@/src/features/organizations/components/AIFeaturesDisabledNotice";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { type FilterState } from "@langfuse/shared";
interface DataTableAIFiltersProps {
@@ -55,7 +55,7 @@ export function DataTableAIFilters({
setAiError("Invalid response format from API");
}
} catch (error) {
- console.error("Error calling tRPC API:", error);
+ reportNonTrpcError(error, "ai-filters");
setAiError(
error instanceof Error ? error.message : "Failed to generate filters",
);
diff --git a/web/src/ee/features/billing/components/SpendAlerts/DeleteSpendAlertDialog.tsx b/web/src/ee/features/billing/components/SpendAlerts/DeleteSpendAlertDialog.tsx
index f51c68e0ea..1f86aac168 100644
--- a/web/src/ee/features/billing/components/SpendAlerts/DeleteSpendAlertDialog.tsx
+++ b/web/src/ee/features/billing/components/SpendAlerts/DeleteSpendAlertDialog.tsx
@@ -8,7 +8,7 @@ import {
DialogTitle,
} from "@/src/components/ui/dialog";
import { Button } from "@/src/components/ui/button";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { toast } from "sonner";
@@ -46,7 +46,7 @@ export function DeleteSpendAlertDialog({
toast.success("Spend alert deleted successfully");
onSuccess();
} catch (error) {
- console.error("Failed to delete spend alert:", error);
+ reportNonTrpcError(error, "billing");
toast.error("Failed to delete spend alert. Please try again.");
} finally {
setIsDeleting(false);
diff --git a/web/src/ee/features/billing/components/SpendAlerts/SpendAlertDialog.tsx b/web/src/ee/features/billing/components/SpendAlerts/SpendAlertDialog.tsx
index 41d7d6d69b..1c328a4184 100644
--- a/web/src/ee/features/billing/components/SpendAlerts/SpendAlertDialog.tsx
+++ b/web/src/ee/features/billing/components/SpendAlerts/SpendAlertDialog.tsx
@@ -18,7 +18,7 @@ import {
} from "@/src/components/ui/form";
import { Input } from "@/src/components/ui/input";
import { Button } from "@/src/components/ui/button";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { toast } from "sonner";
import { Info } from "lucide-react";
@@ -102,7 +102,7 @@ export function SpendAlertDialog({
}
onSuccess();
} catch (error) {
- console.error("Failed to save spend alert:", error);
+ reportNonTrpcError(error, "billing");
toast.error(
`Failed to ${alert ? "update" : "create"} spend alert. Please try again.`,
);
diff --git a/web/src/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsx b/web/src/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsx
index 930df7cd8f..46b40bbd58 100644
--- a/web/src/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsx
+++ b/web/src/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsx
@@ -10,7 +10,7 @@ import {
DropdownMenuLabel,
} from "@/src/components/ui/dropdown-menu";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { type AnnotationQueueObjectType } from "@langfuse/shared";
import { ChevronDown, ExternalLink, ListPlus } from "lucide-react";
import { useSession } from "next-auth/react";
@@ -85,7 +85,7 @@ export const CreateNewAnnotationQueueItem = ({
objectType,
});
} catch (error) {
- console.error("Error toggling queue item:", error);
+ reportNonTrpcError(error, "annotation-queues");
}
},
[
diff --git a/web/src/features/automations/components/actions/WebhookActionForm.tsx b/web/src/features/automations/components/actions/WebhookActionForm.tsx
index 1aad511978..e87dfb5c75 100644
--- a/web/src/features/automations/components/actions/WebhookActionForm.tsx
+++ b/web/src/features/automations/components/actions/WebhookActionForm.tsx
@@ -26,7 +26,7 @@ import {
WebhookDefaultHeaders,
WebhookProtectedHeaders,
} from "@langfuse/shared";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { useState } from "react";
import {
Dialog,
@@ -383,7 +383,7 @@ export const RegenerateWebhookSecretButton = ({
});
setShowConfirmPopover(false);
} catch (error) {
- console.error("Failed to regenerate webhook secret:", error);
+ reportNonTrpcError(error, "automations");
}
};
diff --git a/web/src/features/datasets/components/DatasetForm.tsx b/web/src/features/datasets/components/DatasetForm.tsx
index 938aab2b88..dbf17cbf8b 100644
--- a/web/src/features/datasets/components/DatasetForm.tsx
+++ b/web/src/features/datasets/components/DatasetForm.tsx
@@ -12,7 +12,7 @@ import {
FormLabel,
FormMessage,
} from "@/src/components/ui/form";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import {
useMemo,
useState,
@@ -287,7 +287,7 @@ export const DatasetForm = forwardRef<DatasetFormRef, DatasetFormProps>(
// System error (not validation)
setFormError(error.message);
setServerSideSchemaValidationErrors(null);
- console.error(error);
+ reportNonTrpcError(error, "datasets");
});
} else if (props.mode === "update") {
capture("datasets:update_form_submit");
@@ -313,7 +313,7 @@ export const DatasetForm = forwardRef<DatasetFormRef, DatasetFormProps>(
// System error (not validation)
setFormError(error.message);
setServerSideSchemaValidationErrors(null);
- console.error(error);
+ reportNonTrpcError(error, "datasets");
});
}
}
diff --git a/web/src/features/datasets/components/NewDatasetItemForm.tsx b/web/src/features/datasets/components/NewDatasetItemForm.tsx
index b8b60580b4..47e8fddf22 100644
--- a/web/src/features/datasets/components/NewDatasetItemForm.tsx
+++ b/web/src/features/datasets/components/NewDatasetItemForm.tsx
@@ -12,7 +12,7 @@ import {
FormLabel,
FormMessage,
} from "@/src/components/ui/form";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import {
useState,
useMemo,
@@ -334,9 +334,7 @@ export const NewDatasetItemForm = (props: {
`Item does not match dataset schema. Errors: ${JSON.stringify(result.validationErrors, null, 2)}`,
);
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportTrpcErrorWithoutToast(error, "datasets"));
}
return (
diff --git a/web/src/features/evals/components/template-form.tsx b/web/src/features/evals/components/template-form.tsx
index 8adcec14b0..55396b2f23 100644
--- a/web/src/features/evals/components/template-form.tsx
+++ b/web/src/features/evals/components/template-form.tsx
@@ -13,7 +13,7 @@ import {
FormLabel,
FormMessage,
} from "@/src/components/ui/form";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import { zodResolver } from "@hookform/resolvers/zod";
import {
createBooleanEvalOutputDefinition,
@@ -440,12 +440,14 @@ export const InnerEvalTemplateForm = (props: {
);
})
.catch((error) => {
+ // The mutation's local onError owns the form UX; this owns
+ // classification + Sentry capture.
+ reportTrpcErrorWithoutToast(error, "evals");
if ("message" in error && typeof error.message === "string") {
setFormError(error.message as string);
return;
}
setFormError(JSON.stringify(error));
- console.error(error);
});
}
diff --git a/web/src/features/evals/pages/remap-evaluator.tsx b/web/src/features/evals/pages/remap-evaluator.tsx
index 664f5a70a8..573106ab21 100644
--- a/web/src/features/evals/pages/remap-evaluator.tsx
+++ b/web/src/features/evals/pages/remap-evaluator.tsx
@@ -1,7 +1,7 @@
import { useState, useMemo } from "react";
import { useRouter } from "next/router";
import Page from "@/src/components/layouts/page";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import { InnerEvaluatorForm } from "@/src/features/evals/components/inner-evaluator-form";
import {
mapLegacyToModernTarget,
@@ -130,8 +130,8 @@ export default function RemapEvaluatorPage() {
break;
}
} catch (err) {
- // Error already handled in mutation onError
- console.error(`Failed to ${legacyAction} old eval:`, err);
+ // The mutations' local onError owns the UX; this owns classification + capture.
+ reportTrpcErrorWithoutToast(err, "evals");
}
};
diff --git a/web/src/features/filters/components/filter-builder.tsx b/web/src/features/filters/components/filter-builder.tsx
index ae809ca9f5..f008f438ef 100644
--- a/web/src/features/filters/components/filter-builder.tsx
+++ b/web/src/features/filters/components/filter-builder.tsx
@@ -18,7 +18,7 @@ import {
type SetStateAction,
} from "react";
import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import {
Check,
ChevronDown,
@@ -603,7 +603,7 @@ function FilterBuilderForm({
setAiError("Invalid response format from API");
}
} catch (error) {
- console.error("Error calling tRPC API:", error);
+ reportNonTrpcError(error, "ai-filters");
setAiError(
error instanceof Error ? error.message : "Failed to generate filters",
);
diff --git a/web/src/features/organizations/components/DeleteOrganizationButton.tsx b/web/src/features/organizations/components/DeleteOrganizationButton.tsx
index 675977746e..65f2bf67ad 100644
--- a/web/src/features/organizations/components/DeleteOrganizationButton.tsx
+++ b/web/src/features/organizations/components/DeleteOrganizationButton.tsx
@@ -17,7 +17,7 @@ import {
FormMessage,
} from "@/src/components/ui/form";
import { Input } from "@/src/components/ui/input";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import * as z from "zod";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
@@ -69,7 +69,9 @@ export function DeleteOrganizationButton() {
await new Promise((resolve) => setTimeout(resolve, 5000)); // Delay for 5 seconds
window.location.href = env.NEXT_PUBLIC_BASE_PATH ?? "/"; // Browser reload to refresh jwt
} catch (error) {
- console.error(error);
+ // tRPC failures were already classified + toasted by the react-query
+ // default onError; only report failures of the post-success work here.
+ reportNonTrpcError(error, "organizations");
}
};
diff --git a/web/src/features/organizations/components/NewOrganizationForm.tsx b/web/src/features/organizations/components/NewOrganizationForm.tsx
index f10c9c8720..e3609337bb 100644
--- a/web/src/features/organizations/components/NewOrganizationForm.tsx
+++ b/web/src/features/organizations/components/NewOrganizationForm.tsx
@@ -11,7 +11,7 @@ import {
FormMessage,
} from "@/src/components/ui/form";
import { Input } from "@/src/components/ui/input";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import { useSession } from "next-auth/react";
import { organizationFormSchema } from "@/src/features/organizations/utils/organizationNameSchema";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
@@ -48,9 +48,7 @@ export const NewOrganizationForm = ({
await onSuccess(org.id);
form.reset();
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportTrpcErrorWithoutToast(error, "organizations"));
}
return (
diff --git a/web/src/features/organizations/components/RenameOrganization.tsx b/web/src/features/organizations/components/RenameOrganization.tsx
index 30551b0c31..d43412b130 100644
--- a/web/src/features/organizations/components/RenameOrganization.tsx
+++ b/web/src/features/organizations/components/RenameOrganization.tsx
@@ -1,6 +1,6 @@
import { Button } from "@/src/components/ui/button";
import { Input } from "@/src/components/ui/input";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import type * as z from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
@@ -60,9 +60,7 @@ export default function RenameOrganization() {
.then(() => {
form.reset();
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportTrpcErrorWithoutToast(error, "organizations"));
}
return (
diff --git a/web/src/features/projects/components/ConfigureRetention.tsx b/web/src/features/projects/components/ConfigureRetention.tsx
index 93b0ff5861..eac49e4206 100644
--- a/web/src/features/projects/components/ConfigureRetention.tsx
+++ b/web/src/features/projects/components/ConfigureRetention.tsx
@@ -1,6 +1,6 @@
import { Card } from "@/src/components/ui/card";
import { Input } from "@/src/components/ui/input";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import type * as z from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
@@ -59,9 +59,7 @@ export default function ConfigureRetention() {
.then(() => {
form.reset();
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportTrpcErrorWithoutToast(error, "projects"));
}
return (
diff --git a/web/src/features/projects/components/DeleteProjectButton.tsx b/web/src/features/projects/components/DeleteProjectButton.tsx
index 8b5cd27066..d82ba33b4a 100644
--- a/web/src/features/projects/components/DeleteProjectButton.tsx
+++ b/web/src/features/projects/components/DeleteProjectButton.tsx
@@ -17,7 +17,7 @@ import {
FormMessage,
} from "@/src/components/ui/form";
import { Input } from "@/src/components/ui/input";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import * as z from "zod";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
@@ -66,9 +66,7 @@ export function DeleteProjectButton() {
.then(() => {
window.location.href = env.NEXT_PUBLIC_BASE_PATH ?? "/"; // browser reload to refresh jwt
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportNonTrpcError(error, "projects"));
};
return (
diff --git a/web/src/features/projects/components/NewProjectForm.tsx b/web/src/features/projects/components/NewProjectForm.tsx
index 7adfaea395..81d8dc63bb 100644
--- a/web/src/features/projects/components/NewProjectForm.tsx
+++ b/web/src/features/projects/components/NewProjectForm.tsx
@@ -11,7 +11,7 @@ import {
FormMessage,
} from "@/src/components/ui/form";
import { Input } from "@/src/components/ui/input";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import { useSession } from "next-auth/react";
import { projectNameSchema } from "@/src/features/auth/lib/projectNameSchema";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
@@ -50,9 +50,7 @@ export const NewProjectForm = ({
onSuccess(project.id);
form.reset();
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportTrpcErrorWithoutToast(error, "projects"));
}
return (
<Form {...form}>
diff --git a/web/src/features/projects/components/RenameProject.tsx b/web/src/features/projects/components/RenameProject.tsx
index 8c4db92496..ccc4f0d24c 100644
--- a/web/src/features/projects/components/RenameProject.tsx
+++ b/web/src/features/projects/components/RenameProject.tsx
@@ -1,7 +1,7 @@
import { Card } from "@/src/components/ui/card";
import { Button } from "@/src/components/ui/button";
import { Input } from "@/src/components/ui/input";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import type * as z from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
@@ -57,9 +57,7 @@ export default function RenameProject() {
.then(() => {
form.reset();
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportTrpcErrorWithoutToast(error, "projects"));
}
return (
diff --git a/web/src/features/prompts/components/NewPromptForm/index.tsx b/web/src/features/prompts/components/NewPromptForm/index.tsx
index 141581dd90..87c0aa3b61 100644
--- a/web/src/features/prompts/components/NewPromptForm/index.tsx
+++ b/web/src/features/prompts/components/NewPromptForm/index.tsx
@@ -21,7 +21,7 @@ import {
} from "@/src/components/ui/tabs";
import { Textarea } from "@/src/components/ui/textarea";
import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import { zodResolver } from "@hookform/resolvers/zod";
import {
type CreatePromptTRPCType,
@@ -174,9 +174,7 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {
router.push(getPromptDetailHref(projectId, newPrompt.name));
}
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportTrpcErrorWithoutToast(error, "prompts"));
}
const hasInitializedMessages = useRef(false);
diff --git a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx
index 260edcbf85..5268b63a93 100644
--- a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx
+++ b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx
@@ -15,7 +15,7 @@ import {
} from "@/src/components/ui/popover";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import {
PRODUCTION_LABEL,
PromptLabelSchema,
@@ -111,7 +111,7 @@ export function SetPromptVersionLabels({
capture("prompt_detail:apply_labels", { labels: selectedLabels });
setIsOpen(false);
} catch (err) {
- console.error(err);
+ reportNonTrpcError(err, "prompts");
}
};
diff --git a/web/src/features/prompts/components/duplicate-prompt.tsx b/web/src/features/prompts/components/duplicate-prompt.tsx
index d9144c320b..46721eb11c 100644
--- a/web/src/features/prompts/components/duplicate-prompt.tsx
+++ b/web/src/features/prompts/components/duplicate-prompt.tsx
@@ -1,6 +1,6 @@
import { useRouter } from "next/router";
import { Button } from "@/src/components/ui/button";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { Copy } from "lucide-react";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import {
@@ -82,9 +82,7 @@ const DuplicatePromptForm: React.FC<{
onFormSuccess();
form.reset();
})
- .catch((error: Error) => {
- console.error(error);
- });
+ .catch((error) => reportNonTrpcError(error, "prompts"));
}
const allPrompts = api.prompts.filterOptions.useQuery(
diff --git a/web/src/features/public-api/components/ApiKeyList.tsx b/web/src/features/public-api/components/ApiKeyList.tsx
index 21b4811e66..2d94282557 100644
--- a/web/src/features/public-api/components/ApiKeyList.tsx
+++ b/web/src/features/public-api/components/ApiKeyList.tsx
@@ -17,7 +17,7 @@ import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePos
import { CreateApiKeyButton } from "@/src/features/public-api/components/CreateApiKeyButton";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { TrashIcon } from "lucide-react";
import { useState } from "react";
import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert";
@@ -228,9 +228,7 @@ function DeleteApiKeyButton(props: {
capture(`${scope}_settings:api_key_delete`);
setOpen(false);
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportNonTrpcError(error, "api-keys"));
} else {
mutDeleteOrgApiKey
.mutateAsync({
@@ -241,9 +239,7 @@ function DeleteApiKeyButton(props: {
capture(`${scope}_settings:api_key_delete`);
setOpen(false);
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportNonTrpcError(error, "api-keys"));
}
};
diff --git a/web/src/features/public-api/components/CreateApiKeyButton.tsx b/web/src/features/public-api/components/CreateApiKeyButton.tsx
index 8a4dbc7432..ce93c94115 100644
--- a/web/src/features/public-api/components/CreateApiKeyButton.tsx
+++ b/web/src/features/public-api/components/CreateApiKeyButton.tsx
@@ -1,6 +1,6 @@
import { Button } from "@/src/components/ui/button";
import { Dialog, DialogTrigger } from "@/src/components/ui/dialog";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { useState } from "react";
import { PlusIcon } from "lucide-react";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
@@ -68,9 +68,7 @@ export function CreateApiKeyButton(props: {
});
capture(`${props.scope}_settings:api_key_create`);
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportNonTrpcError(error, "api-keys"));
} else {
mutCreateOrgApiKey
.mutateAsync({
@@ -84,9 +82,7 @@ export function CreateApiKeyButton(props: {
});
capture(`${props.scope}_settings:api_key_create`);
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportNonTrpcError(error, "api-keys"));
}
};
diff --git a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx
index 09df9bf029..fa270d5cf2 100644
--- a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx
+++ b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx
@@ -33,7 +33,7 @@ import {
} from "@/src/components/ui/select";
import { Switch } from "@/src/components/design-system/Switch/Switch";
import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";
-import { api, type RouterOutputs } from "@/src/utils/api";
+import { api, reportNonTrpcError, type RouterOutputs } from "@/src/utils/api";
import { cn } from "@/src/utils/tailwind";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { type useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";
@@ -659,9 +659,7 @@ export function CreateLLMApiKeyForm({
form.reset();
onSuccess();
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportNonTrpcError(error, "llm-api-keys"));
}
return (
diff --git a/web/src/features/public-api/components/LLMApiKeyList.tsx b/web/src/features/public-api/components/LLMApiKeyList.tsx
index d0989a5d82..a3edd99a6d 100644
--- a/web/src/features/public-api/components/LLMApiKeyList.tsx
+++ b/web/src/features/public-api/components/LLMApiKeyList.tsx
@@ -14,7 +14,7 @@ import {
} from "@/src/components/ui/table";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert";
import { CreateLLMApiKeyDialog } from "./CreateLLMApiKeyDialog";
import { UpdateLLMApiKeyDialog } from "./UpdateLLMApiKeyDialog";
@@ -194,9 +194,7 @@ function DeleteApiKeyButton(props: { projectId: string; apiKeyId: string }) {
capture("project_settings:llm_api_key_delete");
setOpen(false);
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportNonTrpcError(error, "llm-api-keys"));
}}
/>
);
diff --git a/web/src/features/rbac/components/CreateProjectMemberButton.tsx b/web/src/features/rbac/components/CreateProjectMemberButton.tsx
index 4e0112ae3a..6bd12c9471 100644
--- a/web/src/features/rbac/components/CreateProjectMemberButton.tsx
+++ b/web/src/features/rbac/components/CreateProjectMemberButton.tsx
@@ -1,5 +1,5 @@
import { Button } from "@/src/components/ui/button";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import { useState } from "react";
import { PlusIcon } from "lucide-react";
import * as z from "zod";
@@ -129,9 +129,7 @@ export function CreateProjectMemberButton(props: {
form.reset();
setOpen(false);
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportTrpcErrorWithoutToast(error, "members"));
}
return (
diff --git a/web/src/features/setup/components/TracesSetupOnboardingCard.tsx b/web/src/features/setup/components/TracesSetupOnboardingCard.tsx
index 0209424f15..9859d33811 100644
--- a/web/src/features/setup/components/TracesSetupOnboardingCard.tsx
+++ b/web/src/features/setup/components/TracesSetupOnboardingCard.tsx
@@ -6,7 +6,7 @@ import { copyTextToClipboard } from "@/src/utils/clipboard";
import { ApiKeyDetailContent } from "@/src/features/public-api/components/ApiKeyDetailContent";
import { useLangfuseBaseUrl } from "@/src/features/public-api/hooks/useLangfuseEnvCode";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { type RouterOutput } from "@/src/utils/types";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { Check, Copy, LockIcon, Sparkles } from "lucide-react";
@@ -85,7 +85,7 @@ export function TracesSetupOnboardingCard({
try {
await mutCreateApiKey.mutateAsync({ projectId });
} catch (error) {
- console.error("Error creating API key:", error);
+ reportNonTrpcError(error, "setup");
toast.error("Failed to create API key");
}
};
diff --git a/web/src/features/slack/components/ChannelSelector.tsx b/web/src/features/slack/components/ChannelSelector.tsx
index 1ca95cfd57..21e9dc63e7 100644
--- a/web/src/features/slack/components/ChannelSelector.tsx
+++ b/web/src/features/slack/components/ChannelSelector.tsx
@@ -16,7 +16,7 @@ import {
CommandList,
} from "@/src/components/ui/command";
import { useVirtualizer } from "@tanstack/react-virtual";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { env } from "@/src/env.mjs";
import { type SlackChannel } from "@langfuse/shared/src/server";
@@ -90,9 +90,9 @@ const useSlackChannels = (projectId: string) => {
useEffect(() => {
if (error || !hasNextPage || isFetchingNextPage) return;
- fetchNextPage().catch((error) => {
- console.error("Failed to load next Slack channels page", error);
- });
+ // Query failures are classified + captured by the QueryCache seam; only
+ // report non-tRPC failures of the fetch dispatch itself.
+ fetchNextPage().catch((error) => reportNonTrpcError(error, "slack"));
}, [error, fetchNextPage, hasNextPage, isFetchingNextPage]);
return {
diff --git a/web/src/features/slack/components/SlackDisconnectButton.tsx b/web/src/features/slack/components/SlackDisconnectButton.tsx
index 33771f7660..c799cf12a5 100644
--- a/web/src/features/slack/components/SlackDisconnectButton.tsx
+++ b/web/src/features/slack/components/SlackDisconnectButton.tsx
@@ -12,7 +12,7 @@ import {
} from "@/src/components/ui/dialog";
import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";
import { showErrorToast } from "@/src/features/notifications/showErrorToast";
-import { api } from "@/src/utils/api";
+import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";
import Spinner from "@/src/components/design-system/Spinner/Spinner";
/**
@@ -117,8 +117,8 @@ export const SlackDisconnectButton: React.FC<SlackDisconnectButtonProps> = ({
try {
await disconnectMutation.mutateAsync({ projectId });
} catch (error) {
- // Error handling is done in the mutation callbacks
- console.error("Disconnect error:", error);
+ // The mutation's local onError owns the UX; this owns classification + capture.
+ reportTrpcErrorWithoutToast(error, "slack");
}
};
diff --git a/web/src/features/support-chat/SupportFormSection.tsx b/web/src/features/support-chat/SupportFormSection.tsx
index b7ce5334b3..9f0588ff84 100644
--- a/web/src/features/support-chat/SupportFormSection.tsx
+++ b/web/src/features/support-chat/SupportFormSection.tsx
@@ -15,7 +15,7 @@ import {
isSeverityAllowedForPlan,
} from "./formConstants";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { Button } from "@/src/components/ui/button";
import {
@@ -360,7 +360,7 @@ export function SupportFormSection({
pylonAttachmentUrls,
});
} catch (err: any) {
- console.error(err);
+ reportNonTrpcError(err, "support");
setIsSubmittingLocal(false);
form.setError("message", {
type: "manual",
diff --git a/web/src/features/v4-migration/V4MigrationContent.tsx b/web/src/features/v4-migration/V4MigrationContent.tsx
index 458197a16c..f551a65e8d 100644
--- a/web/src/features/v4-migration/V4MigrationContent.tsx
+++ b/web/src/features/v4-migration/V4MigrationContent.tsx
@@ -46,7 +46,7 @@ import {
V4_CODING_AGENT_PROMPT,
} from "@/src/features/v4-migration/useV4UpgradeAssistantSupport";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
// Single source of truth for the v4-migration copy and content. Both surfaces
// (side panel and modal) render these components — edit copy here only.
@@ -399,9 +399,7 @@ export function V4MigrationHeaderContent({
});
capture(`project_settings:api_key_create`);
})
- .catch((error) => {
- console.error(error);
- });
+ .catch((error) => reportNonTrpcError(error, "v4-migration"));
};
return (
diff --git a/web/src/pages/account/settings/index.tsx b/web/src/pages/account/settings/index.tsx
index 0f5656df16..59737b19c3 100644
--- a/web/src/pages/account/settings/index.tsx
+++ b/web/src/pages/account/settings/index.tsx
@@ -3,7 +3,7 @@ import Header from "@/src/components/layouts/header";
import { Card } from "@/src/components/ui/card";
import { Button } from "@/src/components/ui/button";
import { Input } from "@/src/components/ui/input";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import * as z from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
@@ -154,7 +154,7 @@ function DeleteAccountButton() {
await new Promise((resolve) => setTimeout(resolve, 2000));
await signOut();
} catch (error) {
- console.error(error);
+ reportNonTrpcError(error, "account");
showErrorToast(
"Failed to Delete Account",
error instanceof Error ? error.message : "An unexpected error occurred",
diff --git a/web/src/pages/project/[projectId]/traces/setup.tsx b/web/src/pages/project/[projectId]/traces/setup.tsx
index 5be6cbfa2b..ce7a21e705 100644
--- a/web/src/pages/project/[projectId]/traces/setup.tsx
+++ b/web/src/pages/project/[projectId]/traces/setup.tsx
@@ -1,6 +1,6 @@
import React, { useEffect } from "react";
import { useRouter } from "next/router";
-import { api } from "@/src/utils/api";
+import { api, reportNonTrpcError } from "@/src/utils/api";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import ContainerPage from "@/src/components/layouts/container-page";
import { ActionButton } from "@/src/components/ActionButton";
@@ -35,7 +35,7 @@ export const TracingSetup = ({
try {
await mutCreateApiKey.mutateAsync({ projectId });
} catch (error) {
- console.error("Error creating API key:", error);
+ reportNonTrpcError(error, "setup");
}
};
diff --git a/web/src/utils/api.clienttest.ts b/web/src/utils/api.clienttest.ts
index c89b311ae8..2515af27ab 100644
--- a/web/src/utils/api.clienttest.ts
+++ b/web/src/utils/api.clienttest.ts
@@ -4,12 +4,31 @@ import {
EXPECTED_TRPC_ERROR_CODES,
fetchWithParseErrorStatus,
getTrpcErrorCode,
+ getTrpcErrorFingerprint,
getTrpcErrorPath,
isExpectedTrpcClientError,
isNetworkConnectivityError,
isTrpcResponseParseError,
+ reportNonTrpcError,
+ reportTrpcErrorWithoutToast,
} from "@/src/utils/api";
+const { captureExceptionMock, addBreadcrumbMock, trpcErrorToastMock } =
+ vi.hoisted(() => ({
+ captureExceptionMock: vi.fn(),
+ addBreadcrumbMock: vi.fn(),
+ trpcErrorToastMock: vi.fn(),
+ }));
+
+vi.mock("@sentry/nextjs", () => ({
+ captureException: captureExceptionMock,
+ addBreadcrumb: addBreadcrumbMock,
+}));
+
+vi.mock("@/src/utils/trpcErrorToast", () => ({
+ trpcErrorToast: trpcErrorToastMock,
+}));
+
/** A JSON.parse SyntaxError annotated with the HTTP status it was parsed
* from, as produced by `fetchWithParseErrorStatus`. */
const parseErrorWithStatus = (message: string, status: number) => {
@@ -331,3 +350,215 @@ describe("isExpectedTrpcClientError", () => {
expect(isExpectedTrpcClientError(undefined)).toBe(false);
});
});
+
+describe("getTrpcErrorFingerprint", () => {
+ // The whole point of the fingerprint: unrelated tRPC failures must STOP
+ // grouping into one issue, while retries of the same failure class must
+ // keep grouping together.
+ it("groups the same code + path together even when messages differ", () => {
+ const first = trpcServerError({
+ code: "FORBIDDEN",
+ httpStatus: 403,
+ path: "organizations.delete",
+ message: "Deletion of your projects is still being processed",
+ });
+ const second = trpcServerError({
+ code: "FORBIDDEN",
+ httpStatus: 403,
+ path: "organizations.delete",
+ message: "some other server-minted advice",
+ });
+
+ expect(getTrpcErrorFingerprint(first)).toEqual(
+ getTrpcErrorFingerprint(second),
+ );
+ });
+
+ it("splits different codes on the same path", () => {
+ const forbidden = trpcServerError({
+ code: "FORBIDDEN",
+ httpStatus: 403,
+ path: "traces.deleteMany",
+ });
+ const internal = trpcServerError({
+ code: "INTERNAL_SERVER_ERROR",
+ httpStatus: 500,
+ path: "traces.deleteMany",
+ });
+
+ expect(getTrpcErrorFingerprint(forbidden)).not.toEqual(
+ getTrpcErrorFingerprint(internal),
+ );
+ });
+
+ it("splits the same code on different paths", () => {
+ const evals = trpcServerError({
+ code: "BAD_REQUEST",
+ httpStatus: 400,
+ path: "evals.createJob",
+ });
+ const traces = trpcServerError({
+ code: "BAD_REQUEST",
+ httpStatus: 400,
+ path: "traces.deleteMany",
+ });
+
+ expect(getTrpcErrorFingerprint(evals)).not.toEqual(
+ getTrpcErrorFingerprint(traces),
+ );
+ });
+
+ it("uses a stable placeholder when the server shape omits the path", () => {
+ const error = trpcServerError({ code: "FORBIDDEN", httpStatus: 403 });
+
+ expect(getTrpcErrorFingerprint(error)).toEqual([
+ "trpc-client-error",
+ "FORBIDDEN",
+ "unknown",
+ ]);
+ });
+
+ it("never leaks the error message into the fingerprint (bounded cardinality)", () => {
+ const message = "user-specific advice with dynamic content 12345";
+ const error = trpcServerError({
+ code: "UNPROCESSABLE_CONTENT",
+ httpStatus: 422,
+ path: "traces.metrics",
+ message,
+ });
+
+ const fingerprint = getTrpcErrorFingerprint(error);
+ expect(fingerprint).toEqual([
+ "trpc-client-error",
+ "UNPROCESSABLE_CONTENT",
+ "traces.metrics",
+ ]);
+ expect(fingerprint.join()).not.toContain("12345");
+ });
+});
+
+describe("reportTrpcErrorWithoutToast", () => {
+ let warnSpy: ReturnType<typeof vi.spyOn>;
+
+ beforeEach(() => {
+ captureExceptionMock.mockClear();
+ addBreadcrumbMock.mockClear();
+ trpcErrorToastMock.mockClear();
+ warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
+ });
+
+ afterEach(() => {
+ warnSpy.mockRestore();
+ });
+
+ it("suppresses expected codes (breadcrumb, no capture) — same policy as the seam", () => {
+ // The organizations.delete FORBIDDEN advice: previously console.error'd by
+ // the component (one Sentry event per retry), now classified as expected.
+ const error = trpcServerError({
+ code: "FORBIDDEN",
+ httpStatus: 403,
+ path: "organizations.delete",
+ message:
+ "Deletion of your projects is still being processed, please try deleting the organization later",
+ });
+
+ reportTrpcErrorWithoutToast(error, "organizations");
+
+ expect(captureExceptionMock).not.toHaveBeenCalled();
+ expect(addBreadcrumbMock).toHaveBeenCalledTimes(1);
+ expect(addBreadcrumbMock.mock.calls[0]![0].data).toMatchObject({
+ code: "FORBIDDEN",
+ path: "organizations.delete",
+ });
+ });
+
+ // Negative fixture: real errors MUST still be captured, with the
+ // procedure/code fingerprint and tags.
+ it("captures a real (5xx) tRPC error with fingerprint and tags", () => {
+ const error = trpcServerError({
+ code: "INTERNAL_SERVER_ERROR",
+ httpStatus: 500,
+ path: "projects.create",
+ });
+
+ reportTrpcErrorWithoutToast(error, "projects");
+
+ expect(captureExceptionMock).toHaveBeenCalledTimes(1);
+ const [, options] = captureExceptionMock.mock.calls[0]!;
+ expect(options.fingerprint).toEqual([
+ "trpc-client-error",
+ "INTERNAL_SERVER_ERROR",
+ "projects.create",
+ ]);
+ // tRPC failures keep the seam's own area regardless of the caller's.
+ expect(options.tags).toMatchObject({
+ area: "trpc",
+ "trpc.code": "INTERNAL_SERVER_ERROR",
+ "trpc.path": "projects.create",
+ });
+ });
+
+ it("captures non-tRPC errors with the caller's area (not the seam's `trpc`)", () => {
+ reportTrpcErrorWithoutToast(new Error("post-success work failed"), "evals");
+
+ expect(captureExceptionMock).toHaveBeenCalledTimes(1);
+ const [, options] = captureExceptionMock.mock.calls[0]!;
+ expect(options.tags.area).toBe("evals");
+ });
+
+ it("never shows the standard error toast (the local onError owns the UX)", () => {
+ reportTrpcErrorWithoutToast(
+ trpcServerError({
+ code: "INTERNAL_SERVER_ERROR",
+ httpStatus: 500,
+ path: "projects.create",
+ }),
+ "projects",
+ );
+ reportTrpcErrorWithoutToast(new Error("boom"), "projects");
+
+ expect(trpcErrorToastMock).not.toHaveBeenCalled();
+ });
+});
+
+describe("reportNonTrpcError", () => {
+ let warnSpy: ReturnType<typeof vi.spyOn>;
+
+ beforeEach(() => {
+ captureExceptionMock.mockClear();
+ addBreadcrumbMock.mockClear();
+ trpcErrorToastMock.mockClear();
+ warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
+ });
+
+ afterEach(() => {
+ warnSpy.mockRestore();
+ });
+
+ it("swallows TRPCClientErrors (already classified by the react-query default onError)", () => {
+ reportNonTrpcError(
+ trpcServerError({
+ code: "INTERNAL_SERVER_ERROR",
+ httpStatus: 500,
+ path: "projects.create",
+ }),
+ "projects",
+ );
+
+ expect(captureExceptionMock).not.toHaveBeenCalled();
+ expect(trpcErrorToastMock).not.toHaveBeenCalled();
+ });
+
+ // Negative fixture: a genuine non-tRPC failure (post-success callback,
+ // router.push, ...) MUST still be captured.
+ it("reports non-tRPC errors with the caller's area", () => {
+ reportNonTrpcError(new Error("router.push failed"), "organizations", {
+ context: "delete-organization",
+ });
+
+ expect(captureExceptionMock).toHaveBeenCalledTimes(1);
+ const [, options] = captureExceptionMock.mock.calls[0]!;
+ expect(options.tags.area).toBe("organizations");
+ expect(options.extra).toEqual({ context: "delete-organization" });
+ });
+});
diff --git a/web/src/utils/api.ts b/web/src/utils/api.ts
index 9d842a8c0f..8e9f1e8ce2 100644
--- a/web/src/utils/api.ts
+++ b/web/src/utils/api.ts
@@ -158,6 +158,24 @@ export const getTrpcErrorPath = (error: unknown): string | undefined => {
return typeof path === "string" ? path : undefined;
};
+/**
+ * Sentry fingerprint for a captured tRPC client error.
+ *
+ * Sentry's default grouping keys on the stack trace, and every
+ * `TRPCClientError` throws from the same client-link frames — so unrelated
+ * failures (different procedures, different codes, different messages)
+ * collapse into one mega-issue. Grouping by code + procedure path gives each
+ * distinct failure class its own issue with bounded cardinality
+ * (procedures × codes) and no user data: `data.path` is the static procedure
+ * name from the router definition (e.g. `traces.deleteMany`) — query input,
+ * ids, and messages are never part of it.
+ */
+export const getTrpcErrorFingerprint = (error: unknown): string[] => [
+ "trpc-client-error",
+ getTrpcErrorCode(error) ?? "unknown",
+ getTrpcErrorPath(error) ?? "unknown",
+];
+
/**
* True when `error` is a TRPCClientError whose code is an EXPECTED, user-facing
* state that should not be captured to Sentry.
@@ -356,10 +374,12 @@ const handleTrpcError = (error: unknown, shouldSilenceError = false) => {
},
});
} else {
- // Real tRPC errors keep flowing to Sentry, tagged by procedure/code
- // so they group and route instead of collapsing into one opaque bucket.
+ // Real tRPC errors keep flowing to Sentry, tagged and fingerprinted by
+ // procedure/code so each failure class gets its own issue instead of
+ // collapsing into one opaque bucket (see getTrpcErrorFingerprint).
reportError(error, {
area: "trpc",
+ fingerprint: getTrpcErrorFingerprint(error),
tags: {
"trpc.code": getTrpcErrorCode(error),
"trpc.path": getTrpcErrorPath(error),
@@ -376,6 +396,46 @@ const handleTrpcError = (error: unknown, shouldSilenceError = false) => {
}
};
+/**
+ * Error handler for `mutateAsync` catch blocks whose mutation KEEPS the
+ * react-query default `onError`: the seam (`handleTrpcError`) already
+ * classified, captured, and toasted the tRPC failure, so the catch only needs
+ * to swallow the rejection — a `console.error` there would mint a second,
+ * unclassified Sentry event via `captureConsoleIntegration`. Non-tRPC errors
+ * (thrown by the catch's own post-success work: callbacks, router.push, ...)
+ * were NOT seen by the seam and are reported with the caller's `area`.
+ */
+export const reportNonTrpcError = (
+ error: unknown,
+ area: string,
+ extra?: Record<string, unknown>,
+): void => {
+ if (error instanceof TRPCClientError) return;
+ reportError(error, { area, extra });
+};
+
+/**
+ * Error handler for `mutateAsync` catch blocks whose mutation defines a local
+ * `onError` (which REPLACES the react-query default): nothing classified or
+ * captured the failure, so route it through the seam here — with the standard
+ * error toast silenced, since the local `onError` owns the UX (form errors,
+ * custom toasts). Replaces the `console.error(error)` anti-pattern, which
+ * minted unclassified Sentry events via `captureConsoleIntegration`.
+ * Non-tRPC errors (thrown by the catch's own post-success work) were never a
+ * tRPC failure, so they are reported with the caller's `area` — mirroring
+ * `reportNonTrpcError` — instead of the seam's generic `trpc` area.
+ */
+export const reportTrpcErrorWithoutToast = (
+ error: unknown,
+ area: string,
+): void => {
+ if (error instanceof TRPCClientError) {
+ handleTrpcError(error, true);
+ return;
+ }
+ reportError(error, { area });
+};
+
// Reads the `x-build-id` response header (the build id serving this response)
// and records it: the module-level `buildId` still drives the legacy
// stale-cache toast, and the version-update store drives the persistent reload
diff --git a/web/src/utils/reportError.clienttest.ts b/web/src/utils/reportError.clienttest.ts
index d4164d5d28..92a2fb4c60 100644
--- a/web/src/utils/reportError.clienttest.ts
+++ b/web/src/utils/reportError.clienttest.ts
@@ -124,6 +124,31 @@ describe("reportError", () => {
});
});
+ it("passes a caller fingerprint through to captureException", () => {
+ reportError(new Error("boom"), {
+ area: "trpc",
+ fingerprint: [
+ "trpc-client-error",
+ "INTERNAL_SERVER_ERROR",
+ "traces.all",
+ ],
+ });
+
+ const [, options] = captureExceptionMock.mock.calls[0]!;
+ expect(options.fingerprint).toEqual([
+ "trpc-client-error",
+ "INTERNAL_SERVER_ERROR",
+ "traces.all",
+ ]);
+ });
+
+ it("omits the fingerprint key entirely when not provided (Sentry default grouping)", () => {
+ reportError(new Error("boom"), { area: "io.parse" });
+
+ const [, options] = captureExceptionMock.mock.calls[0]!;
+ expect("fingerprint" in options).toBe(false);
+ });
+
it("the seam's area tag wins over a conflicting caller tag", () => {
reportError(new Error("boom"), {
area: "trpc",
diff --git a/web/src/utils/reportError.ts b/web/src/utils/reportError.ts
index cdcc063b11..7750904233 100644
--- a/web/src/utils/reportError.ts
+++ b/web/src/utils/reportError.ts
@@ -68,7 +68,10 @@ export function coerceToError(area: string, value: unknown): Error {
* `captureException` with an `area` tag (so issues route/group by surface) and
* the caller's structured `extra`, then log a companion `console.warn`.
* Optional `tags` add further Sentry tags (e.g. `trpc.code`); on a key
- * conflict the seam's `area` tag wins. Optional `warnMessage` overrides the
+ * conflict the seam's `area` tag wins. Optional `fingerprint` overrides
+ * Sentry's default grouping for callers whose errors would otherwise
+ * collapse into one issue (all TRPCClientErrors share the same throw-site
+ * stack) — values must be bounded and static, never user data. Optional `warnMessage` overrides the
* companion console line's body (always prefixed with `[area]`) for callers
* whose legible console text differs from the captured Error's message —
* e.g. a pass-through Error that lacks the caller's context. It never
@@ -89,6 +92,7 @@ export function reportError(
area: string;
expected?: boolean;
extra?: Record<string, unknown>;
+ fingerprint?: string[];
tags?: Record<string, string | undefined>;
warnMessage?: string;
},
@@ -108,6 +112,7 @@ export function reportError(
captureException(err, {
tags: { ...opts.tags, area: opts.area },
extra: opts.extra,
+ ...(opts.fingerprint !== undefined && { fingerprint: opts.fingerprint }),
});
// warn, not error → captureConsoleIntegration only captures console.error, so
// this line does not create a second, opaque event. Show the `area` exactly