Skip to content

Commit

Permalink
Added error capture for nested React Server components by Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLeChat committed Jan 26, 2025
1 parent 0848ebb commit 107498d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
// Ajout la gestion des erreurs et de suivi des performances côté serveur avec Sentry.
// Source : https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#create-initialization-config-files
//
import { init } from "@sentry/nextjs";
import { init, captureRequestError } from "@sentry/nextjs";

export const onRequestError = captureRequestError;

export async function register()
{
if (
process.env.NEXT_RUNTIME === "nodejs"
|| process.env.NEXT_RUNTIME === "edge"
)
const runtime = process.env.NEXT_RUNTIME;
const isNodeRuntime = runtime === "nodejs";
const isEdgeRuntime = runtime === "edge";
const isDevelopment = process.env.NODE_ENV === "development";

if ( isNodeRuntime || isEdgeRuntime )
{
init( {
dsn: process.env.SENTRY_DSN,
tracesSampleRate:
process.env.NODE_ENV === "development" ? 1.0 : 0.01
tracesSampleRate: isDevelopment ? 1.0 : 0.01
} );
}
}

0 comments on commit 107498d

Please sign in to comment.