From a0fc14bdd98a7739073c656b06d9d714765a09dd Mon Sep 17 00:00:00 2001 From: saint Date: Wed, 28 Feb 2024 17:25:10 +0100 Subject: [PATCH] adds sentry support to send errors. in sentry.io you can create a free account for small sites. --- app/__init__.py | 7 +++++++ config.py | 1 + env.sample | 1 + requirements.txt | 1 + 4 files changed, 10 insertions(+) diff --git a/app/__init__.py b/app/__init__.py index 37820676..ac9566b9 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -36,6 +36,13 @@ def create_app(config_class=Config): app = Flask(__name__) app.config.from_object(config_class) + if app.config['SENTRY_DSN']: + import sentry_sdk + sentry_sdk.init( + dsn=app.config["SENTRY_DSN"], + enable_tracing=True + ) + db.init_app(app) migrate.init_app(app, db, render_as_batch=True) login.init_app(app) diff --git a/config.py b/config.py index b0371577..9c716e6a 100644 --- a/config.py +++ b/config.py @@ -38,3 +38,4 @@ class Config(object): BOUNCE_USERNAME = os.environ.get('BOUNCE_USERNAME') or '' BOUNCE_PASSWORD = os.environ.get('BOUNCE_PASSWORD') or '' + SENTRY_DSN = os.environ.get('SENTRY_DSN') or None diff --git a/env.sample b/env.sample index 2c7b4c87..a142a4aa 100644 --- a/env.sample +++ b/env.sample @@ -16,3 +16,4 @@ BOUNCE_USERNAME='' BOUNCE_PASSWORD='' FLASK_APP=pyfedi.py +SENTRY_DSN='' diff --git a/requirements.txt b/requirements.txt index 143e0df5..14c1c0c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,3 +29,4 @@ celery==5.3.6 redis==5.0.1 Werkzeug==2.3.3 pytesseract==0.3.10 +sentry-sdk==1.40.6