From 6eb653b2aa0a12390227277b727afccaebc9f29f Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Wed, 16 Feb 2022 09:31:46 +0100 Subject: [PATCH] Adding Sentry configuration --- config/settings.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/config/settings.py b/config/settings.py index 4c796c8ce4..5e75ed8915 100644 --- a/config/settings.py +++ b/config/settings.py @@ -12,20 +12,26 @@ https://docs.djangoproject.com/en/3.2/ref/settings/ import os import environ -# import sentry_sdk from pathlib import Path -# from sentry_sdk.integrations.django import DjangoIntegration - -# Sentry -# sentry_sdk.init( -# dsn=os.environ['SENTRY_DSN'], -# integrations=[DjangoIntegration()] -# ) # Initialise environment variables env = environ.Env() environ.Env.read_env() +# Sentry +SENTRY_DSN = env("SENTRY_DSN", default=None) +if SENTRY_DSN is not None: + import sentry_sdk + from sentry_sdk.integrations.django import DjangoIntegration + + sentry_sdk.init( + dsn=SENTRY_DSN, + integrations=[DjangoIntegration()], + trace_sample_rate=env("SENTRY_TRACES_SAMPLE_RATE", default=1.0), + send_default_pii=True, + debug=env("SENTRY_DEBUG", default=True) + ) + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent