# Monitoring Setup — frontend-shell What to do once in each service, and what changes in the code. The code changes are made on PR #4 after approval of this setup. Until the values below are filled in, the site sends nothing (safe default). ## 1. Sentry (logging + error e-mails) ### In Sentry (once) 1. In your existing organisation, create a project: platform **React**, name `andreaslop-fotografie`. 2. Copy the **DSN** (Settings → Client Keys). It looks like `https://@o4511795618185216.ingest.de.sentry.io/`. 3. **Settings → Security & Privacy**: turn on **"Prevent Storing of IP Addresses"** (M5). 4. **Alerts**: keep the default rule "A new issue is created" → e-mail to you (Q7 = A). Environments `test` and `production` appear automatically after the first event. ### In the code (after approval) | File | Change | |---|---| | `package.json` | Add `@sentry/react` (same package as SlpSoftware) | | `src/monitoring/config.ts` (new) | `sentryDsn` (from step 2) and `monitoringFor(hostname)` → `{ environment, umamiWebsiteId }` or `null` for unknown hosts (M1) | | `src/monitoring/sentry.ts` (new) | `startSentry()`: loads `@sentry/react` dynamically after the `load` event (M4); `init` with `environment`, `release` (commit SHA from the build), all `dataCollection` categories off (SDK 11 replaced `sendDefaultPii` and collects everything by default), no tracing or replay. `reportError(error)`: queues errors, including unhandled ones, until Sentry is ready. | | `src/monitoring/sentryClient.ts` (new) | Re-exports only `init` and `captureException`, so the lazy chunk is tree-shaken (31 kB gzip instead of 150 kB). | | `src/main.tsx` | Calls `startSentry()` | | `src/components/StatusPage/ErrorPage.tsx` | Besides `console.error`, also `reportError(error)` (BR-ERR-03 extended) | | `config/securityHeaders.ts` | `connect-src` + Sentry ingest host (M7); regenerated into `web.config` and nginx | | Workflow `check` job | Build with `VITE_RELEASE=${{ github.sha }}` so Sentry shows which release an error came from | ### Check after deploy On `https://test.andreaslop.nl`, run in the browser console: ```js setTimeout(() => { throw new Error('Sentry-test vanaf test') }) ``` The error appears in Sentry under environment `test` within a minute, and you get an e-mail for the new issue. ## 2. Umami (visitor dashboard) ### In Umami (once) 1. Log in at `https://analytics.slpsoftware.nl`. 2. **Settings → Websites → Add website**, twice: - name `Andrea Slop Fotografie`, domain `andreaslop.nl` - name `Andrea Slop Fotografie (test)`, domain `test.andreaslop.nl` 3. Copy both **Website IDs** (a UUID per website). ### In the code (after approval) | File | Change | |---|---| | `src/monitoring/config.ts` | The two website IDs, one per hostname (M6) | | `src/components/Analytics/UmamiAnalytics.tsx` (new) | Adds `https://analytics.slpsoftware.nl/script.js` with `data-website-id`, `data-domains=` and `data-do-not-track="true"`, only for a known hostname (M1). Same pattern as SlpSoftware's `UmamiAnalytics`. | | `src/components/AppShell.tsx` | Renders `UmamiAnalytics` | | `config/securityHeaders.ts` | `script-src` and `connect-src` + `https://analytics.slpsoftware.nl` (M7) | ### Check after deploy Open `https://test.andreaslop.nl`. In Umami, the test website shows a visitor under "Realtime". If you have Do Not Track switched on in your browser, you won't see yourself; that is expected. ## 3. UptimeRobot (availability + down e-mails) No code needed. Create these monitors in your existing account (type **HTTP(s)**, interval 5 minutes, alert contact: your e-mail): | Monitor | URL | When | |---|---|---| | Andrea Slop — test | `https://test.andreaslop.nl/` | Now | | Andrea Slop — test — deep link | `https://test.andreaslop.nl/portfolio` | Now (checks the SPA fallback) | | Andrea Slop — productie | `https://andreaslop.nl/` | **Now**. It watches the current WordPress site until the DNS switch, and the new site after that. | | Andrea Slop — productie — deep link | `https://andreaslop.nl/portfolio` | **After go-live**. On WordPress this URL may not exist and would give false alarms. | Optional: type **Keyword** with the keyword `Andrea Slop Fotografie`. That catches an empty or wrong page that still answers 200; the word is in the static HTML of the new site. ## 4. Tests (part of the code changes) - **`monitoringFor`**: example tests for each known hostname, plus a property test that every other hostname (random strings, `localhost`, IP addresses) returns `null` (PBT-03 invariant). - **`UmamiAnalytics`**: no script for an unknown host; the right `data-website-id` and `data-domains` for each known host; only one script element. - **`reportError`**: errors before initialisation are queued and sent once Sentry is ready; nothing is sent for an unknown host. - **`securityHeaders`**: the production CSP contains exactly these two external hosts, in the right directives only, and no wildcards. - **`serverConfig`**: drift test; `web.config` and nginx contain the new CSP. ## 5. Values (filled in 2026-10-19, in `src/monitoring/config.ts`) | Value | Setting | |---|---| | Sentry DSN | `https://12ec77dcc3216a98b96d3fb3dac13f66@o4511795618185216.ingest.de.sentry.io/4512282287472720` (project `andreaslop-fotografie`) | | Umami website ID, production | `3edbb7d1-4388-4f2d-9cef-11ade88ace96` | | Umami website ID, test | `7fb301ab-6ecc-4aea-beee-71bcb6009bfe` | Sentry project created via the Sentry MCP. The default alert ("high priority issues") was changed to "a new issue is created" → e-mail, to match Q7 = A: handled errors from `reportError` often get a lower priority and would not have sent an e-mail.