feat(telemetry): implement glitchtip/sentry integration with smart proxy
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 10s
Build & Deploy / 🧪 QA (push) Failing after 2m43s
Build & Deploy / 🏗️ Build (push) Failing after 5m34s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s

- Added Sentry/GlitchTip relay route handler
- Configured Sentry for client (with tunnel), server, and edge runtimes
- Refactored GlitchTip adapter to use official @sentry/nextjs SDK
- Fixed ComparisonRow type issues and Analytics Suspense bailout
- Integrated Sentry instrumentation into the boot sequence
This commit is contained in:
2026-02-16 23:09:50 +01:00
parent 2038b8fe47
commit 4db820214b
10 changed files with 152 additions and 78 deletions

View File

@@ -0,0 +1,55 @@
import { NextRequest, NextResponse } from "next/server";
import { env } from "@/lib/env";
/**
* Smart Proxy / Relay for Sentry/GlitchTip events.
*
* Mirroring the klz-2026 pattern:
* Receives Sentry envelopes from the client, injects the correct DSN,
* and forwards them to GlitchTip.
*/
export async function POST(request: NextRequest) {
try {
const envelope = await request.text();
const realDsn = env.SENTRY_DSN;
if (!realDsn) {
console.warn(
"[Sentry Relay] Received payload but no SENTRY_DSN configured",
);
return NextResponse.json({ status: "ignored" }, { status: 200 });
}
const dsnUrl = new URL(realDsn);
const projectId = dsnUrl.pathname.replace("/", "");
const relayUrl = `${dsnUrl.protocol}//${dsnUrl.host}/api/${projectId}/envelope/`;
const response = await fetch(relayUrl, {
method: "POST",
body: envelope,
headers: {
"Content-Type": "application/x-sentry-envelope",
},
});
if (!response.ok) {
const errorText = await response.text();
console.error("[Sentry Relay] GlitchTip API responded with error", {
status: response.status,
error: errorText.slice(0, 100),
});
return new NextResponse(errorText, { status: response.status });
}
return NextResponse.json({ status: "ok" });
} catch (error) {
console.error("[Sentry Relay] Failed to relay Sentry request", {
error: (error as Error).message,
});
return NextResponse.json(
{ error: "Internal Server Error" },
{ status: 500 },
);
}
}