Files
accounted/.gitignore
T
Jakob Wennberg d4f82cafc4 feat(analytics): add PostHog (EU) behind a same-origin proxy (#1237)
Recapt shuts down in four days, taking product analytics and session
replay with it. This adds PostHog Cloud EU alongside it; the Recapt
removal follows separately so events can be confirmed landing first.

Wiring choices that are not the tutorial defaults:

- Same-origin reverse proxy (/rl -> eu.i.posthog.com) instead of adding
  PostHog hosts to the CSP. connect-src 'self' and script-src 'self'
  already cover it, tracking blockers have no third-party host to match,
  and the Recapt allowlist entries in next.config.ts get replaced by
  nothing at all when they go. Needs skipTrailingSlashRedirect, since
  PostHog sends trailing-slash API requests; verified that trailing-slash
  URLs on normal routes still resolve 200 rather than 404.

- /rl is excluded from the proxy.ts matcher. Middleware runs BEFORE
  next.config rewrites, so without this updateSession() treats an
  ingestion POST as an unknown protected path and 307s it to /login.
  Verified with a control: /zz/flags/ -> 307 /login, /rl/flags/ -> 200
  from PostHog. This fails silently otherwise, because asset loads keep
  working through the rewrite while no events arrive.

- persistence: 'memory' so nothing is written to the device and no
  cookie-consent banner is required. Everything post-login is unaffected:
  AnalyticsIdentify re-identifies on each dashboard load.

- session_recording.maskTextSelector: '*'. PostHog masks inputs but not
  text by default, and this app renders org numbers (which for an
  enskild firma ARE the owner's personnummer), customer names and
  balances as ordinary text. Replays show where a user gets stuck, never
  what their books say. buildGroupProperties() also refuses to send
  org_number at all, with a test pinning it.

- Error tracking registers through the existing lib/observability sink
  rather than bypassing it, so every error-level createLogger() line is
  captured already redacted. instrumentation.ts onRequestError covers
  what escapes uncaught.

Analytics is hosted-only: isAnalyticsEnabled() short-circuits on
NEXT_PUBLIC_SELF_HOSTED and no Docker sentinel is added, so self-hosted
runs with zero third-party runtime code. Recapt got that outcome only by
accident, via a missing sentinel; here it is explicit and tested.

vitest.config.ts aliases 'server-only' to a stub: it is a build-time
guard whose real entry point always throws, which broke 48 test files the
moment a server-only module entered the graph. request-context.ts was
already carrying the same latent trap.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-27 14:30:49 +02:00

104 lines
2.8 KiB
Plaintext

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
nul
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
!.env.example
!.env.docker.example
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
# supabase temp files
supabase/.temp/
# claude local settings
.claude/settings.local.json
.claude/scheduled_tasks.lock
# swarm audit reports (generated by /swarm)
.swarm/
# compliance scan output (SARIF / dossier / PR comment)
.compliance-reports/
# generated service worker (built from public/sw.template.js by
# scripts/inject-public-branding.mjs: runs via predev/prebuild)
/public/sw.js
# dev docs (internal reference, not published): EXCEPT the iXBRL taxonomy
# sources and the official Bolagsverket example, which CI needs: the committed
# lib/bokslut/ixbrl/taxonomy/generated/ registry is regenerated from them by
# `npm run taxonomy:check` (core-build.yml) and the golden test pins against
# the example document.
/dev_docs/*
# Extension registry (auto-generated but defaults are committed)
# Run `npm run setup:extensions` to regenerate after changing extensions.config.json
# The empty defaults in lib/extensions/_generated/ are committed so core compiles
# out of the box without running the generator.
supabase/.branches/
# Local-only SIE test fixtures: may contain real/scrubbed company data, never commit
tests/fixtures/sie/
# Local-only DESTRUCTIVE duplicate-cleanup tooling: one-off, run by hand against
# real räkenskapsinformation. Deliberately NOT committed so it can never run in
# CI/cron and so its logic isn't mistaken for a supported product feature.
scripts/delete-duplicate-transactions.ts
# Diagnostic/cleanup tooling under /scripts is tracked, but the DATA those
# scripts read or emit (ledger dumps, reconciliation exports) is real customer
# räkenskapsinformation: never commit it. Keep the .ts/.sql tooling, ignore the data.
scripts/*.csv
# Local-only DESTRUCTIVE support tool: reopens a closed räkenskapsår by deleting
# only its bokslut layer (dispositioner + closing entry + next-year IB). Run by
# hand against real räkenskapsinformation; bypasses BFL immutability triggers, so
# it must never live in the repo / CI / cron.
scripts/reopen-bokslut.sql
.claude/plans/write-up-a-plan-streamed-fiddle.md
/ingaende-balanser-test.csv
.agents
.codex
# PostHog wizard scratch: vendor reference docs downloaded by
# `npx @posthog/wizard`, useful locally (and for `wizard audit`) but not
# part of the app. The integration itself lives in lib/analytics/ and
# instrumentation-client.ts.
.posthog/