integration-javascript_node — Claude Code skill: PostHog for Node.js
integration-javascript_node adds PostHog analytics to a server-side Node.js app with posthog-node: events in route handlers, user identification, exception tracking.
MIT 131 installs ★ 80 updated 2026-10-24
npx skills add PostHog/skills --skill integration-javascript_node -a claude-codeWhat integration-javascript_node does
The skill walks an agent through wiring PostHog into a server-side Node.js app. Four step files carry the work in order: basic-integration-1.0-begin.md, basic-integration-1.1-edit.md, basic-integration-1.2-revise.md, basic-integration-1.3-conclude.md. Reference notes on Node.js, the posthog-node SDK and user identification sit next to an example project the agent is told to imitate.
Expect edits like these: a posthog.capture() call in every route that writes data, captureException(err, distinctId) inside the framework's error handler, and enableExceptionAutocapture: true in the client options. Keys stay in environment variables. Code that already integrates something else is left alone.
Server code needs posthog-node. The browser package posthog-js won't do the job here. Long-running servers batch events on their own, so flush settings should stay untouched. CLIs, scripts and serverless functions get flushAt: 1 and flushInterval: 0 so events go out right away. A reverse proxy is not part of this setup — ad blockers only matter for client-side JavaScript. Build and type checks are read from package.json scripts.
What it helps with
- track signup and login events in a Node.js backend
- send exceptions from an Express or Fastify error handler to PostHog
- keep PostHog API keys out of the source code
- flush events from a short-lived CLI or serverless function
- correlate browser sessions with server-side events through headers
Example prompts for the agent
- Add PostHog to our Express server with
posthog-nodeand read the key from an environment variable. - Turn on
enableExceptionAutocaptureand putcaptureExceptionin the error handler. - Run the skill steps, starting at
basic-integration-1.0-begin.mdand finishing withbasic-integration-1.3-conclude.md.
How to install integration-javascript_node
1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a claude-code2Manually: put the files in place
~/.claude/skills/integration-javascript_node/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/integration-javascript_node/
1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a codex2Manually: put the files in place
.agents/skills/integration-javascript_node/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a cursor2Manually: put the files in place
.cursor/skills/integration-javascript_node/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install PostHog/skills skills/posthog/all/skills/integration-javascript_node2Manually: put the files in place
.github/skills/integration-javascript_node/SKILL.md1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a gemini-cli2Platform CLI
gemini skills install https://github.com/PostHog/skills --path skills/posthog/all/skills/integration-javascript_nodeManually: put the files in place
.devin/skills/integration-javascript_node/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about integration-javascript_node
How do I install integration-javascript_node in Claude Code?
Run npx skills add PostHog/skills --skill integration-javascript_node -a claude-code. The skill lands in ~/.claude/skills/integration-javascript_node/SKILL.md.
What does integration-javascript_node do?
It connects PostHog analytics to a server-side Node.js app: events in route handlers, identification on login and signup, and exception capture in the error handler.
Do I need a reverse proxy for server-side PostHog?
No. A proxy helps browser JavaScript get around ad blockers. Node.js servers send events directly.
Source text
SKILL.md · MIT
---
name: integration-javascript_node
description: PostHog integration for server-side Node.js applications using posthog-node
metadata:
author: PostHog
version: 1.9.4
---
# PostHog integration for JavaScript Node
This skill helps you add PostHog analytics to JavaScript Node applications.
## Workflow
Follow these steps in order to complete the integration:
1. `basic-integration-1.0-begin.md` - PostHog Setup - Begin ← **Start here**
2. `basic-integration-1.1-edit.md` - PostHog Setup - Edit
3. `basic-integration-1.2-revise.md` - PostHog Setup - Revise
4. `basic-integration-1.3-conclude.md` - PostHog Setup - Conclusion
## Reference files
- `references/node.md` - Node.js - docs
- `references/posthog-node.md` - PostHog Node.js SDK
- `references/identify-users.md` - Identify users - docs
- `references/basic-integration-1.0-begin.md` - PostHog setup - begin
- `references/basic-integration-1.1-edit.md` - PostHog setup - edit
- `references/basic-integration-1.2-revise.md` - PostHog setup - revise
- `references/basic-integration-1.3-conclude.md` - PostHog setup - conclusion
The example project shows the target implementation pattern. Consult the documentation for API details.
## Key principles
- **Environment variables**: Always use environment variables for PostHog keys. Never hardcode them.
- **Minimal changes**: Add PostHog code alongside existing integrations. Don't replace or restructure existing code.
- **Match the example**: Your implementation should follow the example project's patterns as closely as possible.
## Framework guidelines
- posthog-node is the Node.js server-side SDK package name – do NOT use posthog-js on the server
- Include enableExceptionAutocapture: true in the PostHog constructor options
- Add posthog.capture() calls in route handlers for meaningful user actions – every route that creates, updates, or deletes data should track an event with contextual properties
- Add posthog.captureException(err, distinctId) in the application's error handler (e.g., Express error middleware, Fastify setErrorHandler, Koa app.on('error'))
- In long-running servers, the SDK batches events automatically – do NOT set flushAt or flushInterval unless you have a specific reason to
- For short-lived processes (scripts, CLIs, serverless), set flushAt to 1 and flushInterval to 0 to send events immediately
- Reverse proxy is NOT needed for server-side Node.js – only client-side JavaScript needs a proxy to avoid ad blockers
- Remember that source code is available in the node_modules directory
- Check package.json for type checking or build scripts to validate changes
## Identifying users
Identify users during login and signup events. Refer to the example code and documentation for the correct identify pattern for this framework. If both frontend and backend code exist, pass the client-side session and distinct ID using `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` headers to maintain correlation.
## Error tracking
Add PostHog error tracking to relevant files, particularly around critical user flows and API boundaries.
© PostHog · MIT · PostHog/skills