Skip to content

Commit

Permalink
chore: upgrade sentry sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
rtaieb committed Jan 13, 2025
1 parent 1834e7d commit 138d650
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 44 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ certificates
/scripts/ficheSolution.json
/scripts/retourExperience.json
/scripts/ficheDiagnostic.json

# Sentry Config File
.env.sentry-build-plugin
71 changes: 36 additions & 35 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('next').NextConfig} */
/** @type {import("next").NextConfig} */

const nextConfig = {
async headers() {
Expand Down Expand Up @@ -71,44 +71,45 @@ module.exports = nextConfig;
// Injected content via Sentry wizard below
const { withSentryConfig } = require("@sentry/nextjs");

module.exports = withSentryConfig(
module.exports,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
errorHandler: (err, invokeErr, compilation) => {
compilation.warnings.push("Sentry CLI Plugin: " + err.message);
},

// Suppresses source map uploading logs during build
silent: true,
org: "betagouv",
project: "plusfraichemaville",
url: "https://sentry.incubateur.net/",
module.exports = withSentryConfig(module.exports, {
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
errorHandler: (err, invokeErr, compilation) => {
compilation.warnings.push("Sentry CLI Plugin: " + err.message);
},
{
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
org: "incubateur-ademe",
project: "plusfraichemaville",
sentryUrl: "https://sentry.incubateur.net/",

// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Only print logs for uploading source maps in CI
silent: !process.env.CI,

// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: "/monitoring",
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,

// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically annotate React components to show their full name in breadcrumbs and session replay
reactComponentAnnotation: {
enabled: true,
},

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",

// Enables automatic instrumentation of Vercel Cron Monitors.
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
},
);
// Hides source maps from generated client bundles
hideSourceMaps: true,

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,

// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
});
17 changes: 10 additions & 7 deletions sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@ import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "https://8d4940c318ab411f9ce8eb5d095f5373@sentry.incubateur.net/120",

// Adjust this value in production, or use tracesSampler for greater control
// Add optional integrations for additional features
integrations: [Sentry.replayIntegration()],

// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 0.2,
environment: process.env.NEXT_PUBLIC_SENTRY_ENV,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

replaysOnErrorSampleRate: 1.0,

// Define how likely Replay events are sampled.
// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSessionSampleRate: 0.1,

integrations: [],
// Define how likely Replay events are sampled when an error occurs.
replaysOnErrorSampleRate: 1.0,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
});
2 changes: 1 addition & 1 deletion sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "https://8d4940c318ab411f9ce8eb5d095f5373@sentry.incubateur.net/120",

// Adjust this value in production, or use tracesSampler for greater control
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 0.2,
environment: process.env.NEXT_PUBLIC_SENTRY_ENV,

Expand Down
2 changes: 1 addition & 1 deletion sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "https://8d4940c318ab411f9ce8eb5d095f5373@sentry.incubateur.net/120",

// Adjust this value in production, or use tracesSampler for greater control
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 0.2,
environment: process.env.NEXT_PUBLIC_SENTRY_ENV,

Expand Down
13 changes: 13 additions & 0 deletions src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as Sentry from "@sentry/nextjs";

export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("../sentry.server.config");
}

if (process.env.NEXT_RUNTIME === "edge") {
await import("../sentry.edge.config");
}
}

export const onRequestError = Sentry.captureRequestError;

0 comments on commit 138d650

Please sign in to comment.