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-guide.md

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

PostHog Webhooks & Events — Implementation Guide

Create an Action with Webhook (API)

# Create an Action via API that fires a webhook
curl -X POST "$POSTHOG_PRIVATE_HOST/api/projects/$POSTHOG_PROJECT_ID/actions/" \
  -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "User Signed Up",
    "steps": [{"event": "$autocapture", "url_matching": "signup/complete"}],
    "post_to_slack": false
  }'

Webhook Endpoint Implementation

import express from "express";

const app = express();
app.use(express.json());

app.post("/webhooks/posthog", async (req, res) => {
  const { event, person, properties, timestamp } = req.body;
  res.status(200).json({ received: true });

  await handlePostHogAction(event, person, properties);
});

async function handlePostHogAction(event: string, person: any, properties: any) {
  switch (event) {
    case "user_signed_up":
      await onUserSignup(person, properties);
      break;
    case "subscription_upgraded":
      await onSubscriptionUpgrade(person, properties);
      break;
    case "feature_activated":
      await onFeatureActivated(person, properties);
      break;
    default:
      console.log(`PostHog action: ${event}`);
  }
}

User Event Handlers

async function onUserSignup(person: any, properties: any) {
  const { distinct_id, $set } = person;
  const { $browser, $os, $referrer, utm_source } = properties;

  // Sync to CRM
  await crmClient.createContact({
    email: $set?.email,
    source: utm_source || $referrer,
    browser: $browser,
    os: $os,
    signupDate: new Date(),
  });

  // Send welcome Slack notification
  await slackNotify("#signups", {
    text: `New signup: ${$set?.email} via ${utm_source || "direct"}`,
  });
}

async function onSubscriptionUpgrade(person: any, properties: any) {
  const { plan, mrr, previous_plan } = properties;

  await revenueTracker.recordUpgrade({
    userId: person.distinct_id,
    fromPlan: previous_plan,
    toPlan: plan,
    mrr,
  });
}

Feature Adoption Tracking

async function onFeatureActivated(person: any, properties: any) {
  const { feature_name, $current_url } = properties;

  await analyticsDb.trackAdoption({
    userId: person.distinct_id,
    feature: feature_name,
    activatedAt: new Date(),
    context: $current_url,
  });
}

Query Events via API

async function queryRecentEvents(eventName: string, days: number = 7) {
  const response = await fetch(
    `${process.env.POSTHOG_PRIVATE_HOST}/api/projects/${process.env.POSTHOG_PROJECT_ID}/events/?event=${eventName}&after=-${days}d`,
    {
      headers: { "Authorization": `Bearer ${process.env.POSTHOG_PERSONAL_API_KEY}` },
    }
  );

  const data = await response.json();
  return data.results;
}

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