From cd554e4fb99ff6ba846ec96b23a9d5659e213563 Mon Sep 17 00:00:00 2001 From: mohsentaba Date: Tue, 13 Oct 2026 12:51:18 +0330 Subject: [PATCH] fix(sentry): disable error reporting in development, enable only in production - Remove sentry_sdk import and sentry_sdk.init() from base.py so that development (develop.py) and test (test.py) environments no longer send errors to Sentry - Add sentry_sdk.init() exclusively to production.py with environment=production so production errors are correctly tagged and dev noise is eliminated - Add traces_sample_rate comment placeholder for future performance monitoring --- config/settings/base.py | 6 +----- config/settings/production.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config/settings/base.py b/config/settings/base.py index 3352589..39c5f33 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -16,7 +16,6 @@ from django.urls import reverse_lazy import environ from django.utils.translation import gettext_lazy as _ -import sentry_sdk env = environ.Env( @@ -826,10 +825,7 @@ UNFOLD_STUDIO_PERMISSION = lambda request: request.user.is_authenticated PLAUSIBLE_DOMAIN = env("PLAUSIBLE_DOMAIN") -sentry_sdk.init( - dsn="https://31aaeeb3a42f9a8c1b26272a0cb8ad3e@o4507991743725568.ingest.us.sentry.io/4511127356768256", - send_default_pii=True, -) +# Sentry is configured only in production.py – not here. INTERNAL_WEBHOOK_SECRET = env('INTERNAL_WEBHOOK_SECRET', default='super-secret-key-12345') diff --git a/config/settings/production.py b/config/settings/production.py index 9185dd4..24c463a 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -1,10 +1,20 @@ -# import sentry_sdk +import sentry_sdk from .base import * from celery.schedules import crontab DEBUG = False +# ----------------------------------------------------------------------- +# Sentry – only active in production (not in develop/test environments) +# ----------------------------------------------------------------------- +sentry_sdk.init( + dsn="https://31aaeeb3a42f9a8c1b26272a0cb8ad3e@o4507991743725568.ingest.us.sentry.io/4511127356768256", + send_default_pii=True, + environment="production", + # traces_sample_rate=0.2, # uncomment to enable performance tracing +) + #It is currently active CORS_ALLOW_ALL_ORIGINS = True