Skip to content

Commit 55701f8

Browse files
committed
Merge branch 'refs/heads/main' into sig/hapi-v8
# Conflicts: # yarn.lock
2 parents 75d0f93 + 6dbfb04 commit 55701f8

File tree

71 files changed

+8075
-11021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+8075
-11021
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+
}

apps/astro/src/layouts/Layout.astro

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+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { APIRoute } from 'astro';
2+
3+
export const prerender = false;
4+
5+
export const GET: APIRoute = ({ params }) => {
6+
const param = params.param?.toString();
7+
8+
return new Response(JSON.stringify({ paramWas: param }), {
9+
status: 200,
10+
headers: {
11+
'Content-Type': 'application/json',
12+
},
13+
});
14+
};

apps/astro/src/pages/index.astro

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
import Layout from '../layouts/Layout.astro';
3+
4+
export const prerender = false;
5+
6+
---
7+
8+
<Layout>
9+
<ul>
10+
<!-- li><a href="/test-success/">Test Success</a></li -->
11+
<!-- li><a href="/test-error">Test Error</a></li -->
12+
<li><a href="/test-param-success/1337">Test Param Success</a></li>
13+
<li><a href="/test-param-error/1337">Test Param Error</a></li>
14+
<!-- li><a href="/test-success-manual">Test Success Manual</a></li -->
15+
<!-- li><a href="/test-error-manual">Test Error Manual</a></li -->
16+
<!-- li><a href="/test-local-variables-uncaught">Test Local Variables Uncaught</a></li -->
17+
<!-- li><a href="/test-local-variables-caught">Test Local Variables Caught</a></li -->
18+
</ul>
19+
</Layout>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
3+
export const prerender = false;
4+
5+
const { param } = Astro.params;
6+
7+
const response = await fetch(Astro.url.origin +`/api/test-param-error/${param}`)
8+
const data = await response.json();
9+
10+
---
11+
12+
<h1>{JSON.stringify(data)}</h1>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
3+
export const prerender = false;
4+
5+
const { param } = Astro.params;
6+
7+
const response = await fetch(Astro.url.origin +`/api/test-param-success/${param}`)
8+
const data = await response.json();
9+
10+
---
11+
12+
<h1>{JSON.stringify(data)}</h1>

apps/astro/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "astro/tsconfigs/strict"
3+
}

