Add Mixpanel + PostHog analytics to docs#44
Conversation
- Add PostHog native integration to docs.yml (project: docs.smallest.ai) - Add analytics.js custom script for Mixpanel SDK + event tracking - Tracks: page views, code copies, search, product toggle, CTAs, SDK installs, feedback, scroll depth, API playground usage - PostHog SDK loaded by Fern natively; analytics.js only loads Mixpanel - Both platforms receive identical events via dual-send pattern
EntelligenceAI PR SummaryAdds dual-platform analytics instrumentation (Mixpanel + PostHog) to the Fern documentation site.
Confidence Score: 2/5 - Changes NeededNot safe to merge — Key Findings:
Files requiring special attention
|
| call2_args = arguments; | ||
| call2 = [c].concat(Array.prototype.slice.call(call2_args, 0)); | ||
| a.push([e, call2]); |
There was a problem hiding this comment.
Correctness: call2_args and call2 are assigned without var/let/const declarations inside a file that opens with "use strict" — this throws a ReferenceError at runtime whenever get_group is invoked, silently breaking any Mixpanel group tracking call.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In fern/docs/assets/scripts/analytics.js, lines 57-58, inside the `b()` function within `a.get_group`, the variables `call2_args` and `call2` are assigned without any `var`/`let`/`const` declaration. Because the outer IIFE file uses `"use strict"`, assigning to undeclared variables throws a ReferenceError at runtime. Fix by prepending `var` to both assignments: `var call2_args = arguments;` and `var call2 = [c].concat(...)`. The same variables are referenced on lines 58-59 (the push call) so no further changes are needed there once they are properly declared.
Summary
docs.ymlanalytics config (project: docs.smallest.ai)analytics.jscustom script that loads Mixpanel SDK and sets up custom event trackingEvents Tracked
docs_page_vieweddocs_code_copieddocs_search_performeddocs_search_result_clickeddocs_nav_clickeddocs_product_toggleddocs_signup_clickeddocs_console_link_clickeddocs_sdk_install_copieddocs_feedback_submitteddocs_scroll_depthdocs_api_playground_usedFiles Changed
fern/docs.yml— Addedanalytics:(PostHog) +js:(analytics.js) sectionsfern/docs/assets/scripts/analytics.js— New: Mixpanel loader + all event trackersHow to Test
fern generate --docscdn.mxpnl.com(Mixpanel) andus.i.posthog.com(PostHog)PostHog Dashboards (already created)