posthog-deploy-integration
Deploy PostHog integrations to Vercel, Fly.io, and Cloud Run platforms. Use when deploying PostHog-powered applications to production, configuring platform-specific secrets, or setting up deployment pipelines. Trigger with phrases like "deploy posthog", "posthog Vercel", "posthog production deploy", "posthog Cloud Run", "posthog Fly.io".
- License 许可
- MIT
- 最近更新
- 2026-03-20
- Stars
- ★ 4
- Forks
- 0
01 前言 Front Matter
- name
- posthog-deploy-integration
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- description
- Deploy PostHog integrations to Vercel, Fly.io, and Cloud Run platforms. Use when deploying PostHog-powered applications to production, configuring platform-specific secrets, or setting up deployment pipelines. Trigger with phrases like "deploy posthog", "posthog Vercel", "posthog production deploy", "posthog Cloud Run", "posthog Fly.io".
- allowed-tools
- Read, Write, Edit, Bash(vercel:*), Bash(fly:*), Bash(gcloud:*)
- compatible-with
- claude-code, codex, openclaw
03 SKILL.md 正文
PostHog Deploy Integration
Overview
Deploy PostHog analytics integration to production. Covers client-side snippet deployment, server-side event capture with posthog-node, reverse proxy setup to avoid ad blockers, and self-hosted PostHog deployment using Docker.
Prerequisites
- PostHog project API key (starts with
phc_) - PostHog personal API key for server-side operations
- Platform CLI installed (vercel, docker, or gcloud)
Instructions
Step 1: Client-Side Integration
// lib/posthog.ts
import posthog from "posthog-js";
export function initPostHog() {
if (typeof window !== "undefined") {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://us.i.posthog.com",
capture_pageview: false, // Manual pageview tracking
loaded: (posthog) => {
if (process.env.NODE_ENV === "development") posthog.debug();
},
});
}
}
Step 2: Server-Side Event Capture
// lib/posthog-server.ts
import { PostHog } from "posthog-node";
const posthog = new PostHog(process.env.POSTHOG_API_KEY!, {
host: process.env.POSTHOG_HOST || "https://us.i.posthog.com",
});
export async function trackServerEvent(
distinctId: string,
event: string,
properties?: Record<string, any>
) {
posthog.capture({ distinctId, event, properties });
await posthog.flush();
}
Step 3: Reverse Proxy (Avoid Ad Blockers)
// next.config.js - Proxy PostHog through your domain
module.exports = {
async rewrites() {
return [
{
source: "/ingest/static/:path*",
destination: "https://us-assets.i.posthog.com/static/:path*",
},
{
source: "/ingest/:path*",
destination: "https://us.i.posthog.com/:path*",
},
];
},
};
Step 4: Self-Hosted Docker Deployment
set -euo pipefail
# Deploy PostHog self-hosted
git clone https://github.com/PostHog/posthog.git
cd posthog
docker compose -f docker-compose.hobby.yml up -d
# Your PostHog instance at http://localhost:8000
Step 5: Vercel Deployment
vercel env add NEXT_PUBLIC_POSTHOG_KEY production
vercel env add NEXT_PUBLIC_POSTHOG_HOST production
vercel env add POSTHOG_API_KEY production # Server-side key
vercel --prod
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Events not appearing | Wrong API key | Verify phc_ project key |
| Ad blocker blocking | Direct PostHog requests | Set up reverse proxy |
| Self-hosted slow | Under-provisioned | Increase Docker resources |
| Missing server events | Not flushing | Call posthog.flush() in serverless |
Examples
Basic usage: Apply posthog deploy integration to a standard project setup with default configuration options.
Advanced scenario: Customize posthog deploy integration for production environments with multiple constraints and team-specific requirements.
Resources
Next Steps
For webhook handling, see posthog-webhooks-events.
Output
- Configuration files or code changes applied to the project
- Validation report confirming correct implementation
- Summary of changes made and their rationale
04 同仓库更多 Skills
azure-apim-architecture
Analyzes and explains Azure API Management architecture decisions for enterprise API marketplace implementations using VNet Internal mode, Front Door, hybrid authentication, and multi-environment strategies. Use when discussing APIM component selection, network topology, cost optimization, or comparing alternatives like workspaces vs instances, VNet Internal vs External mode, or Front Door vs Application Gateway.
apiops-deployment
Guides deployment of Azure API Management infrastructure using Infrastructure as Code (Bicep/Terraform), CI/CD pipelines (GitHub Actions/Azure DevOps), and APIOps workflows. Use when deploying APIM, creating pipelines, or implementing dev→test→prod promotion strategies.
apim-policy-authoring
Creates production-ready Azure API Management policy XML for authentication (OAuth 2.0, JWT validation, subscription keys), rate limiting, CORS configuration, error handling, and API transformations. Use when implementing API security, access control, or request/response processing logic.
api-security-review
Reviews Azure API Management configurations for security vulnerabilities, OWASP API Security Top 10 compliance, VNet Internal mode validation, Private Link verification, and Azure Security Benchmark alignment. Use when performing security audits, pre-deployment validation, or compliance reviews.
jira-cli
Interact with Jira from the command line to create, list, view, edit, and transition issues, manage sprints and epics, and perform common Jira workflows. Use when the user asks about Jira tasks, tickets, issues, sprints, or needs to manage project work items.
calculator
Performs arbitrary-precision arithmetic calculations including addition, subtraction, multiplication, division, and exponents. Use when the user asks to calculate, compute, or evaluate math expressions, or when precise decimal arithmetic is needed to avoid floating-point errors.