Prompt
How do I get stack traces, breadcrumbs, and session replay for production bugs?
Latest observation
Use an error-monitoring tool that’s built for production, such as Sentry, Datadog, Bugsnag, or Rollbar. The basic setup is:
1) Capture stack traces
Install the SDK in your app and initialize it with your project DSN/API key.
It automatically records uncaught exceptions and can also log handled errors.
2) Add breadcrumbs
Breadcrumbs are the “trail” of events leading up to a bug, like:
- button clicks
- network requests
- navigation changes
- console logs
Most SDKs collect many of these automatically, and you can add custom ones for important app actions.
3) Enable session replay
Turn on replay/session recording so you can see what the user did before the error. Usually you configure:
- sampling rate for sessions
- sampling rate for sessions with errors
- privacy masking for inputs, tokens, and sensitive text
4) Make sure source maps are uploaded
For frontend apps, upload source maps in CI/CD so stack traces are readable in production.
5) Add context
Attach:
- user ID
- release version
- environment
- feature flags
- app state
That makes bugs much easier to reproduce.
Typical Sentry example
import * as Sentry from "@sentry/browser";
Sentry.init({
dsn: "YOUR_DSN",
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration(),
],
tracesSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
Then add custom breadcrumbs:
Sentry.addBreadcrumb({
category: "ui.click",
message: "User clicked Save",
level: "info",
});
And capture errors:
try {
// risky code
} catch (err) {
Sentry.captureException(err);
}
Important privacy note
If you use replay, be careful to:
- mask passwords, credit cards, tokens
- avoid recording sensitive form fields
- review consent requirements for your users
If you want, I can give you a step-by-step setup for React, Next.js, Node, Python, or mobile.