Skip to content

Commit 9570e7f

Browse files
committed
add astro with sentry v7
1 parent d9b30b8 commit 9570e7f

24 files changed

+4152
-215
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
SENTRY_DSN=
2-
NEXT_PUBLIC_SENTRY_DSN=
2+
NEXT_PUBLIC_SENTRY_DSN=
3+
PUBLIC_SENTRY_DSN=

apps/astro/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# build output
2+
dist/
3+
4+
# generated types
5+
.astro/
6+
7+
# dependencies
8+
node_modules/
9+
10+
# logs
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# environment variables
17+
.env
18+
.env.production
19+
20+
# macOS-specific files
21+
.DS_Store
22+
23+
# jetbrains setting folder
24+
.idea/

apps/astro/astro.config.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { defineConfig } from 'astro/config';
2+
import node from '@astrojs/node';
3+
import sentry from '@sentry/astro';
4+
5+
// https://astro.build/config
6+
export default defineConfig({
7+
output: 'hybrid',
8+
adapter: node({
9+
mode: 'standalone',
10+
}),
11+
integrations: [
12+
sentry({
13+
dsn: import.meta.env.PUBLIC_SENTRY_DSN,
14+
}),
15+
],
16+
});

apps/astro/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "astro-test-application",
3+
"type": "module",
4+
"version": "0.0.1",
5+
"scripts": {
6+
"dev": "astro dev",
7+
"start": "astro dev",
8+
"build": "astro check && astro build",
9+
"preview": "astro preview",
10+
"astro": "astro"
11+
},
12+
"dependencies": {
13+
"@astrojs/check": "^0.5.10",
14+
"@astrojs/node": "^8.2.5",
15+
"@sentry/astro": "7.113.0",
16+
"astro": "^4.7.0",
17+
"typescript": "^5.4.5"
18+
}
19+
}

apps/astro/public/favicon.svg

Lines changed: 9 additions & 0 deletions
Loading

apps/astro/sentry.client.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Sentry from '@sentry/astro';
2+
3+
Sentry.init({
4+
environment: 'qa', // dynamic sampling bias to keep transactions
5+
dsn: import.meta.env.PUBLIC_SENTRY_DSN,
6+
includeLocalVariables: true,
7+
tunnel: `http://localhost:3031/`, // proxy server
8+
tracesSampleRate: 1,
9+
debug: true,
10+
});

apps/astro/sentry.server.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Sentry from '@sentry/astro';
2+
3+
Sentry.init({
4+
environment: 'qa', // dynamic sampling bias to keep transactions
5+
dsn: import.meta.env.PUBLIC_SENTRY_DSN,
6+
includeLocalVariables: true,
7+
tunnel: `http://localhost:3031/`, // proxy server
8+
tracesSampleRate: 1,
9+
debug: true,
10+
});

apps/astro/src/env.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="../.astro/types.d.ts" />
2+
/// <reference types="astro/client" />
3+
interface ImportMetaEnv {
4+
readonly PUBLIC_SENTRY_DSN: string;
5+
}
6+
7+
interface ImportMeta {
8+
readonly env: ImportMetaEnv;
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
interface Props {
3+
title: string;
4+
}
5+
6+
const { title } = Astro.props;
7+
---
8+
9+
<!doctype html>
10+
<html lang="en">
11+
<head>
12+
<meta charset="UTF-8" />
13+
<meta name="description" content="Astro description" />
14+
<meta name="viewport" content="width=device-width" />
15+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
16+
<meta name="generator" content={Astro.generator} />
17+
<title>{title}</title>
18+
</head>
19+
<body>
20+
<slot />
21+
</body>
22+
</html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { APIRoute } from 'astro';
2+
import * as Sentry from '@sentry/astro';
3+
4+
export const prerender = false;
5+
6+
export const GET: APIRoute = ({ params }) => {
7+
const param = params.param?.toString();
8+
9+
const exceptionId = Sentry.captureException(new Error('This is an error'));
10+
11+
return new Response(JSON.stringify({ exceptionId, paramWas: param }), {
12+
status: 500,
13+
headers: {
14+
'Content-Type': 'application/json',
15+
},
16+
});
17+
};

0 commit comments

Comments
 (0)