From e73606b54d4fe6abb45edc65a684e3c2d1036063 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 10 Nov 2021 11:28:08 +0100 Subject: [PATCH] root: catch error in analytics on startup Signed-off-by: Jens Langhammer --- authentik/root/settings.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/authentik/root/settings.py b/authentik/root/settings.py index dda0e4fbf..b51232c1a 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -435,19 +435,24 @@ if _ERROR_REPORTING: if not CONFIG.y_bool("disable_startup_analytics", False): should_send = env not in ["dev", "ci"] if should_send: - get_http_session().post( - "https://goauthentik.io/api/event", - json={ - "domain": "authentik", - "name": "pageview", - "referrer": f"{__version__} ({build_hash})", - "url": f"http://localhost/{env}?utm_source={__version__}&utm_medium={env}", - }, - headers={ - "User-Agent": sha512(SECRET_KEY.encode("ascii")).hexdigest()[:16], - "Content-Type": "application/json", - }, - ) + try: + get_http_session().post( + "https://goauthentik.io/api/event", + json={ + "domain": "authentik", + "name": "pageview", + "referrer": f"{__version__} ({build_hash})", + "url": f"http://localhost/{env}?utm_source={__version__}&utm_medium={env}", + }, + headers={ + "User-Agent": sha512(SECRET_KEY.encode("ascii")).hexdigest()[:16], + "Content-Type": "application/json", + }, + timeout=5, + ) + # pylint: disable=bare-except + except: # nosec + pass # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/