Anomaly Insights, Slack, Discord & Webhooks
How TrimStats detects traffic drops, spikes, conversion dips, and friction surges against rolling 7-day baselines and delivers alerts and digests to email, Slack, Discord, and HMAC-signed webhooks.
How do TrimStats automated anomaly insights, Slack/Discord alerts, and digests work?
Every 6 hours, TrimStats compares rolling 7 completed UTC days against the prior 7 completed UTC days across site traffic, top 40 pages, top 30 referrers, up to 10 goals, and UI friction routes. Alerts and weekly or monthly digests deliver to email, Slack, Discord, or HMAC-signed JSON webhooks, capped by Valkey to 1 anomaly notification per UTC day per rule.
Why rolling 7-day baseline detection avoids false alarms
Naive analytics alerts compare today against yesterday and page you every Saturday morning because B2B traffic naturally dips on weekends. They also trigger false alarms on tiny samples where dropping from 4 visitors to 2 looks like a -50% crash.
TrimStats solves both problems by comparing 7 completed UTC days (yesterday minus 6 through yesterday) against the preceding 7 completed UTC days (yesterday minus 14 through yesterday minus 8). Every full week contains the same mix of weekdays and weekend days, and every detector enforces a strict minimum sample-size guardrail.
+173.8% spike or +146.2% friction surge), which referrers or CSS selectors drove it, and the fastest next step to investigate.Active anomalies appear on the dedicated Insights page in your site sidebar with 14-day daily trends, contributing drivers, 30-day history, and actionable tips, and can trigger automated alerts to email, Slack, Discord, or generic HTTPS webhooks.
Anomaly types & statistical guardrails
Every anomaly detector enforces a minimum sample-size guardrail to prevent false alarms on low-traffic pages or goals:
| Anomaly type | Dimension | Minimum baseline / volume | Trigger threshold |
|---|---|---|---|
traffic_drop | Site-wide | >= 50 baseline visitors | <= -25% change |
traffic_spike | Site-wide | >= 50 baseline visitors | >= +60% change |
traffic_drop / traffic_spike | Top 40 pages (pathname) | >= 40 baseline visitors | <= -30% drop or >= +80% spike |
traffic_drop / traffic_spike | Top 30 referrers | >= 30 baseline visitors | <= -30% drop or >= +80% spike |
conversion_dip | Configured goals (up to 10) | >= 15 baseline goal conversions & >= 50 site visitors | <= -25% drop in conversion rate |
friction_spike | Pages with rage/dead clicks | >= 15 friction clicks in current 7d | >= +50% increase vs baseline |
Supported delivery channels
Configure up to 20 alert rules per site under Site settings -> Anomaly Alerts & Scheduled Digests. Each rule picks a delivery channel, anomaly types to subscribe to, and an optional weekly (Mondays 08:00 UTC) or monthly (1st of month 08:00 UTC) summary digest.
| Channel | Target format | Payload & security |
|---|---|---|
| Verified workspace member email | HTML + plain-text alert and digest emails delivered via Resend. | |
| Slack | https://hooks.slack.com/services/... | Slack Block Kit cards with escaped mrkdwn (prevents @channel/@here injection). URL stored AES-256-GCM encrypted and masked after saving. |
| Discord | https://discord.com/api/webhooks/... (optional ?thread_id=) | Discord embeds with allowed_mentions: { parse: [] } so untrusted paths cannot ping roles. URL stored AES-256-GCM encrypted and masked after saving. |
| Webhook | Any public HTTPS endpoint on port 443 | Versioned JSON signed with X-TrimStats-Signature HMAC-SHA256. DNS is resolved to public IPs only with IP-pinned HTTPS connections, no redirects, and a 5-second timeout. |
Setting up & testing alert rules
- 1
Open Site settings -> Alerts
Navigate to Site settings -> Anomaly Alerts & Scheduled Digests and choose Email, Slack, Discord, or Webhook.
- 2
Enter target, anomaly types, and digest cadence
Paste the verified member email or HTTPS webhook URL, pick an optional display label, toggle which anomaly types should fire, and select Weekly digest + alerts, Monthly digest + alerts, or Anomaly alerts only.
- 3
Copy the signing secret (generic webhooks only)
Generic webhooks automatically generate a 32-byte
whsec_...signing secret that is displayed once immediately after saving. Store it in your receiver environment to verify incoming requests. - 4
Click Test to verify delivery
Click Test next to any rule to send an immediate test ping from the collector (rate-limited to 1 per 10 seconds per rule and 5 per 5 minutes per site). Scheduled anomaly checks run every 6 hours and deduplicate deliveries in Redis to at most one anomaly notification per UTC day per rule.
Verifying generic webhook signatures
Every generic webhook delivery is sent as an application/json POST request with replay-protected HMAC-SHA256 headers:
| Header | Example / Format | Purpose |
|---|---|---|
X-TrimStats-Event | anomaly.detected, digest.weekly, digest.monthly, webhook.test | Event type for routing inside your handler. |
X-TrimStats-Delivery | UUID v4 | Unique delivery identifier for idempotent processing. |
X-TrimStats-Timestamp | Unix seconds (1764576000) | Timestamp used when computing the signature. |
X-TrimStats-Signature | t=<unix>,v1=<hex_hmac_sha256> | Hex HMAC-SHA256 over ${timestamp}.${rawBody} using your whsec_... secret. |
1import crypto from 'node:crypto';23export function verifyTrimStatsAlertWebhook(4 rawBody: string,5 signatureHeader: string | undefined,6 secret: string,7 toleranceSec = 300,8): boolean {9 if (!signatureHeader || !secret) return false;1011 let timestamp = 0;12 let signature = '';13 for (const part of signatureHeader.split(',')) {14 const [k, v] = part.trim().split('=');15 if (k === 't' && v) timestamp = Number(v);16 if (k === 'v1' && v) signature = v;17 }1819 const nowSec = Math.floor(Date.now() / 1000);20 if (!timestamp || !signature || Math.abs(nowSec - timestamp) > toleranceSec) {21 return false;22 }2324 const expected = crypto25 .createHmac('sha256', secret)26 .update(`${timestamp}.${rawBody}`, 'utf8')27 .digest('hex');2829 const a = Buffer.from(signature, 'utf8');30 const b = Buffer.from(expected, 'utf8');31 return a.length === b.length && crypto.timingSafeEqual(a, b);32}1{2 "version": "2026-12-01",3 "event": "anomaly.detected",4 "deliveryId": "c1f8a92e-4f10-4b22-9f41-6b8a7e0e1234",5 "sentAt": "2026-12-01T06:00:00.000Z",6 "site": { "id": "...", "name": "Acme SaaS", "domain": "acme.com" },7 "dashboardUrl": "https://www.trimstats.com/sites/.../insights",8 "data": {9 "count": 1,10 "anomalies": [11 {12 "type": "traffic_drop",13 "dimension": "pathname",14 "dimensionValue": "/pricing",15 "baselineValue": 1200,16 "currentValue": 780,17 "pctChange": -35,18 "sampleSize": 1980,19 "detectedAt": "2026-12-01T06:00:00.000Z"20 }21 ]22 }23}Generic webhooks require HTTPS on port 443 and must resolve exclusively to public IP addresses. TrimStats pins the validated IP per connection, disables HTTP redirects, enforces a 5-second timeout, and treats any non-2xx status as a failed delivery.
Common technical questions
What exact percentage thresholds trigger TrimStats anomaly insights?
Which alert channels and digest cadences can I configure per site?
How do I verify generic TrimStats alert webhook signatures?
Related guides
Learn how conversion goals and conversion rate work, configure exact/wildcard paths or custom events, and monitor automatic conversion dips.
Learn what rage clicks, dead clicks, and deep scroll reach reveal about broken UX, and pinpoint exact offending CSS selectors with zero session-replay bloat.
Learn how visitors, sessions, bounce rate, and active dwell time work, plus how TrimStats calculates core KPIs and click-to-filter segments.