Skip to content

Commit

Permalink
Setup sentry to be more modern
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinhenderson committed Nov 15, 2023
1 parent 8bc734e commit b18fa55
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 25 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { withSentryConfig } = require("@sentry/nextjs");
const REDIRECTS = require("./redirects");

const normalConfig = {
const nextConfig = {
redirects: async () => {
return REDIRECTS;
},
Expand All @@ -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);
28 changes: 21 additions & 7 deletions sentry.client.config.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -11,11 +11,25 @@ Sentry.init({
SENTRY_DSN ||
"https://[email protected]/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
Expand Down
21 changes: 21 additions & 0 deletions sentry.edge.config.js
Original file line number Diff line number Diff line change
@@ -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://[email protected]/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",
],
});
16 changes: 6 additions & 10 deletions sentry.server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]/4505199109210112",
dsn: "https://[email protected]/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
Expand Down

0 comments on commit b18fa55

Please sign in to comment.