| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This SDK is in Beta and not yet fully stable. If you have feedback or encounter any bugs, feel free to open an issue.
This package is a wrapper around @sentry/node for the server and @sentry/browser for the client side.
Install the Sentry Astro SDK with the astro CLI:
npx astro add @sentry/astroRegister 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().
import { defineConfig } from 'astro/config';
import sentry from '@sentry/astro';
export default defineConfig({
integrations: [
sentry({
org: 'your-org-slug',
project: 'your-sentry-project-slug',
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
});Follow this guide to create an auth token and add it to your environment variables:
SENTRY_AUTH_TOKEN="your-token"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):
PUBLIC_SENTRY_DSN="__DSN__"// 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,
});// sentry.server.config.ts
import * as Sentry from '@sentry/astro';
Sentry.init({
dsn: '__DSN__',
tracesSampleRate: 1.0,
});For Astro apps configured for (hybrid) Server Side Rendering (SSR), the Sentry integration will automatically add middleware to your server to instrument incoming requests.
The Sentry middleware enhances the data collected by Sentry on the server side by:
You can opt out of using the automatic sentry server instrumentation in your astro.config.mjs file:
import { defineConfig } from 'astro/config';
import sentry from '@sentry/astro';
export default defineConfig({
integrations: [
sentry({
autoInstrumentation: {
requestHandler: false,
},
}),
],
});If you opt out but still want the middleware, add it manually to your src/middleware.js file:
// src/middleware.js
import { sequence } from 'astro:middleware';
import * as Sentry from '@sentry/astro';
export const onRequest = sequence(
Sentry.handleRequest(),
// Add your other handlers after Sentry.handleRequest()
);Check out our docs for configuring your SDK setup:
| Back | FazBrowse Home | New Git URL |