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,9 +11,13 @@
|
||||
import { browserTracingIntegration } from "@sentry/browser";
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const isDevelopment = process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "local";
|
||||
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";
|
||||
|
||||
/**
|
||||
* Initialize Sentry error tracking and performance monitoring
|
||||
*
|
||||
* This setup includes:
|
||||
@@ -21,9 +25,9 @@ const isDevelopment = process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === "local";
|
||||
* - Long task detection for UI-blocking operations
|
||||
* - beforeSend hook to filter noise
|
||||
*/
|
||||
Sentry.init({
|
||||
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",
|
||||
@@ -104,12 +108,13 @@ Sentry.init({
|
||||
|
||||
return event; // Send to Sentry
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// 👤 Set user context (identifies who experienced the error)
|
||||
// In production, this will be updated after authentication
|
||||
if (isDevelopment) {
|
||||
// 👤 Set user context (identifies who experienced the error)
|
||||
// In production, this will be updated after authentication
|
||||
if (isDevelopment) {
|
||||
Sentry.setUser({
|
||||
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,8 +1,12 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
const SENTRY_DSN = process.env.SENTRY_DSN;
|
||||
|
||||
/**
|
||||
// Only initialize Sentry if DSN is configured
|
||||
if (SENTRY_DSN) {
|
||||
const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
|
||||
/**
|
||||
* Edge runtime Sentry configuration
|
||||
*
|
||||
* Edge runtime has stricter constraints than Node.js:
|
||||
@@ -11,9 +15,9 @@ const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
* - Reduced sample rates to minimize overhead
|
||||
* - No complex integrations
|
||||
*/
|
||||
Sentry.init({
|
||||
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",
|
||||
@@ -61,4 +65,5 @@ Sentry.init({
|
||||
|
||||
return event;
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
const SENTRY_DSN = process.env.SENTRY_DSN;
|
||||
|
||||
/**
|
||||
// Only initialize Sentry if DSN is configured
|
||||
if (SENTRY_DSN) {
|
||||
const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
|
||||
/**
|
||||
* Server-side Sentry configuration
|
||||
*
|
||||
* This setup includes:
|
||||
@@ -10,9 +14,9 @@ const isProduction = process.env.SENTRY_ENVIRONMENT === "pro";
|
||||
* - Error tracking for API routes and server actions
|
||||
* - beforeSend hook to filter noise and add context
|
||||
*/
|
||||
Sentry.init({
|
||||
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",
|
||||
@@ -77,4 +81,5 @@ Sentry.init({
|
||||
|
||||
return event;
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user