Merge pull request #775 from SchrodingersGat/sentry-integration

Add option for sentry.io integration
This commit is contained in:
Oliver 2020-05-02 21:04:07 +10:00 committed by GitHub
commit e998098e4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -72,6 +72,27 @@ if DEBUG:
format='%(asctime)s %(levelname)s %(message)s',
)
# Does the user wish to use the sentry.io integration?
sentry_opts = CONFIG.get('sentry', {})
if sentry_opts.get('enabled', False):
dsn = sentry_opts.get('dsn', None)
if dsn is not None:
# Try to import required modules (exit if not installed)
try:
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(dsn=dsn, integrations=[DjangoIntegration()], send_default_pii=True)
except ModuleNotFoundError:
print("sentry_sdk module not found. Install using 'pip install sentry-sdk'")
sys.exit(-1)
else:
print("Warning: Sentry.io DSN not specified")
# Application definition
INSTALLED_APPS = [

View File

@ -65,4 +65,11 @@ log_queries: False
# Backup options
# Set the backup_dir parameter to store backup files in a specific location
# If unspecified, the local user's temp directory will be used
#backup_dir: '/home/inventree/backup/'
#backup_dir: '/home/inventree/backup/'
# Sentry.io integration
# If you have a sentry.io account, it can be used to log server errors
# Ensure sentry_sdk is installed by running 'pip install sentry-sdk'
sentry:
enabled: False
# dsn: add-your-sentry-dsn-here