apps/express/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ declare global {
1212

1313
Sentry.init({
1414
environment: 'qa', // dynamic sampling bias to keep transactions
15-
dsn: process.env.SENTRY_DSN,
15+
dsn: 'https://eb90fdb87147dfc95899d3e63cc6ff20@o4506778646609920.ingest.us.sentry.io/4507168754761728',
1616
includeLocalVariables: true,
1717
debug: true,
1818
tunnel: `http://localhost:3031/`, // proxy server

apps/nestjs/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@
1515
"extends": "../../package.json"
1616
},
1717
"dependencies": {
18-
"@nestjs/common": "10.3.7",
19-
"@nestjs/core": "10.3.7",
20-
"@nestjs/platform-express": "10.3.7",
21-
"@sentry/node": "7.110.1",
22-
"@sentry/types": "7.110.1",
18+
"@nestjs/common": "10.3.9",
19+
"@nestjs/core": "10.3.9",
20+
"@nestjs/platform-express": "10.3.8",
21+
"@sentry/node": "8.9.2",
22+
"@sentry/types": "8.9.2",
2323
"dotenv": "^16.4.5",
2424
"reflect-metadata": "0.2.2",
2525
"rxjs": "7.8.1"
2626
},
2727
"devDependencies": {
2828
"@nestjs/cli": "10.3.2",
29-
"@nestjs/schematics": "10.1.1",
30-
"@types/express": "^4.17.17"
29+
"@nestjs/schematics": "10.1.1"
3130
}
3231
}

apps/nestjs/src/app.controller.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { Controller, Get, Param, UseFilters } from '@nestjs/common';
1+
import { Controller, Get, Param } from '@nestjs/common';
22
import { AppService } from './app.service';
3-
import { AllExceptionsFilter } from './all-exceptions.filter';
43

54
@Controller()
6-
@UseFilters(new AllExceptionsFilter())
75
export class AppController {
86
constructor(private readonly appService: AppService) {}
97

@@ -37,7 +35,6 @@ export class AppController {
3735
return this.appService.testErrorManual();
3836
}
3937

40-
// unhandled exceptions do not send an event in v7 (just the transaction, if the error is handled with an exception filter)
4138
@Get('test-local-variables-uncaught')
4239
testLocalVariablesUncaught() {
4340
return this.appService.testLocalVariablesUncaught();

apps/nestjs/src/instrument.ts

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

apps/nestjs/src/main.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
1-
import { NestFactory } from '@nestjs/core';
1+
import './instrument';
22
import * as Sentry from '@sentry/node';
3+
import { BaseExceptionFilter, HttpAdapterHost, NestFactory } from '@nestjs/core';
34
import { AppModule } from './app.module';
4-
import dotenv from 'dotenv';
5-
6-
dotenv.config({ path: './../../.env' });
75

86
async function bootstrap() {
9-
Sentry.init({
10-
environment: 'qa', // dynamic sampling bias to keep transactions
11-
dsn: process.env.SENTRY_DSN,
12-
includeLocalVariables: true,
13-
tunnel: `http://localhost:3031/`, // proxy server
14-
tracesSampleRate: 1,
15-
});
16-
177
const app = await NestFactory.create(AppModule);
188

19-
app.use(Sentry.Handlers.requestHandler());
20-
app.use(Sentry.Handlers.tracingHandler());
21-
22-
// Uncaught exceptions are not sent as event in v7, in v8 they are sent as events and transactions
23-
app.use(Sentry.Handlers.errorHandler());
9+
const { httpAdapter } = app.get(HttpAdapterHost);
10+
Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));
2411

2512
await app.listen(3030);
2613
}

apps/nextjs-13_2_0/instrumentation.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export async function register() {
2+
if (process.env.NEXT_RUNTIME === 'nodejs') {
3+
await import('./sentry.server.config');
4+
}
5+
6+
if (process.env.NEXT_RUNTIME === 'edge') {
7+
await import('./sentry.edge.config');
8+
}
9+
}

apps/nextjs-13_2_0/next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { withSentryConfig } = require('@sentry/nextjs');
44
const nextConfig = {
55
experimental: {
66
appDir: true,
7+
instrumentationHook: true,
78
},
89
};
910

apps/nextjs-13_2_0/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@sentry/nextjs": "7.110.1",
12+
"@sentry/nextjs": "8.9.2",
1313
"@types/node": "20.12.7",
1414
"@types/react": "18.2.79",
1515
"@types/react-dom": "18.2.25",

apps/nextjs-14_2_1/instrumentation.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as Sentry from '@sentry/nextjs';
2+
3+
export async function register() {
4+
if (process.env.NEXT_RUNTIME === 'nodejs') {
5+
await import('./sentry.server.config');
6+
}
7+
8+
if (process.env.NEXT_RUNTIME === 'edge') {
9+
await import('./sentry.edge.config');
10+
}
11+
}

apps/nextjs-14_2_1/next.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { withSentryConfig } from '@sentry/nextjs';
22

33
/** @type {import('next').NextConfig} */
4-
const nextConfig = {};
4+
const nextConfig = {
5+
experimental: { instrumentationHook: true },
6+
};
57

68
export default withSentryConfig(nextConfig);

apps/nextjs-14_2_1/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint": "next lint"
1111
},
1212
"dependencies": {
13-
"@sentry/nextjs": "7.110.1",
13+
"@sentry/nextjs": "8.9.2",
1414
"next": "14.2.1",
1515
"react": "^18",
1616
"react-dom": "^18"

0 commit comments

Comments
 (0)