diff --git a/.gitignore b/.gitignore index a0955863a..4775a5e64 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,6 @@ yarn-error.log* .netlify !.netlify/functions-internal/add-to-cohort-background.js !.netlify/functions-internal/add-to-cohort.js + +# Sentry Config File +.sentryclirc diff --git a/next.config.js b/next.config.js index 36047f4c2..8cf2df02e 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,7 @@ const { withSentryConfig } = require("@sentry/nextjs"); const REDIRECTS = require("./redirects"); -const normalConfig = { +const nextConfig = { redirects: async () => { return REDIRECTS; }, @@ -13,12 +13,32 @@ const normalConfig = { workerThreads: false, cpus: 1, }, + sentry: { + // 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, + + // Transpiles SDK to be compatible with IE11 (increases bundle size) + transpileClientSDK: false, + + // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load) + tunnelRoute: "/monitoring", + + // Hides source maps from generated client bundles + hideSourceMaps: true, + + // Automatically tree-shake Sentry logger statements to reduce bundle size + disableLogger: true, + }, }; const SentryWebpackPluginOptions = { - silent: false, - autoInstrumentServerFunctions: false, - hideSourceMaps: false, + // Suppresses source map uploading logs during build + silent: true, + org: "ace-centre", + project: "acecentreorguk", }; -module.exports = withSentryConfig(normalConfig, SentryWebpackPluginOptions); +module.exports = withSentryConfig(nextConfig, SentryWebpackPluginOptions); diff --git a/sentry.client.config.js b/sentry.client.config.js index c6a02133d..879c84fcb 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -1,5 +1,5 @@ -// This file configures the initialization of Sentry on the browser. -// The config you add here will be used whenever a page is visited. +// This file configures the initialization of Sentry on the client. +// The config you add here will be used whenever a users loads a page in their browser. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ import * as Sentry from "@sentry/nextjs"; @@ -11,11 +11,25 @@ Sentry.init({ SENTRY_DSN || "https://30f18363ee6b4cb88b8f73d901a7ae84@o975862.ingest.sentry.io/4505199109210112", // Adjust this value in production, or use tracesSampler for greater control - tracesSampleRate: 1.0, - // ... - // Note: if you want to override the automatic release value, do not set a - // `release` value here - use the environment variable `SENTRY_RELEASE`, so - // that it will also get attached to your source maps, + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, + + replaysOnErrorSampleRate: 1.0, + + // 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, + + // You can remove this option if you're not planning to use the Sentry Session Replay feature: + integrations: [ + new Sentry.Replay({ + // Additional Replay configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], ignoreErrors: [ // This error comes from Microsofts outlook crawler diff --git a/sentry.edge.config.js b/sentry.edge.config.js new file mode 100644 index 000000000..63ed2d1d4 --- /dev/null +++ b/sentry.edge.config.js @@ -0,0 +1,21 @@ +// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on). +// The config you add here will be used whenever one of the edge features is loaded. +// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "https://30f18363ee6b4cb88b8f73d901a7ae84@o975862.ingest.sentry.io/4505199109210112", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, + + ignoreErrors: [ + // This error comes from Microsofts outlook crawler + "Non-Error promise rejection captured with value: Object Not Found Matching Id", + ], +}); diff --git a/sentry.server.config.js b/sentry.server.config.js index bd3b59305..5a2553180 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -4,18 +4,14 @@ import * as Sentry from "@sentry/nextjs"; -const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; - Sentry.init({ - dsn: - SENTRY_DSN || - "https://30f18363ee6b4cb88b8f73d901a7ae84@o975862.ingest.sentry.io/4505199109210112", + dsn: "https://30f18363ee6b4cb88b8f73d901a7ae84@o975862.ingest.sentry.io/4505199109210112", + // Adjust this value in production, or use tracesSampler for greater control - tracesSampleRate: 1.0, - // ... - // Note: if you want to override the automatic release value, do not set a - // `release` value here - use the environment variable `SENTRY_RELEASE`, so - // that it will also get attached to your source maps + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, ignoreErrors: [ // This error comes from Microsofts outlook crawler