From b511d7617c89c7c3062ed7ee2c3010d2cbe439b8 Mon Sep 17 00:00:00 2001 From: Trey Date: Wed, 28 Feb 2024 16:13:24 +0000 Subject: [PATCH] Added the ability to configure analytics --- backend/context_processors.py | 10 ++++++---- frontend/templates/base/_head.html | 1 + settings/settings.py | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/context_processors.py b/backend/context_processors.py index 3b3ea429..bb3ca981 100644 --- a/backend/context_processors.py +++ b/backend/context_processors.py @@ -1,9 +1,10 @@ -import os from typing import List, Optional, Dict, Any from django.http import HttpRequest from django.urls import reverse +from settings.helpers import get_var + ## Context processors need to be put in SETTINGS TEMPLATES to be recognized def navbar(request): @@ -24,9 +25,10 @@ def extras(request: HttpRequest): # import_method can be one of: "webpack", "public_cdn", "custom_cdn" data = {} - data["git_branch"] = os.environ.get("BRANCH") - data["git_version"] = os.environ.get("VERSION") - data["import_method"] = os.environ.get("IMPORT_METHOD", default="webpack") + data["git_branch"] = get_var("BRANCH") + data["git_version"] = get_var("VERSION") + data["import_method"] = get_var("IMPORT_METHOD", default="webpack") + data["analytics"] = get_var("ANALYTICS_STRING") return data diff --git a/frontend/templates/base/_head.html b/frontend/templates/base/_head.html index f793e251..a019348a 100644 --- a/frontend/templates/base/_head.html +++ b/frontend/templates/base/_head.html @@ -58,4 +58,5 @@ Alpine.start() + {{ analytics|safe }} diff --git a/settings/settings.py b/settings/settings.py index 9b4c2b42..aee71441 100644 --- a/settings/settings.py +++ b/settings/settings.py @@ -223,6 +223,8 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" +ANALYTICS = get_var("ANALYTICS_SCRIPT") + SOCIAL_AUTH_GITHUB_SCOPE = ["user:email"] SOCIAL_AUTH_GITHUB_KEY = get_var("GITHUB_KEY") SOCIAL_AUTH_GITHUB_SECRET = get_var("GITHUB_SECRET")