fix(frontend): hardcode Simple Analytics for javachat.ai domain#23
fix(frontend): hardcode Simple Analytics for javachat.ai domain#23WilliamAGH merged 3 commits intomainfrom
Conversation
Simple Analytics traffic was being sent without an explicit production hostname, which can cause events to be attributed to the wrong site identity in the dashboard. This commit makes analytics wiring deterministic by hardcoding the canonical javachat.ai hostname in the injected script and noscript pixel. It also switches to explicit HTML tag descriptors for the injection logic and keeps analytics disabled in development mode to avoid polluting production data during local testing. - Replace dynamic script filename logic with a fixed production script URL - Inject data-hostname="javachat.ai" on the analytics script tag - Add a hostname-qualified noscript pixel URL for non-JS tracking - Move analytics injection into a dedicated buildSimpleAnalyticsTags() helper - Use Vite HtmlTagDescriptor typing for safer transform output
📝 WalkthroughSummary by CodeRabbit
WalkthroughExtracts and centralizes Simple Analytics tag generation in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73dfd9d57c
ℹ️ 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".
Prevent production analytics contamination from local preview, test, and staging usage by loading the Simple Analytics script only when the browser hostname is javachat.ai. Keep non-production mode builds analytics-free and remove hostname forcing from the noscript pixel so local/non-prod traffic cannot be attributed to production. - Add runtime guard script that injects analytics only on javachat.ai - Restrict build-time injection to mode=production only - Remove hardcoded hostname override from noscript fallback URL
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@frontend/vite.config.ts`:
- Line 24: Update the noscript pixel URL to include the hostname query parameter
so attribution works when referrers are missing: change the construction of the
noScriptImageUrl (currently using SIMPLE_ANALYTICS_QUEUE_ORIGIN) to append
?hostname=... using SIMPLE_ANALYTICS_HOSTNAME so it matches the script's
data-hostname behavior; ensure encoding if needed and that noScriptImageUrl is
used in the noscript img src.
Ensure Simple Analytics noscript tracking can be reliably attributed even when browsers omit referrer metadata by including the explicit hostname query parameter in the noscript.gif URL. This aligns the noscript fallback with the script tag hostname configuration. - Add hostname query parameter to noscript.gif URL - Keep runtime guard and production-only injection behavior unchanged
Simple Analytics traffic was being sent without an explicit production hostname, which can cause events to be attributed to the wrong site identity in the dashboard. This commit makes analytics wiring deterministic by hardcoding the canonical javachat.ai hostname in the injected script and noscript pixel.
It also switches to explicit HTML tag descriptors for the injection logic and keeps analytics disabled in development mode to avoid polluting production data during local testing.