From aa23caa0354f5eaa8717c4b769c2f20dd24e409c Mon Sep 17 00:00:00 2001 From: Enno Gelhaus Date: Fri, 1 Aug 2025 22:55:13 +0200 Subject: [PATCH] feat/allow network requests to be captured --- .../src/sentry/initialize.sentry.client.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libraries/react-shared-libraries/src/sentry/initialize.sentry.client.ts b/libraries/react-shared-libraries/src/sentry/initialize.sentry.client.ts index 70e626d7..39caf6e3 100644 --- a/libraries/react-shared-libraries/src/sentry/initialize.sentry.client.ts +++ b/libraries/react-shared-libraries/src/sentry/initialize.sentry.client.ts @@ -1,6 +1,11 @@ import * as Sentry from '@sentry/nextjs'; import { initializeSentryBasic } from '@gitroom/react/sentry/initialize.sentry.next.basic'; +// Import or define frontendUrl, backendUrl and internalBackendUrl +const frontendUrl = process.env.FRONTEND_URL || 'http://localhost:4200'; +const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:3000'; +const internalBackendUrl = process.env.BACKEND_INTERNAL_URL || 'http://localhost:3000'; + export const initializeSentryClient = (environment: string, dsn: string) => initializeSentryBasic(environment, dsn, { integrations: [ @@ -9,6 +14,15 @@ export const initializeSentryClient = (environment: string, dsn: string) => Sentry.replayIntegration({ maskAllText: true, maskAllInputs: true, + + // Allow (Internal) API and Frontend requests to be captured + networkDetailAllowUrls: [ + new RegExp(`^${frontendUrl}(?:/.*)?$`), + new RegExp(`^${backendUrl}(?:/.*)?$`), + new RegExp(`^${internalBackendUrl}(?:/.*)?$`) + ], + networkRequestHeaders: ['X-Custom-Header'], + networkResponseHeaders: ['X-Custom-Header'], }), Sentry.feedbackIntegration({ // Disable the injection of the default widget