bootstrap-posthog
Installation
SKILL.md
Bootstrap PostHog Analytics
Add full PostHog analytics to a Phoenix 1.8 app — server-side event tracking, automatic page view plug, LiveView helpers, and client-side JS with user identification.
What Gets Created/Configured
- mix.exs —
{:posthog, "~> 0.2"}dependency - config/config.exs — PostHog config with
enabled: true(uses env vars for API key) - config/runtime.exs — Production PostHog config with
System.fetch_env! - lib//analytics/posthog.ex — Server-side PostHog wrapper module
- lib//analytics.ex — Analytics context with domain event helpers
- lib/_web/plugs/analytics.ex — Automatic page view tracking plug
- lib/_web/live/analytics_helpers.ex — LiveView tracking helpers
- root.html.heex — Client-side PostHog JS snippet with user identification
- assets/js/app.js —
phx:track-analyticsevent listener andTrackViewhook - .env.sample —
POSTHOG_API_KEYandPOSTHOG_API_URLentries