root: don't set signal on start when running in ci or dev

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-04 14:32:21 +01:00
parent 9ac3b29418
commit 8d766efecb
2 changed files with 20 additions and 14 deletions

View File

@ -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/

View File

@ -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)