Add error tracking to your app
Most users who hit an error just leave. Error tracking tells you what broke, for whom and since when, before the reviews do.
Key takeaways
- An error tracker records crashes with stack traces, browser, page and release, and groups repeats into issues. Sentry is the common choice; GlitchTip, Bugsnag and Rollbar work similarly.
- A Sentry DSN is designed to be public. Auth tokens for uploads or API access are secrets and never go in client code.
- Scrub personal data before sending, tag every event with release and environment, and alert on new issues rather than every event.
To add error tracking to your app, create a project in an error tracking service such as Sentry, install its SDK in your frontend with the project's DSN, and initialize it as early as possible so it catches unhandled errors and rejected promises. Tag each event with the release and environment, strip personal data, and set an alert for new issues. Within a day you will see errors you never knew about, grouped by cause, with the browser, page and steps that led to each one.
Why logs are not enough
Your backend already keeps logs: in Startbase Cloud, Backend → Logs searches API, auth, database, storage and function events, and the Fix with AI button sends a failing event straight to the agent. That covers the server. It does not see the white screen a Safari user got when a date parsed differently, or the button that throws on Android because of an old WebView. Those errors happen in the browser, and without a tracker they vanish when the tab closes. An error tracker is the browser half of your logs.
What you need
- An account with Sentry (it has a free tier with a monthly event quota; check its pricing page for current limits) or an alternative. GlitchTip is open source and accepts Sentry's SDKs, which is handy if you want to self-host.
- A project per app and platform: one for the web app, one for the Expo app if you have both. Each gets its own DSN.
- The DSN in the client environment. A DSN only allows sending events to your project, and Sentry documents it as safe to expose, so it goes in the workspace `.env` as a client variable such as `VITE_SENTRY_DSN`, not in Backend → Secrets.
- Any auth token in Secrets or build settings only. Tokens for uploading source maps or reading issues through the API can read or change your Sentry data. They never get a `VITE_` or `EXPO_PUBLIC_` name.
A setup that stays useful
Initialize early and tag everything
Initialize the SDK in the entry file (`src/main.tsx` in a Vite React app) before rendering. Set `environment` to `production` only on your published domain and `preview` everywhere else, so test noise never mixes with real users. Set `release` to a version or build id that changes on every publish; it is what lets you say 'this started with Tuesday's release' and see whether a fix worked.
Wrap the app in an error boundary
A React error boundary catches rendering crashes, reports them, and shows a friendly fallback ('Something went wrong. Reload, or go back home.') instead of a blank page. Put one around the whole app and smaller ones around risky widgets like a chart or an embedded editor, so one broken panel does not take down the page.
Add context, not personal data
Attach the user's internal id and plan so you can tell 'one user, 400 times' from '400 users, once each', but not their email or name. Keep `sendDefaultPii` off, and add a `beforeSend` hook that removes emails, tokens and query strings from URLs and messages. If you enable session replay, keep its default text masking and input blocking on: replays of a checkout form should never show what people typed.
Sample performance, not errors
Send every error (they are what you are here for), but sample performance traces. A `tracesSampleRate` of 0.1 (10 percent) is a reasonable starting value for a small app; lower it as traffic grows so tracing does not eat your event quota.
Turning errors into fixes
- 01Alert on new issues and regressions, not every event. Route alerts to email or a team channel (see Slack notifications for keeping a channel readable).
- 02Ignore what you cannot fix. Browser extension errors, `ResizeObserver loop` warnings and network failures from flaky connections can be filtered by message or by `allowUrls` set to your own domain.
- 03Read the breadcrumbs. The clicks, route changes and network calls before the crash usually point straight at the cause.
- 04Hand it to the agent. Paste the issue's message, stack trace and breadcrumbs into chat with what the user was doing. Startbase also lists Sentry among its MCP connectors, which give the agent tools to work with your Sentry data directly while it debugs. The bug-fixing guide covers how to describe a bug so the fix sticks.
- 05Resolve in the release that fixes it. If the issue comes back in a later release, the tracker marks it as a regression and alerts you again.
Paste-ready brief
Add Sentry error tracking to my web app. The DSN is in the workspace .env as VITE_SENTRY_DSN. Initialize Sentry in main.tsx before render with environment set to production only on my published domains and preview elsewhere, and release set to the current build id. Wrap the app in an error boundary with a friendly fallback that offers Reload and Home, and add smaller boundaries around the dashboard chart and the editor. Attach user id and plan, never email or name. Keep sendDefaultPii off and add a beforeSend that strips query strings, emails and anything that looks like a token. Sample traces at 10 percent. Ignore errors from browser extensions and only accept errors from my own domains. Add a hidden test-error button visible only in preview.
Pitfalls
- Auth tokens in the bundle. The DSN is fine in the browser; an auth token is not. If one ever lands in client code, revoke it in Sentry immediately.
- Personal data in error messages. `throw new Error('No account for ana@example.com')` sends that email to a third party. Write error messages with ids, and scrub in `beforeSend` as a backstop.
- Quota burn from one bug. A loop that throws on every animation frame can use a month of events in an hour. Set rate limits or spike protection in the tracker and fix loud issues first.
- Mixing preview and production. Without environments, agent test runs look like user crashes and real problems hide in the noise.
- Swallowed errors. A `try { ... } catch {}` that hides a failure also hides it from the tracker. Report caught errors you recover from with a lower severity, so you still see how often they happen.
- Never looking. A tracker nobody opens is decoration. Ten minutes after each publish, and a weekly sweep of the top issues by users affected, keeps it worth having.
- Mobile builds. Expo apps use Sentry's React Native SDK with its own DSN; the same rules on tagging and scrubbing apply.
Frequently asked questions
Is it safe to put a Sentry DSN in frontend code?
Yes. A DSN only lets clients send events to your project, and Sentry documents it as safe to expose. Auth tokens are different: keep them out of client code entirely.
What is the difference between error tracking and logs?
Backend logs record what happens on your server. An error tracker captures crashes in users browsers and apps, with stack traces, device details and breadcrumbs, and groups repeats into issues with alerts.
Why are my Sentry stack traces unreadable?
The browser runs minified code. Without source maps uploaded for that release, the tracker can only show the minified file and position. Check that source maps are uploaded and the release names match.
Are there free alternatives to Sentry?
Sentry has a free tier with an event quota. GlitchTip is open source, accepts Sentry SDKs and can be self-hosted. Bugsnag and Rollbar are other hosted options; compare current plans on their sites.

