From 0c6ce121b040266a3e6510b6c0fb295929245822 Mon Sep 17 00:00:00 2001 From: swve Date: Sun, 4 Feb 2024 19:19:32 +0100 Subject: [PATCH] fix: improve sentry handling + upgrade version --- apps/web/package.json | 2 +- apps/web/sentry.client.config.ts | 42 +++++++++++++++++--------------- apps/web/sentry.edge.config.ts | 16 ------------ apps/web/sentry.server.config.ts | 16 ++++++------ pnpm-lock.yaml | 2 +- 5 files changed, 32 insertions(+), 46 deletions(-) delete mode 100644 apps/web/sentry.edge.config.ts diff --git a/apps/web/package.json b/apps/web/package.json index 37324eb4..1deadc16 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -16,7 +16,7 @@ "@radix-ui/react-icons": "^1.1.1", "@radix-ui/react-switch": "^1.0.3", "@radix-ui/react-tooltip": "^1.0.5", - "@sentry/nextjs": "^7.92.0", + "@sentry/nextjs": "^7.93.0", "@stitches/react": "^1.2.8", "@tiptap/extension-code-block-lowlight": "^2.1.11", "@tiptap/extension-collaboration": "^2.0.0-beta.199", diff --git a/apps/web/sentry.client.config.ts b/apps/web/sentry.client.config.ts index df526510..c128f326 100644 --- a/apps/web/sentry.client.config.ts +++ b/apps/web/sentry.client.config.ts @@ -4,27 +4,31 @@ import * as Sentry from "@sentry/nextjs"; -Sentry.init({ - dsn: "https://5a456d54654c494b9a416c19e3b94573@o4505007882436608.ingest.sentry.io/4505008095625216", +if (process.env.NODE_ENV !== "development") { + const DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; - // Adjust this value in production, or use tracesSampler for greater control - tracesSampleRate: 1, + Sentry.init({ + dsn: DSN, - // Setting this option to true will print useful information to the console while you're setting up Sentry. - debug: false, + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, - replaysOnErrorSampleRate: 1.0, + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, - // 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, + replaysOnErrorSampleRate: 1.0, - // 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, - }), - ], -}); + // 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, + }), + ], + }); +} diff --git a/apps/web/sentry.edge.config.ts b/apps/web/sentry.edge.config.ts deleted file mode 100644 index 00fc639b..00000000 --- a/apps/web/sentry.edge.config.ts +++ /dev/null @@ -1,16 +0,0 @@ -// 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://5a456d54654c494b9a416c19e3b94573@o4505007882436608.ingest.sentry.io/4505008095625216", - - // 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, -}); diff --git a/apps/web/sentry.server.config.ts b/apps/web/sentry.server.config.ts index ea085c48..a2a48ed9 100644 --- a/apps/web/sentry.server.config.ts +++ b/apps/web/sentry.server.config.ts @@ -4,12 +4,10 @@ import * as Sentry from "@sentry/nextjs"; -Sentry.init({ - dsn: "https://5a456d54654c494b9a416c19e3b94573@o4505007882436608.ingest.sentry.io/4505008095625216", - - // 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, -}); +if (process.env.NODE_ENV !== "development") { + const DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; + Sentry.init({ + dsn: DSN, + tracesSampleRate: 1.0, + }); +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f7584c41..b882fd1e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -42,7 +42,7 @@ importers: specifier: ^1.0.5 version: 1.0.7(@types/react-dom@18.0.6)(@types/react@18.2.8)(react-dom@18.2.0)(react@18.2.0) '@sentry/nextjs': - specifier: ^7.92.0 + specifier: ^7.93.0 version: 7.93.0(next@14.0.4)(react@18.2.0) '@stitches/react': specifier: ^1.2.8