Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions packages/astro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ Install the Sentry Astro SDK with the `astro` CLI:
npx astro add @sentry/astro
```

Add your DSN and source maps upload configuration:
### Build-time Configuration

Register the Sentry integration in your `astro.config.mjs`. This is where you configure build-time options such as
source maps upload (`org`, `project`, `authToken`). Runtime SDK options (`dsn`, `environment`, `tracesSampleRate`, Replay
sample rates, and so on) belong in dedicated init files, not on `sentry()`.

```javascript
import { defineConfig } from 'astro/config';
Expand All @@ -40,11 +44,9 @@ import sentry from '@sentry/astro';
export default defineConfig({
integrations: [
sentry({
dsn: '__DSN__',
sourceMapsUploadOptions: {
project: 'your-sentry-project-slug',
authToken: process.env.SENTRY_AUTH_TOKEN,
},
org: 'your-org-slug',
project: 'your-sentry-project-slug',
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
});
Expand All @@ -57,6 +59,41 @@ token and add it to your environment variables:
SENTRY_AUTH_TOKEN="your-token"
```

### Runtime SDK Configuration

If you do not add `sentry.client.config.ts` or `sentry.server.config.ts`, Sentry still initializes with default options
and reads the DSN from `PUBLIC_SENTRY_DSN`. Add those files at the project root when you want to customize client or
server options, and pass them to `Sentry.init()`.

Set `PUBLIC_SENTRY_DSN` in your environment (for example in `.env`):

```bash
PUBLIC_SENTRY_DSN="__DSN__"
```

```javascript
// sentry.client.config.ts
import * as Sentry from '@sentry/astro';

Sentry.init({
dsn: '__DSN__',
tracesSampleRate: 1.0,
integrations: [Sentry.replayIntegration()],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
```

```javascript
// sentry.server.config.ts
import * as Sentry from '@sentry/astro';

Sentry.init({
dsn: '__DSN__',
tracesSampleRate: 1.0,
});
```

### Server Instrumentation

For Astro apps configured for (hybrid) Server Side Rendering (SSR), the Sentry integration will automatically add
Expand All @@ -79,7 +116,6 @@ import sentry from '@sentry/astro';
export default defineConfig({
integrations: [
sentry({
dsn: '__DSN__',
autoInstrumentation: {
requestHandler: false,
},
Expand Down
Loading