# Sentry Error Tracking {#sentry-error-tracking}


Configure Sentry for error monitoring and performance tracking.


## Setup {#setup}



### 1. Create Sentry Project {#1-create-sentry-project}


1. Go to [sentry.io](https://sentry.io)
2. Create a new project for Node.js
3. Copy the DSN


### 2. Configure {#2-configure}


```env
SENTRY_DSN=https://xxx@sentry.io/12345
SENTRY_TRACES_SAMPLE_RATE=0.1
SENTRY_ENVIRONMENT=production
```


### 3. Integration {#3-integration}


Sentry is automatically configured in the API when `SENTRY_DSN` is set. It captures:

- Unhandled exceptions
- HTTP 5xx responses
- Slow database queries
- Performance traces


## Features {#features}


| Feature          | Description                    |
| ---------------- | ------------------------------ |
| Error grouping   | Similar errors grouped         |
| Stack traces     | Full stack traces with context |
| Breadcrumbs      | Events leading to error        |
| Performance      | Transaction tracing            |
| Release tracking | Errors by release version      |
| Alerts           | Email/Slack notifications      |


## Custom Error Context {#custom-error-context}


```typescript
import * as Sentry from "@sentry/node";

Sentry.setUser({ id: userId, email: userEmail });
Sentry.setTag("tenant", tenantId);
Sentry.captureMessage("Custom event");
```


## Source Maps {#source-maps}


Upload source maps for readable stack traces:

```bash
sentry-cli releases files $VERSION upload-sourcemaps ./dist
```


## Related Pages {#related-pages}


- [Error Handling Architecture](https://sourcey-gauzy.pages.dev/architecture/error-handling-architecture/index.md) — error patterns
- [Prometheus Metrics](https://sourcey-gauzy.pages.dev/observability/prometheus-metrics/index.md) — metrics monitoring
- [Grafana Dashboards](https://sourcey-gauzy.pages.dev/observability/grafana-dashboards/index.md) — visualization
