Compare commits

..

4 Commits

Author SHA1 Message Date
42ccafd445 2.4.35
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 22s
Build & Deploy / 🚀 Deploy (push) Successful in 26s
Build & Deploy / 🧪 QA (push) Successful in 1m18s
Build & Deploy / 🏗️ Build (push) Successful in 2m41s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 50s
Build & Deploy / 🔔 Notify (push) Successful in 2s
2026-07-17 16:28:51 +02:00
84402f90fc fix: sentry tunnel relay forwarding logic and DSN overriding 2026-07-17 16:28:50 +02:00
a701495607 2.4.34
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 22s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 49s
Build & Deploy / 🧪 QA (push) Successful in 1m18s
Build & Deploy / 🏗️ Build (push) Successful in 2m36s
Build & Deploy / 🚀 Deploy (push) Successful in 24s
Build & Deploy / 🔔 Notify (push) Successful in 3s
2026-07-17 15:19:27 +02:00
88132b8f84 fix: lazy initialize client services to bootstrap sentry 2026-07-17 15:19:27 +02:00
3 changed files with 60 additions and 8 deletions

View File

@@ -1,13 +1,58 @@
import { NextResponse } from 'next/server';
const ALLOWED_HOSTS = ['glitchtip.infra.mintel.me', 'errors.infra.mintel.me'];
export async function POST(req: Request) {
try {
const rawText = await req.text();
// Sentry sends NDJSON (Newline Delimited JSON). Split by newline to parse safely.
const items = rawText.split('\n').filter(Boolean).map(line => JSON.parse(line));
console.log("CLIENT ERROR INTERCEPTED:", JSON.stringify(items[0], null, 2));
const items = rawText.split('\n');
if (items.length === 0 || !items[0]) {
return NextResponse.json({ error: 'Empty payload' }, { status: 400 });
}
const header = JSON.parse(items[0]);
// Use the server's configured DSN (if available) to override the client's potentially fake DSN
// This allows the client to work without exposing NEXT_PUBLIC_SENTRY_DSN
const dsn = process.env.SENTRY_DSN || header.dsn;
if (!dsn) {
return NextResponse.json({ error: 'No DSN found' }, { status: 400 });
}
const url = new URL(dsn);
const projectId = url.pathname.replace('/', '');
const host = url.hostname;
if (!ALLOWED_HOSTS.includes(host)) {
return NextResponse.json({ error: 'Invalid Sentry Host' }, { status: 400 });
}
// Rewrite the DSN in the envelope header so Glitchtip doesn't reject the fake client DSN
if (process.env.SENTRY_DSN) {
header.dsn = process.env.SENTRY_DSN;
items[0] = JSON.stringify(header);
}
const sentryIngestUrl = `https://${host}/api/${projectId}/envelope/`;
const payloadToForward = items.join('\n');
const response = await fetch(sentryIngestUrl, {
method: 'POST',
body: payloadToForward,
headers: {
'Content-Type': 'application/x-sentry-envelope',
},
});
if (!response.ok) {
const errorText = await response.text();
console.error(`[Sentry Tunnel] Relay rejected (${response.status}):`, errorText);
return NextResponse.json({ error: 'Sentry rejection' }, { status: response.status });
}
return NextResponse.json({ success: true });
} catch (e) {
console.log("Failed to parse relay body (NDJSON)", e);
console.error("[Sentry Tunnel] Failed to parse or relay body", e);
return NextResponse.json({ error: 'Relay failed' }, { status: 500 });
}
return NextResponse.json({ success: true });
}

View File

@@ -22,11 +22,18 @@ export default function AnalyticsShell() {
return;
}
const initServices = () => {
import('@/lib/services/create-services').then(({ getAppServices }) => {
getAppServices();
setShouldLoad(true);
}).catch(console.error);
};
// Wait until browser is completely idle before loading heavy analytics/logger/sentry SDKs
if (typeof window !== 'undefined' && 'requestIdleCallback' in window) {
window.requestIdleCallback(() => setShouldLoad(true), { timeout: 3000 });
window.requestIdleCallback(initServices, { timeout: 3000 });
} else {
const timer = setTimeout(() => setShouldLoad(true), 2500);
const timer = setTimeout(initServices, 2500);
return () => clearTimeout(timer);
}
}, []);

View File

@@ -140,7 +140,7 @@
"prepare": "husky",
"preinstall": "npx only-allow pnpm"
},
"version": "2.4.33",
"version": "2.4.35",
"pnpm": {
"onlyBuiltDependencies": [
"@parcel/watcher",