Skip to content

crm: internal dashboard on Railway (PostHog traffic with AI-referral channel, bench and harness health, Dune) - #2540

Merged
Flotapponnier merged 3 commits into
devfrom
feat/crm
Sep 20, 2026
Merged

Flotapponnier merged 3 commits into
devfrom
feat/crm

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

New crm/ app (own package, Next 16 standalone, Dockerfile), deployed as service ocb-crm in the Railway project Dashboard OpenChainBench with a /data volume: https://ocb-crm-production.up.railway.app (password in ~/.ocb-secrets/crm.env).

What it shows

  • Overview: visitors / pageviews / sessions 7 d vs previous 7 d, AI-referred visitors (ChatGPT, Perplexity, Claude, Gemini, Copilot, Mistral, Grok, …) and search-referred visitors with their share, 28 d daily series, 12 w weekly series with the AI share, channels, AI domains, sections.
  • Pages: sections w/w, biggest gains and losses, top 100 pages with a section filter, entry pages.
  • Audience: new vs returning, bounce, countries, devices, UTM, referring domains with their channel.
  • Data health: live / stale (> 24 h) / expired (> 7 d) benches per category, benches needing attention, Prometheus targets down, Dune credits and period end, a daily history line kept on the volume.

PostHog rate limit

PostHog allows 2400 query requests per hour per organisation. The app never queries in the request path: a refresh runs a fixed list of 11 HogQL queries sequentially and writes a snapshot; the scheduler runs it every 60 min (11/hour, ~0.5 %); the Refresh button has a 10 min cooldown; a local rolling-hour budget (300) is a second guard; a 429 or an exhausted budget stops the batch and the untouched sections keep their previous values.

Every HogQL query was run against a real PostHog project (syntax and shapes verified; the OCB project is not wired yet, see below). bun test (22 tests: channel and path classification, query scoping, budget, auth), tsc clean, next build clean, auth flow and redirects tested locally behind simulated proxy headers and on Railway.

Not in this PR

The OCB PostHog project is not receiving data: production's bundle calls posthog.init("[SENSITIVE]", …), i.e. NEXT_PUBLIC_POSTHOG_KEY on Vercel holds a redacted placeholder, and staging has no key at all. Until the real project token and a personal API key (query:read) are set, the traffic pages show "PostHog is not configured" and only data health is populated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HJgbZCqjR4nvCfcJSzofbw

florent-sys and others added 3 commits September 20, 2026 12:14
…eferral channel, bench and harness health, Dune credits); a fixed list of 11 HogQL queries per hourly refresh writes a snapshot the pages read, so the PostHog query budget stays under 1 % of the organisation's 2400/hour

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJgbZCqjR4nvCfcJSzofbw
…t (the root typecheck pulled it into the Vercel build) with its own CI job; sessions are random, signed with a separate secret, listed on the volume and revoked on logout, login limited per client; snapshot cache, refresh mutex and PostHog budget on globalThis with mtime re-reads (instrumentation and routes are separate bundler layers); history append-only and tolerant of a torn line; bench health from index.json so expired chain RPC benches show instead of vanishing; exact AI/search 7 d uniques in the KPIs; page and referrer rows ranked on either week so losses survive the LIMIT

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJgbZCqjR4nvCfcJSzofbw
… with a global cap and evicts idle keys; session writes serialised with unique temp files; one referrer rule for the SQL KPIs and the TS channel table (Google and Bing country hosts count as search on both sides); sitemap body parse guarded; Dune sub text keys on the recorded error

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJgbZCqjR4nvCfcJSzofbw
@Flotapponnier
Flotapponnier merged commit ccb0d5f into dev Sep 20, 2026
1 of 2 checks passed
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