Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sentry Integration as a Recipe #8450

Merged
merged 20 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7038f3a
Simplest form of Sentry Monitoring
smeubank May 24, 2024
468cbb5
Merge branch 'withastro:main' into main
smeubank Jun 5, 2024
fe431b5
Merge branch 'withastro:main' into main
smeubank Jun 6, 2024
d682845
Add link to official announcement
smeubank Jun 6, 2024
99be8f7
Merge branch 'main' of https://github.com/smeubank/docs
smeubank Jun 6, 2024
aed2160
Merge branch 'main' into main
sarah11918 Jun 11, 2024
3cad522
Update src/content/docs/en/guides/monitor/sentry.mdx
smeubank Jun 14, 2024
f05b667
Update src/content/docs/en/guides/monitor/sentry.mdx
smeubank Jun 14, 2024
dd15855
Update src/content/docs/en/guides/monitor/sentry.mdx
smeubank Jun 14, 2024
7f1380a
Update src/content/docs/en/guides/monitor/sentry.mdx
smeubank Jun 14, 2024
bde30e9
Update src/content/docs/en/guides/monitor/sentry.mdx
smeubank Jun 14, 2024
3ca809a
Update src/content/docs/en/guides/monitor/sentry.mdx
smeubank Jun 14, 2024
bec6f9b
Apply suggestions from code review
sarah11918 Jun 14, 2024
e13430e
move to backend, add logo entry
sarah11918 Jun 14, 2024
8fd301b
Update src/content/docs/en/guides/backend/sentry.mdx
sarah11918 Jun 14, 2024
dce8c2c
add comments about monitoring on the main backend services page
sarah11918 Jun 14, 2024
651c29e
Merge branch 'main' of https://github.com/smeubank/docs
sarah11918 Jun 14, 2024
86b4f0d
Merge branch 'main' into main
sarah11918 Jun 14, 2024
ad44e9e
Apply suggestions from Kevin's walk through tech check
sarah11918 Jun 17, 2024
ba8776b
Merge branch 'main' into main
sarah11918 Jun 19, 2024
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
1 change: 1 addition & 0 deletions public/logos/sentry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/content/docs/en/guides/backend.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ i18nReady: true
---
import BackendGuidesNav from '~/components/BackendGuidesNav.astro';

**Ready to add features like authentication, storage or data to your Astro project?** Follow one of our guides to integrate a backend service.
**Ready to add features like authentication, monitoring, storage, or data to your Astro project?** Follow one of our guides to integrate a backend service.

:::tip
Find [community-maintained integrations](https://astro.build/integrations/) for adding popular features to your project in our integrations directory.
Expand All @@ -29,3 +29,4 @@ You might want to consider a backend service if your project has complex server-
- user-uploaded asset storage
- API generation
- realtime communication
- application monitoring
71 changes: 71 additions & 0 deletions src/content/docs/en/guides/backend/sentry.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: Monitor your Astro Site with Sentry
description: How to monitor your Astro site with Sentry
type: backend
service: Sentry
stub: false
i18nReady: true
---
import ReadMore from '~/components/ReadMore.astro';
import { Steps } from '@astrojs/starlight/components';

[Sentry](https://sentry.io) offers a comprehensive application monitoring and error tracking service designed to help developers identify, diagnose, and resolve issues in real-time.

Read more on our blog about [Astro's partnership with Sentry](https://astro.build/blog/sentry-official-monitoring-partner/) and Sentry's Spotlight dev toolbar app that brings a rich debug overlay into your Astro development environment. Spotlight shows errors, traces, and important context right in your browser during local development.

Sentry's Astro SDK enables automatic reporting of errors and tracing data in your Astro application.

## Project Configuration

A full list of prerequisites can be found in [the Sentry guide for Astro](https://docs.sentry.io/platforms/javascript/guides/astro/#prerequisites).

## Install

Sentry captures data by using an SDK within your application’s runtime.

Install the SDK by running the following command for the package manager of your choice in the Astro CLI:

```bash
npx astro add @sentry/astro
```
The astro CLI installs the SDK package and adds the Sentry integration to your `astro.config.mjs` file.

## Configure

To configure the Sentry integration, you need to provide the following credentials in your `astro.config.mjs` file.

1. **Client key (DSN)** - You can find the DSN in your Sentry project settings under *Client keys (DSN)*.
2. **Project name** - You can find the project name in your Sentry project settings under *General settings*.
3. **Auth token** - You can create an auth token in your Sentry organization settings under *Auth tokens*.

:::note
If you are creating a new Sentry project, select Astro as your platform to get all the necessary information to configure the SDK.
:::

```js title="astro.config.mjs" ins={2, 6-12}
import {defineConfig} from 'astro/config';
import sentry from '@sentry/astro';

export default defineConfig({
integrations: [
sentry({
dsn: 'https://[email protected]/0',
sourceMapsUploadOptions: {
project: 'example-project',
authToken: process.env.SENTRY_AUTH_TOKEN,
},
}),
],
});
```
Once you've configured your `sourceMapsUploadOptions` and added your `dsn`, the SDK will automatically capture and send errors and performance events to Sentry.

## Test your setup

Add the following `<button>` element to one of your `.astro` pages. This will allow you to manually trigger an error so you can test the error reporting process.

```astro title="src/pages/index.astro"
<button onclick="throw new Error('This is a test error')">Throw test error</button>
```

To view and resolve the recorded error, log into [sentry.io](https://sentry.io/) and open your project.
1 change: 1 addition & 0 deletions src/data/logos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const logos = LogoCheck({
zerops: { file: 'zerops.svg', padding: '.2em' },
apostrophecms: { file: 'apostrophecms.svg', padding: '.15em .15em' },
db: { file: 'db.svg', padding: '.1em' },
sentry: { file: 'sentry.svg', padding: '.1em' },
umbraco: { file: 'umbraco.svg', padding: '.05em' },
});

Expand Down
Loading