feat: finish PostHog analytics integration - #2
Draft
posthog-eu[bot] wants to merge 1 commit into
Draft
posthog-eu[bot] wants to merge 1 commit into
posthog-eu[bot] wants to merge 1 commit into
Conversation
Guard PostHog initialization behind both key and host, enable exception autocapture, and wire up capture calls across the content pipeline actions. Generated-By: PostHog Code Task-Id: 55b0b5a0-270b-42cd-92c2-bf10fd8c1e8e
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jeevesh2515
force-pushed
the
posthog/instrumentation-e014d3
branch
from
August 24, 2026 03:04
f00014b to
6718e7a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR finishes the PostHog analytics setup for the app (building on the
posthog-jsclient already added in 1a7dec0). It hardens initialization and wires up capture calls across the content-production workflow:src/main.tsx— only initializes PostHog when bothVITE_POSTHOG_KEYandVITE_POSTHOG_HOSTare present (previously fell back to a hardcoded host), enables exception autocapture (capture_exceptions), setsdefaults: '2026-05-30', and throws a dev-only error if the env vars are missing/misconfigured so it's caught before shipping.src/App.tsx— adds a guardedcapturehelper (no-ops if PostHog isn't configured) and instruments the operator workflow:manual_short_run_completed,script_generation_completed,video_production_completed,topic_created,topic_discovery_completed,topic_rejected,video_rerender_completed,analytics_sync_completed,upload_approved_for_publish,automation_toggled,youtube_connection_started,youtube_disconnected,script_judge_evaluated. All are personless browser events, each tagged withexecution_mode: 'api' | 'offline'depending on whether the app is running against the live API or in offline/demo mode..env.example— un-commentsVITE_POSTHOG_KEY/VITE_POSTHOG_HOSTand updates the host tohttps://eu.i.posthog.com.package-lock.json— lockfile metadata refresh (no dependency changes).Insights and dashboards created
How to verify
.env, or in Vercel once deployed).npm run dev:all) and click through a few actions — discover a topic, generate a script, produce a video.$exceptionevents if an error is thrown.Environment variables (action needed before PostHog works in production)
Based on
vercel.json(which proxies/apitohttps://shorty-production-8fc1.up.railway.app), the frontend is deployed on Vercel and the API on Railway. Vercel keeps its settings in the Vercel dashboard rather than in a file in this repository, so I could not set these up automatically.Environment variables are named settings your hosting provider passes to the app when it builds — they let the app know things (like the PostHog project token below) without hardcoding them in the code. PostHog will not receive any data from production until these two are set on the Vercel project:
VITE_POSTHOG_KEYphc_z8J9DsNxvyF4ZqcgLW7mqMq8LMSkrN2iEutYnE5txbuwVITE_POSTHOG_HOSThttps://eu.i.posthog.comTo set them via the dashboard:
Setting environment variables via a local CLI
Alternatively, from a machine with the Vercel CLI linked to this project:
Then trigger a redeploy for the new variables to take effect.
Created with PostHog Code