Advanced
Sampling
Reduce event volume by sampling sessions. Reliable uses session-level sampling — when a session loses the dice roll, it sends nothing for the entire session.
Why session-level sampling#
Per-event sampling (sending 50% of errors, 50% of vitals) is broken — you end up with errors whose breadcrumbs were dropped, replays for events that aren't there, and incoherent timelines.
Reliable uses session-level sampling instead. Each session does one dice roll on init: if it loses, the SDK goes fully dark for the rest of the session. No errors, no vitals, no requests, no replay. If it wins, every event is sent. The result: every session you do see is complete, with no missing context.
Configuring the rate#
init({
publicKey: 'pk_live_rl_...',
sampleRate: 25, // 25% of sessions are recorded
});sampleRate is a percentage from 0 to 100. The default is 100 (every session captured).
When to sample down#
- High-traffic apps — millions of sessions per day means cost. 10–25% is usually plenty for trend signal.
- Anonymous traffic — bots and scrapers don't need full coverage; sample more aggressively.
- Low-value pages — marketing sites, status pages, anything where a missed error doesn't hurt anyone. Sample to taste.
When to keep it at 100#
- Logged-in dashboards — every user matters; you want every error.
- Checkout flows / payment — a failed sample is a lost dollar. Capture every session.
- Low-traffic apps — at < 10k sessions/month, sampling is a false economy.
Dynamic sampling per environment#
const sampleRate = process.env.NODE_ENV === 'production'
? Number(process.env.NEXT_PUBLIC_RELIABLE_SAMPLE_RATE ?? 100)
: 100;
init({
publicKey: process.env.NEXT_PUBLIC_RELIABLE_KEY!,
sampleRate,
});User-tier-based sampling#
For SaaS apps, capture every paid user but sample free-tier traffic. The trick: roll the dice yourself based on user info, then either init or skip:
const isPaidUser = currentUser?.plan && currentUser.plan !== 'free';
const sampleRate = isPaidUser ? 100 : 10;
init({
publicKey: 'pk_live_rl_...',
sampleRate,
});The sample decision is sticky
sessionStorage. Reloads inside the same tab keep the same decision so navigation across pages stays coherent.