integration-javascript_node — скилл для Claude Code: PostHog в Node.js
Скилл integration-javascript_node ставит PostHog в серверное Node.js-приложение через posthog-node: события в роутах, идентификация пользователей, отлов исключений.
MIT 131 установок ★ 80 обновлён 2026-10-24
npx skills add PostHog/skills --skill integration-javascript_node -a claude-codeЧто делает integration-javascript_node
Скилл проводит агента через подключение PostHog к серверному Node.js. Работа идёт по четырём файлам шагов: basic-integration-1.0-begin.md, дальше basic-integration-1.1-edit.md, basic-integration-1.2-revise.md и basic-integration-1.3-conclude.md. Рядом лежат справочники по Node.js, SDK posthog-node, идентификации пользователей, и пример проекта, с которого агент копирует структуру.
Что появляется в коде: posthog.capture() в роутах, которые создают, меняют или удаляют данные, captureException(err, distinctId) в обработчике ошибок (Express, Fastify, Koa), enableExceptionAutocapture: true в конструкторе. Ключи берутся из переменных окружения, существующие интеграции остаются на месте.
Пакет для сервера — posthog-node; с posthog-js на бэкенде ничего не выйдет, это браузерный SDK. В долгоживущем сервере события копятся пачками сами, трогать flushAt и flushInterval не нужно. Короткоживущим скриптам и serverless скилл выставляет flushAt: 1 и flushInterval: 0, иначе события не успеют уйти. Сборку и типы агент проверяет по скриптам в package.json.
Какие задачи решает
- добавить
posthog.capture()в роуты, которые пишут данные - отправлять исключения из обработчика ошибок Express или Fastify в PostHog
- держать ключи PostHog в переменных окружения, а не в коде
- настроить отправку событий из короткоживущего скрипта или CLI
- связать клиентскую сессию с серверными событиями по заголовкам
Примеры запросов агенту
- Добавь PostHog в наш Express-сервер через
posthog-node, ключ возьми из переменной окружения. - Включи
enableExceptionAutocaptureи поставьcaptureExceptionв обработчик ошибок. - Пройди шаги скилла: начни с
basic-integration-1.0-begin.mdи доведи доbasic-integration-1.3-conclude.md.
Как установить integration-javascript_node
1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a claude-code2Вручную: положить файлы
~/.claude/skills/integration-javascript_node/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/integration-javascript_node/
1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a codex2Вручную: положить файлы
.agents/skills/integration-javascript_node/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a cursor2Вручную: положить файлы
.cursor/skills/integration-javascript_node/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install PostHog/skills skills/posthog/all/skills/integration-javascript_node2Вручную: положить файлы
.github/skills/integration-javascript_node/SKILL.md1Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a gemini-cli2Командой платформы
gemini skills install https://github.com/PostHog/skills --path skills/posthog/all/skills/integration-javascript_nodeВручную: положить файлы
.devin/skills/integration-javascript_node/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_node -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы об integration-javascript_node
Как установить integration-javascript_node в Claude Code?
Выполните npx skills add PostHog/skills --skill integration-javascript_node -a claude-code. Скилл окажется в ~/.claude/skills/integration-javascript_node/SKILL.md.
Что делает integration-javascript_node?
Подключает аналитику PostHog к серверному Node.js-приложению: события в роутах, идентификация на логине и регистрации, отлов исключений в обработчике ошибок.
Как связать события фронтенда и бэкенда?
Если в проекте есть обе части, скилл велит передавать X-POSTHOG-DISTINCT-ID и X-POSTHOG-SESSION-ID заголовками с клиента на сервер. Так события попадают в одну сессию.
Исходный текст
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