Skip to content
Back to skills

Posthog

ASecurity

PostHog provides complete product analytics. The Node.js SDK allows you to capture events, identify users, and evaluate feature flags from your backend.

  • 13 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 5, 2026
ai-agentsbashnodeawstestingapibackendsecurityperformance

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 7 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add ashish7802/awesome-api-skills --skill posthog --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Posthog?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Posthog
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ashish7802-posthog/badge)](https://www.skillsdirectory.com/skills/ashish7802-posthog)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# PostHog API Skill

## Quick Start
PostHog provides complete product analytics. The Node.js SDK allows you to capture events, identify users, and evaluate feature flags from your backend.

```bash
npm install posthog-node
```

## Common Workflows
### User Identification and Events
When a user signs up, call `posthog.identify()` to map their internal DB ID to their analytics profile. Then, call `posthog.capture()` for key backend actions (e.g., 'Subscription Created').

## Production Patterns
### Feature Flag Evaluation
Evaluate feature flags on the backend before returning UI states. Use `posthog.getFeatureFlag(flagKey, distinctId)` to gate beta features securely. Local evaluation can dramatically speed up flag checks without hitting the API.

## Error Recovery
The `posthog-node` SDK batches events and flushes them asynchronously. Ensure you call `await posthog.shutdown()` during your application's graceful shutdown sequence, or you will lose pending events.

## Security Notes
Do not log PII (Passwords, SSNs, raw financial data) to PostHog. Scrub payloads before capture. Utilize PostHog's proxy capabilities to bypass ad-blockers securely.

## Performance Considerations
Backend feature flag evaluation requires a network round-trip unless you configure Local Evaluation, which periodically syncs flag definitions and evaluates them entirely in-memory.

## Testing Guidance
Disable PostHog in unit tests by passing a dummy API key and setting `enable: false` in the client configuration, or mock the `posthog` module entirely.

## Troubleshooting
If events are missing in the dashboard, verify that you are flushing the queue before the serverless function (e.g., AWS Lambda) terminates. Standard asynchronous event capture will be killed instantly in Lambda.

## References
- [PostHog Node SDK](https://posthog.com/docs/libraries/node)

## Related Skills
- [Mixpanel](/skills/mixpanel)

## Why use this skill
Use this when your agent works with **posthog** — structured patterns beat pasted docs and prevent common hallucinations.

## AI pitfalls
- Using outdated SDK or API versions from training data
- Inventing environment variable names
- Omitting error handling and retry logic

## Production checklist
- [ ] Secrets in environment variables, not source code
- [ ] Error handling and logging in place
- [ ] Rate limits and timeouts configured

## Related skills
- [`mixpanel`](../mixpanel/SKILL.md) — related to

---
> **Last Verified:** 2026-07-02

Files in this skill

  • SKILL.md2.4 KB
  • examples/basic.go40 B
  • examples/basic.py97 B
  • examples/capture.ts217 B
  • examples/flag.ts72 B
  • prompts/lambda-flush.md152 B
  • tests/skill.test.ts25 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.