// PEP-218: the card of one production error, read from Bugsink on the server. The superadmin // opens any error, a project's owner or member — errors of that project only (else 404). // «Инженер» and the superadmin see the stack, tags, events and the link to Bugsink. import Link from "next/link"; import { notFound } from "next/navigation"; import { Bug, ExternalLink } from "lucide-react"; import { errorDetail, errorScope } from "@peppa/core"; import { ErrorActions, ErrorStack, ErrorStateBadge, ErrorsDown } from "@/components/Errors"; import { ago, Empty, Flash, Key, PageHeader, Section } from "@/components/common"; import { Card } from "@/components/ui/card"; import { Workspace } from "@/components/Workspace"; import { requireUser } from "@/lib/auth"; import { db } from "@/lib/db"; import { getT } from "@/lib/i18n"; export const dynamic = "force-dynamic"; export async function generateMetadata() { const t = await getT(); return { title: t("Ошибка — FORGE") }; } export default async function ErrorPage({ params, searchParams }: { params: Promise<{ id: string }>; searchParams: Promise<{ error?: string; from?: string }> }) { const user = await requireUser(); const t = await getT(); const { id } = await params; const { error, from } = await searchParams; const scope = await errorScope(db, user); const d = await errorDetail(db, scope, decodeURIComponent(id)); if (!d) notFound(); const r = d.row; const back = from && from.startsWith("/") && !from.startsWith("//") ? from : r.projectKey ? `/p/${r.projectKey}?tab=bugs` : "/observability?tab=errors"; const self = `/errors/${encodeURIComponent(r.id)}?from=${encodeURIComponent(back)}`; const tags = Object.entries(d.tags); const grouped = new Map>(); for (const x of d.tagCounts) grouped.set(x.key, [...(grouped.get(x.key) ?? []), { value: x.value, count: x.count }]); return (
{t("← К списку ошибок")}} title={{r.title}} />
{t.n(r.events, "{n} раз", "{n} раза", "{n} раз")} {d.users != null ? {t.n(d.users, "у {n} пользователя", "у {n} пользователей", "у {n} пользователей")} : null} {t("впервые {ago}", { ago: ago(r.firstSeen, t) })} {t("последний раз {ago}", { ago: ago(r.lastSeen, t) })}
{r.taskKey ? ( {t("Задача по этой ошибке:")} {r.taskKey} ) : ( {d.projectId != null ? t("Задачи по этой ошибке нет.") : t("Ошибка не относится ни к одному проекту.")} )}
{scope.tech ? ( <> {/* glossary-ignore: everything below is for «Инженер» and the superadmin only */}
{t("Проект учёта: {name}", { name: r.bugsinkName })}{r.friendlyId ? ` · ${r.friendlyId}` : ""} {d.environment ? {t("Окружение: {env}", { env: d.environment })} : null} {/* glossary-ignore: «Инженер» and the superadmin only */} {r.release ? {t("релиз {sha}", { sha: r.release.slice(0, 8) })} : null} {d.level ? {t("Уровень: {level}", { level: d.level })} : null}
{r.culprit ?
{r.culprit}
: null} {d.url ?
{d.url}
: null} {/* glossary-ignore: link for «Инженер» and the superadmin */} {t("Открыть в Bugsink")}
{tags.length === 0 ? ( {t("Тегов нет.")} ) : (
{tags.map(([k, v]) => ( ))}
{k} {v} {(grouped.get(k)?.length ?? 0) > 1 ? {t("ещё значений: {n}", { n: grouped.get(k)!.length - 1 })} : null}
)}
{d.events.length === 0 ? ( {t("Событий нет.")} ) : (
    {d.events.map((e) => (
  • {e.at.toLocaleString(t.locale === "en" ? "en-GB" : "ru-RU", { dateStyle: "short", timeStyle: "medium" })} {e.id.slice(0, 8)}
  • ))}
)}
) : (

{t("Подробности для разработчиков видны в режиме «Инженер».")}

)}
); }