From 95ef0e375020376b9d44b57921b7971040948412 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:26:22 +0200 Subject: [PATCH] Avoids capturing false-positive 404 pages when building the 404 page --- src/app/components/MultiversalAppBootstrap.tsx | 10 ++++++---- src/modules/core/sentry/init.ts | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/components/MultiversalAppBootstrap.tsx b/src/app/components/MultiversalAppBootstrap.tsx index 254c4cd7..80f03650 100644 --- a/src/app/components/MultiversalAppBootstrap.tsx +++ b/src/app/components/MultiversalAppBootstrap.tsx @@ -301,11 +301,13 @@ const MultiversalAppBootstrap: React.FunctionComponent = (props): JSX.Ele }); } } else { - // XXX Opinionated: Record an exception in Sentry for 404, if you don't want this then uncomment the below code - const err = new Error(`Page not found (404) for "${router?.asPath}"`); + if (!process.env.IS_SERVER_INITIAL_BUILD) { // Avoids capturing false-positive 404 pages when building the 404 page + // XXX Opinionated: Record an exception in Sentry for 404, if you don't want this then uncomment the below code + const err = new Error(`Page not found (404) for "${router?.asPath}"`); - logger.warn(err); - Sentry.captureException(err); + logger.warn(err); + Sentry.captureException(err); + } } const i18nextInstance: i18n = i18nextLocize(lang, i18nTranslations); // Apply i18next configuration with Locize backend diff --git a/src/modules/core/sentry/init.ts b/src/modules/core/sentry/init.ts index 7f823ae8..394dc72e 100644 --- a/src/modules/core/sentry/init.ts +++ b/src/modules/core/sentry/init.ts @@ -44,6 +44,7 @@ if (process.env.SENTRY_DSN) { scope.setTag('nodejsAWS', process.env.AWS_EXECUTION_ENV || null); // Optional - Available on production environment only scope.setTag('memory', process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE || null); // Optional - Available on production environment only scope.setTag('runtimeEngine', isBrowser() ? 'browser' : 'server'); + scope.setTag('isServerInitialBuild', process.env.IS_SERVER_INITIAL_BUILD || '0'); }); } else { if (process.env.NODE_ENV !== 'test') {