From b106ebf82779744053b909cf85c069213421d9a6 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Sun, 25 Apr 2021 12:53:43 +0200 Subject: [PATCH] Load dotenv on all environments --- src/newsreader/conf/base.py | 6 ++++++ src/newsreader/conf/production.py | 9 +++------ src/newsreader/conf/version.py | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/newsreader/conf/base.py b/src/newsreader/conf/base.py index 11ba8cc..6fd4fdd 100644 --- a/src/newsreader/conf/base.py +++ b/src/newsreader/conf/base.py @@ -2,10 +2,15 @@ import os from pathlib import Path +from dotenv import load_dotenv + + +load_dotenv() try: from sentry_sdk.integrations.celery import CeleryIntegration from sentry_sdk.integrations.django import DjangoIntegration + from .sentry import sentry_filter except ImportError: CeleryIntegration = None DjangoIntegration = None @@ -258,6 +263,7 @@ SENTRY_CONFIG = { "dsn": os.environ.get("SENTRY_DSN"), "send_default_pii": True, "environment": ENVIRONMENT, + "before_send": sentry_filter, "integrations": [DjangoIntegration(), CeleryIntegration()] if DjangoIntegration and CeleryIntegration else [], diff --git a/src/newsreader/conf/production.py b/src/newsreader/conf/production.py index 6bce6f6..c58f93a 100644 --- a/src/newsreader/conf/production.py +++ b/src/newsreader/conf/production.py @@ -1,15 +1,10 @@ import os -from dotenv import load_dotenv - from .version import get_current_version from .base import * # isort:skip - -load_dotenv() - DEBUG = False ALLOWED_HOSTS = ["rss.fudiggity.nl"] @@ -83,7 +78,9 @@ REGISTRATION_OPEN = False try: from sentry_sdk import init as sentry_init - SENTRY_CONFIG.update({"release": VERSION, "environment": ENVIRONMENT}) + SENTRY_CONFIG.update( + {"release": VERSION, "environment": ENVIRONMENT, "debug": False} + ) sentry_init(**SENTRY_CONFIG) except ImportError: diff --git a/src/newsreader/conf/version.py b/src/newsreader/conf/version.py index 4ed2d96..873c45b 100644 --- a/src/newsreader/conf/version.py +++ b/src/newsreader/conf/version.py @@ -9,7 +9,7 @@ def get_current_version(debug=True): if debug: try: output = subprocess.check_output( - ["git", "show", "--no-patch", "--format=%s"], universal_newlines=True + ["git", "show", "--no-patch", "--format=%H"], universal_newlines=True ) return output.strip() except (subprocess.CalledProcessError, OSError):