mirror of
https://github.com/prowler-cloud/prowler.git
synced 2025-12-19 05:17:47 +00:00
fix(ui): skip Sentry initialization when DSN is not configured (#9368)
This commit is contained in:
@@ -11,6 +11,10 @@
|
||||
import { browserTracingIntegration } from "@sentry/browser";
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN;
|
||||
|
||||
// Only initialize Sentry if DSN is configured
|
||||
if (SENTRY_DSN) {
|
||||
const isDevelopment = process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "local";
|
||||
|
||||
/**
|
||||
@@ -23,7 +27,7 @@ const isDevelopment = process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "local";
|
||||
*/
|
||||
Sentry.init({
|
||||
// 📍 DSN - Data Source Name (identifies your Sentry project)
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
dsn: SENTRY_DSN,
|
||||
|
||||
// 🌍 Environment - Separate dev errors from production
|
||||
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT || "local",
|
||||
@@ -113,3 +117,4 @@ if (isDevelopment) {
|
||||
id: "dev-user",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,14 @@
|
||||
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const SENTRY_DSN = process.env.SENTRY_DSN;
|
||||
|
||||
export async function register() {
|
||||
// Skip Sentry initialization if DSN is not configured
|
||||
if (!SENTRY_DSN) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The Sentry SDK automatically loads the appropriate config based on runtime
|
||||
if (process.env.NEXT_RUNTIME === "nodejs") {
|
||||
await import("./sentry/sentry.server.config");
|
||||
@@ -27,4 +34,7 @@ export async function register() {
|
||||
}
|
||||
}
|
||||
|
||||
export const onRequestError = Sentry.captureRequestError;
|
||||
// Only capture request errors if Sentry is configured
|
||||
export const onRequestError = SENTRY_DSN
|
||||
? Sentry.captureRequestError
|
||||
: undefined;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const SENTRY_DSN = process.env.SENTRY_DSN;
|
||||
|
||||
// Only initialize Sentry if DSN is configured
|
||||
if (SENTRY_DSN) {
|
||||
const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
|
||||
/**
|
||||
@@ -13,7 +17,7 @@ const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
*/
|
||||
Sentry.init({
|
||||
// 📍 DSN - Data Source Name (identifies your Sentry project)
|
||||
dsn: process.env.SENTRY_DSN,
|
||||
dsn: SENTRY_DSN,
|
||||
|
||||
// 🌍 Environment configuration
|
||||
environment: process.env.SENTRY_ENVIRONMENT || "local",
|
||||
@@ -62,3 +66,4 @@ Sentry.init({
|
||||
return event;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const SENTRY_DSN = process.env.SENTRY_DSN;
|
||||
|
||||
// Only initialize Sentry if DSN is configured
|
||||
if (SENTRY_DSN) {
|
||||
const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
|
||||
/**
|
||||
@@ -12,7 +16,7 @@ const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
*/
|
||||
Sentry.init({
|
||||
// 📍 DSN - Data Source Name (identifies your Sentry project)
|
||||
dsn: process.env.SENTRY_DSN,
|
||||
dsn: SENTRY_DSN,
|
||||
|
||||
// 🌍 Environment configuration
|
||||
environment: process.env.SENTRY_ENVIRONMENT || "local",
|
||||
@@ -78,3 +82,4 @@ Sentry.init({
|
||||
return event;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user