root: catch error in analytics on startup

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-10 11:28:08 +01:00
parent 0a413fe21a
commit e73606b54d
1 changed files with 18 additions and 13 deletions

View File

@ -435,19 +435,24 @@ if _ERROR_REPORTING:
if not CONFIG.y_bool("disable_startup_analytics", False): if not CONFIG.y_bool("disable_startup_analytics", False):
should_send = env not in ["dev", "ci"] should_send = env not in ["dev", "ci"]
if should_send: if should_send:
get_http_session().post( try:
"https://goauthentik.io/api/event", get_http_session().post(
json={ "https://goauthentik.io/api/event",
"domain": "authentik", json={
"name": "pageview", "domain": "authentik",
"referrer": f"{__version__} ({build_hash})", "name": "pageview",
"url": f"http://localhost/{env}?utm_source={__version__}&utm_medium={env}", "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], headers={
"Content-Type": "application/json", "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) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/ # https://docs.djangoproject.com/en/2.1/howto/static-files/