Skip to content

Commit 07b4c76

Browse files
authored
doc(astro): Update Readme (#9333)
Update the Astro readme with up-to-date installation instructions and links to our docs.
1 parent a6c44af commit 07b4c76

File tree

1 file changed

+21
-81
lines changed

1 file changed

+21
-81
lines changed

packages/astro/README.md

Lines changed: 21 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010
[![npm dm](https://img.shields.io/npm/dm/@sentry/astro.svg)](https://www.npmjs.com/package/@sentry/astro)
1111
[![npm dt](https://img.shields.io/npm/dt/@sentry/astro.svg)](https://www.npmjs.com/package/@sentry/astro)
1212

13-
<!--
14-
TODO: Add links once we have official docs
1513
## Links
1614

1715
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/astro/)
18-
-->
1916

2017
## Experimental Note
2118

@@ -28,98 +25,41 @@ This package is a wrapper around `@sentry/node` for the server and `@sentry/brow
2825

2926
## Installation and Setup
3027

31-
### 1. Registering the Sentry Astro integration:
28+
Install the Sentry Astro SDK with the `astro` CLI:
3229

33-
Add the `sentryAstro` integration to your `astro.config.mjs` file:
34-
35-
```javascript
36-
import { sentryAstro } from "@sentry/astro/integration";
37-
38-
export default defineConfig({
39-
// Rest of your Astro project config
40-
integrations: [
41-
sentryAstro({
42-
dsn: '__DSN__',
43-
}),
44-
],
45-
})
30+
```bash
31+
npx astro add @sentry/astro
4632
```
4733

48-
This is the easiest way to configure Sentry in an Astro project.
49-
You can pass a few additional options to `sentryAstro` but the SDK comes preconfigured in an opinionated way.
50-
If you want to fully customize your SDK setup, you can do so, too:
34+
Complete the setup by adding your DSN and source maps upload configuration:
5135

52-
### 2. [Optional] Uploading Source Maps
53-
54-
To upload source maps to Sentry, simply add the `project` and `authToken` options to `sentryAstro`:
55-
56-
```js
57-
// astro.config.mjs
58-
import { sentryAstro } from "@sentry/astro/integration";
36+
```javascript
37+
import { defineConfig } from "astro/config";
38+
import sentry from "@sentry/astro";
5939

6040
export default defineConfig({
61-
// Rest of your Astro project config
6241
integrations: [
63-
sentryAstro({
64-
dsn: '__DSN__',
65-
project: 'your-project-slug',
66-
authToken: import.meta.env('SENTRY_AUTH_TOKEN'),
42+
sentry({
43+
dsn: "__DSN__",
44+
sourceMapsUploadOptions: {
45+
project: "your-sentry-project-slug",
46+
authToken: process.env.SENTRY_AUTH_TOKEN,
47+
},
6748
}),
6849
],
69-
})
50+
});
7051
```
7152

72-
You can also define these values as environment variables in e.g. a `.env` file
73-
or in you CI configuration:
53+
Follow [this guide](https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens) to create an auth token and add it to your environment variables:
7454

75-
```sh
76-
SENTRY_PROJECT="your-project"
55+
```bash
7756
SENTRY_AUTH_TOKEN="your-token"
7857
```
7958

80-
Follow [this guide](https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens) to create an auth token.
81-
82-
### 3. [Optional] Advanced Configuration
83-
84-
To fully customize and configure Sentry in an Astro project, follow step 1 and in addition,
85-
add a `sentry.client.config.(js|ts)` and `sentry.server.config(js|ts)` file to the root directory of your project.
86-
Inside these files, you can call `Sentry.init()` and use the full range of Sentry options.
87-
88-
Configuring the client SDK:
89-
90-
```js
91-
// sentry.client.config.ts or sentry.server.config.ts
92-
import * as Sentry from "@sentry/astro";
93-
94-
Sentry.init({
95-
dsn: "__DSN__",
96-
beforeSend(event) {
97-
console.log("Sending event on the client");
98-
return event;
99-
},
100-
tracesSampler: () => {/* ... */}
101-
});
102-
```
103-
104-
**Important**: Once you created a sentry config file, the SDK options passed to `sentryAstro` will be ignored for the respective runtime. You can also only define create of the two files.
105-
106-
#### 3.1 Custom file location
59+
## Configuration
10760

108-
If you want to move the `sentry.*.config` files to another location,
109-
you can specify the file path, relative to the project root, in `sentryAstro`:
61+
Check out our docs for configuring your SDK setup:
11062

111-
```js
112-
// astro.config.mjs
113-
import { sentryAstro } from "@sentry/astro/integration";
114-
115-
export default defineConfig({
116-
// Rest of your Astro project config
117-
integrations: [
118-
sentryAstro({
119-
dsn: '__DSN__',
120-
clientInitPath: '.config/sentry.client.init.js',
121-
serverInitPath: '.config/sentry.server.init.js',
122-
}),
123-
],
124-
})
125-
```
63+
* [Getting Started](https://docs.sentry.io/platforms/javascript/guides/astro/)
64+
* [Manual Setup and Configuration](https://docs.sentry.io/platforms/javascript/guides/astro/manual-setup/)
65+
* [Source Maps Upload](https://docs.sentry.io/platforms/javascript/guides/astro/sourcemaps/)

0 commit comments

Comments
 (0)