Guides

How to set up error tracking — and hear about bugs before your users leave

Illustration: a signal lamp above an app window, a report flying to the developer

The uncomfortable truth: users don't report bugs. They close the tab and don't come back. You never find out — your numbers are just quietly worse than they could have been.

And here's the specific trap with web apps. The error happened in the user's browser, which means the message about it stayed there too, in their console, where you can't look. Your server has no idea anything broke.

This is one evening of work to fix. You add an error tracker — a service that catches crashes across all your users and mails you a report with the exact line of code.

1. Create a Sentry project

Go to sentry.io, sign up, create an organisation and a project. The free tier is plenty for a side project: there's a monthly event limit, and you don't pay anything to start.

When creating the project, pick your platform — Next.js, React, Node.js, Python. That choice decides which instructions you get.

Alternatives if Sentry doesn't fit: Bugsnag, Rollbar, or GlitchTip (open source, self-hostable). I'll show Sentry below — it's the most common one, and the principle is identical everywhere.

2. Install the SDK with one command

Next.js has a wizard that does the chores for you:

npx @sentry/wizard@latest -i nextjs

It opens a browser to log you in, asks which features to enable (keep Error Monitoring, the rest is taste), then writes the config files, updates next.config, adds a global-error.tsx handler and creates a test page.

Other stacks have their own flag: -i react, -i sveltekit, -i nuxt. If your framework isn't on the list, install the package by hand and call Sentry.init({ dsn: ... }) at your app's entry point. That's ten lines.

Run git status to see what the wizard added — it's worth knowing what landed in your project.

3. Fire a test error

Don't take the install on faith. The wizard creates a /sentry-example-page with a button that breaks the app on purpose. Run the project, open it, click the button.

No wizard? Throw one by hand:

throw new Error("Sentry test error");

Within seconds the event should show up under Issues. If it doesn't, it's almost always the DSN: either it isn't set, or it didn't get picked up on the side you tested (client vs server).

One detail worth knowing: errors triggered from the browser console are deliberately ignored by Sentry. Test with the button or with code, not by typing throw into devtools.

4. Put the keys in environment variables

Sentry gives you two different values, and mixing them up is dangerous.

  • The DSN is a public address that reports are sent to. It ends up in your client code — that's normal and by design.
  • The auth token is secret and only needed at build time to upload source maps. It belongs in .env.local and in your host's environment variables, and it must never be committed.

If you haven't worked through this before, here's the piece on environment variables and the one on storing keys safely.

5. Turn on source maps, or the stack trace is useless

In production your code is minified: variable names become a, b, c, everything is squashed into one line. An error in that shape reads as “broke at t.js:1:48219”. Worthless.

Source maps are the map between the built bundle and your original source. With them, Sentry shows you your file, your line, your surrounding code. The wizard configures the upload itself — all you need is SENTRY_AUTH_TOKEN in your host's environment variables, otherwise the upload silently does nothing at build time.

6. Set up alerts so you never open the dashboard

The most common failure: errors pile up and nobody goes to look at them.

In project settings → Alerts, enable a notification for new issues. Email at minimum. Better: Slack or a Telegram channel you already check daily.

A good starting rule: alert on every new error, not on every repeat. That way you learn about a breakage the moment it appears, without drowning in noise from the same bug.

7. Filter out the noise

Within a day you'll see events that have nothing to do with you: browser extensions, analytics scripts, network drops from users on the subway.

You filter those in Sentry.init — ignoreErrors with a list of typical messages, and denyUrls for third-party scripts. A busier project also wants tracesSampleRate to control what share of performance traces actually gets sent.

What you end up with

A user hits a bug — and a minute later you get an email: the error text, a stack trace pointing at your line of code, their browser and OS, and the trail of actions that led there. That's often enough to find the cause without asking the user anything.

From there it's just reading the report itself, which has its own walkthrough: how to read an error message.

Does this replace logs?

No, they solve different problems. Logs are a continuous feed: what happened and in what order. An error tracker only catches crashes, but groups them, counts them and adds context. You go looking through logs once you know where to look; an error alert comes to you.

Is it worth it with ten users?

Especially then. With ten users, every unnoticed breakage costs you ten percent of your audience. And the setup takes fifteen minutes, exactly once.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →