feat(sentry): integrate Sentry SDK with Next.js and configure DSN
- Added Sentry client, server, and edge configurations for enhanced error monitoring. - Updated `.env.example` and `docker-compose` to include `NEXT_PUBLIC_SENTRY_DSN`. - Modified `next.config.ts` to use `withSentryConfig` for source map uploads. - Installed `@sentry/nextjs` as a dependency and updated `pnpm-lock.yaml`.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { withSentryConfig } from "@sentry/nextjs";
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const appUrl = process.env.NEXT_PUBLIC_APP_URL || "https://memegoat.fr";
|
||||
@@ -29,4 +30,23 @@ const nextConfig: NextConfig = {
|
||||
output: "standalone",
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
export default withSentryConfig(nextConfig, {
|
||||
// For all available options, see:
|
||||
// https://github.com/getsentry/sentry-webpack-plugin#options
|
||||
|
||||
org: "yidhra",
|
||||
project: "javascript-nextjs",
|
||||
|
||||
// Only print logs for uploading source maps in CI
|
||||
silent: !process.env.CI,
|
||||
|
||||
// For all available options, see:
|
||||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
||||
|
||||
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
||||
widenClientFileUpload: true,
|
||||
|
||||
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
||||
// This can increase your server load as well as your Sentry bill.
|
||||
tunnelRoute: "/monitoring",
|
||||
});
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"@radix-ui/react-toggle": "^1.1.10",
|
||||
"@radix-ui/react-toggle-group": "^1.1.11",
|
||||
"@radix-ui/react-tooltip": "^1.2.8",
|
||||
"@sentry/nextjs": "^10.38.0",
|
||||
"axios": "^1.13.2",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
|
||||
22
frontend/sentry.client.config.ts
Normal file
22
frontend/sentry.client.config.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
|
||||
// Ajustez ces valeurs en production
|
||||
tracesSampleRate: 1.0,
|
||||
|
||||
// Replay est activé par défaut
|
||||
replaysSessionSampleRate: 0.1,
|
||||
replaysOnErrorSampleRate: 1.0,
|
||||
|
||||
integrations: [
|
||||
Sentry.replayIntegration({
|
||||
maskAllText: true,
|
||||
blockAllMedia: true,
|
||||
}),
|
||||
],
|
||||
|
||||
// Protection PII
|
||||
sendDefaultPii: false,
|
||||
});
|
||||
11
frontend/sentry.edge.config.ts
Normal file
11
frontend/sentry.edge.config.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
|
||||
// Ajustez ces valeurs en production
|
||||
tracesSampleRate: 1.0,
|
||||
|
||||
// Protection PII
|
||||
sendDefaultPii: false,
|
||||
});
|
||||
22
frontend/sentry.server.config.ts
Normal file
22
frontend/sentry.server.config.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
|
||||
// Ajustez ces valeurs en production
|
||||
tracesSampleRate: 1.0,
|
||||
|
||||
// Protection PII
|
||||
sendDefaultPii: false,
|
||||
|
||||
beforeSend(event) {
|
||||
// Hachage de l'IP utilisateur pour Sentry si elle est présente
|
||||
if (event.user?.ip_address) {
|
||||
event.user.ip_address = createHash("sha256")
|
||||
.update(event.user.ip_address)
|
||||
.digest("hex");
|
||||
}
|
||||
return event;
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user