Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/posthog-webhooks-events

@0d57af8
Run it yourself

Build and verify PostHog realtime webhook destinations and bounded private-API or HogQL event queries. Use when delivering selected events to another system or investigating event data. Trigger with "PostHog webhook", "PostHog destination", or "PostHog HogQL query".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/posthog-webhooks-events

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesimplementation.md

≈476 tokens on demand. Your agent reads this file only when SKILL.md points to it.

PostHog Webhooks & Events - Implementation

Webhook Receiver

import express from 'express';
import crypto from 'crypto';

const app = express();
app.use(express.raw({ type: 'application/json' }));

app.post('/webhooks/posthog', (req, res) => {
  const sig = req.headers['x-posthog-signature'] as string;
  const hmac = crypto
    .createHmac('sha256', process.env.POSTHOG_WEBHOOK_SECRET!)
    .update(req.body)
    .digest('hex');

  if (!crypto.timingSafeEqual(Buffer.from(hmac), Buffer.from(sig))) {
    return res.status(401).json({ error: 'Invalid signature' });
  }

  const event = JSON.parse(req.body.toString());
  console.log('Event:', event.event, '| User:', event.distinct_id);

  switch (event.event) {
    case '$feature_flag_called': handleFeatureFlag(event); break;
    case 'purchase': handlePurchase(event); break;
  }

  res.json({ received: true });
});

Capture Custom Events (Node.js)

import PostHog from 'posthog-node';

const ph = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
  host: 'https://us.i.posthog.com',
});

// Track event
ph.capture({
  distinctId: userId,
  event: 'subscription_upgraded',
  properties: { plan: 'pro', mrr: 99, source: 'settings_page' },
});

// Identify user
ph.identify({
  distinctId: userId,
  properties: { email, name, plan: 'pro' },
});

await ph.shutdown();

Batch Ingest via API

curl -X POST "$POSTHOG_PUBLIC_HOST/batch/" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "'"$NEXT_PUBLIC_POSTHOG_KEY"'",
    "batch": [
      {"event":"page_view","distinct_id":"user_1","properties":{"path":"/dashboard"}},
      {"event":"button_click","distinct_id":"user_1","properties":{"button":"upgrade"}}
    ]
  }'

Tons of Skills by Intent Solutions | jeremylongshore.com

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides templates and instructions for integrating PostHog webhooks and event querying. It follows security best practices by implementing webhook signature verification and using environment variables for sensitive credentials.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: MEDIUM · 1 issue

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago
What it can do
Reads files Edits files Runs commands
argument-hint
[project] [destination-or-query]
version
1.14.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
All 4 allowed tools
ReadWriteEditBash(curl:*)
Other metadata
tags
[
  "saas",
  "posthog",
  "webhooks"
]
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/posthog-webhooks-events