Skip to content

Commit

Permalink
Added the ability to configure analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
TreyWW committed Feb 28, 2024
1 parent 1652520 commit b511d76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend/context_processors.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions frontend/templates/base/_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@
Alpine.start()

</script>
{{ analytics|safe }}
</head>
2 changes: 2 additions & 0 deletions settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit b511d76

Please sign in to comment.