Skip to content

Refuse a production deploy that leaves relay analytics unset - #282

Closed
pstayets wants to merge 1 commit into
TeoSlayer:mainfrom
pstayets:fix/relay-posthog-deploy-gate
Closed

pstayets wants to merge 1 commit into
TeoSlayer:mainfrom
pstayets:fix/relay-posthog-deploy-gate

Conversation

@pstayets

Copy link
Copy Markdown
Contributor

What changes for the user?

Since 23 September at 17:11 UTC, the relay has sent nothing to PostHog: no downloads, installs, sessions, viewers or MCP results. That was four minutes after Release 0.23.1 (#250) landed, and it has stayed that way through 0.23.3. Over the same period the accounts app kept reporting normally, about 235–325k service_request events a day.

The capture code hasn't changed since the last good release (558c3b4..main touches no capture path in shared/posthog.ts or worker/index.ts). The relay only sends when vars.POSTHOG_ENABLED === "1", and that flag exists only in the private wrangler.production.jsonc. Wrangler replaces every Worker variable on deploy, so the production config used since 0.23.1 leaves the flag out and relay analytics switched off without any error. The app worker wasn't affected because its flag is committed in app/wrangler.jsonc.

Changes:

  • validateProductionConfig now refuses a config unless vars.POSTHOG_ENABLED is exactly "0" or "1". MCP_CONTROL_ENABLED already gets the same explicit-setting check.
  • wrangler.example.jsonc sets "POSTHOG_ENABLED": "0", so self-hosters see the flag and still send nothing.
  • docs/self-hosting.md and CHANGELOG.md explain the requirement and the failure it prevents.

Verification

  • npx vitest run tests/production-deploy.test.ts: 16 passed. With the guard removed from deploy-production.mjs, the 5 new regression cases fail (missing flag, "", "true", "yes", numeric 1).
  • npx vitest run: 66 files, 756 tests passed.
  • npm run typecheck: passed.
  • sh ./scripts/test-deploy-production.sh: passed.

Access and privacy

No change to authorization, terminal input, encryption or stored content. This PR changes only whether a deploy is allowed to go ahead; the analytics payloads are untouched.

  • No real share links, credentials, private terminal content or deployment secrets are included.
  • User-facing docs and the changelog are updated.

Rollout

Source only. This PR does not bring relay analytics back by itself. Whoever deploys production needs to add "POSTHOG_ENABLED": "1" to the vars in their private wrangler.production.jsonc and run npm run deploy:production again. After this PR, a deploy without the flag is refused instead of silently turning analytics off.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN

Relay PostHog events (downloads, installs, sessions, viewers, MCP results)
stopped at 2026-09-23 17:11 UTC, four minutes after the 0.23.1 release, and
have not come back through 0.23.3. The capture code is unchanged since the
last good release; the relay only sends when vars.POSTHOG_ENABLED is "1",
and Wrangler replaces every Worker var on deploy. The production config used
since 0.23.1 leaves the flag out, so relay analytics turned off silently while
the accounts app, whose flag is committed, kept reporting.

The production guard now requires POSTHOG_ENABLED to be "0" or "1", as it
already does for MCP_CONTROL_ENABLED, so the choice is always written down.
The example config sets it to "0" so self-hosters see the flag.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ScihqCEjAhjFfkvfSR3ZXN
@pstayets

Copy link
Copy Markdown
Contributor Author

Combined into #285, with the other open fixes and the two flaky CI checks fixed.

@pstayets pstayets closed this Sep 29, 2026
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.

2 participants