From a87602ef5a5a1d184ff48d8679c01ef2f1396cc1 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Mon, 19 Oct 2026 09:01:45 +0200 Subject: [PATCH 01/12] Deploys to test without waiting for Lighthouse Test exists to try things out, so it now deploys as soon as the check job passes; Lighthouse runs alongside and its reports are information. Production still waits for both check and Lighthouse, so accessibility, best-practices and SEO problems never go live. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/continuous_integration.yaml | 6 +++- aidlc-docs/features/frontend-shell/audit.md | 36 +++++++++++++++++++ .../operations/deployment/deployment-plan.md | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/continuous_integration.yaml b/.gitea/workflows/continuous_integration.yaml index 0a39103..91c54b7 100644 --- a/.gitea/workflows/continuous_integration.yaml +++ b/.gitea/workflows/continuous_integration.yaml @@ -157,8 +157,10 @@ jobs: path: web/lighthouse-reports/ retention-days: 14 + # Test wacht niet op Lighthouse: test is om te testen, de rapporten zie je + # achteraf. Lighthouse draait ernaast. deploy-test: - needs: [check, lighthouse] + needs: check if: (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_test == 'true') || (github.event_name == 'push' && github.ref == 'refs/heads/master') runs-on: ubuntu-latest steps: @@ -206,6 +208,8 @@ jobs: curl -fsSI "$HEALTH_URL" | grep -qi '^content-security-policy:' echo "Test bereikbaar met security headers" + # Productie wacht wel op Lighthouse: toegankelijkheid, Best Practices en SEO + # moeten slagen voordat er iets live gaat. deploy-production: needs: [check, lighthouse] # Alleen handmatig, en alleen vanaf een release-branch diff --git a/aidlc-docs/features/frontend-shell/audit.md b/aidlc-docs/features/frontend-shell/audit.md index 30f90bb..2ec3ead 100644 --- a/aidlc-docs/features/frontend-shell/audit.md +++ b/aidlc-docs/features/frontend-shell/audit.md @@ -702,3 +702,39 @@ Verder heb ik de vraag ook beantwoord" **Context**: OPERATIONS - Deployment Setup; fixing CI --- + +## Deployment Setup - PR Green and Merged + +**Timestamp**: 2026-10-18T23:42:04Z + +**User Input**: "(none — monitoring as authorised)" + +**AI Response**: "Run 530 (PR #3, 23f7020): check and lighthouse succeeded. PR #3 auto-merged by the owner (merge commit fccc909). Run 531 (push to master) started with deploy-test; watching it." + +**Context**: OPERATIONS - Deployment Setup; watching first master run + +--- + +## Deployment Setup - First Master Run 531 + +**Timestamp**: 2026-10-19T00:01:36Z + +**User Input**: "(none — monitoring as authorised)" + +**AI Response**: "Run 531 (push to master, fccc909): check and lighthouse succeeded; deploy-test reached the Pi (SSH login with secrets OK, WordPress guard passed) but failed on 'mkdir: cannot create directory /var/www/html/andreaslop-test: Permission denied'. Cause: folder missing and /var/www/html owned by root (deployment-instructions 1.2.1 not yet done). Not solved with sudo in the pipeline (would widen deploy-user rights). Asked owner to create and chown the folder once, then re-run." + +**Context**: OPERATIONS - Deployment Setup; awaiting owner action on the Pi + +--- + +## Deployment Setup - Lighthouse After Test Deploy + +**Timestamp**: 2026-10-19T07:01:45Z + +**User Input**: "Ja, voer maar door, maar wacht met een PR maken totdat de huidige run de deploy-test job heeft afgerond. Ik heb voor PR's bewust alleen de check job aangegeven omdat ik dacht dat lighthouse vooral belangrijk is voor productie om te blokkeren en voor test is het info waar je eventueel op kan reageren als je het lokaal vergeten bent bijvoorbeeld. Voor nu hoeft het niet als check voor mergen naar master." + +**AI Response**: "Owner re-ran run 531 after creating the test folder via a symlink (/var/www/html -> /mnt/storage1/www/html; explained symlink permissions are ignored, target folder rights count). Fast-forwarded feature/frontend-shell to master (fccc909). Workflow: deploy-test now needs only check (Lighthouse runs alongside as information); deploy-production still needs check and lighthouse. Deployment plan D6 updated incl. branch protection (only check required, Lighthouse deliberately not). Pushing to the feature branch; PR to be created after run 531's deploy-test finishes." + +**Context**: OPERATIONS - Deployment Setup + +--- diff --git a/aidlc-docs/features/frontend-shell/operations/deployment/deployment-plan.md b/aidlc-docs/features/frontend-shell/operations/deployment/deployment-plan.md index cd2c7ce..bd25445 100644 --- a/aidlc-docs/features/frontend-shell/operations/deployment/deployment-plan.md +++ b/aidlc-docs/features/frontend-shell/operations/deployment/deployment-plan.md @@ -34,7 +34,7 @@ Text alternative: feature branches go through a pull request with CI into master | D3 | **Environments**: test and production. | Q5 = B | | D4 | **Test deploy**: automatically on every push to `master` (incl. a merged PR), and manually from any branch with "Deploy to Test", for example to try a branch before merging. | Q6 = B, CQ1 | | D5 | **Production deploy**: manual only ("Deploy to Production"), and only from a `release/*` branch; the workflow refuses other branches. | Q6 = B, CQ1 | -| D6 | **Quality gate**: every run does lint, format, tests, build, audit and Lighthouse (mobile + desktop) before any deploy job can start. In CI, Lighthouse **Performance is report-only** (the Pi runner gives scores 30-40 points too low); accessibility, best practices and SEO block. Performance blocks in `pnpm check` on a PC. HTML reports are attached to every run as the `lighthouse-reports` artifact. | Q7 = A; Lighthouse CI question A | +| D6 | **Quality gate**: every run does lint, format, tests, build and audit (`check`) before any deploy. **Test deploys right after `check`**, and Lighthouse (mobile + desktop) runs alongside as information. **Production waits for both `check` and Lighthouse.** Branch protection on `master` requires only `check`; Lighthouse is deliberately not a merge requirement. In CI, Lighthouse **Performance is report-only** (the Pi runner gives scores 30-40 points too low); accessibility, best practices and SEO block. Performance blocks in `pnpm check` on a PC. HTML reports are attached to every run as the `lighthouse-reports` artifact. | Q7 = A; Lighthouse CI question A | | D7 | **Chrome for Lighthouse**: Playwright's Chromium (supports linux-arm64), installed in the job with a pinned Playwright version. Not the browser on the host: jobs run in containers and cannot see it. | CQ5 | | D8 | **Test target**: Raspberry Pi with nginx behind the reverse-proxy Pi, **next to the current WordPress site**. Deploy over SSH (`sshpass` + `scp`, same secrets as your other projects). Simple: empty the test folder, then copy the new build in; no old versions are kept. The step refuses an empty path, `/`, or a folder containing WordPress (`wp-config.php` / `wp-content`). The nginx block has its own `server_name` and never `default_server`. | CQ4 = B; owner: simpler than other apps, must not conflict with WordPress | | D9 | **Test is never indexed**: `X-Robots-Tag: noindex, nofollow` and a `robots.txt` that disallows everything. | Derived | -- 2.39.5 From 67ef16b9f28d45a5345e22d102d82e0b37b9467e Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Mon, 19 Oct 2026 09:32:23 +0200 Subject: [PATCH 02/12] Lets the test deploy work with group write access `scp -r dist/.` also sets the mode of the target folder, which only its owner may do. Copying the contents (`dist/*`, with dotglob for hidden files) leaves the folder itself alone, so group write access on the test folder is enough. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/continuous_integration.yaml | 7 +++++- aidlc-docs/features/frontend-shell/audit.md | 24 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/continuous_integration.yaml b/.gitea/workflows/continuous_integration.yaml index 91c54b7..84ea453 100644 --- a/.gitea/workflows/continuous_integration.yaml +++ b/.gitea/workflows/continuous_integration.yaml @@ -196,7 +196,12 @@ jobs: fi mkdir -p '$DEPLOY_PATH' find '$DEPLOY_PATH' -mindepth 1 -delete" - sshpass -e scp -P "$SSH_PORT" -o StrictHostKeyChecking=accept-new -r dist/. "$SSH_USER@$SSH_HOST:$DEPLOY_PATH/" + # De inhoud kopiëren (dist/*), niet de map zelf (dist/.): dan probeert + # scp de rechten van de doelmap niet te zetten, wat alleen de eigenaar + # mag. Zo zijn groeps-schrijfrechten op de doelmap genoeg. + # dotglob: ook bestanden die met een punt beginnen gaan mee. + shopt -s dotglob + sshpass -e scp -P "$SSH_PORT" -o StrictHostKeyChecking=accept-new -r dist/* "$SSH_USER@$SSH_HOST:$DEPLOY_PATH/" echo "Gedeployd naar test: ${GITHUB_REF_NAME} (${GITHUB_SHA::7})" - name: Controle na deploy diff --git a/aidlc-docs/features/frontend-shell/audit.md b/aidlc-docs/features/frontend-shell/audit.md index 2ec3ead..edc7095 100644 --- a/aidlc-docs/features/frontend-shell/audit.md +++ b/aidlc-docs/features/frontend-shell/audit.md @@ -738,3 +738,27 @@ Verder heb ik de vraag ook beantwoord" **Context**: OPERATIONS - Deployment Setup --- + +## Deployment Setup - Run 531 Re-run Result + +**Timestamp**: 2026-10-19T07:08:01Z + +**User Input**: "ik zie niet dat je de run in de gaten aan het houden bent, klopt dat? Hij zit al in de deploy-test en heb je nog niks zien zeggen over de run" + +**AI Response**: "Explained the watcher only notified at run completion. Re-run of 531: check and lighthouse succeeded; deploy-test resolved the symlink (/var/www/html/andreaslop-test -> /mnt/storage1/www/html/andreaslop-test), SSH login, WordPress guard and mkdir OK; scp failed with 'Permission denied' on files and 'remote setstat' on the folder: deploy user lacks write access and is not the owner. Asked owner to chown the target folder to the SSH user and re-run the failed job. Watcher extended with STOP_ON_JOB to report as soon as deploy-test finishes; started for the next re-run." + +**Context**: OPERATIONS - Deployment Setup; awaiting owner action on the Pi + +--- + +## Deployment Setup - Test Folder Permissions + +**Timestamp**: 2026-10-19T07:32:23Z + +**User Input**: "hoe doet de workspace `K:\Development\Projects\SimpleDeckApp` het in de deployment? want die kan wel deployen terwijl daar dezelfde rechten op staan en dezelfde gebruiker wordt gebruikt" / "ik heb de rechten aangepast. de gebruiker zat al wel in de juiste groep, maar ik zag dat die nog niet mocht schrijven naar de map. alleen uitlezen en uitvoeren. dus even deze run afwachten nu" + +**AI Response**: "SimpleDeckApp creates a new releases/ folder as the SSH user before scp, so the user owns its target; our pipeline wrote into an existing folder not owned by the user. Owner gave the group write access. Remaining issue: scp -r dist/. also sets the target folder's mode (setstat), which only the owner may do. Changed deploy-test to copy dist/* with dotglob (contents, not the folder; hidden files included, verified locally), so group write is sufficient. Pushed to feature/frontend-shell; current run 531 still uses the old step." + +**Context**: OPERATIONS - Deployment Setup; watching run 531 + +--- -- 2.39.5 From 736756a36bc4e0b757babd1faedc4b78ee7c4217 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Mon, 19 Oct 2026 09:34:55 +0200 Subject: [PATCH 03/12] Logs the first successful test deploy in the AI-DLC audit Co-Authored-By: Claude Opus 5.5 --- aidlc-docs/features/frontend-shell/audit.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/aidlc-docs/features/frontend-shell/audit.md b/aidlc-docs/features/frontend-shell/audit.md index edc7095..dc2a2ed 100644 --- a/aidlc-docs/features/frontend-shell/audit.md +++ b/aidlc-docs/features/frontend-shell/audit.md @@ -762,3 +762,15 @@ Verder heb ik de vraag ook beantwoord" **Context**: OPERATIONS - Deployment Setup; watching run 531 --- + +## Deployment Setup - First Successful Test Deploy + +**Timestamp**: 2026-10-19T07:34:55Z + +**User Input**: "(none — monitoring as authorised)" + +**AI Response**: "Run 531 re-run succeeded: check, lighthouse and deploy-test green. Verified https://test.andreaslop.nl with curl and headless Chrome: /, /portfolio, /bestaat-niet return 200 and render correct title, h1 and robots meta with footer; no console errors or failed requests; robots.txt disallows all; all five security headers plus X-Robots-Tag noindex; index no-cache, assets immutable 1 year; http -> https 301. Fallback head present in served HTML (title wrapped over lines by Prettier). Creating PR for job order (a87602e) and group-write deploy (67ef16b)." + +**Context**: OPERATIONS - Deployment Setup + +--- -- 2.39.5 From 7750971170221ab9e6dbe66e51e1342c7f808f58 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Mon, 19 Oct 2026 09:41:36 +0200 Subject: [PATCH 04/12] Documents the deploy user and test folder rights The pipeline logs in as gitea-workflow, a member of the www-data group. The test folder needs group write access (775, or 2775 with setgid); new folders get 755 by default, which made the first deploys fail. Co-Authored-By: Claude Opus 5.5 --- aidlc-docs/features/frontend-shell/audit.md | 12 ++++++++++++ .../deployment/deployment-instructions.md | 14 +++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/aidlc-docs/features/frontend-shell/audit.md b/aidlc-docs/features/frontend-shell/audit.md index dc2a2ed..6503943 100644 --- a/aidlc-docs/features/frontend-shell/audit.md +++ b/aidlc-docs/features/frontend-shell/audit.md @@ -774,3 +774,15 @@ Verder heb ik de vraag ook beantwoord" **Context**: OPERATIONS - Deployment Setup --- + +## Deployment Setup - Deploy User and Folder Rights in Instructions + +**Timestamp**: 2026-10-19T07:41:36Z + +**User Input**: "kan in de deployinstructies worden opgenomen dat voor de pipeline de gebruiker gitea-workflow gebruikt moet worden. die zit in de www-data groep en die groep moet wel schrijfrechten hebben. ik had bijvoorbeeld met de webadmin gebruiker in filezilla de map aangemaakt. die zit ook in de www-data groep, maar de rechten worden standaard 755 en die staan nu op 775 en dat werkte dus." + +**AI Response**: "Updated deployment-instructions.md: PI_MAIN_USERNAME = gitea-workflow (member of www-data); step 1.2.1 now creates the folder with chgrp www-data and chmod 2775, explains the 755 default (FileZilla/mkdir) pitfall, setgid tip, and the external-disk symlink; added a troubleshooting row for mkdir/scp Permission denied. Pushing to the PR #4 branch (restarts the PR run)." + +**Context**: OPERATIONS - Deployment Setup + +--- diff --git a/aidlc-docs/features/frontend-shell/operations/deployment/deployment-instructions.md b/aidlc-docs/features/frontend-shell/operations/deployment/deployment-instructions.md index 5899357..6dfca79 100644 --- a/aidlc-docs/features/frontend-shell/operations/deployment/deployment-instructions.md +++ b/aidlc-docs/features/frontend-shell/operations/deployment/deployment-instructions.md @@ -13,7 +13,7 @@ In Gitea, under **Repository → Settings → Actions**: |---|---| | `PI_MAIN_ADDRESS` | Address of the Pi as reachable from the runner (same as in your other projects) | | `PI_MAIN_PORT` | SSH port | -| `PI_MAIN_USERNAME` | SSH user | +| `PI_MAIN_USERNAME` | `gitea-workflow`: the deploy user for pipelines, member of the `www-data` group (see 1.2) | | `PI_MAIN_PASSWORD` | SSH password (see 1.4 for switching to a key) | | `FTP_HOST` | Domain or A-record IP of the hosting space (control panel) | | `FTP_USERNAME` | FTP account **including** the FTP prefix | @@ -33,11 +33,18 @@ Check that Actions is enabled for the repository. The global runner `raspberry-p ### 1.2 Test server (Raspberry Pi with nginx) The current WordPress site runs on the same Pi. The test site gets its **own folder** and its **own nginx block**, and touches nothing of WordPress. -1. Create a separate folder, **not** inside the WordPress folder: +1. Create a separate folder, **not** inside the WordPress folder, and give the `www-data` group **write** access. + + The pipeline logs in as **`gitea-workflow`**, a member of the `www-data` group. Group write access on the folder is enough; `gitea-workflow` does not need to own it. The folder may be created by another user, for example `webadmin` (also in `www-data`) via FileZilla. ```bash sudo mkdir -p /var/www/html/andreaslop-test - sudo chown /var/www/html/andreaslop-test + sudo chgrp www-data /var/www/html/andreaslop-test + sudo chmod 2775 /var/www/html/andreaslop-test ``` + - **775 is required.** New folders get **755** by default, also when created with FileZilla or `mkdir`. With 755 the group may only read, and the deploy fails with `Permission denied`. Check it with `ls -ld /var/www/html/andreaslop-test`: it must show `drwxrwxr-x` (or `drwxrwsr-x` with the 2). + - **The 2 (setgid)** is optional but recommended. New files and folders in the test folder then also get group `www-data`, so `webadmin` and `gitea-workflow` can keep managing each other's files. + - **On the Pi** `/var/www/html` is a symlink to `/mnt/storage1/www/html` (external disk). Rights on the symlink itself are ignored; the folder it points to counts. The commands above work through the symlink. + Every deploy empties this folder first. The pipeline refuses a folder with `wp-config.php` or `wp-content` in it. 2. Copy [`web/deploy/nginx/andreaslop-test.conf`](../../../../../web/deploy/nginx/andreaslop-test.conf) to `/etc/nginx/conf.d/andreaslop-test.conf`. nginx loads everything in `conf.d/` automatically, so no symlink is needed. Adjust `server_name` and `root` if needed. ```bash @@ -120,5 +127,6 @@ git rm --cached -r -q . && git reset --hard | Lighthouse: "Chrome could not be started" | Sandbox | `LIGHTHOUSE_CHROME_FLAGS` must contain `--no-sandbox` (already set). | | `Format` fails only in CI | Line endings | See 1.5. | | `sshpass`: Permission denied | Wrong secret, or special characters | Secrets go via `env:` (already so); check the values. | +| `mkdir: cannot create directory` or `scp: dest open …: Permission denied` | The test folder does not exist, or the `www-data` group may not write to it (755 instead of 775) | See 1.2: `chgrp www-data` and `chmod 2775` on the test folder. | | `lftp`: certificate verification failed | Hostname does not match the hoster's certificate | Use the hostname from the control panel in `FTP_HOST`, not the IP. | | Health check fails, page is 404 on deep links | SPA fallback missing | Production: `web.config` not uploaded or URL Rewrite off. Test: nginx config not active. | -- 2.39.5 From 0bfe50e7231e227d90ef772e9f1398e9255bfcf9 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Mon, 19 Oct 2026 11:49:35 +0200 Subject: [PATCH 05/12] Adds the monitoring plan and setup for the front-end shell Monitoring reuses the existing Sentry organisation, the self-hosted Umami instance and UptimeRobot, with e-mail alerts. One build serves both environments; the browser picks test or production from the hostname and sends nothing on other hosts. Sentry captures errors only, loads after the page and stores no personal data. Code changes follow after approval. Co-Authored-By: Claude Opus 5.5 --- .../features/frontend-shell/aidlc-state.md | 14 ++- aidlc-docs/features/frontend-shell/audit.md | 72 ++++++++++++++ .../operations/monitoring/monitoring-plan.md | 61 ++++++++++++ .../operations/monitoring/monitoring-setup.md | 78 +++++++++++++++ .../operations/plans/monitoring-setup-plan.md | 95 +++++++++++++++++++ 5 files changed, 315 insertions(+), 5 deletions(-) create mode 100644 aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-plan.md create mode 100644 aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-setup.md create mode 100644 aidlc-docs/features/frontend-shell/operations/plans/monitoring-setup-plan.md diff --git a/aidlc-docs/features/frontend-shell/aidlc-state.md b/aidlc-docs/features/frontend-shell/aidlc-state.md index aa86921..25cf27f 100644 --- a/aidlc-docs/features/frontend-shell/aidlc-state.md +++ b/aidlc-docs/features/frontend-shell/aidlc-state.md @@ -5,7 +5,7 @@ - **Feature Slug**: frontend-shell - **Project Type**: Brownfield - **Start Date**: 2026-10-14T09:46:02Z -- **Current Stage**: OPERATIONS - Deployment Setup (awaiting approval) +- **Current Stage**: OPERATIONS - Monitoring Setup (awaiting approval) - **Branch**: feature/frontend-shell ## Workspace State @@ -40,6 +40,10 @@ - **Included**: Yes - **Method**: CI/CD (Gitea Actions) — test via SSH/scp to Raspberry Pi nginx, production via FTPS to IIS webhost (manual, release/* only) +### Monitoring Setup +- **Included**: Yes +- **Approach**: Combination — Sentry (JS errors), Umami (cookieless visitor stats), UptimeRobot (availability); e-mail alerts; reuses existing services + ## Scope Notes (from user) - Side area / "Info menu" from the static design is OUT of scope (deliberately left out) - E-mail address in the mobile menu is OUT of scope (deliberately left out) @@ -69,14 +73,14 @@ - [x] Build and Test - EXECUTE (complete) ### 🟡 OPERATIONS PHASE -- [~] Deployment Setup - EXECUTE (artifacts generated, awaiting approval) -- [ ] Monitoring Setup - EXECUTE +- [x] Deployment Setup - EXECUTE (approved; pipeline verified, first test deploy green) +- [~] Monitoring Setup - EXECUTE (artifacts generated, awaiting approval) - [ ] Production Readiness Validation - EXECUTE ## Current Status - **Lifecycle Phase**: OPERATIONS -- **Current Stage**: Deployment Setup -- **Next Stage**: Monitoring Setup +- **Current Stage**: Monitoring Setup +- **Next Stage**: Production Readiness Validation ## Reverse Engineering Status - [x] Reverse Engineering - Artifacts generated on 2026-10-14T09:58:04Z (approved 2026-10-14T10:05:21Z) diff --git a/aidlc-docs/features/frontend-shell/audit.md b/aidlc-docs/features/frontend-shell/audit.md index 6503943..485d893 100644 --- a/aidlc-docs/features/frontend-shell/audit.md +++ b/aidlc-docs/features/frontend-shell/audit.md @@ -786,3 +786,75 @@ Verder heb ik de vraag ook beantwoord" **Context**: OPERATIONS - Deployment Setup --- + +## Deployment Setup - Commit/Push Scope + +**Timestamp**: 2026-10-19T07:43:33Z + +**User Input**: "laat mij weten wanneer die klaar is. gezien alles nu lijkt te werken wi lik niet meer dat je zelf commit en pusht. dat was voor het fixen van de pipeline. dese pr kunnen we nu ook gebruiken voor de rest van deze aidlc feature" + +**AI Response**: "Autonomous commit/push withdrawn; only on explicit request from now on. PR #4 stays open for the rest of the frontend-shell AI-DLC feature. Watching run 533 and will report when done." + +**Context**: OPERATIONS - Deployment Setup + +--- + +## Deployment Setup - Approval + +**Timestamp**: 2026-10-19T08:02:45Z + +**User Input**: "ja, zodra hij groen is mag je door naar de monitoring fase" + +**AI Response**: "Run 533 (PR #4, 7750971) green: check and lighthouse succeeded. Deployment Setup marked approved (decision: included; method CI/CD via Gitea Actions, test via SSH/scp to Raspberry Pi nginx, production via FTPS to IIS, manual from release/*). Started OPERATIONS - Monitoring Setup. Found existing monitoring stack in owner's projects (SlpSoftware react-frontend, SlpModularCms): Sentry free tier, self-hosted Umami on the Pi, UptimeRobot." + +**Context**: OPERATIONS - Deployment Setup complete; Monitoring Setup started + +--- + +## Monitoring Setup - Plan and Questions + +**Timestamp**: 2026-10-19T08:03:14Z + +**User Input**: "(none — stage start)" + +**AI Response**: "Created operations/plans/monitoring-setup-plan.md: context (static site; existing Sentry/Umami/UptimeRobot stack in other projects), pre-decided items (one build for both environments, environment from hostname at runtime; narrow CSP exceptions per chosen service generated into web.config/nginx; privacy statement action item), and 7 questions (inclusion, approach, reuse, Sentry delivery without tunnel, Umami, UptimeRobot, alert channels)." + +**Context**: OPERATIONS - Monitoring Setup; awaiting answers + +--- + +## Monitoring Setup - Answers and Artifacts + +**Timestamp**: 2026-10-19T09:23:26Z + +**User Input**: "ik heb de vragen beantwoord" + +**AI Response**: "Answers: Q1 A, Q2 D, Q3 A, Q4 A, Q5 A, Q6 'A, maar gezien er nu ook al een site draait kan ik die nu ook al opzetten voor productie. Voor UptimeRobot hoeven we verder geen code toe te voegen toch?', Q7 A. Confirmed UptimeRobot needs no code; production monitor can start now (watches WordPress until DNS switch), deep-link monitor after go-live. Read SlpSoftware's Sentry init (tunnel via reverse proxy) and UmamiAnalytics (analytics.slpsoftware.nl). Generated operations/monitoring/monitoring-plan.md (M1-M8: hostname-based environment with one build, config in code, direct Sentry without tunnel, lazy Sentry for performance, errors only without PII, separate Umami websites with data-domains and DNT, narrow CSP exceptions, UptimeRobot monitors) and monitoring-setup.md (one-time steps per service, code changes per file, tests, checks after deploy, values needed). Code changes deferred until approval. State updated." + +**Context**: OPERATIONS - Monitoring Setup; awaiting approval + +--- + +## Monitoring Setup - Sentry Plugin + +**Timestamp**: 2026-10-19T09:47:28Z + +**User Input**: "Help me met het opzetten van sentry. org slug: slp-software run code: 8fc9ce6c75" / "ik heb net de sentry agent plugin geinstalleerd. die zou je kunnen gebruiken. ik heb namelijk uitgevoerd `npx @sentry/agent-plugin install slp-software#8fc9ce6c75`" + +**AI Response**: "Read Sentry's instrument playbook: provisioning, DSN retrieval, onboarding progress (run code) and verification all go through the Sentry MCP. Owner installed the Sentry plugin (sentry@claude-plugins-official 1.4.0, MCP https://mcp.sentry.dev/mcp, enabled globally); its tools are not loaded in this already-running session. Advised: restart Claude Code, authenticate via /mcp, start the Sentry setup with a first prompt containing the onboarding code and the M1-M7 constraints (errors only, no tracing/replay, lazy load, hostname-based environment, no PII), on feature/frontend-shell without committing/pushing unasked. Monitoring artifacts and audit entries are uncommitted; offered to commit on request." + +**Context**: OPERATIONS - Monitoring Setup; awaiting session restart for Sentry MCP + +--- + +## Session End - Commit + +**Timestamp**: 2026-10-19T09:49:35Z + +**User Input**: "ik start een nieuwe sessie. de ssh agent. moet die dan ook opnieuw gestart worden? Commit alle wijzigingen voor ik de sessie sluit" + +**AI Response**: "Explained the ssh-agent survives Claude sessions (key lifetime 4h). Committed all pending changes (monitoring plan and setup, monitoring question file with answers, state and audit) on feature/frontend-shell; not pushed." + +**Context**: OPERATIONS - Monitoring Setup; awaiting approval / Sentry setup in a new session + +--- diff --git a/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-plan.md b/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-plan.md new file mode 100644 index 0000000..0d14400 --- /dev/null +++ b/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-plan.md @@ -0,0 +1,61 @@ +# Monitoring Plan — frontend-shell + +Decisions: [monitoring-setup-plan.md](../plans/monitoring-setup-plan.md) (Q1 = A, Q2 = D, Q3 = A, Q4 = A, Q5 = A, Q6 = A + production now, Q7 = A). + +## Overview + +```mermaid +graph LR + Visitor["Visitor browser"] -->|"JS errors"| Sentry["Sentry (EU), existing org"] + Visitor -->|"page views, cookieless"| Umami["Umami on the Pi, analytics.slpsoftware.nl"] + Uptime["UptimeRobot"] -->|"HTTP checks"| Site["andreaslop.nl and test.andreaslop.nl"] + Sentry -->|"e-mail, new error type"| Owner["Owner"] + Uptime -->|"e-mail, site down"| Owner + + classDef visitor fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; + classDef service fill:#e9d5ff,stroke:#6b21a8,stroke-width:1px,color:#000; + classDef site fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; + classDef owner fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; + + class Visitor visitor; + class Sentry,Umami,Uptime service; + class Site site; + class Owner owner; +``` + +Text alternative: visitors' browsers send JavaScript errors to Sentry and cookieless page views to Umami; UptimeRobot checks both sites from outside; Sentry and UptimeRobot e-mail the owner. + +## Chosen Approach (all three, reusing existing services) + +| Area | Service | What it covers | Code needed | +|---|---|---|---| +| **Logging** | **Sentry** (existing EU organisation, new project `andreaslop-fotografie`) | JavaScript errors in visitors' browsers: render errors caught by `ErrorPage` and unhandled errors, tagged `test` or `production` | Yes | +| **Dashboards: visitors** | **Umami** (existing install on the Pi, two new "websites": test and production) | Page views, referrers, devices, without cookies or personal data | Yes | +| **Dashboards: availability** | **UptimeRobot** (existing account, new monitors) | Whether test and production respond; response time history | No | +| **Alerting** | Sentry + UptimeRobot defaults | E-mail on a **new** type of error (Sentry) and when a site is **down** (UptimeRobot) | No | + +## Key Decisions + +| # | Decision | Why | +|---|---|---| +| M1 | **One build for both environments**: the browser picks the environment from the hostname (`andreaslop.nl` → production, `test.andreaslop.nl` → test). Any other host (localhost, Lighthouse CI, previews) sends **nothing**. | Keeps "deploy exactly what was tested" (D-pipeline). Local runs and CI never pollute the dashboards. | +| M2 | **Sentry and Umami settings live in code** (`src/monitoring/config.ts`), not in Gitea variables. | The Sentry DSN and Umami website IDs are public by design: they end up in every visitor's browser anyway. In code they are reviewed, tested and versioned. | +| M3 | **Sentry sends directly** to `*.ingest.de.sentry.io` (no tunnel). | Q4 = A: the IIS host serves only static files until the .NET API exists; some errors from visitors with ad-blockers are missed. Follow-up: tunnel via the API. | +| M4 | **Sentry loads after the page**, not in the main bundle. | Keeps the performance budget: the home page on mobile already sits just above its 0.8 target. Errors are queued until Sentry is ready. | +| M5 | **Sentry: errors only.** No performance tracing, no session replay, no personal data (`sendDefaultPii: false`, IP storage off in the project settings). | Smallest bundle, least data, simplest privacy story. | +| M6 | **Umami: separate websites for test and production**; `data-domains` restricts counting to the right hostname, and `data-do-not-track` respects the browser's Do Not Track setting. | Test traffic never mixes with real numbers. | +| M7 | **CSP exceptions as narrow as possible**, generated into `web.config` and the nginx config like the other headers.
  • `script-src`: `https://analytics.slpsoftware.nl` (the Umami script)
  • `connect-src`: `https://analytics.slpsoftware.nl` and `https://o4511795618185216.ingest.de.sentry.io`
| Nothing else is opened. | +| M8 | **UptimeRobot**: production monitor now (it watches the current WordPress site until the DNS switch, then the new site automatically), test now, and the `/portfolio` deep-link monitors. | Q6 = A, owner: production can start now. | + +## Explicitly Out of Scope +- Sentry tunnel against ad-blockers: comes with the .NET API (follow-up). +- Server-side logging (nginx, IIS): not managed by this project. nginx logs on the Pi and the hoster's IIS logs stay where they are. +- Performance tracing, session replay, custom Umami events. +- Alerts other than e-mail. + +## Privacy (action item for the privacy statement page) +The privacy statement (still a placeholder) must mention: +- **Umami**: anonymous, cookieless visit statistics, self-hosted in the Netherlands, no personal data. +- **Sentry**: technical error reports, sent to Sentry (EU region) without IP address or personal data. + +Umami without cookies needs no cookie banner under the Dutch DPA's guidance for analytics that are set up privacy-friendly. Sentry error reporting falls under legitimate interest. **This is not legal advice; check it when writing the privacy statement.** diff --git a/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-setup.md b/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-setup.md new file mode 100644 index 0000000..a2776b1 --- /dev/null +++ b/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-setup.md @@ -0,0 +1,78 @@ +# 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), `sendDefaultPii: false`, no tracing or replay. `reportError(error)`: queues errors until Sentry is ready. | +| `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 needed from you +Fill these in after steps 1 and 2. Placeholders are fine to start with; monitoring stays off until they are set. + +| Value | From | +|---|---| +| Sentry DSN | Sentry, step 1.2 | +| Umami website ID, production | Umami, step 2.3 | +| Umami website ID, test | Umami, step 2.3 | diff --git a/aidlc-docs/features/frontend-shell/operations/plans/monitoring-setup-plan.md b/aidlc-docs/features/frontend-shell/operations/plans/monitoring-setup-plan.md new file mode 100644 index 0000000..e147771 --- /dev/null +++ b/aidlc-docs/features/frontend-shell/operations/plans/monitoring-setup-plan.md @@ -0,0 +1,95 @@ +# Monitoring Setup Plan — frontend-shell + +## Context + +- **What runs**: a static site (no back-end), deployed to test (Raspberry Pi, nginx) and later production (IIS webhost). See [deployment-plan.md](../deployment/deployment-plan.md). +- **Current state**: no monitoring in this project. Errors only go to the browser console (`ErrorPage`, BR-ERR-03). +- **Existing stack in your other projects** (SlpSoftware `react-frontend`, SlpModularCms): + - **Sentry** (free tier): JavaScript errors + - **Umami**, self-hosted on the Pi: visitor statistics without cookies + - **UptimeRobot**: is the site reachable +- **Already decided** (no question needed): + - **One build for both environments stays.** Test vs production (for example for Sentry or Umami) is determined in the browser from the hostname, not with a separate build. The pipeline keeps deploying exactly the same build that was tested. + - **External monitoring services need CSP exceptions.** The current CSP only allows the site's own origin. Each external service you choose is added to `config/securityHeaders.ts`, and from there to `web.config` and the nginx config, as narrowly as possible (only that host, only the directive that needs it). + - **Privacy statement.** Whatever measures visitors must later be mentioned there. The page is still a placeholder, so this becomes an action item for that page. + +## Plan + +- [x] 1. Answer the questions below +- [x] 2. Analyze answers (follow-up questions if needed) +- [x] 3. Generate `operations/monitoring/monitoring-plan.md` +- [x] 4. Generate `operations/monitoring/monitoring-setup.md` (and, if needed, code and config changes on this PR after your approval) +- [ ] 5. Update CSP, server config, tests and privacy action items for the chosen services + +--- + +## Questions + +Vul per vraag de letter in na `[Answer]:`. Past geen enkele optie, kies dan de laatste (Anders) en licht toe. Waar ik een voorkeur heb staat **(aanbevolen)**. + +### Vraag 1: Monitoring opzetten voor deze feature? + +A) Ja, help me monitoring op te zetten +B) Nee, dit sluit aan op bestaande monitoring of valt nu buiten de scope +C) Weet ik niet, stel een aanpak voor en ik beslis +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +### Vraag 2: Welke vormen van monitoring? + +A) Logging: JavaScript-fouten bij bezoekers vastleggen +B) Meldingen: een bericht als de site plat ligt of er fouten optreden +C) Dashboards: bezoekersstatistieken en een overzicht van de beschikbaarheid +D) Een combinatie, namelijk alle drie, net als je andere projecten **(aanbevolen)** +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: D + +### Vraag 3: Bestaande diensten hergebruiken? + +A) Ja: hetzelfde Sentry-account (een nieuw project of een eigen omgeving), dezelfde Umami-installatie op de Pi (nieuwe "websites" voor test en productie) en hetzelfde UptimeRobot-account (nieuwe monitors) **(aanbevolen)** Eén plek om alles te bekijken, geen extra kosten. +B) Aparte, nieuwe accounts of installaties voor deze site +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +### Vraag 4: Hoe komen JavaScript-fouten bij Sentry? + +De site is statisch. In SlpSoftware loopt Sentry via een eigen doorgeefluik ("tunnel") langs adblockers, maar daarvoor is een server-onderdeel nodig. Bij de webhoster draait alleen IIS met statische bestanden, tot de .NET API er is. + +A) Nu rechtstreeks naar Sentry. De CSP krijgt alleen het ingest-adres van Sentry erbij (`connect-src`). Een deel van de fouten mist bij bezoekers met een adblocker. De tunnel komt later via de .NET API. **(aanbevolen)** +B) Nog geen Sentry. Fouten alleen in de browserconsole, Sentry pas met de API. +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +### Vraag 5: Bezoekersstatistieken met Umami + +Umami gebruikt geen cookies en slaat geen persoonsgegevens op. Daarmee is volgens de Autoriteit Persoonsgegevens meestal geen cookiebanner nodig, mits het zo ingesteld is. + +A) Ja, met de bestaande Umami op de Pi. Aparte "websites" voor test en productie, zodat testverkeer niet in de echte cijfers komt. De CSP krijgt het Umami-adres erbij (`script-src` en `connect-src`). **(aanbevolen)** +B) Alleen voor productie, niet voor test +C) Nog geen statistieken +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +### Vraag 6: Beschikbaarheid bewaken met UptimeRobot + +A) Monitors op test nu, en op productie zodra de DNS omgezet is. Ze controleren de homepage en een deep link (`/portfolio`, om de SPA-fallback te testen). **(aanbevolen)** +B) Alleen productie, na de livegang +C) Geen beschikbaarheidsbewaking +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A, maar gezien er nu ook al een site draait kan ik die nu ook al opzetten voor productie. Voor UptimeRobot hoeven we verder geen code toe te voegen toch? + +### Vraag 7: Meldingen + +A) E-mail van UptimeRobot als de site plat ligt, en e-mail van Sentry bij een nieuw soort fout (hun standaardmeldingen) **(aanbevolen)** +B) Alleen bij een storing (UptimeRobot), niet bij fouten +C) Geen meldingen, ik kijk zelf in de dashboards +D) Een ander kanaal (bv. Telegram, ntfy, Teams); beschrijf welk na de [Answer]:-tag +X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A -- 2.39.5 From 6d3a1566c2c5de5786307ebf8364a9f4df7cca11 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Mon, 19 Oct 2026 12:08:47 +0200 Subject: [PATCH 06/12] Adds Sentry and Umami monitoring to the site 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 --- .gitea/workflows/continuous_integration.yaml | 3 + .../features/frontend-shell/aidlc-state.md | 4 +- aidlc-docs/features/frontend-shell/audit.md | 36 +++++++ .../operations/monitoring/monitoring-setup.md | 16 +-- web/config/securityHeaders.test.ts | 27 ++++- web/config/securityHeaders.ts | 9 +- web/deploy/iis/web.config | 2 +- web/deploy/nginx/andreaslop-test.conf | 8 +- web/package.json | 1 + web/pnpm-lock.yaml | 88 +++++++++++++++++ .../Analytics/UmamiAnalytics.test.tsx | 47 +++++++++ .../components/Analytics/UmamiAnalytics.tsx | 31 ++++++ web/src/components/AppShell.tsx | 2 + web/src/components/StatusPage/ErrorPage.tsx | 4 +- web/src/main.tsx | 4 + web/src/monitoring/config.test.ts | 56 +++++++++++ web/src/monitoring/config.ts | 43 ++++++++ web/src/monitoring/sentry.test.ts | 99 +++++++++++++++++++ web/src/monitoring/sentry.ts | 55 +++++++++++ web/src/monitoring/sentryClient.ts | 4 + 20 files changed, 518 insertions(+), 21 deletions(-) create mode 100644 web/src/components/Analytics/UmamiAnalytics.test.tsx create mode 100644 web/src/components/Analytics/UmamiAnalytics.tsx create mode 100644 web/src/monitoring/config.test.ts create mode 100644 web/src/monitoring/config.ts create mode 100644 web/src/monitoring/sentry.test.ts create mode 100644 web/src/monitoring/sentry.ts create mode 100644 web/src/monitoring/sentryClient.ts diff --git a/.gitea/workflows/continuous_integration.yaml b/.gitea/workflows/continuous_integration.yaml index 84ea453..327e1fb 100644 --- a/.gitea/workflows/continuous_integration.yaml +++ b/.gitea/workflows/continuous_integration.yaml @@ -77,8 +77,11 @@ jobs: - name: Tests run: pnpm test + # Sentry toont bij elke fout uit welke commit de build komt - name: Build run: pnpm build + env: + VITE_RELEASE: ${{ github.sha }} - name: Audit (productiepakketten, blokkerend) run: pnpm audit:deps diff --git a/aidlc-docs/features/frontend-shell/aidlc-state.md b/aidlc-docs/features/frontend-shell/aidlc-state.md index 25cf27f..d4bded1 100644 --- a/aidlc-docs/features/frontend-shell/aidlc-state.md +++ b/aidlc-docs/features/frontend-shell/aidlc-state.md @@ -5,7 +5,7 @@ - **Feature Slug**: frontend-shell - **Project Type**: Brownfield - **Start Date**: 2026-10-14T09:46:02Z -- **Current Stage**: OPERATIONS - Monitoring Setup (awaiting approval) +- **Current Stage**: OPERATIONS - Monitoring Setup (code done, awaiting approval) - **Branch**: feature/frontend-shell ## Workspace State @@ -74,7 +74,7 @@ ### 🟡 OPERATIONS PHASE - [x] Deployment Setup - EXECUTE (approved; pipeline verified, first test deploy green) -- [~] Monitoring Setup - EXECUTE (artifacts generated, awaiting approval) +- [~] Monitoring Setup - EXECUTE (setup done in Sentry/Umami, code implemented and green; awaiting approval) - [ ] Production Readiness Validation - EXECUTE ## Current Status diff --git a/aidlc-docs/features/frontend-shell/audit.md b/aidlc-docs/features/frontend-shell/audit.md index 485d893..0217b7c 100644 --- a/aidlc-docs/features/frontend-shell/audit.md +++ b/aidlc-docs/features/frontend-shell/audit.md @@ -858,3 +858,39 @@ Verder heb ik de vraag ook beantwoord" **Context**: OPERATIONS - Monitoring Setup; awaiting approval / Sentry setup in a new session --- + +## Monitoring Setup - Sentry Project via MCP + +**Timestamp**: 2026-10-19T09:55:00Z + +**User Input**: "ik wil verder met de openstaande feature. we waren bezig met monitoring en ik was bezig met het opzetten van sentry. Die geeft mij de volgende prompt zodat jij mij kan helpen opzetten met behulp van de mcp server die ik heb toegevoegd, prompt van sentry: Help me create and set up Sentry projects for this application. org slug: slp-software run code: 8fc9ce6c75" / "kan je het nog eens proberen? members kunnen nu een project aanmaken" + +**AI Response**: "Org slp-software (EU, de.sentry.io), team slp-software. First create_project failed with 403: the MCP OAuth token acts as a member and 'Let Members Create Projects' was off. Owner enabled it; created project andreaslop-fotografie (javascript-react), DSN https://12ec77dcc3216a98b96d3fb3dac13f66@o4511795618185216.ingest.de.sentry.io/4512282287472720. Changed the default alert 1390900 from 'high priority issues' to 'first seen event' (a new issue is created) → e-mail, renamed 'Send a notification for new issues', to match Q7 = A. 'Prevent Storing of IP Addresses' has no MCP tool: left for the owner in the UI. Seer PR-ready rule left untouched." + +**Context**: OPERATIONS - Monitoring Setup; one-time Sentry setup + +--- + +## Monitoring Setup - Umami IDs and Code Changes + +**Timestamp**: 2026-10-19T10:07:53Z + +**User Input**: "de umami Website ID's zijn: - Andrea Slop Fotografie (Test): 7fb301ab-6ecc-4aea-beee-71bcb6009bfe - Andrea Slop Fotografie: 3edbb7d1-4388-4f2d-9cef-11ade88ace96" + +**AI Response**: "Took the owner's completed one-time setup and supplied values as approval of the monitoring setup and implemented the code changes from monitoring-setup.md: @sentry/react 11.8.0; src/monitoring/config.ts (DSN, ingest origin derived from DSN, Umami origin, monitoringFor via Map); src/monitoring/sentry.ts (startSentry after load event, queue incl. early unhandled errors/rejections, reportError); src/monitoring/sentryClient.ts (named re-exports, lazy chunk 31 kB gzip instead of 150 kB); UmamiAnalytics in AppShell (data-website-id, data-domains, data-do-not-track); ErrorPage calls reportError; CSP script-src + Umami, connect-src + Umami + Sentry ingest, regenerated web.config and nginx; workflow Build step sets VITE_RELEASE=github.sha. Found: SDK 11 removed sendDefaultPii and collects all data by default, so every dataCollection category is set off explicitly (M5). Tests: monitoringFor examples + PBT (domains, IPs, strings, lookalikes → null), sentry queue/start/once/load-event/unhandled, UmamiAnalytics per host/unknown host/once, CSP exactly two external hosts in the right directives. lint, format, 109 tests and build green. Main bundle unchanged (572 kB vs 579 kB before). Not committed." + +**Context**: OPERATIONS - Monitoring Setup; code changes done, awaiting approval + +--- + +## Monitoring Setup - Commit/Push and Watch Run + +**Timestamp**: 2026-10-19T10:08:46Z + +**User Input**: "Zodra je klaar bent mag je comiiten en pushen. Daarna wil ik dat je de run van de PR in de gaten houdt om te zien of die slaagt. Je hebt toestemming om zelf de problemen die je tegenkomt op te lossen, te committen en te pushen totdat alles weer slaagt en groen is. Ik wil achteraf wel een samenvatting van wat je gedaan hebt. ga nog NIET automatisch door naar de volgende stage van aidlc. dat geef ik aan wanneer dat mag" + +**AI Response**: "Committing and pushing the monitoring changes to PR #4; watching the PR run and fixing/committing/pushing until green (permission scoped to this task). Monitoring Setup stays awaiting approval; not proceeding to Production Readiness until the owner says so." + +**Context**: OPERATIONS - Monitoring Setup; task-scoped commit/push permission + +--- diff --git a/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-setup.md b/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-setup.md index a2776b1..7862028 100644 --- a/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-setup.md +++ b/aidlc-docs/features/frontend-shell/operations/monitoring/monitoring-setup.md @@ -15,7 +15,8 @@ What to do once in each service, and what changes in the code. The code changes |---|---| | `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), `sendDefaultPii: false`, no tracing or replay. `reportError(error)`: queues errors until Sentry is ready. | +| `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 | @@ -68,11 +69,12 @@ Optional: type **Keyword** with the keyword `Andrea Slop Fotografie`. That catch - **`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 needed from you -Fill these in after steps 1 and 2. Placeholders are fine to start with; monitoring stays off until they are set. +## 5. Values (filled in 2026-10-19, in `src/monitoring/config.ts`) -| Value | From | +| Value | Setting | |---|---| -| Sentry DSN | Sentry, step 1.2 | -| Umami website ID, production | Umami, step 2.3 | -| Umami website ID, test | Umami, step 2.3 | +| 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. diff --git a/web/config/securityHeaders.test.ts b/web/config/securityHeaders.test.ts index 69c0024..b51c328 100644 --- a/web/config/securityHeaders.test.ts +++ b/web/config/securityHeaders.test.ts @@ -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'); }); diff --git a/web/config/securityHeaders.ts b/web/config/securityHeaders.ts index 3979130..8575f7b 100644 --- a/web/config/securityHeaders.ts +++ b/web/config/securityHeaders.ts @@ -1,17 +1,20 @@ // HTTP-securityheaders voor de Vite dev- en preview-server. De productieset is // ook het voorschrift voor de toekomstige host (zie NFR-SEC-01/02). +import { sentryIngestOrigin, umamiOrigin } from '../src/monitoring/config.ts'; + type Mode = 'production' | 'development'; // Chakra/Emotion zetten tijdens runtime