Analytics for Sentry
Sentry tells you what broke. BetterMeter tells you who was affected. Together, they answer the full question: did that error spike happen because traffic surged, because an AI crawler hammered a fragile endpoint, or because a deploy went wrong?
The error-traffic correlation workflow
When Sentry fires an alert, query BetterMeter for the same time window. If traffic spiked simultaneously, the errors are likely load-related. If traffic is flat but errors are up, the root cause is a code or infrastructure change.
// Sentry webhook → correlate with BetterMeter traffic
export async function handleSentryAlert(alert: SentryAlert) {
const timestamp = new Date(alert.triggeredAt);
const oneHourBefore = new Date(timestamp.getTime() - 60 * 60 * 1000);
// Fetch BetterMeter traffic for the same window
const res = await fetch(
`https://bettermeter.com/api/v1/timeseries?` +
`site=your-domain.com&start=${oneHourBefore.toISOString()}&end=${timestamp.toISOString()}`,
{ headers: { Authorization: "Bearer bm_your_api_key" } }
);
const traffic = await res.json();
const avgVisitors = traffic.data.reduce((s, d) => s + d.visitors, 0) / traffic.data.length;
const latestVisitors = traffic.data.at(-1)?.visitors ?? 0;
return {
errorCount: alert.count,
trafficCorrelation: latestVisitors > avgVisitors * 1.5
? "Traffic spike detected — errors likely load-related"
: "Traffic normal — errors likely code-related",
aiTraffic: traffic.aiVisitorPercent,
topReferrers: traffic.topReferrers?.slice(0, 3),
};
}Why Sentry alone isn't enough
- 01No traffic context — Sentry shows error counts but not whether a traffic surge caused them. BetterMeter provides the traffic timeline.
- 02Bot-induced errors — AI crawlers hitting undocumented routes can trigger 500s. BetterMeter identifies exactly which bots are responsible.
- 03Referrer attribution — When errors spike, see which traffic sources sent the users who encountered them.
- 04Privacy-first — Sentry captures user sessions and IPs. BetterMeter's traffic data uses no cookies and stores no PII.
Complementary, not competing
Sentry is the best error tracker. BetterMeter is the best privacy-first analytics platform. Use both: Sentry for what broke, BetterMeter for who was there and why traffic behaved the way it did. The combination gives you full incident context without sacrificing user privacy.