Start a fresh conversation. Replace the highlighted placeholders.
Use adding-analytics to integrate PostHog into [web application], implementing page-view tracking and [custom events]; provide guidance on environment variables and request explicit consent before enabling session replay or feature flags.
Required inputs
[web application]
[custom events]
User-approved starter prompt based on a pinned source version; check current skill requirements before running. Task evidence ↗
SKILL.md
name: adding-analyticsdescription: Add PostHog analytics to a web application, including event tracking, page views, feature flags, and session replay.
Add Analytics (PostHog)
Use this skill when the user asks to add analytics, event tracking, page views, feature flags, or session replay to a web application.
Steps
Detect the framework — check for next.config.*, vite.config.*, package.json scripts, or index.html to determine if this is Next.js, React (Vite/CRA), Vue, Svelte, or plain HTML.
Add custom events — if the user specifies events to track (e.g. sign-up, purchase), add posthog.capture("event_name", { ...properties }) calls in the relevant handlers.
Feature flags (optional) — if requested, show how to use posthog.isFeatureEnabled("flag-name") or the useFeatureFlagEnabled hook.
Session replay (optional) — enable by adding session_recording: { maskAllInputs: false } to the init config if requested.
Notes
Never hardcode API keys — always use environment variables.
Add posthog-js to the Content Security Policy if the project has one.
For monorepos, install in the package that renders the UI, not the root.
adding-analytics by spencerpauly · The Skill Leaderboard