fix(website): bundle the PostHog init so analytics actually loads#5449
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…oads
define:vars made the script inline, where import("posthog-js") is a bare
specifier the browser cannot resolve — analytics never initialized. Bundled
client scripts get PUBLIC_* env statically replaced, so no value handoff is
needed.
Claude-Session: https://claude.ai/code/session_013Qe1Vf2yvj33BVd5W1q7HB
mmabrouk
force-pushed
the
fix/website-posthog-bundled-init
branch
from
July 22, 2026 15:19
c25ccc3 to
75af427
Compare
Contributor
Website previewPreview URL: https://pr-5449-agenta-website-preview.mahmoud-637.workers.dev Built from |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesPostHog client bootstrap
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
mmabrouk
enabled auto-merge
July 22, 2026 15:21
ashrafchowdury
approved these changes
Jul 22, 2026
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.
What
Analytics never initialized on the live site: the init script was emitted inline (via define:vars), and an inline script's
import("posthog-js")is a bare module specifier the browser cannot resolve — it threw an unhandled promise rejection on every page load. Zero events reached PostHog.Fix
Make the script a bundled Astro client script. Vite statically replaces the
PUBLIC_POSTHOG_KEY/PUBLIC_NOINDEXreads in bundled client code, so the inline value handoff was never needed. The host guard (agenta.ai / www only) and DNT handling are unchanged. Verified: the built Analytics chunk contains posthog-js and pages reference it; live event delivery confirmed on agenta.ai after a direct production deploy.https://claude.ai/code/session_013Qe1Vf2yvj33BVd5W1q7HB