Adds Sentry and Umami monitoring to the site
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>
This commit is contained in:
2026-10-19 12:08:47 +02:00
co-authored by Claude Opus 5.5
parent 0bfe50e723
commit 6d3a1566c2
20 changed files with 518 additions and 21 deletions
+24 -3
View File
@@ -1,6 +1,9 @@
import { describe, expect, it } from 'vitest';
import { contentSecurityPolicy, securityHeaders } from './securityHeaders';
const umami = 'https://analytics.slpsoftware.nl';
const sentry = 'https://o4511795618185216.ingest.de.sentry.io';
const directive = (csp: string, name: string) =>
csp.split('; ').find((d) => d.startsWith(name + ' ')) ?? '';
@@ -8,19 +11,37 @@ describe('securityHeaders', () => {
it('productie-CSP heeft geen onveilige uitzonderingen voor scripts', () => {
const csp = contentSecurityPolicy('production');
expect(csp).not.toContain('unsafe-eval');
expect(directive(csp, 'script-src')).toBe("script-src 'self'");
expect(directive(csp, 'script-src')).toBe(`script-src 'self' ${umami}`);
expect(csp).not.toContain('ws:');
expect(directive(csp, 'frame-ancestors')).toBe(
"frame-ancestors 'none'",
);
});
it('productie-CSP opent alleen Umami en Sentry, op de juiste plekken (M7)', () => {
const csp = contentSecurityPolicy('production');
const externalHosts = new Set(csp.match(/https:\/\/[^\s;]+/g));
expect([...externalHosts].sort()).toEqual([sentry, umami].sort());
expect(directive(csp, 'connect-src')).toBe(
`connect-src 'self' ${umami} ${sentry}`,
);
// Alleen script-src en connect-src noemen een externe host
for (const d of csp.split('; ')) {
if (!/^(script|connect)-src /.test(d)) {
expect(d).not.toContain('https://');
}
}
expect(csp).not.toContain('*');
});
it('dev-CSP voegt alleen toe wat Vite nodig heeft', () => {
const csp = contentSecurityPolicy('development');
expect(directive(csp, 'script-src')).toBe(
"script-src 'self' 'unsafe-inline'",
`script-src 'self' ${umami} 'unsafe-inline'`,
);
expect(directive(csp, 'connect-src')).toBe(
`connect-src 'self' ${umami} ${sentry} ws:`,
);
expect(directive(csp, 'connect-src')).toBe("connect-src 'self' ws:");
expect(csp).not.toContain('unsafe-eval');
});