Skip to content

fix(server): keep request telemetry anonymous and exclude sensitive payloads - #128

Merged
jackshim415 merged 5 commits into
mainfrom
jackshim415/lvt-334-server-redact-request-analytics-and
Nov 21, 2026
Merged

jackshim415 merged 5 commits into
mainfrom
jackshim415/lvt-334-server-redact-request-analytics-and

Conversation

@jackshim415

@jackshim415 jackshim415 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Server request analytics previously sent bodies, full URLs, IPs and caller identities to PostHog. This replaces them with an anonymous allowlist of route patterns, status, latency, cache state and deployment metadata. PostgreSQL/Redis identity lookups and device aliases are removed.

Adds 14 HTTP regression tests for secret exclusion, safe route/method grouping, dependency-free telemetry and capture failures. Documents chart migration and the historical-data/access review still required for LVT-334. That operational review remains open.

Areas affected

  • Server
  • Dashboard
  • Collection
  • Website
  • Shared documentation, CI, or deployment

Contracts and data

  • No API, report-schema, authentication, deep-link, season-metric, or database contract changed
  • Every affected producer and consumer was updated together
  • Tenant and source-team visibility was reviewed
  • No credentials, production data, or private scouting notes are included

PostHog charts must use route instead of path/$pathname; person breakdowns are removed. Counts now include anonymous callers and polling responses.

Verification

From apps/server, using Node 22.20.0:

  • npm run build, npm run typecheck, npm run typecheck:test — passed.
  • DATABASE_URL=postgresql://lovat_test:lovat_test@127.0.0.1:5432/lovat_test npm run test:coverage:unit — 73 files, 1,458 tests passed; 100% statements, branches, functions and lines for every source file. One earlier coverage attempt hit an ECONNRESET in the unchanged Slack challenge test; the full rerun passed.
  • npm run lint — passed with 79 existing warnings.
  • ./node_modules/.bin/prettier --check src/lib/middleware/posthogMiddleware.ts test/posthogReporter.unit.test.ts README.md docs/request-telemetry.md — passed.

From repository root: ./scripts/check-structure.sh and git diff --check passed.

A clean dependency install ran out of disk space. Verification reused installed dependencies with identical Server/DB lockfiles and regenerated the database client in this worktree. No production or database-backed integration tests were run.

Deployment

No hosting, environment-variable or migration changes. New request events change when deployed; historical PostHog data and live access/retention settings still require the documented administrator review. Railway automatically built the PR preview; no production settings were changed.

Review follow-up

Express can clear a router’s mount while propagating an error. When the mount is unknown, telemetry now uses unmatched. Added coverage for root routes, unwound static and dynamic mounts, and rejected background tasks. The 40 focused tests and required Monorepo CI run passed at c961770f.

The Lovat PostHog project reports a 12-month default without an explicit project or organization override. The connector doesn’t expose project access-control metadata. The historical payload review remains open.

Remove request and response payloads, caller identities, and analytics-only database and Redis lookups. Keep endpoint counts, error rates, and latency available without person profiles.

Refs: LVT-334
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T06:32:39.448902Z 2d658c3 PR opened
🔒 Security Review ✅ Completed 2026-11-13T06:34:27.550825Z 2d658c3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@railway-app
railway-app Bot temporarily deployed to lovat / lovat-pr-128 November 13, 2026 06:30 Destroyed
@railway-app

railway-app Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the lovat-pr-128 environment in lovat

Service Status Web Updated
api ✅ Success (View Logs) Web Nov 20, 2026 at 11:51 pm UTC
website 😴 Sleeping (View Logs) Web Nov 20, 2026 at 11:48 pm UTC
worker ✅ Success (View Logs) Nov 20, 2026 at 11:39 pm UTC
dashboard 😴 Sleeping (View Logs) Web Nov 13, 2026 at 6:39 am UTC
learn 😴 Sleeping (View Logs) Web Nov 13, 2026 at 6:38 am UTC
1 service not affected by this PR
  • support

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Lovat AI review

Status: completed · Model: z-ai/glm-5.3-flash · Findings: 0

Reviewed commit: c961770f1f4c5d79170d413df061f2eacebaa545

Critical: 0 · High: 0 · Medium: 0 · Low: 0

Overall assessment

The rewrite replaces identity-based telemetry with an anonymous allowlisted schema, removes payload capture, person lookups, aliasing, and Redis/Prisma dependencies, and documents the historical-data remediation that remains for the PostHog administrator. The route allowlist correctly falls back to 'unmatched' for parameterized or unwound mounts, request IDs are server-generated, cache values are validated against an allowlist, and capture failures are contained without leaking details. Tests cover the sensitive paths including dynamic mounts, error unwinding, and SDK failures. No concrete defect is evidenced in the changed code.

No high-confidence issues were found in the reviewed changes.

Review details

  • Review batches: 1
  • Diff characters reviewed: 28,473
  • Tokens: 9,896 prompt + 946 completion
  • Estimated inference cost: $0.0005

Limitations

  • The reviewer examined only changed lines and their diff context, not the whole repository.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d658c3d87

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +64 to +66
const route =
typeof routePath === "string" && telemetryMounts.has(req.baseUrl)
? `${mount}${routePath}`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep unwound dynamic mounts unmatched

When a handler under a parameterized or otherwise unallowlisted mount throws and the outer error handler finishes the response, Express restores req.baseUrl to "" while retaining req.route.path—the same unwind behavior used by the new failure test. Because "" is in telemetryMounts, this condition then emits the leaf pattern (for example, /reports/:uuid) instead of unmatched, contrary to the documented rule for dynamic mounts and incorrectly combining failures from unrelated routers into one endpoint group. Track whether the matched mount itself was allowlisted rather than treating an unwound empty baseUrl as proof that it was safe.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

📱 Connect your app to this PR deployment

Scan a QR code to use this PR's Server API. Worker changes use the same API;
the Worker has no public app endpoint.

Server URL: https://api-lovat-pr-128.up.railway.app

Lovat Collection

QR code — Lovat Collection

lovat-collection://set-url?u=https%3A%2F%2Fapi-lovat-pr-128.up.railway.app

Lovat Dashboard

QR code — Lovat Dashboard

com.frc8033.lovatdashboard:///set-url?u=https%3A%2F%2Fapi-lovat-pr-128.up.railway.app

Exercise the OTHER method bucket so request telemetry meets the required branch coverage threshold.

Refs: LVT-334
@railway-app
railway-app Bot temporarily deployed to lovat / lovat-pr-128 November 20, 2026 23:39 Destroyed
@railway-app
railway-app Bot temporarily deployed to lovat / lovat-pr-128 November 20, 2026 23:49 Destroyed
@jackshim415
jackshim415 merged commit 2f5b778 into main Nov 21, 2026
25 checks passed

This branch was successfully deployed

No deployments
lovat / lovat-pr-128 — c961770f Deployed Nov 20, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant