Continuous Integration / lighthouse (pull_request) Canceled after 0s
Continuous Integration / deploy-test (pull_request) Canceled after 0s
Continuous Integration / deploy-production (pull_request) Canceled after 0s
Continuous Integration / check (pull_request) Canceled after 2m22s
Sentry loads after the page and reports errors only, without personal data; Umami counts visits per environment. Both only run on andreaslop.nl and test.andreaslop.nl. The CSP allows just these two hosts, and builds carry the commit SHA as release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
import { monitoringFor, sentryDsn } from './config';
|
|
|
|
// Sentry laadt pas na het load-event, buiten de hoofdbundel (M4). Fouten van
|
|
// daarvoor wachten in een wachtrij en gaan mee zodra Sentry klaar is.
|
|
|
|
type State =
|
|
| { kind: 'off' }
|
|
| { kind: 'loading'; queue: unknown[] }
|
|
| { kind: 'ready'; capture: (error: unknown) => void };
|
|
|
|
let state: State = { kind: 'off' };
|
|
|
|
export function reportError(error: unknown): void {
|
|
if (state.kind === 'ready') state.capture(error);
|
|
else if (state.kind === 'loading') state.queue.push(error);
|
|
}
|
|
|
|
// Onafgevangen fouten tijdens het laden; daarna vangt Sentry ze zelf
|
|
const onError = (event: ErrorEvent) => reportError(event.error);
|
|
const onRejection = (event: PromiseRejectionEvent) => reportError(event.reason);
|
|
|
|
export function startSentry(hostname = window.location.hostname): void {
|
|
const monitoring = monitoringFor(hostname);
|
|
if (!monitoring || state.kind !== 'off') return;
|
|
|
|
const queue: unknown[] = [];
|
|
state = { kind: 'loading', queue };
|
|
window.addEventListener('error', onError);
|
|
window.addEventListener('unhandledrejection', onRejection);
|
|
|
|
const load = async () => {
|
|
const Sentry = await import('./sentryClient');
|
|
// Alleen fouten: geen tracing, geen replay, geen persoonsgegevens (M5).
|
|
// Sinds SDK 11 verzamelt Sentry standaard alles; daarom alles expliciet uit.
|
|
Sentry.init({
|
|
dsn: sentryDsn,
|
|
environment: monitoring.environment,
|
|
release: import.meta.env.VITE_RELEASE,
|
|
dataCollection: {
|
|
userInfo: false,
|
|
cookies: false,
|
|
httpHeaders: false,
|
|
httpBodies: [],
|
|
urlQueryParams: false,
|
|
},
|
|
});
|
|
window.removeEventListener('error', onError);
|
|
window.removeEventListener('unhandledrejection', onRejection);
|
|
state = { kind: 'ready', capture: Sentry.captureException };
|
|
queue.forEach(reportError);
|
|
};
|
|
|
|
if (document.readyState === 'complete') void load();
|
|
else window.addEventListener('load', () => void load(), { once: true });
|
|
}
|