How to Set Up Error Tracking

Without error tracking, you find out about bugs from annoyed customers, or you never find out at all. Setting it up takes less than an hour, and the useful part is what you do afterwards.

How to Set Up Error Tracking — Troiana insight cover

In short

To set up error tracking, choose a tool such as Sentry, install its SDK in both your front end and back end, upload source maps so stack traces are readable, tag each release, and scrub personal data before anything is sent. Then alert only on new errors or sudden spikes. Trigger a test error to confirm it works, and review new issues weekly.

Why you need it

Most users don't report bugs. They leave. Server logs miss errors that happen only in the browser, and even when an error is logged, it's easy to overlook. Error tracking captures failures automatically, groups them into issues, and shows you how many people they affect.

It's also different to other monitoring. Uptime checks tell you if the site is reachable. Error tracking tells you that the checkout button crashes on Safari.

Step 1: Choose a tool

Common options include Sentry, Bugsnag, Rollbar and Honeybadger. GlitchTip is an open-source option you can self-host, and it's compatible with Sentry's SDKs. Sentry can be self-hosted as well, although it's a substantial system to run.

For most small teams, a hosted service with a free or low-cost tier is the sensible start. Check current limits and how many errors you're expecting. An error storm can use up your whole quota.

Step 2: Install the SDK

The details vary by framework, so follow the current docs. In a plain browser app using Sentry, it looks like this:

import * as Sentry from "@sentry/browser";

Sentry.init({
  dsn: "YOUR_PROJECT_DSN",
  environment: "production",
  release: "my-app@1.4.2",
  sendDefaultPii: false,
});

Add it to the back end as well, because many of the worst errors happen on the server. Frameworks like Next.js have dedicated setups, often with a wizard. Set up the front end and back end as separate projects if you've got different teams.

The DSN is designed to be public in browser code, so it isn't a secret key. Other tokens, such as those used to upload source maps, are secrets. See how to handle secrets and API keys.

Step 3: Confirm that it works

Trigger a test error on purpose in a non-production environment:

setTimeout(() => {
  throw new Error("Test error from setup");
}, 0);

Check that it arrives, with the right environment and release. Then remove the code. If it doesn't appear, check ad blockers, your Content Security Policy and whether initialisation runs early enough.

Step 4: Make stack traces readable

Production JavaScript is minified, so an error may point to a.js:1:29341. Source maps translate this back to your original code. Most tools have a build plugin that uploads them for you.

  • Upload source maps during your build
  • Use a matching release name
  • Avoid publishing them publicly, unless you're happy to expose your source
  • Test using a real production error

This step is often skipped, and it's the difference between a useful report and a puzzle.

Without source maps
TypeError
at a (a.js:1:20449)
With them
TypeError
at getTotal
(src/checkout/total.ts:42)
An invented error. Same crash, and only the second tells you where to start.

Step 5: Tag releases and environments

Set release from your commit or version, as part of your deployment pipeline. This tells you which deployment introduced a bug, and whether a fix actually worked. Keep staging separate from production, so test noise doesn't hide real problems.

Step 6: Remove personal data

Error reports can capture far more than you'd expect: URLs with tokens, form values, headers, and user details.

  • Keep default personal data collection off unless there's a clear need
  • Use a filter such as beforeSend to strip sensitive fields
  • Never log passwords, payment details or health data
  • Scrub tokens from URLs
  • Use an internal user ID, rather than an email address
  • Check where the data is stored, and how long it's kept
  • Mention it in your privacy notice, if required, and be careful with session replay

Tools have server-side scrubbing rules too, which are useful as a second layer.

Step 7: Add useful context

Include what you'll need to debug the problem:

  • User ID, plan or account type, without personal details
  • Feature flag values
  • Key actions before the error, known as breadcrumbs
  • Request IDs that link to your server logs

Good context can save hours. Don't send everything you've got, as it costs money and adds privacy risk.

Step 8: Set alerts carefully

If every error sends a message to everyone, then people will soon ignore them all. Start with:

  • New issue types in production, sent to a team channel
  • Sudden spikes in errors
  • Errors in critical journeys, such as signup, login and payment, with higher priority
  • Regressions: resolved issues that have come back

Avoid alerts for one-off errors. Route them to whoever owns the code.

Step 9: Deal with noise

Browsers produce a lot of junk: extensions, old devices, network failures and third-party scripts. Filter out what you can't act on, such as errors from extension URLs, or set up your tool to ignore them. Be careful, because broad filters can hide real bugs. Mark issues as ignored with a condition, instead of deleting them.

Step 10: Build a routine

A tool with 4,000 unresolved issues isn't helping anybody. A simple workflow:

  1. Each week, look at new and increasing issues.
  2. Prioritise by impact: users affected, and how important the journey is.
  3. Assign an owner, and create a ticket for anything real.
  4. Resolve it in the next release, so that you'll know if it comes back.
  5. Ignore what isn't worth fixing, with a reason.

Check the error dashboard immediately after each deployment. For AI features, you'll need extra tooling as well, because a wrong answer doesn't throw an error. See how to log and debug AI features.

Vibe-coded apps

Generated apps rarely include any of this by default. It's one of the highest-value additions you can make, and an agent can often install it for you. Check the personal-data settings yourself, and make sure the test error arrives. See how to test a vibe-coded app.

If you'd like help setting up monitoring that your team will really use, book a call.

Common questions

What is error tracking?

It's a system that automatically records errors from your app, groups similar ones, and shows you the details, including a stack trace and how many users were affected. It helps you to find problems which users never report and that logs can bury.

Is Sentry free?

Sentry has offered a free tier for small use, plus paid plans for more. Its code can also be self-hosted, although that takes effort. Check the current limits on its pricing page, as errors can use up a quota quickly.

What are source maps?

They're files that map minified production code back to your original source. Without them, stack traces are hard to read. Upload them to your error tracker during the build, and avoid publishing them openly unless you're happy to expose your code.

Do error trackers collect personal data?

They can, including through URLs, form values, headers and user details. Keep default collection off, filter sensitive fields before sending, and use internal IDs. Check retention and where the data is stored, and cover it in your privacy notice where needed.

Have something worth building right?