From 8d766efecbdeb083585abdde42f11dec66d7faba Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 4 Nov 2021 14:32:21 +0100 Subject: [PATCH] root: don't set signal on start when running in ci or dev Signed-off-by: Jens Langhammer --- authentik/root/settings.py | 28 +++++++++++++++------------- internal/outpost/ak/analytics.go | 6 +++++- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/authentik/root/settings.py b/authentik/root/settings.py index d2eb9d1e9..2bdd0ff1a 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -432,19 +432,21 @@ if _ERROR_REPORTING: env=CONFIG.y("error_reporting.environment", "customer"), ) if not CONFIG.y_bool("disable_startup_analytics", False): - get_http_session().post( - "https://goauthentik.io/api/event", - json={ - "domain": "authentik", - "name": "pageview", - "url": f"http://localhost/{env}", - "referrer": f"{__version__} ({build_hash})", - }, - headers={ - "User-Agent": sha512(SECRET_KEY.encode("ascii")).hexdigest()[:16], - "Content-Type": "text/plain", - }, - ) + should_send = env not in ["dev", "ci"] + if should_send: + get_http_session().post( + "https://goauthentik.io/api/event", + json={ + "domain": "authentik", + "name": "pageview", + "url": f"http://localhost/{env}", + "referrer": f"{__version__} ({build_hash})", + }, + headers={ + "User-Agent": sha512(SECRET_KEY.encode("ascii")).hexdigest()[:16], + "Content-Type": "text/plain", + }, + ) # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/ diff --git a/internal/outpost/ak/analytics.go b/internal/outpost/ak/analytics.go index 5f37e1cda..f3e83a3d8 100644 --- a/internal/outpost/ak/analytics.go +++ b/internal/outpost/ak/analytics.go @@ -44,6 +44,10 @@ func analytics(akURL url.URL, on string) { if _, s := os.LookupEnv("AUTHENTIK_DISABLE_ANALYTICS"); s { return } + e := getEnv() + if e == "ci" { + return + } body := struct { Domain string `json:"domain"` Name string `json:"name"` @@ -52,7 +56,7 @@ func analytics(akURL url.URL, on string) { }{ Domain: "authentik", Name: "pageview", - URL: fmt.Sprintf("http://localhost/outpost/%s", getEnv()), + URL: fmt.Sprintf("http://localhost/outpost/%s", e), Referrer: fmt.Sprintf("%s (%s)", constants.VERSION, constants.BUILD()), } b, err := json.Marshal(body)