From 2c3e76edd04a0a98b5681f730aea044af989cd89 Mon Sep 17 00:00:00 2001
From: Stefan Hynek <stefan.hynek@uni-goettingen.de>
Date: Fri, 5 Nov 2021 09:34:21 +0100
Subject: [PATCH] feat(main): init sentry very early if dsn is set

also, default wsgi config "host" to "localhost" and "port" to "8080" if unset; remove "simple_dc" config
---
 src/main.py | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/main.py b/src/main.py
index 8a202dd..d73f145 100644
--- a/src/main.py
+++ b/src/main.py
@@ -1,8 +1,19 @@
+"""Configure and start the WSGI DAV Server."""
 import logging
 import os
 
+import sentry_sdk
 from cheroot import wsgi
 from wsgidav.wsgidav_app import WsgiDAVApp
+from repdav.config import AppConfig
+
+app_config = AppConfig()
+
+if app_config.dsn:
+    sentry_sdk.init(
+        app_config.dsn,
+        traces_sample_rate=1.0
+    )
 
 logging.basicConfig(level=logging.DEBUG,
                     format='%(name)s %(levelname)s %(asctime)s %(message)s')
@@ -19,20 +30,14 @@ TMP_logger.setLevel(logging.WARNING)
 
 # Configuration of the WsgiDAVApp.
 # https://wsgidav.readthedocs.io/en/latest/user_guide_configure.html
+# TODO: move to config.py
 config = {
-    "host": os.getenv("host"),
-    "port": int(os.getenv("port")),
+    "host": os.getenv("host") or "localhost",
+    "port": int(os.getenv("port") or "8080"),
     "provider_mapping": {
         "/": {"provider": "repdav.textgrid_dav_provider.TextgridResourceProvider"},
     },
     "verbose": 1,
-    "simple_dc": {
-        "user_mapping": {
-            "*": {
-                "user": {
-                    "password": "pass"}}
-        }
-    },
     "http_authenticator": {
         "domain_controller": "repdav.textgrid_domain_controller.TextgridDC",
         "accept_basic": True,  # Allow basic authentication, True or False
-- 
GitLab