From db63d967dbe990a11f07aa542160ec4dd62d53b1 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Mon, 4 Dec 2023 14:13:38 -0600 Subject: [PATCH 01/10] intentionally throw an error to test the org sentry auth token --- utils/api/base.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/api/base.js b/utils/api/base.js index b16c0ab1..8bbef984 100644 --- a/utils/api/base.js +++ b/utils/api/base.js @@ -7,9 +7,10 @@ const defaultHeaders = (token) => ({ Authorization: `Bearer ${token || process.e const api = axios.create({ baseURL }) export const fetcher = (url, token) => { - return api.get(url, { headers: defaultHeaders(token) }) + return api.get(url, { headers: `Bearer 1234` }) .then(res => res.data) .catch(error => { + console.log({ error }) Sentry.captureException(error) }) } From 9b83dc736225480b9aba3633f926aeacaab3bcb4 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Mon, 4 Dec 2023 14:21:00 -0600 Subject: [PATCH 02/10] add Sentry.captureEvent for testing --- utils/api/base.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/api/base.js b/utils/api/base.js index 8bbef984..0f880422 100644 --- a/utils/api/base.js +++ b/utils/api/base.js @@ -12,6 +12,11 @@ export const fetcher = (url, token) => { .catch(error => { console.log({ error }) Sentry.captureException(error) + Sentry.captureEvent({ + message: error, + stacktrace: error.stacktrace, + name: error.name, + }) }) } From afaf8694a9a3ebf66ae5a3026db66095f36a83f0 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Mon, 4 Dec 2023 16:19:09 -0600 Subject: [PATCH 03/10] test throwing the error instead --- utils/api/base.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/api/base.js b/utils/api/base.js index 0f880422..d2628d61 100644 --- a/utils/api/base.js +++ b/utils/api/base.js @@ -11,12 +11,12 @@ export const fetcher = (url, token) => { .then(res => res.data) .catch(error => { console.log({ error }) - Sentry.captureException(error) - Sentry.captureEvent({ - message: error, - stacktrace: error.stacktrace, - name: error.name, - }) + throw Sentry.captureException(error) + // Sentry.captureEvent({ + // message: error, + // stacktrace: error.stacktrace, + // name: error.name, + // }) }) } From 91644aa03ac35e93fdb1c84ba8baee53cf94af36 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Mon, 4 Dec 2023 16:23:47 -0600 Subject: [PATCH 04/10] throw the event instead? --- utils/api/base.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/api/base.js b/utils/api/base.js index d2628d61..8bade216 100644 --- a/utils/api/base.js +++ b/utils/api/base.js @@ -11,12 +11,12 @@ export const fetcher = (url, token) => { .then(res => res.data) .catch(error => { console.log({ error }) - throw Sentry.captureException(error) - // Sentry.captureEvent({ - // message: error, - // stacktrace: error.stacktrace, - // name: error.name, - // }) + // Sentry.captureException(error) + throw Sentry.captureEvent({ + message: error, + stacktrace: error.stacktrace, + name: error.name, + }) }) } From 1e6ac518ffe72a2c47bcc2ab7a0f359c8b902975 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Mon, 4 Dec 2023 16:27:52 -0600 Subject: [PATCH 05/10] new error? --- utils/api/base.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/api/base.js b/utils/api/base.js index 8bade216..03dfe4bd 100644 --- a/utils/api/base.js +++ b/utils/api/base.js @@ -11,12 +11,12 @@ export const fetcher = (url, token) => { .then(res => res.data) .catch(error => { console.log({ error }) - // Sentry.captureException(error) - throw Sentry.captureEvent({ - message: error, - stacktrace: error.stacktrace, - name: error.name, - }) + Sentry.captureException(new Error(error)) + // Sentry.captureEvent({ + // message: error, + // stacktrace: error.stacktrace, + // name: error.name, + // }) }) } From f2f02e6ea19e46ddfa24613bedf3b9625235b9d1 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Mon, 4 Dec 2023 17:07:18 -0600 Subject: [PATCH 06/10] testing out more theories... --- next.config.js | 15 +++++++-------- sentry.client.config.js | 2 +- sentry.edge.config.js | 2 +- sentry.server.config.js | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/next.config.js b/next.config.js index df3483ed..46de15af 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,6 @@ // This guard clause allows the app to still build in the event another exception handler will be used, // or the sentry project hasn't been set up yet -if (!process.env.SENTRY_DSN && !process.env.NEXT_PUBLIC_SENTRY_DSN) return +if (!process.env.SENTRY_DSN) return // This file sets a custom webpack configuration to use your Next.js app // with Sentry. @@ -8,14 +8,13 @@ if (!process.env.SENTRY_DSN && !process.env.NEXT_PUBLIC_SENTRY_DSN) return // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ const { withSentryConfig } = require('@sentry/nextjs') -/** @type {import('next').NextConfig} */ -const moduleExports = { - output: 'standalone', +const nextConfig = { + // output: 'standalone', reactStrictMode: true, swcMinify: true, - eslint: { - dirs: ['pages', 'utils'], // Only run ESLint on the 'pages' and 'utils' directories during production builds - }, + // eslint: { + // dirs: ['pages', 'utils'], // Only run ESLint on the 'pages' and 'utils' directories during production builds + // }, sentry: { // Use `hidden-source-map` rather than `source-map` as the Webpack `devtool` // for client-side builds. (This will be the default starting in @@ -44,6 +43,6 @@ const sentryWebpackPluginOptions = { // Make sure adding Sentry options is the last code to run before exporting, to // ensure that your source maps include changes from all other Webpack plugins module.exports = withSentryConfig( - moduleExports, + nextConfig, sentryWebpackPluginOptions ) diff --git a/sentry.client.config.js b/sentry.client.config.js index 443157fb..c288393f 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -5,7 +5,7 @@ import * as Sentry from '@sentry/nextjs' Sentry.init({ - dsn: process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN, + dsn: process.env.SENTRY_DSN, // Adjust this value in production, or use tracesSampler for greater control // ref: https://develop.sentry.dev/sdk/performance/#sdk-configuration tracesSampleRate: 1.0, diff --git a/sentry.edge.config.js b/sentry.edge.config.js index 7eb9bfcd..3833c840 100644 --- a/sentry.edge.config.js +++ b/sentry.edge.config.js @@ -5,7 +5,7 @@ import * as Sentry from '@sentry/nextjs' Sentry.init({ - dsn: process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN, + dsn: process.env.SENTRY_DSN, // Adjust this value in production, or use tracesSampler for greater control // ref: https://develop.sentry.dev/sdk/performance/#sdk-configuration tracesSampleRate: 1.0, diff --git a/sentry.server.config.js b/sentry.server.config.js index 9d5e645a..464e0932 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -5,7 +5,7 @@ import * as Sentry from '@sentry/nextjs' Sentry.init({ - dsn: process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN, + dsn: process.env.SENTRY_DSN, // Adjust this value in production, or use tracesSampler for greater control // ref: https://develop.sentry.dev/sdk/performance/#sdk-configuration tracesSampleRate: 1.0, From d566a9694d50f23cf6618a5e69f5a89534f362b6 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Wed, 6 Dec 2023 15:56:51 -0600 Subject: [PATCH 07/10] reporting errors to sentry turns out that hardcoding the SENTRY_DSN was the necessary change. idk why though. the sentry docs, referenced below, mention using the env variable. https://docs.sentry.io/product/sentry-basics/concepts/dsn-explainer/#what-the-dsn-does --- sentry.client.config.js | 2 +- sentry.edge.config.js | 2 +- sentry.server.config.js | 2 +- utils/api/base.js | 8 +------- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/sentry.client.config.js b/sentry.client.config.js index c288393f..2daf1e0a 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -5,7 +5,7 @@ import * as Sentry from '@sentry/nextjs' Sentry.init({ - dsn: process.env.SENTRY_DSN, + dsn: 'https://78ce09ae2f694f0e8981cf5cec6fc2c7@o1008683.ingest.sentry.io/4504810271408128', // Adjust this value in production, or use tracesSampler for greater control // ref: https://develop.sentry.dev/sdk/performance/#sdk-configuration tracesSampleRate: 1.0, diff --git a/sentry.edge.config.js b/sentry.edge.config.js index 3833c840..fe70ab07 100644 --- a/sentry.edge.config.js +++ b/sentry.edge.config.js @@ -5,7 +5,7 @@ import * as Sentry from '@sentry/nextjs' Sentry.init({ - dsn: process.env.SENTRY_DSN, + dsn: 'https://78ce09ae2f694f0e8981cf5cec6fc2c7@o1008683.ingest.sentry.io/4504810271408128', // Adjust this value in production, or use tracesSampler for greater control // ref: https://develop.sentry.dev/sdk/performance/#sdk-configuration tracesSampleRate: 1.0, diff --git a/sentry.server.config.js b/sentry.server.config.js index 464e0932..0b86ab64 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -5,7 +5,7 @@ import * as Sentry from '@sentry/nextjs' Sentry.init({ - dsn: process.env.SENTRY_DSN, + dsn: 'https://78ce09ae2f694f0e8981cf5cec6fc2c7@o1008683.ingest.sentry.io/4504810271408128', // Adjust this value in production, or use tracesSampler for greater control // ref: https://develop.sentry.dev/sdk/performance/#sdk-configuration tracesSampleRate: 1.0, diff --git a/utils/api/base.js b/utils/api/base.js index 03dfe4bd..b79a565d 100644 --- a/utils/api/base.js +++ b/utils/api/base.js @@ -10,13 +10,7 @@ export const fetcher = (url, token) => { return api.get(url, { headers: `Bearer 1234` }) .then(res => res.data) .catch(error => { - console.log({ error }) - Sentry.captureException(new Error(error)) - // Sentry.captureEvent({ - // message: error, - // stacktrace: error.stacktrace, - // name: error.name, - // }) + Sentry.captureException(error) }) } From 70f318a3c7b8e3531e402bd4b7b22f5217dc772c Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Wed, 6 Dec 2023 15:57:34 -0600 Subject: [PATCH 08/10] update .env.development.example list references to how users would determine the values of the sentry variables --- .env.development.example | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.env.development.example b/.env.development.example index feb98509..be458f74 100644 --- a/.env.development.example +++ b/.env.development.example @@ -5,9 +5,8 @@ CLIENT_SECRET= NEXT_PUBLIC_TOKEN= # uncomment the “SENTRY” prefixed variables below if you are using sentry and need to catch errors in local dev -# SENTRY_DSN= -# NEXT_PUBLIC_SENTRY_DSN= +# SENTRY_DSN=ref: https://docs.sentry.io/product/sentry-basics/concepts/dsn-explainer/#where-to-find-your-dsn # SENTRY_URL=https://sentry.io/ -# SENTRY_ORG= -# SENTRY_PROJECT= -# SENTRY_AUTH_TOKEN= +# SENTRY_ORG= ref: https://github.com/getsentry/sentry-webpack-plugin#options (org) +# SENTRY_PROJECT= ref: https://github.com/getsentry/sentry-webpack-plugin#options (project) +# SENTRY_AUTH_TOKEN= ref: https://github.com/getsentry/sentry-webpack-plugin#options (authToken) From aa204243132e9929ff152a76ed1350fce45cf6aa Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Wed, 6 Dec 2023 16:02:05 -0600 Subject: [PATCH 09/10] revert changes made while debugging --- next.config.js | 6 +++--- utils/api/base.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/next.config.js b/next.config.js index 46de15af..7b855403 100644 --- a/next.config.js +++ b/next.config.js @@ -12,9 +12,9 @@ const nextConfig = { // output: 'standalone', reactStrictMode: true, swcMinify: true, - // eslint: { - // dirs: ['pages', 'utils'], // Only run ESLint on the 'pages' and 'utils' directories during production builds - // }, + eslint: { + dirs: ['pages', 'utils'], // Only run ESLint on the 'pages' and 'utils' directories during production builds + }, sentry: { // Use `hidden-source-map` rather than `source-map` as the Webpack `devtool` // for client-side builds. (This will be the default starting in diff --git a/utils/api/base.js b/utils/api/base.js index b79a565d..b16c0ab1 100644 --- a/utils/api/base.js +++ b/utils/api/base.js @@ -7,7 +7,7 @@ const defaultHeaders = (token) => ({ Authorization: `Bearer ${token || process.e const api = axios.create({ baseURL }) export const fetcher = (url, token) => { - return api.get(url, { headers: `Bearer 1234` }) + return api.get(url, { headers: defaultHeaders(token) }) .then(res => res.data) .catch(error => { Sentry.captureException(error) From 2e1330cdca287eb5bdde60f561177f1cff9130b5 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Wed, 6 Dec 2023 16:03:44 -0600 Subject: [PATCH 10/10] reverting one more --- next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index 7b855403..f9f1c01f 100644 --- a/next.config.js +++ b/next.config.js @@ -9,7 +9,7 @@ if (!process.env.SENTRY_DSN) return const { withSentryConfig } = require('@sentry/nextjs') const nextConfig = { - // output: 'standalone', + output: 'standalone', reactStrictMode: true, swcMinify: true, eslint: {