# Sentry

> Connect Sentry for error tracking, structured logs, and deploy regression analysis

Rocketgraph connects to your Sentry org to pull error events and structured logs for ML analysis. It reads from Sentry — no Sentry SDK changes needed.

## What Rocketgraph uses from Sentry

- **Error events** — Exceptions captured by `captureException`, with stack traces and tags
- **Structured logs** — Log lines sent via `Sentry.logger.info/warn/error()` (the logs dataset)
- **Issues** — Grouped error patterns with `firstSeen`/`lastSeen` for deploy correlation
- **Environments** — Filter analysis to production, staging, or any environment

## Setup

### 1. Create a Sentry Auth Token

1. Go to [sentry.io](https://sentry.io) → click your avatar → **User Settings**
2. Under **Auth Tokens**, click **Create New Token**
3. Select scopes: `project:read` and `event:read`
4. Copy the token (starts with `sntrys_`)

> **Warning:** Use a **User Auth Token**, not an Organization token. Org tokens cannot read events or structured logs.

### 2. Connect in Rocketgraph

Go to [rocketgraph.app/sentry](https://rocketgraph.app/sentry) and enter:

- **Organization slug** — from your Sentry URL: `sentry.io/organizations/{org-slug}/`
- **Project slug(s)** — one or more Sentry projects (e.g. `my-api`, `my-web`, `my-cli`)
- **Auth token** — the token from step 1

### 3. Select environment

After connecting, use the environment selector on the Sentry page to choose which environment to analyze (e.g. `production`, `railway`). This filters out development noise.

## Deploy diffs

When you expand a deploy on the Sentry page, Rocketgraph fetches logs from before and after the deploy and shows:

- **New errors** — Error templates that didn't exist before the deploy
- **Disappeared patterns** — Errors that were fixed, or info logs that stopped appearing
- **Behavior changes** — Templates with unusual frequency or error rate shifts
- **Volume diff** — Total log, error, and warning counts before vs. after

Click **Run RCA** on any deploy to trigger a Claude-powered root cause analysis.

## Multi-project support

Connect multiple Sentry projects (e.g. `lore-api`, `lore-web`, `lore-cli`). The cross-service analysis scans all connected projects and identifies causal chains across services.

## Events vs. structured logs

Sentry has two data streams. Rocketgraph fetches both and merges them:

| Source | What it captures | API |
|---|---|---|
| **Events** | Exceptions from `captureException`, unhandled rejections | Project events endpoint |
| **Structured logs** | Explicit `Sentry.logger.info/warn/error()` calls | Discover dataset=logs |

Some errors only exist in events (exceptions), while some only exist in structured logs (explicit log calls). Rocketgraph merges both for complete coverage.
