PostHog
Receive PostHog metric alerts as signals in Loop.
PostHog Integration
The PostHog integration receives webhook alerts for metric changes, creating signals in Loop with severity derived from the magnitude of the change.
Endpoint
POST /api/signals/posthogAuthentication
PostHog webhooks use a shared secret sent as a header value. Loop compares the header directly against the configured secret.
- Header:
X-PostHog-Secret - Format: Raw secret string (no HMAC computation)
- Comparison: Timing-safe (
crypto.timingSafeEqual)
If the header is missing or the secret does not match, Loop responds with 401.
This is simpler than the HMAC-based verification used by GitHub and Sentry. PostHog sends the secret itself in the header rather than a computed signature.
Severity Mapping
Loop derives severity from the absolute percentage change in the metric:
| Change Magnitude | Severity |
|---|---|
| >= 50% | critical |
| >= 25% | high |
| >= 10% | medium |
| < 10% | low |
What Gets Created
Each webhook delivery creates:
- A signal record with
source: "posthog", typemetric_change, severity, and full payload. - A linked issue with type
signal, statustriage, and a title likePostHog: page_load_time 35% (last_7_days).
The issue title includes the metric name, percentage change, and timeframe.
Setup
Generate a webhook secret
Create a random secret string:
openssl rand -hex 32Save this value for both PostHog and your Loop environment.
Set the environment variable
Add the secret to your Loop API environment:
POSTHOG_WEBHOOK_SECRET=your_generated_secret_hereThis variable must be available to the Loop API process at runtime.
Configure the webhook in PostHog
- In PostHog, go to Data pipelines > Destinations (or Project Settings > Webhooks depending on your PostHog version).
- Add a new webhook destination.
- Set the URL to your Loop endpoint:
https://your-loop-api.example.com/api/signals/posthog - Configure the webhook to include the header
X-PostHog-Secretwith the same secret value you used forPOSTHOG_WEBHOOK_SECRET. - Select which actions or alerts should trigger the webhook (e.g., metric threshold alerts).
- Save and enable the destination.
Verify the connection
Trigger a test event in PostHog or use a tool like curl to send a test payload:
curl -X POST https://your-loop-api.example.com/api/signals/posthog \
-H "Content-Type: application/json" \
-H "X-PostHog-Secret: your_generated_secret_here" \
-d '{"name": "test_metric", "value": 15, "timeframe": "last_7_days"}'Check your Loop instance for a new signal with source posthog.
Example Payload
Loop reads the following fields from the PostHog webhook payload:
event.nameorname-- the metric name, used in the issue titlevalue-- the percentage change, used for severity calculation and the issue titletimeframe-- the time period, used in the issue title (defaults torecent)