Skip to content

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

feat: classify errors and track success toasts (#18410)

Nikita Kabardin3ff1ad7da3ce
diff --git a/web/src/__tests__/account-settings-sign-out-all-sessions.clienttest.tsx b/web/src/__tests__/account-settings-sign-out-all-sessions.clienttest.tsx
index 766f8d9e03..7e56940209 100644
--- a/web/src/__tests__/account-settings-sign-out-all-sessions.clienttest.tsx
+++ b/web/src/__tests__/account-settings-sign-out-all-sessions.clienttest.tsx
@@ -123,6 +123,7 @@ describe("SignOutAllSessionsButton", () => {
expect(showSuccessToastMock).toHaveBeenCalledWith({
title: "Signed Out of All Sessions",
description: "All sessions have been invalidated.",
+ operation: "account.revoke_sessions",
});
});
expect(showErrorToastMock).not.toHaveBeenCalledWith(
diff --git a/web/src/components/BatchExportTableButton.tsx b/web/src/components/BatchExportTableButton.tsx
index 5948944519..cf21a3874d 100644
--- a/web/src/components/BatchExportTableButton.tsx
+++ b/web/src/components/BatchExportTableButton.tsx
@@ -41,6 +41,7 @@ export const BatchExportTableButton: React.FC<BatchExportTableButtonProps> = (
},
onSuccess: () => {
showSuccessToast({
+ operation: "export.queue",
title: "Export queued",
description: "You will receive an email when the export is ready.",
duration: 10000,
diff --git a/web/src/components/deleteButton.tsx b/web/src/components/deleteButton.tsx
index 4ec45d206b..9efc2258bc 100644
--- a/web/src/components/deleteButton.tsx
+++ b/web/src/components/deleteButton.tsx
@@ -251,6 +251,7 @@ export function DeleteMonitorButton(props: DeleteButtonProps) {
const monitorMutation = api.monitors.delete.useMutation({
onSuccess: () => {
showSuccessToast({
+ operation: "monitor.delete",
title: "Alert deleted",
description: "The alert has been deleted successfully",
});
@@ -302,6 +303,7 @@ export function DeleteEvalConfigButton(props: DeleteButtonProps) {
const evaluatorMutation = api.evals.deleteEvalJob.useMutation({
onSuccess: () => {
showSuccessToast({
+ operation: "evaluator.delete",
title: "Running evaluator deleted",
description: "The running evaluator has been deleted successfully",
});
@@ -358,6 +360,7 @@ export function DeleteEvaluationModelButton(
api.defaultLlmModel.deleteDefaultModel.useMutation({
onSuccess: () => {
showSuccessToast({
+ operation: "evaluation_model.delete",
title: "Default evaluation model deleted",
description:
"The default evaluation model has been deleted. Any running evaluations relying on the default model will be inactivated. Queued jobs will fail.",
diff --git a/web/src/components/table/peek/peek-evaluator-config-detail.tsx b/web/src/components/table/peek/peek-evaluator-config-detail.tsx
index ff78177b96..1cd532419a 100644
--- a/web/src/components/table/peek/peek-evaluator-config-detail.tsx
+++ b/web/src/components/table/peek/peek-evaluator-config-detail.tsx
@@ -213,6 +213,7 @@ const PeekViewEvaluatorConfigDetail = ({
setIsEditMode(false);
utils.evals.invalidate();
showSuccessToast({
+ operation: "evaluator.update",
title: "Running Evaluator updated",
description: "The evaluator configuration has been updated.",
});
diff --git a/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx b/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx
index fe169f49bb..404a4170c1 100644
--- a/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx
+++ b/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx
@@ -95,6 +95,7 @@ const copyPermalinkAndToast = (href: string) => {
copyTextToClipboard(href)
.then(() =>
showSuccessToast({
+ operation: "saved_view.permalink_copy",
title: "Permalink copied to clipboard",
description: "You can now share the permalink with others",
}),
diff --git a/web/src/components/table/table-view-presets/hooks/useDefaultViewMutations.ts b/web/src/components/table/table-view-presets/hooks/useDefaultViewMutations.ts
index aa54fc7d08..4de70f8970 100644
--- a/web/src/components/table/table-view-presets/hooks/useDefaultViewMutations.ts
+++ b/web/src/components/table/table-view-presets/hooks/useDefaultViewMutations.ts
@@ -25,6 +25,7 @@ export function useDefaultViewMutations({
});
const scopeLabel = variables.scope === "user" ? "your" : "project";
showSuccessToast({
+ operation: "saved_view.default_set",
title: "Default view set",
description: `Set as ${scopeLabel} default`,
});
@@ -46,6 +47,7 @@ export function useDefaultViewMutations({
});
const scopeLabel = variables.scope === "user" ? "Your" : "Project";
showSuccessToast({
+ operation: "saved_view.default_clear",
title: "Default cleared",
description: `${scopeLabel} default view cleared`,
});
diff --git a/web/src/components/table/table-view-presets/hooks/useViewMutations.ts b/web/src/components/table/table-view-presets/hooks/useViewMutations.ts
index 187b3ceddd..3c9cf43ac1 100644
--- a/web/src/components/table/table-view-presets/hooks/useViewMutations.ts
+++ b/web/src/components/table/table-view-presets/hooks/useViewMutations.ts
@@ -29,6 +29,7 @@ export const useViewMutations = ({
});
utils.TableViewPresets.getByTableName.invalidate();
showSuccessToast({
+ operation: "saved_view.update",
title: "View updated",
description: `${data.view.name} has been updated to reflect your current table state`,
});
@@ -56,6 +57,7 @@ export const useViewMutations = ({
copyTextToClipboard(data)
.then(() =>
showSuccessToast({
+ operation: "saved_view.permalink_copy",
title: "Permalink copied to clipboard",
description: "You can now share the permalink with others",
}),
diff --git a/web/src/components/useShareMenuItems.ts b/web/src/components/useShareMenuItems.ts
index cf5b687b5c..29a1777762 100644
--- a/web/src/components/useShareMenuItems.ts
+++ b/web/src/components/useShareMenuItems.ts
@@ -45,6 +45,7 @@ export function useShareMenuItems({
.then(() => {
if (!nextPublic) return;
showSuccessToast({
+ operation: "sharing.enable",
title: `${label} shared publicly`,
description:
"Anyone with the link can view it. Link copied to clipboard.",
diff --git a/web/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable.tsx b/web/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable.tsx
index 05b1f01ad0..3afdfb7682 100644
--- a/web/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable.tsx
+++ b/web/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable.tsx
@@ -52,6 +52,7 @@ export function ConnectedAuditLogsTable(props: AuditLogsTableProps) {
const createExport = api.batchExport.create.useMutation({
onSuccess: (_data, variables) => {
showSuccessToast({
+ operation: "audit_log.export",
title: "Export queued",
description: "You will receive an email when the export is ready.",
duration: 10000,
diff --git a/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx b/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx
index 24fe738082..0fdcaf364e 100644
--- a/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx
+++ b/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx
@@ -13,6 +13,7 @@ import {
} from "@/src/components/ui/dialog";
import { Input } from "@/src/components/ui/input";
import { api } from "@/src/utils/api";
+import { showSuccessToast } from "@/src/features/notifications";
import { toast } from "sonner";
import { nanoid } from "nanoid";
@@ -26,7 +27,11 @@ export const BillingDiscountCodeButton = ({ orgId }: { orgId: string }) => {
const mutation = api.cloudBilling.applyPromotionCode.useMutation({
onSuccess: async () => {
- toast.success("Promotion code applied");
+ showSuccessToast({
+ operation: "billing_discount.apply",
+ title: "Promotion code applied",
+ description: "",
+ });
setProcessing(false);
setOpen(false);
setCode("");
diff --git a/web/src/ee/features/billing/components/SpendAlerts/DeleteSpendAlertDialog.tsx b/web/src/ee/features/billing/components/SpendAlerts/DeleteSpendAlertDialog.tsx
index f366dc0e34..167acc081c 100644
--- a/web/src/ee/features/billing/components/SpendAlerts/DeleteSpendAlertDialog.tsx
+++ b/web/src/ee/features/billing/components/SpendAlerts/DeleteSpendAlertDialog.tsx
@@ -10,6 +10,7 @@ import {
import { Button } from "@/src/components/ui/button";
import { api, reportNonTrpcError } from "@/src/utils/api";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
+import { showSuccessToast } from "@/src/features/notifications";
import { toast } from "sonner";
interface DeleteSpendAlertDialogProps {
@@ -43,7 +44,11 @@ export function DeleteSpendAlertDialog({
orgId,
alertId,
});
- toast.success("Spend alert deleted successfully");
+ showSuccessToast({
+ operation: "spend_alert.delete",
+ title: "Spend alert deleted successfully",
+ description: "",
+ });
onSuccess();
} catch (error) {
reportNonTrpcError(error, "billing");
diff --git a/web/src/ee/features/billing/components/SpendAlerts/SpendAlertDialog.tsx b/web/src/ee/features/billing/components/SpendAlerts/SpendAlertDialog.tsx
index 7752667fd9..df7385ad20 100644
--- a/web/src/ee/features/billing/components/SpendAlerts/SpendAlertDialog.tsx
+++ b/web/src/ee/features/billing/components/SpendAlerts/SpendAlertDialog.tsx
@@ -21,6 +21,7 @@ import { Input } from "@/src/components/ui/input";
import { Button } from "@/src/components/ui/button";
import { api, reportNonTrpcError } from "@/src/utils/api";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
+import { showSuccessToast } from "@/src/features/notifications";
import { toast } from "sonner";
import { Info } from "lucide-react";
@@ -87,7 +88,11 @@ export function SpendAlertDialog({
alertId: alert.id,
limit: data.limit,
});
- toast.success("Spend alert updated successfully");
+ showSuccessToast({
+ operation: "spend_alert.update",
+ title: "Spend alert updated successfully",
+ description: "",
+ });
} else {
// Create new alert
await createMutation.mutateAsync({
@@ -99,7 +104,11 @@ export function SpendAlertDialog({
orgId,
limit: data.limit,
});
- toast.success("Spend alert created successfully");
+ showSuccessToast({
+ operation: "spend_alert.create",
+ title: "Spend alert created successfully",
+ description: "",
+ });
}
onSuccess();
} catch (error) {
diff --git a/web/src/ee/features/billing/components/StripeCancellationButton.tsx b/web/src/ee/features/billing/components/StripeCancellationButton.tsx
index a7aec6b175..7f145cb425 100644
--- a/web/src/ee/features/billing/components/StripeCancellationButton.tsx
+++ b/web/src/ee/features/billing/components/StripeCancellationButton.tsx
@@ -13,6 +13,7 @@ import {
import { useBillingInformation } from "./useBillingInformation";
import { api } from "@/src/utils/api";
import { useState } from "react";
+import { showSuccessToast } from "@/src/features/notifications";
import { toast } from "sonner";
import { nanoid } from "nanoid";
@@ -31,7 +32,11 @@ export const StripeCancellationButton = ({
const cancelMutation = api.cloudBilling.cancelStripeSubscription.useMutation({
onSuccess: () => {
- toast.success("Subscription will be cancelled at period end");
+ showSuccessToast({
+ operation: "subscription.cancel",
+ title: "Subscription will be cancelled at period end",
+ description: "",
+ });
setLoading(false);
setOpId(null);
setTimeout(() => window.location.reload(), 500);
@@ -46,7 +51,11 @@ export const StripeCancellationButton = ({
const reactivateMutation =
api.cloudBilling.reactivateStripeSubscription.useMutation({
onSuccess: () => {
- toast.success("Subscription reactivated");
+ showSuccessToast({
+ operation: "subscription.reactivate",
+ title: "Subscription reactivated",
+ description: "",
+ });
setLoading(false);
setOpId(null);
setTimeout(() => window.location.reload(), 500);
diff --git a/web/src/ee/features/billing/components/StripeKeepPlanButton.tsx b/web/src/ee/features/billing/components/StripeKeepPlanButton.tsx
index 006c12defb..3522525c77 100644
--- a/web/src/ee/features/billing/components/StripeKeepPlanButton.tsx
+++ b/web/src/ee/features/billing/components/StripeKeepPlanButton.tsx
@@ -12,6 +12,7 @@ import {
DialogTrigger,
} from "@/src/components/ui/dialog";
import { api } from "@/src/utils/api";
+import { showSuccessToast } from "@/src/features/notifications";
import { toast } from "sonner";
import { nanoid } from "nanoid";
@@ -30,7 +31,11 @@ export const StripeKeepPlanButton = ({
const clearSchedule = api.cloudBilling.clearPlanSwitchSchedule.useMutation({
onSuccess: () => {
- toast.success("Kept current plan");
+ showSuccessToast({
+ operation: "billing_plan.keep",
+ title: "Kept current plan",
+ description: "",
+ });
onProcessing(null);
setOpId(null);
setTimeout(() => window.location.reload(), 500);
diff --git a/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx b/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx
index 25b5ee8f54..562d625236 100644
--- a/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx
+++ b/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx
@@ -15,6 +15,7 @@ import {
import { ActionButton } from "@/src/components/ActionButton";
import { planLabels } from "@langfuse/shared";
import { api } from "@/src/utils/api";
+import { showSuccessToast } from "@/src/features/notifications";
import { toast } from "sonner";
import { nanoid } from "nanoid";
@@ -42,7 +43,11 @@ export const StripeSwitchPlanButton = ({
const mutChangePlan =
api.cloudBilling.changeStripeSubscriptionProduct.useMutation({
onSuccess: () => {
- toast.success("Plan changed successfully");
+ showSuccessToast({
+ operation: "billing_plan.change",
+ title: "Plan changed successfully",
+ description: "",
+ });
onProcessing(null);
setOpId(null);
setTimeout(() => window.location.reload(), 500);
diff --git a/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx b/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx
index 76dc6327d1..d6f89b5f25 100644
--- a/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx
+++ b/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx
@@ -19,6 +19,7 @@ export function DeleteSsoConfigDialogController({
onSuccess: () => {
utils.ssoConfig.get.invalidate({ orgId });
showSuccessToast({
+ operation: "sso.disable",
title: "SSO disabled",
description: `SSO for @${selectedDomain} has been removed.`,
});
diff --git a/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx b/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx
index 8632c20ca7..f5789fceec 100644
--- a/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx
+++ b/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx
@@ -168,6 +168,7 @@ function SsoConfigDialogContent({
onSuccess: () => {
utils.ssoConfig.get.invalidate({ orgId });
showSuccessToast({
+ operation: existing ? "sso.update" : "sso.configure",
title: existing ? "SSO updated" : "SSO configured",
description: `Active for @${domain} within 1 hour.`,
});
diff --git a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx
index 22318f0c0c..df10dcb95a 100644
--- a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx
+++ b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx
@@ -124,6 +124,7 @@ function AddDomainButton({ orgId }: { orgId: string }) {
onSuccess: () => {
utils.verifiedDomain.list.invalidate({ orgId });
showSuccessToast({
+ operation: "verified_domain.add",
title: "Domain added",
description:
"Click Verify to view the DNS TXT record, then confirm after adding it.",
diff --git a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettingsTable/ConnectedVerifiedDomainsSettingsTable.tsx b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettingsTable/ConnectedVerifiedDomainsSettingsTable.tsx
index c0b12c0262..b3bfbcf3ee 100644
--- a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettingsTable/ConnectedVerifiedDomainsSettingsTable.tsx
+++ b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettingsTable/ConnectedVerifiedDomainsSettingsTable.tsx
@@ -26,6 +26,7 @@ export function ConnectedVerifiedDomainsSettingsTable({
utils.ssoConfig.get.invalidate({ orgId });
const domain = query.data?.find((row) => row.id === variables.id);
showSuccessToast({
+ operation: "verified_domain.verify",
title: "Domain verified",
description: `${domain?.domain ?? "Domain"} is now verified.`,
});
@@ -39,6 +40,7 @@ export function ConnectedVerifiedDomainsSettingsTable({
utils.verifiedDomain.list.invalidate({ orgId });
const domain = query.data?.find((row) => row.id === variables.id);
showSuccessToast({
+ operation: "verified_domain.remove",
title: "Domain removed",
description: `${domain?.domain ?? "Domain"} has been removed.`,
});
diff --git a/web/src/features/account/AccountSettingsPage.tsx b/web/src/features/account/AccountSettingsPage.tsx
index 46d584b4bd..d65b24f245 100644
--- a/web/src/features/account/AccountSettingsPage.tsx
+++ b/web/src/features/account/AccountSettingsPage.tsx
@@ -60,6 +60,7 @@ function UpdateDisplayName() {
await utils.invalidate();
form.reset();
showSuccessToast({
+ operation: "account.display_name_update",
title: "Display Name Updated",
description: "Your display name has been successfully updated.",
});
@@ -151,6 +152,7 @@ function DeleteAccountButton() {
try {
await deleteAccount.mutateAsync();
showSuccessToast({
+ operation: "account.delete",
title: "Account Deleted",
description: "Your account has been successfully deleted.",
});
@@ -247,6 +249,7 @@ function SignOutAllSessionsButton() {
try {
await signOutAllSessions.mutateAsync();
showSuccessToast({
+ operation: "account.revoke_sessions",
title: "Signed Out of All Sessions",
description: "All sessions have been invalidated.",
});
diff --git a/web/src/features/ai-gateway/components/GatewayConfigurationPage/GatewayConfigurationPage.tsx b/web/src/features/ai-gateway/components/GatewayConfigurationPage/GatewayConfigurationPage.tsx
index 71e68e1cad..d47793e5ca 100644
--- a/web/src/features/ai-gateway/components/GatewayConfigurationPage/GatewayConfigurationPage.tsx
+++ b/web/src/features/ai-gateway/components/GatewayConfigurationPage/GatewayConfigurationPage.tsx
@@ -40,6 +40,7 @@ export function GatewayConfigurationPage({
});
await utils.aiGateway.getConfig.invalidate({ orgId: organizationId });
showSuccessToast({
+ operation: "gateway_configuration.save",
title: "Gateway configuration saved",
description: "New gateway requests will use this configuration.",
});
diff --git a/web/src/features/annotation-queues/components/UserAssignmentSection.tsx b/web/src/features/annotation-queues/components/UserAssignmentSection.tsx
index 37fdd04875..a8bb3940de 100644
--- a/web/src/features/annotation-queues/components/UserAssignmentSection.tsx
+++ b/web/src/features/annotation-queues/components/UserAssignmentSection.tsx
@@ -45,6 +45,7 @@ export const UserAssignmentSection = ({
utils.annotationQueueAssignments.invalidate();
utils.annotationQueues.invalidate();
showSuccessToast({
+ operation: "annotation_queue_assignment.remove",
title: "Removed assignment",
description: "User removed from queue successfully",
});
diff --git a/web/src/features/automations/components/DeleteAutomationDialogController.tsx b/web/src/features/automations/components/DeleteAutomationDialogController.tsx
index e9e7fbf963..5c16fafc97 100644
--- a/web/src/features/automations/components/DeleteAutomationDialogController.tsx
+++ b/web/src/features/automations/components/DeleteAutomationDialogController.tsx
@@ -32,6 +32,7 @@ export const DeleteAutomationDialogController = ({
{
onSuccess: () => {
showSuccessToast({
+ operation: "automation.delete",
title: "Automation deleted",
description: "The automation has been deleted successfully.",
});
diff --git a/web/src/features/automations/components/actions/WebhookActionForm.tsx b/web/src/features/automations/components/actions/WebhookActionForm.tsx
index 9cd95ec26e..b0b739db7b 100644
--- a/web/src/features/automations/components/actions/WebhookActionForm.tsx
+++ b/web/src/features/automations/components/actions/WebhookActionForm.tsx
@@ -325,6 +325,7 @@ const RegenerateWebhookSecretButton = ({
api.automations.regenerateWebhookSecret.useMutation({
onSuccess: (data) => {
showSuccessToast({
+ operation: "webhook_secret.regenerate",
title: "Webhook Secret Regenerated",
description: "Your webhook secret has been successfully regenerated.",
});
diff --git a/web/src/features/automations/components/automationForm.tsx b/web/src/features/automations/components/automationForm.tsx
index f20e435131..c8edfc8247 100644
--- a/web/src/features/automations/components/automationForm.tsx
+++ b/web/src/features/automations/components/automationForm.tsx
@@ -579,6 +579,7 @@ export const AutomationForm = ({
});
showSuccessToast({
+ operation: "automation.update",
title: "Automation Updated",
description: `Successfully updated automation "${resolvedName}".`,
});
@@ -598,6 +599,7 @@ export const AutomationForm = ({
});
showSuccessToast({
+ operation: "automation.create",
title: "Automation Created",
description: `Successfully created automation "${resolvedName}".`,
});
diff --git a/web/src/features/background-migrations/components/retry-background-migration.tsx b/web/src/features/background-migrations/components/retry-background-migration.tsx
index c0d39b30e3..6e14c1310a 100644
--- a/web/src/features/background-migrations/components/retry-background-migration.tsx
+++ b/web/src/features/background-migrations/components/retry-background-migration.tsx
@@ -5,6 +5,7 @@ import type * as React from "react";
import { PopoverController } from "@/src/components/ui/popover";
import { Input } from "@/src/components/ui/input";
import { Label } from "@/src/components/ui/label";
+import { showSuccessToast } from "@/src/features/notifications";
import { toast } from "sonner";
type RetryBackgroundMigrationPopoverControllerProps = {
@@ -26,7 +27,11 @@ export function RetryBackgroundMigrationPopoverController({
api.backgroundMigrations.retry.useMutation({
onSuccess: () => {
utils.backgroundMigrations.invalidate();
- toast.success("Migration scheduled for retry");
+ showSuccessToast({
+ operation: "background_migration.retry",
+ title: "Migration scheduled for retry",
+ description: "",
+ });
},
onError: (error) => {
toast.error(error?.message || "Failed to retry migration");
diff --git a/web/src/features/batch-actions/components/RunEvaluationDialog/index.tsx b/web/src/features/batch-actions/components/RunEvaluationDialog/index.tsx
index 189290ff72..5bc92b065c 100644
--- a/web/src/features/batch-actions/components/RunEvaluationDialog/index.tsx
+++ b/web/src/features/batch-actions/components/RunEvaluationDialog/index.tsx
@@ -300,6 +300,7 @@ export function RunEvaluationDialog(props: RunEvaluationDialogProps) {
});
showSuccessToast({
+ operation: "evaluation.queue",
title: "Evaluation queued",
description: isExperimentsSource
? `Scheduled evaluation for items from ${displayCount} selected experiment${displayCount === 1 ? "" : "s"} with ${evaluatorIds.length} ${evaluatorIds.length === 1 ? "evaluator" : "evaluators"}.`
diff --git a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx
index fce474c854..e60b007ef0 100644
--- a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx
+++ b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx
@@ -79,6 +79,7 @@ export const BlobStorageIntegrationContainer = ({
const mutValidate = api.blobStorageIntegration.validate.useMutation({
onSuccess: (data) => {
showSuccessToast({
+ operation: "blob_storage.validate",
title: data.message,
description: `Test file: ${data.testFileName}`,
});
diff --git a/web/src/features/dashboard/DashboardDetailPage.tsx b/web/src/features/dashboard/DashboardDetailPage.tsx
index bbb36c3900..cb1169e825 100644
--- a/web/src/features/dashboard/DashboardDetailPage.tsx
+++ b/web/src/features/dashboard/DashboardDetailPage.tsx
@@ -748,6 +748,7 @@ function DashboardDetailView({ readPath }: { readPath: ResolvedReadPath }) {
}, 150);
showSuccessToast({
+ operation: "dashboard.import",
title: "Dashboard imported",
description: `Added ${newPlacements.length} widget${
newPlacements.length === 1 ? "" : "s"
diff --git a/web/src/features/dashboard/NewDashboardPage.tsx b/web/src/features/dashboard/NewDashboardPage.tsx
index 5b6d9cbbf7..0438c1cd58 100644
--- a/web/src/features/dashboard/NewDashboardPage.tsx
+++ b/web/src/features/dashboard/NewDashboardPage.tsx
@@ -27,6 +27,7 @@ export default function NewDashboardPage() {
const createDashboard = api.dashboard.createDashboard.useMutation({
onSuccess: (data) => {
showSuccessToast({
+ operation: "dashboard.create",
title: "Dashboard created",
description: "Your new dashboard has been created successfully",
});
diff --git a/web/src/features/dashboard/components/CloneFirstDialogController.tsx b/web/src/features/dashboard/components/CloneFirstDialogController.tsx
index 4d204c9162..ad640ee0ce 100644
--- a/web/src/features/dashboard/components/CloneFirstDialogController.tsx
+++ b/web/src/features/dashboard/components/CloneFirstDialogController.tsx
@@ -132,6 +132,7 @@ function CloneFirstDialogContent({
owner: "LANGFUSE",
});
showSuccessToast({
+ operation: "dashboard.clone",
title: "Editable copy created",
description: setAsHome
? "The copy is now this project's Home dashboard"
diff --git a/web/src/features/dashboard/components/DashboardTable/ConnectedDashboardTable.tsx b/web/src/features/dashboard/components/DashboardTable/ConnectedDashboardTable.tsx
index 6dd4ddc275..592a55b820 100644
--- a/web/src/features/dashboard/components/DashboardTable/ConnectedDashboardTable.tsx
+++ b/web/src/features/dashboard/components/DashboardTable/ConnectedDashboardTable.tsx
@@ -31,6 +31,7 @@ export function ConnectedDashboardTable() {
onSuccess: () => {
utils.dashboard.invalidate();
showSuccessToast({
+ operation: "dashboard.clone",
title: "Dashboard cloned",
description: "The dashboard has been cloned successfully",
});
@@ -43,6 +44,7 @@ export function ConnectedDashboardTable() {
onSuccess: () => {
capture("dashboard:delete_dashboard_button_click");
showSuccessToast({
+ operation: "dashboard.delete",
title: "Dashboard deleted",
description: "The dashboard has been deleted successfully",
});
diff --git a/web/src/features/datasets/DatasetExperimentsPage.tsx b/web/src/features/datasets/DatasetExperimentsPage.tsx
index 7668d5ba29..f8bd993cb1 100644
--- a/web/src/features/datasets/DatasetExperimentsPage.tsx
+++ b/web/src/features/datasets/DatasetExperimentsPage.tsx
@@ -114,6 +114,7 @@ function DatasetExperimentsView({
}
showSuccessToast({
+ operation: "experiment.trigger",
title: "Experiment triggered successfully",
description: "Waiting for experiment to complete...",
link: {
diff --git a/web/src/features/datasets/components/DatasetVersionHistoryPanel.tsx b/web/src/features/datasets/components/DatasetVersionHistoryPanel.tsx
index cc3749a801..3e554c8380 100644
--- a/web/src/features/datasets/components/DatasetVersionHistoryPanel.tsx
+++ b/web/src/features/datasets/components/DatasetVersionHistoryPanel.tsx
@@ -78,6 +78,7 @@ export function DatasetVersionHistoryPanel({
const isoTimestamp = version.toISOString();
navigator.clipboard.writeText(isoTimestamp);
showSuccessToast({
+ operation: "dataset_version_timestamp.copy",
title: "Copied!",
description: `Version timestamp: ${isoTimestamp}`,
});
diff --git a/web/src/features/datasets/components/DatasetsTable.tsx b/web/src/features/datasets/components/DatasetsTable.tsx
index f58fa01ebf..a9b5d62895 100644
--- a/web/src/features/datasets/components/DatasetsTable.tsx
+++ b/web/src/features/datasets/components/DatasetsTable.tsx
@@ -134,6 +134,7 @@ function DatasetsMultiSelectActionMenu({
const deleteManyMutation = api.datasets.deleteMany.useMutation({
onSuccess: () => {
showSuccessToast({
+ operation: "dataset.bulk_delete",
title: "Datasets deleted",
description:
"Selected datasets will be deleted. Associated run items and media links are cleaned up asynchronously.",
diff --git a/web/src/features/evals/components/default-eval-model-setup.tsx b/web/src/features/evals/components/default-eval-model-setup.tsx
index a86929837c..ee78b64e5f 100644
--- a/web/src/features/evals/components/default-eval-model-setup.tsx
+++ b/web/src/features/evals/components/default-eval-model-setup.tsx
@@ -22,6 +22,7 @@ import { Pencil } from "lucide-react";
import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";
type DefaultEvalModelSuccessMessage = {
+ operation: string;
title: string;
description: string;
};
@@ -145,6 +146,7 @@ export function DefaultEvalModelSetup({
onSuccess?.();
},
successMessage: {
+ operation: "evaluation_model.update",
title: "Default evaluation model updated",
description: "All running evaluators will use the new model.",
},
@@ -261,6 +263,7 @@ export function InlineDefaultEvalModelSetup({
projectId,
onSuccess,
successMessage: {
+ operation: "evaluation_model.set",
title: "Default evaluation model set",
description: "LLM-as-a-judge evaluators can now use this model.",
},
diff --git a/web/src/features/evals/components/delete-eval-template-dialog.tsx b/web/src/features/evals/components/delete-eval-template-dialog.tsx
index 175fed4195..63ce9a9cf1 100644
--- a/web/src/features/evals/components/delete-eval-template-dialog.tsx
+++ b/web/src/features/evals/components/delete-eval-template-dialog.tsx
@@ -65,6 +65,7 @@ export function DeleteEvalTemplateDialog({
const templateMutation = api.evals.deleteEvalTemplate.useMutation({
onSuccess: () => {
showSuccessToast({
+ operation: "evaluator.delete",
title: "Evaluator deleted",
description: `Evaluator "${templateName}" was deleted.`,
});
diff --git a/web/src/features/evals/components/eval-templates-table.tsx b/web/src/features/evals/components/eval-templates-table.tsx
index 62a638f4f8..b69f6465bc 100644
--- a/web/src/features/evals/components/eval-templates-table.tsx
+++ b/web/src/features/evals/components/eval-templates-table.tsx
@@ -611,6 +611,7 @@ export default function EvalsTemplateTable({
setEditTemplateId(null);
utils.evals.templateNames.invalidate();
showSuccessToast({
+ operation: "evaluator.update",
title: "Evaluator updated successfully",
description: "You can now use this evaluator.",
});
@@ -664,6 +665,7 @@ export default function EvalsTemplateTable({
setCloneTemplateId(null);
utils.evals.templateNames.invalidate();
showSuccessToast({
+ operation: "evaluator.clone",
title: "Evaluator cloned successfully",
description:
"This evaluator is now available and maintained on project level. ",
diff --git a/web/src/features/evals/components/evaluator-paused-callout.tsx b/web/src/features/evals/components/evaluator-paused-callout.tsx
index d3daa21a7a..9285625986 100644
--- a/web/src/features/evals/components/evaluator-paused-callout.tsx
+++ b/web/src/features/evals/components/evaluator-paused-callout.tsx
@@ -59,6 +59,7 @@ export function EvaluatorPausedCallout({
onSuccess: async () => {
await utils.evals.invalidate();
showSuccessToast({
+ operation: "evaluator.reactivate",
title: "Evaluator reactivated",
description: "The evaluator is active again.",
});
diff --git a/web/src/features/evals/components/evaluator-table.tsx b/web/src/features/evals/components/evaluator-table.tsx
index 478aee7899..658e050db2 100644
--- a/web/src/features/evals/components/evaluator-table.tsx
+++ b/web/src/features/evals/components/evaluator-table.tsx
@@ -543,6 +543,7 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
setEditConfigId(null);
utils.evals.allConfigs.invalidate();
showSuccessToast({
+ operation: "evaluator.update",
title: "Evaluator updated successfully",
description:
"Changes will automatically be reflected future evaluator runs",
diff --git a/web/src/features/evals/components/select-evaluator-list.tsx b/web/src/features/evals/components/select-evaluator-list.tsx
index ae146c7ead..2a60d9f583 100644
--- a/web/src/features/evals/components/select-evaluator-list.tsx
+++ b/web/src/features/evals/components/select-evaluator-list.tsx
@@ -408,6 +408,7 @@ function CreateEvaluatorTemplateForm({
onFormSuccess={(newTemplate) => {
onSuccess(newTemplate);
showSuccessToast({
+ operation: "evaluator.create",
title: "Evaluator created successfully",
description: "You can now use this evaluator.",
});
diff --git a/web/src/features/evals/components/template-form.tsx b/web/src/features/evals/components/template-form.tsx
index 3d24d1eb0f..02abf304a0 100644
--- a/web/src/features/evals/components/template-form.tsx
+++ b/web/src/features/evals/components/template-form.tsx
@@ -364,6 +364,7 @@ const InnerEvalTemplateForm = (props: {
utils.models.invalidate();
if (data.updatedConfigCount > 0) {
showSuccessToast({
+ operation: "evaluator.update",
title: "Updated evaluators",
description:
"Updated referenced evaluators to use new template version.",
diff --git a/web/src/features/evals/v2/components/Rules/CreateRuleDialog/components/CreateRuleDialogContent/CreateRuleDialogContent.tsx b/web/src/features/evals/v2/components/Rules/CreateRuleDialog/components/CreateRuleDialogContent/CreateRuleDialogContent.tsx
index 1adaed79bf..80bad0b293 100644
--- a/web/src/features/evals/v2/components/Rules/CreateRuleDialog/components/CreateRuleDialogContent/CreateRuleDialogContent.tsx
+++ b/web/src/features/evals/v2/components/Rules/CreateRuleDialog/components/CreateRuleDialogContent/CreateRuleDialogContent.tsx
@@ -124,6 +124,7 @@ export function CreateRuleDialogContent({
onCreated?.();
if (successNotification === "toast") {
showSuccessToast({
+ operation: "evaluation_rule.create",
title: "Rule created",
description: `${rule.name} is active.`,
});
diff --git a/web/src/features/evals/v2/components/Rules/EditRuleDialog/components/EditRuleDialogContent/EditRuleDialogContent.tsx b/web/src/features/evals/v2/components/Rules/EditRuleDialog/components/EditRuleDialogContent/EditRuleDialogContent.tsx
index c70fb928c9..4a2cfc2df7 100644
--- a/web/src/features/evals/v2/components/Rules/EditRuleDialog/components/EditRuleDialogContent/EditRuleDialogContent.tsx
+++ b/web/src/features/evals/v2/components/Rules/EditRuleDialog/components/EditRuleDialogContent/EditRuleDialogContent.tsx
@@ -111,6 +111,7 @@ export function EditRuleDialogContent({
});
}
showSuccessToast({
+ operation: "evaluation_rule.update",
title: "Rule saved",
description: "Your changes have been saved.",
});
diff --git a/web/src/features/evals/v2/hooks/useProjectDefaultModel.ts b/web/src/features/evals/v2/hooks/useProjectDefaultModel.ts
index 571d58ff65..b022b8dc8f 100644
--- a/web/src/features/evals/v2/hooks/useProjectDefaultModel.ts
+++ b/web/src/features/evals/v2/hooks/useProjectDefaultModel.ts
@@ -77,6 +77,7 @@ export function useProjectDefaultModel({
isReplacement,
});
showSuccessToast({
+ operation: "project_default_model.update",
title: "Project default model updated",
description: `${model.provider} / ${model.model} is now the project default.`,
});
diff --git a/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx b/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx
index 52545b2fc0..eb4f60bd55 100644
--- a/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx
+++ b/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx
@@ -393,6 +393,7 @@ export function EvaluatorSetupPage(
const reactivate = api.evalsV2.reactivate.useMutation({
onSuccess: async () => {
showSuccessToast({
+ operation: "evaluator.reactivate",
title: "Evaluator reactivated",
description:
"The model test succeeded and the evaluator is active again.",
@@ -417,6 +418,7 @@ export function EvaluatorSetupPage(
isAllMatching: false,
});
showSuccessToast({
+ operation: "evaluator.delete",
title: "Evaluator deleted",
description: "The evaluator and all of its versions were deleted.",
});
@@ -612,6 +614,7 @@ export function EvaluatorSetupPage(
: {}),
});
showSuccessToast({
+ operation: "evaluator.save",
title: "Evaluator saved",
description: "Your evaluator changes are saved.",
});
diff --git a/web/src/features/evals/v2/pages/EvaluatorsPage.tsx b/web/src/features/evals/v2/pages/EvaluatorsPage.tsx
index 273a308855..7b1f47b0c0 100644
--- a/web/src/features/evals/v2/pages/EvaluatorsPage.tsx
+++ b/web/src/features/evals/v2/pages/EvaluatorsPage.tsx
@@ -344,6 +344,7 @@ export default function EvaluatorsPage() {
isAllMatching: deleteAll,
});
showSuccessToast({
+ operation: "evaluator.bulk_delete",
title: "Evaluators deleted",
description: `${deletedCount} evaluator${deletedCount === 1 ? "" : "s"} deleted.`,
});
diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsx
index ef90500c34..2cbbd83615 100644
--- a/web/src/features/events/components/EventsTable.tsx
+++ b/web/src/features/events/components/EventsTable.tsx
@@ -1047,6 +1047,7 @@ export default function ObservationsEventsTable({
const traceDeleteMutation = api.traces.deleteMany.useMutation({
onSuccess: () => {
showSuccessToast({
+ operation: "trace.bulk_delete",
title: "Traces deleted",
description:
"Selected traces will be deleted. Traces are removed asynchronously and may continue to be visible for up to 15 minutes.",
diff --git a/web/src/features/events/hooks/useEventsTableData.ts b/web/src/features/events/hooks/useEventsTableData.ts
index 654363af76..b5765368f9 100644
--- a/web/src/features/events/hooks/useEventsTableData.ts
+++ b/web/src/features/events/hooks/useEventsTableData.ts
@@ -280,6 +280,7 @@ export function useEventsTableData({
});
}
showSuccessToast({
+ operation: "observation.add_to_annotation_queue",
title: "Observations added to queue",
description: `Selected observations will be added to queue "${data.queueName}". This may take a minute.`,
link: {
diff --git a/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx b/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx
index d0956f4c81..04648b09da 100644
--- a/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx
+++ b/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx
@@ -71,6 +71,7 @@ export const RemoteExperimentTriggerModal = ({
);
} else if (data.success) {
showSuccessToast({
+ operation: "remote_experiment.trigger",
title: "Remote experiment triggered",
description:
"Your remote experiment may take a few minutes to complete.",
diff --git a/web/src/features/experiments/components/RemoteExperimentUpsertForm.tsx b/web/src/features/experiments/components/RemoteExperimentUpsertForm.tsx
index ce9c77596d..57e5e58f08 100644
--- a/web/src/features/experiments/components/RemoteExperimentUpsertForm.tsx
+++ b/web/src/features/experiments/components/RemoteExperimentUpsertForm.tsx
@@ -117,6 +117,7 @@ export const RemoteExperimentUpsertForm = ({
api.datasets.upsertRemoteExperiment.useMutation({
onSuccess: (data) => {
showSuccessToast({
+ operation: "remote_experiment.configure",
title: "Setup successfully",
description: "Your changes have been saved.",
});
@@ -142,6 +143,7 @@ export const RemoteExperimentUpsertForm = ({
api.datasets.deleteRemoteExperiment.useMutation({
onSuccess: () => {
showSuccessToast({
+ operation: "remote_experiment.delete",
title: "Deleted successfully",
description:
"The remote dataset run trigger has been removed from this dataset.",
diff --git a/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx b/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx
index 8e7499b97d..19f6814f44 100644
--- a/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx
+++ b/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx
@@ -54,6 +54,7 @@ export default function ExternalMediaStoragePage() {
onSuccess: async () => {
await utils.externalMediaStorage.get.invalidate({ projectId });
showSuccessToast({
+ operation: "external_media_storage.save",
title: "External media storage saved",
description: "The integration configuration has been saved.",
});
@@ -66,6 +67,7 @@ export default function ExternalMediaStoragePage() {
onSuccess: async () => {
await utils.externalMediaStorage.get.invalidate({ projectId });
showSuccessToast({
+ operation: "external_media_storage.delete",
title: "External media storage deleted",
description: "The integration configuration has been deleted.",
});
diff --git a/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx b/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx
index cd96325a2e..3a370c668c 100644
--- a/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx
+++ b/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx
@@ -57,6 +57,7 @@ export function OrganizationFeaturePreviewsSettings({
session.update(),
]);
showSuccessToast({
+ operation: "organization_feature_preview.update",
title: "Feature preview default updated",
description: `${featurePreviewLabels[variables.flag]} was ${
variables.enabled ? "enabled" : "disabled"
diff --git a/web/src/features/feature-flags/components/UserFeaturePreviewsPopover.tsx b/web/src/features/feature-flags/components/UserFeaturePreviewsPopover.tsx
index 230855a416..71e0a1a15c 100644
--- a/web/src/features/feature-flags/components/UserFeaturePreviewsPopover.tsx
+++ b/web/src/features/feature-flags/components/UserFeaturePreviewsPopover.tsx
@@ -52,6 +52,7 @@ export function UserFeaturePreviewsControl({
await session.update();
}
showSuccessToast({
+ operation: "user_feature_preview.update",
title: "Feature preview updated",
description: `${featurePreviewLabels[variables.flag]} was ${
variables.enabled ? "enabled" : "disabled"
diff --git a/web/src/features/feature-previews/components/ControlledFeaturePreviewModal.tsx b/web/src/features/feature-previews/components/ControlledFeaturePreviewModal.tsx
index 22e4aa09e9..d3c26163f3 100644
--- a/web/src/features/feature-previews/components/ControlledFeaturePreviewModal.tsx
+++ b/web/src/features/feature-previews/components/ControlledFeaturePreviewModal.tsx
@@ -33,6 +33,7 @@ export function ControlledFeaturePreviewModal({
isEnabled: variables.enabled,
});
showSuccessToast({
+ operation: "user_feature_preview.update",
title: "Feature preview updated",
description: `${featurePreviewLabels[variables.flag]} preview has been ${variables.enabled ? "enabled" : "disabled"}.`,
});
diff --git a/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.tsx b/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.tsx
index e98fd8f7f2..3bc567df57 100644
--- a/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.tsx
+++ b/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.tsx
@@ -152,6 +152,7 @@ export function UpsertModelFormDialogContent({
utils.models.invalidate();
showSuccessToast({
+ operation: props.action === "edit" ? "model.update" : "model.create",
title: `Model ${props.action === "edit" ? "updated" : "created"}`,
description: `The model '${upsertedModel.modelName}' has been successfully ${props.action === "edit" ? "updated" : "created"}. New generations will use these model prices.`,
});
diff --git a/web/src/features/monitors/components/MonitorForm.tsx b/web/src/features/monitors/components/MonitorForm.tsx
index 7d64f75f00..c8ff2e7e34 100644
--- a/web/src/features/monitors/components/MonitorForm.tsx
+++ b/web/src/features/monitors/components/MonitorForm.tsx
@@ -263,6 +263,7 @@ export const MonitorForm = ({
monitorCreateAnalyticsProperties(analyticsSource, variables),
);
showSuccessToast({
+ operation: "monitor.create",
title: "Alert created",
description: `"${variables.name}" is now active.`,
});
@@ -276,6 +277,7 @@ export const MonitorForm = ({
onSuccess: async (_data, variables) => {
await utils.monitors.invalidate();
showSuccessToast({
+ operation: "monitor.update",
title: "Alert saved",
description: `Your changes to "${variables.name}" have been applied.`,
});
diff --git a/web/src/features/monitors/components/MonitorsTable.tsx b/web/src/features/monitors/components/MonitorsTable.tsx
index f57a8354d1..c3a4f22607 100644
--- a/web/src/features/monitors/components/MonitorsTable.tsx
+++ b/web/src/features/monitors/components/MonitorsTable.tsx
@@ -83,6 +83,8 @@ export function MonitorsTable() {
onSuccess: async (_data, variables) => {
await utils.monitors.invalidate();
showSuccessToast({
+ operation:
+ variables.status === "PAUSED" ? "monitor.pause" : "monitor.resume",
title: variables.status === "PAUSED" ? "Alert paused" : "Alert resumed",
description:
variables.status === "PAUSED"
diff --git a/web/src/features/monitors/pages/EditMonitorPage.tsx b/web/src/features/monitors/pages/EditMonitorPage.tsx
index 6809dbf46c..f61a102b57 100644
--- a/web/src/features/monitors/pages/EditMonitorPage.tsx
+++ b/web/src/features/monitors/pages/EditMonitorPage.tsx
@@ -56,6 +56,7 @@ const EditMonitorFormPage = ({ monitor }: { monitor: Monitor }) => {
onSuccess: async () => {
await invalidateMonitorQueriesAfterDelete(utils.monitors);
showSuccessToast({
+ operation: "monitor.delete",
title: "Alert deleted",
description: `"${monitor.name}" has been deleted.`,
});
diff --git a/web/src/features/notifications/ErrorNotification.clienttest.tsx b/web/src/features/notifications/ErrorNotification.clienttest.tsx
index a5f3839641..50cbea59e9 100644
--- a/web/src/features/notifications/ErrorNotification.clienttest.tsx
+++ b/web/src/features/notifications/ErrorNotification.clienttest.tsx
@@ -1,4 +1,4 @@
-import { render, waitFor } from "@testing-library/react";
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { vi } from "vitest";
import { ErrorNotification } from "@/src/features/notifications/ErrorNotification";
@@ -40,6 +40,12 @@ describe("ErrorNotification", () => {
source: "trpc" as const,
path: "traces.byId",
traceId: "0123456789abcdef",
+ analytics: {
+ errorOrigin: "backend" as const,
+ errorCategory: "internal" as const,
+ trpcCode: "INTERNAL_SERVER_ERROR",
+ httpStatus: 500,
+ },
};
const view = render(<ErrorNotification {...props} />);
@@ -51,6 +57,10 @@ describe("ErrorNotification", () => {
path: "traces.byId",
hasErrorId: true,
errorId: props.traceId,
+ errorOrigin: "backend",
+ errorCategory: "internal",
+ trpcCode: "INTERNAL_SERVER_ERROR",
+ httpStatus: 500,
});
});
@@ -85,6 +95,8 @@ describe("ErrorNotification", () => {
toastType: "WARNING",
source: "application",
hasErrorId: false,
+ errorOrigin: "unknown",
+ errorCategory: "unknown",
});
});
expect(mocks.capture.mock.calls[0]?.[1]).not.toHaveProperty("errorId");
@@ -107,7 +119,51 @@ describe("ErrorNotification", () => {
toastType: "WARNING",
source: "trpc",
hasErrorId: false,
+ errorOrigin: "unknown",
+ errorCategory: "unknown",
});
});
});
+
+ it("uses the same bounded dimensions for error interactions", async () => {
+ const dismissToast = vi.fn();
+ render(
+ <ErrorNotification
+ error="Sensitive error"
+ description="Sensitive details"
+ type="ERROR"
+ dismissToast={dismissToast}
+ toast="toast-4"
+ analytics={{
+ errorOrigin: "frontend",
+ errorCategory: "user_input",
+ operation: "form.submit",
+ }}
+ />,
+ );
+
+ await waitFor(() => expect(mocks.capture).toHaveBeenCalledTimes(1));
+ fireEvent.click(
+ screen.getByRole("button", { name: "Report issue to Langfuse team" }),
+ );
+
+ expect(mocks.capture).toHaveBeenLastCalledWith("toast:report_issue", {
+ toastType: "ERROR",
+ source: "application",
+ errorOrigin: "frontend",
+ errorCategory: "user_input",
+ operation: "form.submit",
+ });
+
+ fireEvent.click(screen.getByRole("button", { name: "Close" }));
+ expect(mocks.capture).toHaveBeenLastCalledWith("toast:dismiss", {
+ toastType: "ERROR",
+ source: "application",
+ errorOrigin: "frontend",
+ errorCategory: "user_input",
+ operation: "form.submit",
+ });
+ expect(dismissToast).toHaveBeenCalledWith("toast-4");
+ expect(JSON.stringify(mocks.capture.mock.calls)).not.toContain("Sensitive");
+ });
});
diff --git a/web/src/features/notifications/ErrorNotification.tsx b/web/src/features/notifications/ErrorNotification.tsx
index ba2669c658..04db2c5bb3 100644
--- a/web/src/features/notifications/ErrorNotification.tsx
+++ b/web/src/features/notifications/ErrorNotification.tsx
@@ -1,4 +1,8 @@
import { Button } from "@/src/components/ui/button";
+import {
+ type ToastErrorAnalytics,
+ type ToastErrorEventProperties,
+} from "@/src/features/notifications/toastAnalytics";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
import { useSupportDrawer } from "@/src/features/support-chat";
import { useV4MigrationPanel } from "@/src/features/v4-migration/V4MigrationPanelProvider";
@@ -15,6 +19,7 @@ interface ErrorNotificationProps {
source?: "application" | "trpc";
path?: string;
traceId?: string;
+ analytics?: ToastErrorAnalytics;
}
export const ErrorNotification: React.FC<ErrorNotificationProps> = ({
@@ -26,6 +31,7 @@ export const ErrorNotification: React.FC<ErrorNotificationProps> = ({
source = "application",
path,
traceId,
+ analytics,
}) => {
const { setOpen } = useSupportDrawer();
const { setOpen: setMigrationPanelOpen } = useV4MigrationPanel();
@@ -36,18 +42,29 @@ export const ErrorNotification: React.FC<ErrorNotificationProps> = ({
const textColor = isError
? "text-destructive-foreground"
: "text-dark-yellow";
+ const interactionProperties = {
+ toastType: type,
+ source,
+ ...(path ? { path } : {}),
+ errorOrigin: analytics?.errorOrigin ?? "unknown",
+ errorCategory: analytics?.errorCategory ?? "unknown",
+ ...(analytics?.operation ? { operation: analytics.operation } : {}),
+ ...(analytics?.trpcCode ? { trpcCode: analytics.trpcCode } : {}),
+ ...(analytics?.httpStatus !== undefined
+ ? { httpStatus: analytics.httpStatus }
+ : {}),
+ };
+ const eventProperties: ToastErrorEventProperties = {
+ ...interactionProperties,
+ hasErrorId: Boolean(traceId),
+ ...(traceId ? { errorId: traceId } : {}),
+ };
const captureShown = (element: HTMLDivElement | null) => {
if (!element || didCaptureShown.current) return;
didCaptureShown.current = true;
- capture("toast:shown", {
- toastType: type,
- source,
- ...(path ? { path } : {}),
- hasErrorId: Boolean(traceId),
- ...(traceId ? { errorId: traceId } : {}),
- });
+ capture("toast:shown", eventProperties);
};
return (
@@ -100,8 +117,7 @@ export const ErrorNotification: React.FC<ErrorNotificationProps> = ({
size="sm"
onClick={() => {
capture("toast:report_issue", {
- toast_type: type,
- path,
+ ...interactionProperties,
});
setMigrationPanelOpen(false);
setOpen(true, {
@@ -122,8 +138,7 @@ export const ErrorNotification: React.FC<ErrorNotificationProps> = ({
className={`flex h-6 w-6 cursor-pointer items-start justify-end border-none bg-transparent p-0 ${textColor} transition-colors duration-200`}
onClick={() => {
capture("toast:dismiss", {
- toast_type: type,
- path,
+ ...interactionProperties,
});
dismissToast(toast);
}}
diff --git a/web/src/features/notifications/SuccessNotification.clienttest.tsx b/web/src/features/notifications/SuccessNotification.clienttest.tsx
new file mode 100644
index 0000000000..de7a5064f6
--- /dev/null
+++ b/web/src/features/notifications/SuccessNotification.clienttest.tsx
@@ -0,0 +1,74 @@
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { vi } from "vitest";
+import { SuccessNotification } from "@/src/features/notifications/SuccessNotification";
+
+const mocks = vi.hoisted(() => ({
+ capture: vi.fn(),
+}));
+
+vi.mock("@/src/features/posthog-analytics", () => ({
+ usePostHogClientCapture: () => mocks.capture,
+}));
+
+describe("SuccessNotification", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it("captures bounded metadata once without rendered toast content", async () => {
+ const view = render(
+ <SuccessNotification
+ title="Sensitive success title"
+ description="Sensitive customer-controlled details"
+ operation="dashboard.create"
+ onDismiss={vi.fn()}
+ />,
+ );
+
+ await waitFor(() => {
+ expect(mocks.capture).toHaveBeenCalledWith("toast:shown", {
+ toastType: "SUCCESS",
+ source: "application",
+ operation: "dashboard.create",
+ hasErrorId: false,
+ });
+ });
+
+ view.rerender(
+ <SuccessNotification
+ title="Another title"
+ description="Another description"
+ operation="dashboard.update"
+ onDismiss={vi.fn()}
+ />,
+ );
+
+ expect(mocks.capture).toHaveBeenCalledTimes(1);
+ expect(JSON.stringify(mocks.capture.mock.calls)).not.toContain("Sensitive");
+ expect(JSON.stringify(mocks.capture.mock.calls)).not.toContain(
+ "Another title",
+ );
+ });
+
+ it("captures a manual dismiss with the same operation", async () => {
+ const onDismiss = vi.fn();
+ render(
+ <SuccessNotification
+ title="Saved"
+ description="Done"
+ operation="dashboard.update"
+ onDismiss={onDismiss}
+ />,
+ );
+
+ await waitFor(() => expect(mocks.capture).toHaveBeenCalledTimes(1));
+ fireEvent.click(screen.getByRole("button", { name: "Close" }));
+
+ expect(mocks.capture).toHaveBeenLastCalledWith("toast:dismiss", {
+ toastType: "SUCCESS",
+ source: "application",
+ operation: "dashboard.update",
+ });
+ expect(onDismiss).toHaveBeenCalledOnce();
+ });
+});
diff --git a/web/src/features/notifications/SuccessNotification.tsx b/web/src/features/notifications/SuccessNotification.tsx
index c6ce843568..48200f3d34 100644
--- a/web/src/features/notifications/SuccessNotification.tsx
+++ b/web/src/features/notifications/SuccessNotification.tsx
@@ -1,9 +1,12 @@
import { ActionButton } from "@/src/components/ActionButton";
+import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
import { BadgeCheck, X } from "lucide-react";
+import { useRef } from "react";
export type SuccessNotificationProps = {
title: string;
description: string;
+ operation: string;
onDismiss: () => void;
link?: {
href: string;
@@ -14,11 +17,36 @@ export type SuccessNotificationProps = {
export const SuccessNotification: React.FC<SuccessNotificationProps> = ({
title,
description,
+ operation,
onDismiss,
link,
}) => {
+ const capture = usePostHogClientCapture();
+ const didCaptureShown = useRef(false);
+
+ const captureShown = (element: HTMLDivElement | null) => {
+ if (!element || didCaptureShown.current) return;
+ didCaptureShown.current = true;
+
+ capture("toast:shown", {
+ toastType: "SUCCESS",
+ source: "application",
+ operation,
+ hasErrorId: false,
+ });
+ };
+
+ const handleDismiss = () => {
+ capture("toast:dismiss", {
+ toastType: "SUCCESS",
+ source: "application",
+ operation,
+ });
+ onDismiss();
+ };
+
return (
- <div className="flex justify-between">
+ <div ref={captureShown} className="flex justify-between">
<div className="flex min-w-[300px] flex-1 flex-col gap-2">
<div className="flex items-center gap-2">
<BadgeCheck className="icon-lg text-primary-foreground" />
@@ -41,7 +69,7 @@ export const SuccessNotification: React.FC<SuccessNotificationProps> = ({
</div>
<button
className="text-primary-foreground flex h-6 w-6 cursor-pointer items-start justify-end border-none bg-transparent p-0 transition-colors duration-200"
- onClick={onDismiss}
+ onClick={handleDismiss}
aria-label="Close"
>
<X className="icon-base" />
diff --git a/web/src/features/notifications/showErrorToast.tsx b/web/src/features/notifications/showErrorToast.tsx
index 81ed91476e..a587b9edc4 100644
--- a/web/src/features/notifications/showErrorToast.tsx
+++ b/web/src/features/notifications/showErrorToast.tsx
@@ -1,5 +1,6 @@
import { toast } from "sonner";
import { ErrorNotification } from "@/src/features/notifications/ErrorNotification";
+import { type ToastErrorAnalytics } from "@/src/features/notifications/toastAnalytics";
const toastErrorStyleProps = {
border: "1px solid hsl(var(--destructive))",
@@ -23,6 +24,7 @@ export const showErrorToast = (
path?: string,
traceId?: string,
source: "application" | "trpc" = "application",
+ analytics?: ToastErrorAnalytics,
) => {
toast.custom(
(t) => (
@@ -33,6 +35,7 @@ export const showErrorToast = (
source={source}
path={path}
traceId={traceId}
+ analytics={analytics}
dismissToast={toast.dismiss}
toast={t}
/>
diff --git a/web/src/features/notifications/toastAnalytics.ts b/web/src/features/notifications/toastAnalytics.ts
new file mode 100644
index 0000000000..c27ca50faa
--- /dev/null
+++ b/web/src/features/notifications/toastAnalytics.ts
@@ -0,0 +1,44 @@
+type ToastSource = "application" | "trpc";
+
+type ToastErrorOrigin = "frontend" | "backend" | "network" | "unknown";
+
+type ToastErrorCategory =
+ | "user_input"
+ | "permission"
+ | "product_state"
+ | "rate_limit"
+ | "resource_limit"
+ | "transient"
+ | "internal"
+ | "unknown";
+
+export type ToastErrorAnalytics = {
+ errorOrigin: ToastErrorOrigin;
+ errorCategory: ToastErrorCategory;
+ operation?: string;
+ trpcCode?: string;
+ httpStatus?: number;
+};
+
+export type ToastErrorEventProperties = ToastErrorAnalytics & {
+ toastType: "WARNING" | "ERROR";
+ source: ToastSource;
+ path?: string;
+ hasErrorId: boolean;
+ errorId?: string;
+};
+
+type ToastSuccessEventProperties = {
+ toastType: "SUCCESS";
+ source: "application";
+ operation: string;
+ hasErrorId: false;
+};
+
+export type ToastShownEventProperties =
+ | ToastErrorEventProperties
+ | ToastSuccessEventProperties;
+
+export type ToastInteractionEventProperties =
+ | Omit<ToastErrorEventProperties, "hasErrorId" | "errorId">
+ | Omit<ToastSuccessEventProperties, "hasErrorId">;
diff --git a/web/src/features/organizations/components/DeleteOrganizationDialogController.tsx b/web/src/features/organizations/components/DeleteOrganizationDialogController.tsx
index 4c582894df..4f3df2ab1b 100644
--- a/web/src/features/organizations/components/DeleteOrganizationDialogController.tsx
+++ b/web/src/features/organizations/components/DeleteOrganizationDialogController.tsx
@@ -48,6 +48,7 @@ export function DeleteOrganizationDialogController({
});
capture("organization_settings:delete_organization");
showSuccessToast({
+ operation: "organization.delete",
title: "Organization Deleted",
description: "The organization has been successfully deleted.",
});
diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.ts
index e9854fb708..b40cab54e6 100644
--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts
+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts
@@ -3,17 +3,17 @@ import { usePostHog } from "posthog-js/react";
import { useCallback } from "react";
import type { AnnotationEventMap } from "@/src/features/scores/lib/annotationAnalytics";
import type { EvalOnboardingEventMap } from "@/src/features/evals/v2/types/evalOnboardingAnalytics";
+import type {
+ ToastInteractionEventProperties,
+ ToastShownEventProperties,
+} from "@/src/features/notifications/toastAnalytics";
export const V4_BETA_ENABLED_POSTHOG_PROPERTY = "v4BetaEnabled";
type ToastEventMap = {
- "toast:shown": {
- toastType: "WARNING" | "ERROR";
- source: "trpc" | "application";
- path?: string;
- hasErrorId: boolean;
- errorId?: string;
- };
+ "toast:shown": ToastShownEventProperties;
+ "toast:report_issue": ToastInteractionEventProperties;
+ "toast:dismiss": ToastInteractionEventProperties;
};
// resource:action, only use snake_case
@@ -377,9 +377,9 @@ const events = {
// props carry user content.
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 and `errorId` is the opaque ID shown in the
- // toast; never send toast text or error payloads.
+ // User-visible toast denominator. Metadata only: `path` is a static tRPC
+ // procedure, `operation` is a static action id, 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",
diff --git a/web/src/features/projects/components/TransferProjectDialogController.tsx b/web/src/features/projects/components/TransferProjectDialogController.tsx
index 3a2b11dfb1..e7e9383669 100644
--- a/web/src/features/projects/components/TransferProjectDialogController.tsx
+++ b/web/src/features/projects/components/TransferProjectDialogController.tsx
@@ -50,6 +50,7 @@ export function TransferProjectDialogController({
const transferProject = api.projects.transfer.useMutation({
onSuccess: async () => {
showSuccessToast({
+ operation: "project.transfer",
title: "Project transferred",
description:
"The project is successfully transferred to the new organization. Redirecting...",
diff --git a/web/src/features/prompts/components/prompt-detail.tsx b/web/src/features/prompts/components/prompt-detail.tsx
index d622db22de..f102e28736 100644
--- a/web/src/features/prompts/components/prompt-detail.tsx
+++ b/web/src/features/prompts/components/prompt-detail.tsx
@@ -237,6 +237,7 @@ export const PromptDetail = ({
utils.datasets.baseRunDataByDatasetId.invalidate();
utils.datasets.runsByDatasetId.invalidate();
showSuccessToast({
+ operation: "experiment.trigger",
title: "Experiment triggered successfully",
description: "Waiting for experiment to complete...",
link: {
diff --git a/web/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable.tsx b/web/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable.tsx
index 3b467780f5..ca182a4b3c 100644
--- a/web/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable.tsx
+++ b/web/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable.tsx
@@ -136,6 +136,7 @@ export function ConnectedMembersSettingsTable({
utils.members.invalidate();
if (data.userId === session.data?.user?.id) session.update();
showSuccessToast({
+ operation: "organization_role.update",
title: "Saved",
description: "Organization role updated successfully",
duration: 2000,
@@ -148,6 +149,7 @@ export function ConnectedMembersSettingsTable({
utils.members.invalidate();
if (data.userId === session.data?.user?.id) session.update();
showSuccessToast({
+ operation: "project_role.update",
title: "Saved",
description: "Project role updated successfully",
duration: 2000,
diff --git a/web/src/features/scores/ScoresTable.tsx b/web/src/features/scores/ScoresTable.tsx
index 71fa62f405..b5f22a9430 100644
--- a/web/src/features/scores/ScoresTable.tsx
+++ b/web/src/features/scores/ScoresTable.tsx
@@ -343,6 +343,7 @@ export default function ScoresTable({
const scoreDeleteMutation = api.scores.deleteMany.useMutation({
onSuccess: () => {
showSuccessToast({
+ operation: "score.bulk_delete",
title: "Scores deleted",
description:
"Selected scores will be deleted. Scores are removed asynchronously and may continue to be visible for up to 15 minutes.",
diff --git a/web/src/features/sessions/SessionsTable.tsx b/web/src/features/sessions/SessionsTable.tsx
index dd244f83e9..a81f268954 100644
--- a/web/src/features/sessions/SessionsTable.tsx
+++ b/web/src/features/sessions/SessionsTable.tsx
@@ -425,6 +425,7 @@ export default function SessionsTable({
});
}
showSuccessToast({
+ operation: "session.add_to_annotation_queue",
title: "Sessions added to queue",
description: `Selected sessions will be added to queue "${data.queueName}". This may take a minute.`,
link: {
diff --git a/web/src/features/skills/components/ImportSkillsDialog.tsx b/web/src/features/skills/components/ImportSkillsDialog.tsx
index ba70f88ea3..0a1ddb7d47 100644
--- a/web/src/features/skills/components/ImportSkillsDialog.tsx
+++ b/web/src/features/skills/components/ImportSkillsDialog.tsx
@@ -181,6 +181,7 @@ export function ImportSkillsDialog({
});
utils.skills.invalidate();
showSuccessToast({
+ operation: "skills.import",
title: `Imported ${importedCount} ${importedCount === 1 ? "skill" : "skills"}`,
description: "The imported copies are available in your skills list.",
});
diff --git a/web/src/features/skills/components/SkillEditor.tsx b/web/src/features/skills/components/SkillEditor.tsx
index 6383befba1..d2a4d5d899 100644
--- a/web/src/features/skills/components/SkillEditor.tsx
+++ b/web/src/features/skills/components/SkillEditor.tsx
@@ -217,6 +217,7 @@ export function SkillEditor({
isFirstVersion: createNew,
});
showSuccessToast({
+ operation: "skill_version.create",
title: "Skill version created",
description: `Version ${created.version} is now available.`,
});
@@ -261,6 +262,7 @@ export function SkillEditor({
]),
});
showSuccessToast({
+ operation: "skill_labels.update",
title: "Skill labels updated",
description: `Version ${version} now uses the selected labels.`,
});
@@ -293,6 +295,7 @@ export function SkillEditor({
]),
});
showSuccessToast({
+ operation: "skill_tags.update",
title: "Skill tags updated",
description: "All versions now use the selected tags.",
});
diff --git a/web/src/features/slack/components/SlackConnectButton.tsx b/web/src/features/slack/components/SlackConnectButton.tsx
index 7b375a560b..3ed0236f5c 100644
--- a/web/src/features/slack/components/SlackConnectButton.tsx
+++ b/web/src/features/slack/components/SlackConnectButton.tsx
@@ -113,6 +113,7 @@ export const SlackConnectButton: React.FC<SlackConnectButtonProps> = ({
setIsConnecting(false);
showSuccessToast({
+ operation: "slack.connect",
title: "Slack Connected",
description: `Successfully connected to ${event.data.teamName}.`,
});
diff --git a/web/src/features/slack/components/SlackDisconnectButton.tsx b/web/src/features/slack/components/SlackDisconnectButton.tsx
index 4f112b3e4c..da7679a5c0 100644
--- a/web/src/features/slack/components/SlackDisconnectButton.tsx
+++ b/web/src/features/slack/components/SlackDisconnectButton.tsx
@@ -91,6 +91,7 @@ export const SlackDisconnectButton: React.FC<SlackDisconnectButtonProps> = ({
setIsDialogOpen(false);
showSuccessToast({
+ operation: "slack.disconnect",
title: "Slack Disconnected",
description: "Successfully disconnected from your Slack workspace.",
});
diff --git a/web/src/features/slack/components/SlackTestMessageButton.tsx b/web/src/features/slack/components/SlackTestMessageButton.tsx
index f05d5112af..fc8dcb4d04 100644
--- a/web/src/features/slack/components/SlackTestMessageButton.tsx
+++ b/web/src/features/slack/components/SlackTestMessageButton.tsx
@@ -57,6 +57,7 @@ export const SlackTestMessageButton: React.FC<SlackTestMessageButtonProps> = ({
const testMessageMutation = api.slack.sendTestMessage.useMutation({
onSuccess: (data) => {
showSuccessToast({
+ operation: "slack.test_message_send",
title: "Test Message Sent",
description: "Test message sent successfully to the selected channel.",
});
diff --git a/web/src/features/traces/TracesTable.tsx b/web/src/features/traces/TracesTable.tsx
index 93a5b59027..46c574e82a 100644
--- a/web/src/features/traces/TracesTable.tsx
+++ b/web/src/features/traces/TracesTable.tsx
@@ -604,6 +604,7 @@ function TracesTableInternal({
const traceDeleteMutation = api.traces.deleteMany.useMutation({
onSuccess: () => {
showSuccessToast({
+ operation: "trace.bulk_delete",
title: "Traces deleted",
description:
"Selected traces will be deleted. Traces are removed asynchronously and may continue to be visible for up to 15 minutes.",
@@ -628,6 +629,7 @@ function TracesTableInternal({
});
}
showSuccessToast({
+ operation: "trace.add_to_annotation_queue",
title: "Traces added to queue",
description: `Selected traces will be added to queue "${data.queueName}". This may take a minute.`,
link: {
@@ -1677,6 +1679,7 @@ export default function TracesTable(props: TracesTableProps) {
onSuccess: () => {
capture("trace:delete", { source: "table-single-row" });
showSuccessToast({
+ operation: "trace.delete",
title: "Trace deleted",
description:
"Selected trace will be deleted. Traces are removed asynchronously and may continue to be visible for up to 24 hours.",
diff --git a/web/src/features/traces/components/DeleteTraceDialogController.tsx b/web/src/features/traces/components/DeleteTraceDialogController.tsx
index 18ebb5418f..c3fcd762d1 100644
--- a/web/src/features/traces/components/DeleteTraceDialogController.tsx
+++ b/web/src/features/traces/components/DeleteTraceDialogController.tsx
@@ -57,6 +57,7 @@ export function DeleteTraceDialogController({
await deleteMutation.mutateAsync({ traceIds: [traceId], projectId });
setIsDeleted(true);
showSuccessToast({
+ operation: "trace.delete",
title: "Trace deleted",
description:
"Selected trace will be deleted. Traces are removed asynchronously and may continue to be visible for up to 24 hours.",
diff --git a/web/src/features/traces/components/TraceLogView/useLogViewDownload.clienttest.ts b/web/src/features/traces/components/TraceLogView/useLogViewDownload.clienttest.ts
index b155cee13f..d9f229df27 100644
--- a/web/src/features/traces/components/TraceLogView/useLogViewDownload.clienttest.ts
+++ b/web/src/features/traces/components/TraceLogView/useLogViewDownload.clienttest.ts
@@ -10,7 +10,12 @@ const { copyTextToClipboard } = vi.hoisted(() => ({
vi.mock("@/src/utils/clipboard", () => ({ copyTextToClipboard }));
vi.mock("sonner", () => ({
- toast: { success: vi.fn(), warning: vi.fn(), error: vi.fn() },
+ toast: {
+ custom: vi.fn(),
+ dismiss: vi.fn(),
+ warning: vi.fn(),
+ error: vi.fn(),
+ },
}));
// Escaped Japanese as ingested via the Python SDK's ensure_ascii=True.
diff --git a/web/src/features/traces/components/TraceLogView/useLogViewDownload.ts b/web/src/features/traces/components/TraceLogView/useLogViewDownload.ts
index 5e735db3fd..28e95221eb 100644
--- a/web/src/features/traces/components/TraceLogView/useLogViewDownload.ts
+++ b/web/src/features/traces/components/TraceLogView/useLogViewDownload.ts
@@ -10,6 +10,7 @@ import { useState, useCallback } from "react";
import { toast } from "sonner";
import { stringify } from "@langfuse/shared";
import { copyTextToClipboard } from "@/src/utils/clipboard";
+import { showSuccessToast } from "@/src/features/notifications";
import { type ObservationIOData } from "./useLogViewAllObservationsIO";
export interface UseLogViewDownloadParams {
@@ -53,7 +54,11 @@ export function useLogViewDownload({
try {
const data = buildDataFromCache();
copyTextToClipboard(stringify(data, undefined, 2));
- toast.success("Copied to clipboard (cache only)");
+ showSuccessToast({
+ operation: "trace_log.copy",
+ title: "Copied to clipboard (cache only)",
+ description: "",
+ });
} finally {
setIsActionLoading(false);
}
@@ -68,7 +73,11 @@ export function useLogViewDownload({
`Copied to clipboard. ${failedObservationIds.length} observation${failedObservationIds.length === 1 ? "" : "s"} failed to load and ${failedObservationIds.length === 1 ? "is" : "are"} missing I/O data.`,
);
} else {
- toast.success("Copied to clipboard");
+ showSuccessToast({
+ operation: "trace_log.copy",
+ title: "Copied to clipboard",
+ description: "",
+ });
}
} else {
setIsActionLoading(true);
@@ -81,7 +90,11 @@ export function useLogViewDownload({
`Copied to clipboard. ${failedObservationIds.length} observation${failedObservationIds.length === 1 ? "" : "s"} failed to load and ${failedObservationIds.length === 1 ? "is" : "are"} missing I/O data.`,
);
} else {
- toast.success("Copied to clipboard");
+ showSuccessToast({
+ operation: "trace_log.copy",
+ title: "Copied to clipboard",
+ description: "",
+ });
}
} finally {
setIsActionLoading(false);
diff --git a/web/src/features/tracing-tables/observations/ObservationsTable.tsx b/web/src/features/tracing-tables/observations/ObservationsTable.tsx
index f8b6618f21..d13d4b63b6 100644
--- a/web/src/features/tracing-tables/observations/ObservationsTable.tsx
+++ b/web/src/features/tracing-tables/observations/ObservationsTable.tsx
@@ -677,6 +677,7 @@ export default function ObservationsTable({
});
}
showSuccessToast({
+ operation: "observation.add_to_annotation_queue",
title: "Observations added to queue",
description: `Selected observations will be added to queue "${data.queueName}". This may take a minute.`,
link: {
diff --git a/web/src/features/v4-migration/V4MigrationContent.tsx b/web/src/features/v4-migration/V4MigrationContent.tsx
index bc01824ba6..1129815229 100644
--- a/web/src/features/v4-migration/V4MigrationContent.tsx
+++ b/web/src/features/v4-migration/V4MigrationContent.tsx
@@ -125,6 +125,7 @@ export function useCopyMigrationPrompt() {
await copyTextToClipboard(V4_CODING_AGENT_PROMPT);
capture("v4_migration:coding_agent_prompt_copied");
showSuccessToast({
+ operation: "prompt.copy",
title: "Prompt copied",
description: "Paste it into Cursor, Codex, or another coding agent.",
});
diff --git a/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx b/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx
index a185041aa2..5ccdbfb734 100644
--- a/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx
+++ b/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx
@@ -30,6 +30,7 @@ export function useWebCalloutAction(props: WebCalloutTarget, enabled: boolean) {
if (!callout?.enabled) return;
showSuccessToast({
+ operation: "web_callout.invoke",
title: callout.toastMessage,
description: callout.name,
});
diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx
index f9801ec91a..4c5c76d1c4 100644
--- a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx
+++ b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx
@@ -176,6 +176,9 @@ function WebCalloutEndpointDialog(props: {
onSuccess: async () => {
await utils.webCallouts.invalidate();
showSuccessToast({
+ operation: props.endpoint
+ ? "web_callout_endpoint.update"
+ : "web_callout_endpoint.create",
title: props.endpoint
? "Callout endpoint updated"
: "Callout endpoint created",
diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsx
index 51df903d7c..31278b5326 100644
--- a/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsx
+++ b/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsx
@@ -24,6 +24,7 @@ export function ConnectedWebCalloutSettingsTable({
onSuccess: async () => {
await utils.webCallouts.invalidate();
showSuccessToast({
+ operation: "web_callout_endpoint.delete",
title: "Callout endpoint deleted",
description: "The endpoint was removed from this project.",
});
diff --git a/web/src/features/widgets/EditWidgetPage.tsx b/web/src/features/widgets/EditWidgetPage.tsx
index acc9dc81ab..424131653c 100644
--- a/web/src/features/widgets/EditWidgetPage.tsx
+++ b/web/src/features/widgets/EditWidgetPage.tsx
@@ -50,6 +50,7 @@ export default function EditWidgetPage() {
filterCount: variables.filters.length,
});
showSuccessToast({
+ operation: "widget.update",
title: "Widget updated successfully",
description: "Your widget has been updated.",
});
diff --git a/web/src/features/widgets/NewWidgetPage.tsx b/web/src/features/widgets/NewWidgetPage.tsx
index adeb0acd57..82a0099389 100644
--- a/web/src/features/widgets/NewWidgetPage.tsx
+++ b/web/src/features/widgets/NewWidgetPage.tsx
@@ -52,6 +52,7 @@ function NewWidgetView({ projectId }: { projectId: string }) {
filterCount: variables.filters.length,
});
showSuccessToast({
+ operation: "widget.create",
title: "Widget created successfully",
description: "Your widget has been created.",
});
diff --git a/web/src/features/widgets/components/DashboardWidget.tsx b/web/src/features/widgets/components/DashboardWidget.tsx
index 14a87c204e..6913896f28 100644
--- a/web/src/features/widgets/components/DashboardWidget.tsx
+++ b/web/src/features/widgets/components/DashboardWidget.tsx
@@ -591,6 +591,7 @@ export function DashboardWidget({
dashboard_id: dashboardId,
});
showSuccessToast({
+ operation: "widget.copy",
title: "Widget copied",
description: "Paste it on any dashboard with Cmd/Ctrl+V.",
});
diff --git a/web/src/features/widgets/components/PresetDashboardWidget.tsx b/web/src/features/widgets/components/PresetDashboardWidget.tsx
index b6e6a67eec..74602da4ee 100644
--- a/web/src/features/widgets/components/PresetDashboardWidget.tsx
+++ b/web/src/features/widgets/components/PresetDashboardWidget.tsx
@@ -208,6 +208,7 @@ export function PresetDashboardWidget({
dashboard_id: dashboardId,
});
showSuccessToast({
+ operation: "dashboard_card.copy",
title: "Card copied",
description: "Paste it on any dashboard with Cmd/Ctrl+V.",
});
diff --git a/web/src/features/widgets/components/WidgetImporter.tsx b/web/src/features/widgets/components/WidgetImporter.tsx
index b864749ca4..f1e387381a 100644
--- a/web/src/features/widgets/components/WidgetImporter.tsx
+++ b/web/src/features/widgets/components/WidgetImporter.tsx
@@ -188,6 +188,7 @@ async function runImport(params: {
params.onImport(result.snapshot);
showSuccessToast({
+ operation: "widget.import",
title: "Widget uploaded successfully",
description: "Widget configuration has been loaded.",
});
diff --git a/web/src/features/widgets/components/WidgetTable/ConnectedWidgetTable.tsx b/web/src/features/widgets/components/WidgetTable/ConnectedWidgetTable.tsx
index 87fea51249..bb092c1e04 100644
--- a/web/src/features/widgets/components/WidgetTable/ConnectedWidgetTable.tsx
+++ b/web/src/features/widgets/components/WidgetTable/ConnectedWidgetTable.tsx
@@ -150,6 +150,7 @@ function ConnectedDashboardWidgetTableContent({
widget_id: widgetId,
});
showSuccessToast({
+ operation: "widget.copy",
title: "Widget copied",
description: "Paste it on any dashboard with Cmd/Ctrl+V.",
});
@@ -182,6 +183,7 @@ function ConnectedDashboardWidgetTableContent({
});
utils.dashboardWidgets.invalidate();
showSuccessToast({
+ operation: "widget.clone",
title: "Widget cloned",
description: `Created "${exportSource.name} (Copy)".`,
});
diff --git a/web/src/utils/api.ts b/web/src/utils/api.ts
index e75f95928e..9db45d7dd3 100644
--- a/web/src/utils/api.ts
+++ b/web/src/utils/api.ts
@@ -26,10 +26,12 @@ import { versionUpdateStore } from "@/src/features/version-update/versionUpdateS
import { type AppRouter } from "@/src/server/api/root";
import { reportError } from "@/src/utils/reportError";
import { setUpSuperjson } from "@/src/utils/superjson";
+import { EXPECTED_TRPC_BAD_REQUEST_PATHS } from "@/src/utils/trpcErrorClassification";
import { trpcErrorToast } from "@/src/utils/trpcErrorToast";
import { isTrpcZodValidationError } from "@/src/utils/trpcValidationError";
export { isTrpcZodValidationError } from "@/src/utils/trpcValidationError";
+export { EXPECTED_TRPC_BAD_REQUEST_PATHS } from "@/src/utils/trpcErrorClassification";
setUpSuperjson();
@@ -161,22 +163,6 @@ export const EXPECTED_TRPC_CONFLICT_PATHS = [
"inAppAgent.decideToolApproval",
] as const;
-/**
- * BAD_REQUEST is usually a client bug (a missing hydrated route param,
- * an invariant the UI should not have sent). These procedures throw 400
- * only as user-configured-URL / secret-header validation the product
- * already toasts — expected user-facing state, not a regression.
- *
- * `datasets.triggerRemoteExperiment` and `datasets.upsertRemoteExperiment`
- * wrap `validateWebhookURL` (and related header checks) as BAD_REQUEST.
- * A DNS miss, private IP, or missing remote URL is the user fixing their
- * webhook, not an app failure.
- */
-export const EXPECTED_TRPC_BAD_REQUEST_PATHS = [
- "datasets.triggerRemoteExperiment",
- "datasets.upsertRemoteExperiment",
-] as const;
-
const getTrpcErrorData = (
error: unknown,
): { code?: unknown; path?: unknown } | undefined =>
diff --git a/web/src/utils/trpcErrorClassification.clienttest.ts b/web/src/utils/trpcErrorClassification.clienttest.ts
new file mode 100644
index 0000000000..09fbf63046
--- /dev/null
+++ b/web/src/utils/trpcErrorClassification.clienttest.ts
@@ -0,0 +1,111 @@
+// @vitest-environment node
+
+import { TRPCClientError } from "@trpc/client";
+import { describe, expect, it } from "vitest";
+import {
+ classifyTrpcToastError,
+ EXPECTED_TRPC_BAD_REQUEST_PATHS,
+} from "@/src/utils/trpcErrorClassification";
+
+const trpcError = (code: string, httpStatus: number, path = "test.procedure") =>
+ TRPCClientError.from({
+ error: {
+ code: -32600,
+ message: "Expected failure",
+ data: { code, httpStatus, path },
+ },
+ });
+
+describe("classifyTrpcToastError", () => {
+ it.each([
+ ["BAD_REQUEST", 400, "frontend", "internal"],
+ ["FORBIDDEN", 403, "backend", "permission"],
+ ["NOT_FOUND", 404, "backend", "product_state"],
+ ["TOO_MANY_REQUESTS", 429, "backend", "rate_limit"],
+ ["UNPROCESSABLE_CONTENT", 422, "backend", "resource_limit"],
+ ["SERVICE_UNAVAILABLE", 503, "network", "transient"],
+ ["INTERNAL_SERVER_ERROR", 500, "backend", "internal"],
+ ["PARSE_ERROR", 418, "backend", "unknown"],
+ ] as const)(
+ "maps %s (%i) to %s/%s",
+ (code, httpStatus, errorOrigin, errorCategory) => {
+ expect(classifyTrpcToastError(trpcError(code, httpStatus))).toEqual({
+ errorOrigin,
+ errorCategory,
+ trpcCode: code,
+ httpStatus,
+ });
+ },
+ );
+
+ it.each(EXPECTED_TRPC_BAD_REQUEST_PATHS)(
+ "classifies user-configured BAD_REQUEST path %s as user input",
+ (path) => {
+ expect(
+ classifyTrpcToastError(trpcError("BAD_REQUEST", 400, path)),
+ ).toEqual({
+ errorOrigin: "backend",
+ errorCategory: "user_input",
+ trpcCode: "BAD_REQUEST",
+ httpStatus: 400,
+ });
+ },
+ );
+
+ it("classifies non-JSON transport responses without capturing their content", () => {
+ const error = new TRPCClientError("Unexpected token", {
+ cause: new SyntaxError("Sensitive response body"),
+ });
+
+ expect(classifyTrpcToastError(error)).toEqual({
+ errorOrigin: "network",
+ errorCategory: "transient",
+ });
+ });
+
+ it("classifies an explicit failed fetch as a network failure", () => {
+ const error = new TRPCClientError("Failed to fetch", {
+ cause: new TypeError("Failed to fetch"),
+ });
+
+ expect(classifyTrpcToastError(error)).toEqual({
+ errorOrigin: "network",
+ errorCategory: "transient",
+ });
+ });
+
+ it("keeps an unrecognized pathless tRPC client failure in the frontend bucket", () => {
+ const error = new TRPCClientError("Transformer failed", {
+ cause: new Error("Transformer failed"),
+ });
+
+ expect(classifyTrpcToastError(error)).toEqual({
+ errorOrigin: "frontend",
+ errorCategory: "internal",
+ });
+ });
+
+ it("keeps oversized request parse failures in the frontend bucket", () => {
+ const cause = new SyntaxError(
+ "Unexpected end of JSON input",
+ ) as SyntaxError & {
+ responseStatus?: number;
+ };
+ cause.responseStatus = 431;
+
+ expect(
+ classifyTrpcToastError(new TRPCClientError("parse failed", { cause })),
+ ).toEqual({
+ errorOrigin: "frontend",
+ errorCategory: "internal",
+ httpStatus: 431,
+ });
+ });
+
+ it("classifies values outside the tRPC seam as frontend failures", () => {
+ expect(classifyTrpcToastError(new Error("boom"))).toEqual({
+ errorOrigin: "frontend",
+ errorCategory: "internal",
+ });
+ });
+});
diff --git a/web/src/utils/trpcErrorClassification.ts b/web/src/utils/trpcErrorClassification.ts
new file mode 100644
index 0000000000..125654919e
--- /dev/null
+++ b/web/src/utils/trpcErrorClassification.ts
@@ -0,0 +1,186 @@
+import { TRPCClientError } from "@trpc/client";
+import { type ToastErrorAnalytics } from "@/src/features/notifications/toastAnalytics";
+import { isTrpcZodValidationError } from "@/src/utils/trpcValidationError";
+
+type SyntaxErrorWithResponseStatus = SyntaxError & { responseStatus?: number };
+
+/**
+ * BAD_REQUEST is normally a client bug. These procedures also use it for
+ * rejected user-configured values, so they belong to the user-input bucket.
+ */
+export const EXPECTED_TRPC_BAD_REQUEST_PATHS = [
+ "datasets.triggerRemoteExperiment",
+ "datasets.upsertRemoteExperiment",
+ "models.upsert",
+] as const;
+
+const FAILED_FETCH_MESSAGE = /^failed to fetch(?: \([^)]+\))?$/i;
+
+const getResponseStatus = (error: TRPCClientError<any>): number | undefined => {
+ if (
+ error.cause instanceof SyntaxError &&
+ typeof (error.cause as SyntaxErrorWithResponseStatus).responseStatus ===
+ "number"
+ ) {
+ return (error.cause as SyntaxErrorWithResponseStatus).responseStatus;
+ }
+
+ return error.meta?.response instanceof Response
+ ? error.meta.response.status
+ : undefined;
+};
+
+const getCode = (error: TRPCClientError<any>): string | undefined =>
+ typeof error.data?.code === "string" ? error.data.code : undefined;
+
+const getPath = (error: TRPCClientError<any>): string | undefined =>
+ typeof error.data?.path === "string" ? error.data.path : undefined;
+
+const getHttpStatus = (error: TRPCClientError<any>): number | undefined =>
+ typeof error.data?.httpStatus === "number"
+ ? error.data.httpStatus
+ : getResponseStatus(error);
+
+const withTransportMetadata = (
+ error: TRPCClientError<any>,
+ classification: Pick<ToastErrorAnalytics, "errorOrigin" | "errorCategory">,
+): ToastErrorAnalytics => {
+ const trpcCode = getCode(error);
+ const httpStatus = getHttpStatus(error);
+
+ return {
+ ...classification,
+ ...(trpcCode ? { trpcCode } : {}),
+ ...(httpStatus !== undefined ? { httpStatus } : {}),
+ };
+};
+
+export const classifyTrpcToastError = (error: unknown): ToastErrorAnalytics => {
+ if (!(error instanceof TRPCClientError)) {
+ return { errorOrigin: "frontend", errorCategory: "internal" };
+ }
+
+ const code = getCode(error);
+ const path = getPath(error);
+ const httpStatus = getHttpStatus(error);
+
+ if (
+ error.cause instanceof SyntaxError &&
+ ![414, 431].includes(httpStatus ?? 0)
+ ) {
+ return withTransportMetadata(error, {
+ errorOrigin: "network",
+ errorCategory: "transient",
+ });
+ }
+
+ if ([414, 431].includes(httpStatus ?? 0)) {
+ return withTransportMetadata(error, {
+ errorOrigin: "frontend",
+ errorCategory: "internal",
+ });
+ }
+
+ if (
+ !error.data &&
+ !error.meta?.response &&
+ ((error.cause instanceof TypeError &&
+ FAILED_FETCH_MESSAGE.test(error.cause.message)) ||
+ FAILED_FETCH_MESSAGE.test(error.message))
+ ) {
+ return withTransportMetadata(error, {
+ errorOrigin: "network",
+ errorCategory: "transient",
+ });
+ }
+
+ if (
+ isTrpcZodValidationError(error) ||
+ (code === "BAD_REQUEST" &&
+ path !== undefined &&
+ (EXPECTED_TRPC_BAD_REQUEST_PATHS as readonly string[]).includes(path))
+ ) {
+ return withTransportMetadata(error, {
+ errorOrigin: "backend",
+ errorCategory: "user_input",
+ });
+ }
+
+ if (
+ code === "UNAUTHORIZED" ||
+ code === "FORBIDDEN" ||
+ httpStatus === 401 ||
+ httpStatus === 403
+ ) {
+ return withTransportMetadata(error, {
+ errorOrigin: "backend",
+ errorCategory: "permission",
+ });
+ }
+
+ if (
+ code === "NOT_FOUND" ||
+ code === "CONFLICT" ||
+ code === "PRECONDITION_FAILED" ||
+ [404, 409, 412].includes(httpStatus ?? 0)
+ ) {
+ return withTransportMetadata(error, {
+ errorOrigin: "backend",
+ errorCategory: "product_state",
+ });
+ }
+
+ if (code === "TOO_MANY_REQUESTS" || httpStatus === 429) {
+ return withTransportMetadata(error, {
+ errorOrigin: "backend",
+ errorCategory: "rate_limit",
+ });
+ }
+
+ if (
+ code === "PAYLOAD_TOO_LARGE" ||
+ code === "UNPROCESSABLE_CONTENT" ||
+ httpStatus === 413 ||
+ httpStatus === 422
+ ) {
+ return withTransportMetadata(error, {
+ errorOrigin: "backend",
+ errorCategory: "resource_limit",
+ });
+ }
+
+ if (
+ code === "TIMEOUT" ||
+ code === "CLIENT_CLOSED_REQUEST" ||
+ code === "SERVICE_UNAVAILABLE" ||
+ [408, 499, 502, 503, 504, 524].includes(httpStatus ?? 0)
+ ) {
+ return withTransportMetadata(error, {
+ errorOrigin: "network",
+ errorCategory: "transient",
+ });
+ }
+
+ if (code === "INTERNAL_SERVER_ERROR" || (httpStatus ?? 0) >= 500) {
+ return withTransportMetadata(error, {
+ errorOrigin: "backend",
+ errorCategory: "internal",
+ });
+ }
+
+ if (
+ !error.data ||
+ code === "BAD_REQUEST" ||
+ code === "METHOD_NOT_SUPPORTED"
+ ) {
+ return withTransportMetadata(error, {
+ errorOrigin: "frontend",
+ errorCategory: "internal",
+ });
+ }
+
+ return withTransportMetadata(error, {
+ errorOrigin: "backend",
+ errorCategory: "unknown",
+ });
+};
diff --git a/web/src/utils/trpcErrorToast.clienttest.ts b/web/src/utils/trpcErrorToast.clienttest.ts
index 5608aed4f1..d72c8c22b1 100644
--- a/web/src/utils/trpcErrorToast.clienttest.ts
+++ b/web/src/utils/trpcErrorToast.clienttest.ts
@@ -124,6 +124,10 @@ describe("trpcErrorToast", () => {
undefined,
undefined,
"trpc",
+ {
+ errorOrigin: "network",
+ errorCategory: "transient",
+ },
);
});
@@ -144,6 +148,12 @@ describe("trpcErrorToast", () => {
"prompts.create",
undefined,
"trpc",
+ {
+ errorOrigin: "backend",
+ errorCategory: "user_input",
+ trpcCode: "BAD_REQUEST",
+ httpStatus: 400,
+ },
);
});
@@ -164,6 +174,12 @@ describe("trpcErrorToast", () => {
"prompts.create",
undefined,
"trpc",
+ {
+ errorOrigin: "frontend",
+ errorCategory: "internal",
+ trpcCode: "BAD_REQUEST",
+ httpStatus: 400,
+ },
);
});
@@ -185,6 +201,47 @@ describe("trpcErrorToast", () => {
"prompts.create",
"abc123def456",
"trpc",
+ {
+ errorOrigin: "backend",
+ errorCategory: "internal",
+ trpcCode: "INTERNAL_SERVER_ERROR",
+ httpStatus: 500,
+ },
);
});
+
+ it.each([
+ ["FORBIDDEN", 403, "permission"],
+ ["TOO_MANY_REQUESTS", 429, "rate_limit"],
+ ["NOT_FOUND", 404, "product_state"],
+ ["PAYLOAD_TOO_LARGE", 413, "resource_limit"],
+ ["TIMEOUT", 524, "transient"],
+ ] as const)(
+ "classifies %s (%i) as %s telemetry",
+ (code, httpStatus, errorCategory) => {
+ trpcErrorToast(
+ trpcError({
+ code,
+ httpStatus,
+ path: "prompts.create",
+ message: "Expected failure",
+ }),
+ );
+
+ expect(showErrorToastMock).toHaveBeenCalledWith(
+ expect.any(String),
+ "Expected failure",
+ expect.any(String),
+ "prompts.create",
+ undefined,
+ "trpc",
+ {
+ errorOrigin: errorCategory === "transient" ? "network" : "backend",
+ errorCategory,
+ trpcCode: code,
+ httpStatus,
+ },
+ );
+ },
+ );
});
diff --git a/web/src/utils/trpcErrorToast.tsx b/web/src/utils/trpcErrorToast.tsx
index f2844b4041..b9bc433381 100644
--- a/web/src/utils/trpcErrorToast.tsx
+++ b/web/src/utils/trpcErrorToast.tsx
@@ -1,5 +1,6 @@
import { TRPCClientError } from "@trpc/client";
import { showErrorToast } from "@/src/features/notifications";
+import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";
import { formatTrpcZodValidationDescription } from "@/src/utils/trpcValidationError";
// Catch network level errors, e.g. by proxy rate-limiting
@@ -92,6 +93,7 @@ export const trpcErrorToast = (error: unknown) => {
undefined,
undefined,
"trpc",
+ classifyTrpcToastError(error),
);
return;
}
@@ -115,6 +117,7 @@ export const trpcErrorToast = (error: unknown) => {
path,
traceId,
"trpc",
+ classifyTrpcToastError(error),
);
} else {
showErrorToast(
@@ -124,6 +127,7 @@ export const trpcErrorToast = (error: unknown) => {
undefined,
undefined,
"trpc",
+ classifyTrpcToastError(error),
);
}
};