You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(monitoring): single-source PostHog Error Tracking + CLI UA middleware
- Remove @sentry/node dep + delete lib/services/sentry.js + sentry tests
- Simplify errorTracker.js: PostHog-only fan-out, drop Sentry references
- Drop sentryService.init() from app.js bootstrap and shutdown
- Drop sentry config from development.config.js + production.config.js
- Flip posthog.errorTracking default to true
- Replace monitoring/Sentry readiness row with errorTracking/PostHog row
- NEW posthog-context.middleware.js: parse @trawlme/cli/<ver> UA header
- Wire posthogContextMiddleware in express.js after CORS, before routes
- analytics.capture() accepts optional req to merge req.posthogContext
- NEW posthog-context.middleware.unit.tests.js (7 cases)
- NEW home.service.unit.tests.js (readiness unit tests)
- Update errorTracker.unit.tests.js and home.integration.tests.js
* chore(config): drop leftover sentry block from test.config.js
DeepSeek pre-merge audit P1 finding: development.config.js + production.config.js
Sentry blocks were dropped, but test.config.js was missed. No functional
break (nothing reads it post-removal), but stale config invites confusion.
* docs(migrations) + test(analytics): address P2 audit findings
DeepSeek pre-merge audit P2 findings:
- MIGRATIONS.md: add v10 "Sentry removed" section so /update-project sub-agents
understand the propagation expectations (env var drops, @sentry/* dep cleanup,
config override removal, posthog.errorTracking opt-in semantics).
- analytics.capture.unit.tests.js: add 3 tests covering the new req.posthogContext
injection path (merges into defaults, user properties win on conflict, absent req
is backward-compat — no source/cli_version leak).
Copy file name to clipboardExpand all lines: MIGRATIONS.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,35 @@ Breaking changes and upgrade notes for downstream projects.
4
4
5
5
---
6
6
7
+
## Sentry removed — PostHog Error Tracking is now sole source (2026-05-10)
8
+
9
+
The `@sentry/node` integration shipped in 2026-03-26 (still documented below as **PostHog Analytics (2026-03-26)** + the now-removed Sentry monitoring section) is dropped. Error capture moves entirely to PostHog Error Tracking via `posthog.capture('$exception', ...)`.
10
+
11
+
### What changed
12
+
13
+
-**Deleted** : `lib/services/sentry.js` + its unit tests + the `@sentry/node` dependency.
14
+
-**`lib/services/errorTracker.js`** simplified to PostHog-only path. The `captureExceptionPostHogOnly` fan-out helper is removed (collapsed into `captureException` since there is no longer a double-reporting risk from a parallel Sentry Express handler).
15
+
-**`lib/app.js`** — Sentry init/shutdown calls removed from bootstrap and shutdown paths.
-**`config/defaults/development.config.js` + `production.config.js`** — `posthog.errorTracking` default flipped from `false` → `true`. Error capture is now enabled by default whenever `posthog.apiKey` is set.
18
+
-**`modules/home/services/home.service.js`**`getReadinessStatus()` — the `monitoring` row (Sentry presence) is replaced by an `errorTracking` row that gates on `posthog.apiKey && posthog.errorTracking === true`.
19
+
-**NEW `lib/middlewares/posthog-context.middleware.js`** — parses the `User-Agent` header, attaches `req.posthogContext = { source: 'cli'|'web', cli_version? }` for CLI-source attribution. Wired in `lib/services/express.js` after CORS / before routes.
20
+
-**`lib/services/analytics.js`**`capture()` accepts an optional `req` param. When provided, `req.posthogContext` is merged into event defaults so that CLI-originated requests carry `source` + `cli_version` automatically. Backward-compatible: callers that omit `req` see no behaviour change.
21
+
22
+
### Action required for downstream projects (`/update-project`)
23
+
24
+
1.**Drop env vars**`SENTRY_DSN` + any `SENTRY_*` references from `.env`, K8s manifests (`clusters/*/apps/*-node.yaml`), `.env.example`, deploy scripts, and CI secrets — they are no longer read.
25
+
2.**Drop `@sentry/*` deps** from project `package.json` if pinned downstream. Run `npm install` to regen lockfile.
26
+
3.**Remove project `config/defaults/*.config.js` overrides** of the `sentry: { ... }` block — they were either referencing the now-removed config path (no-op merge) or overriding fields that no longer exist.
27
+
4.**Confirm `posthog.errorTracking`** : if downstream config explicitly sets `posthog.errorTracking: false` to suppress capture, that override still wins via deepmerge. To opt into error tracking, set it to `true` (or rely on the new default if you remove the override).
28
+
5.**Optional — wire `req` into existing `capture()` callers** : if you want CLI-source attribution on existing events, change `capture({ distinctId, event, properties })` → `capture({ distinctId, event, properties, req })`. Without this opt-in, events still capture correctly but lack the `source`/`cli_version` properties.
29
+
30
+
### Why
31
+
32
+
Cf `infra/docs/superpowers/plans/2026-05-10-posthog-observability-followups.md` (decision matrix). PostHog Error Tracking is GA, free tier covers 100k exceptions/mo, and the single-tracker setup eliminates dual-config drift + cross-tool funnel friction.
33
+
34
+
---
35
+
7
36
## Test DB isolation: per-pid Mongo database default + globalTeardown (2026-04-24)
8
37
9
38
Default test database is now `mongodb://127.0.0.1:27017/NodeTest_${process.pid}` instead of the shared `NodeTest`. Concurrent jest invocations (e.g. multiple agent worktrees running `npm run test:coverage` in parallel) get isolated databases, eliminating the 401 / 404 / 422 / `MongoPoolClosedError` flake patterns documented in trawl_node#980.
0 commit comments