Import Sentry in middleware

This commit is contained in:
Greg Bergé
2025-01-08 17:14:16 +01:00
parent 2cda8d4cad
commit 3491bdc522
4 changed files with 4 additions and 14 deletions
-10
View File
@@ -1,10 +0,0 @@
import { init } from '@sentry/nextjs';
const dsn = process.env.SENTRY_DSN;
if (dsn) {
init({
dsn,
// Disable tracing as it creates additional requests in an env where subrequests are limited.
tracesSampleRate: 0,
});
}
+1 -2
View File
@@ -2,8 +2,7 @@ import * as Sentry from '@sentry/nextjs';
import { Instrumentation } from 'next';
export async function register() {
console.log('Instrumentation.register');
await import('../sentry.edge.config');
await import('./sentry');
}
export const onRequestError: Instrumentation.onRequestError = async (...args) => {
+1
View File
@@ -1,3 +1,4 @@
import './sentry';
import { ContentAPITokenPayload, GitBookAPI } from '@gitbook/api';
import { setTag, setContext } from '@sentry/nextjs';
import assertNever from 'assert-never';
@@ -1,9 +1,9 @@
import { init } from '@sentry/nextjs';
import * as Sentry from '@sentry/nextjs';
const dsn = process.env.SENTRY_DSN;
if (dsn) {
console.log('Initializing Sentry with DSN:', dsn);
init({
Sentry.init({
dsn,
// Disable tracing as it creates additional requests in an env where subrequests are limited.
tracesSampleRate: 0,