♻️(backend) split posthog configuration

The posthog information were only available using the POSTHOG_KEY
settings. We split it in POSTHOG_KEY and POSTHOG_HOST to use them with
the pyhton posthog sdk
This commit is contained in:
Manuel Raynaud
2026-06-01 17:02:43 +02:00
parent 9f98af1387
commit 76544ab64a
5 changed files with 31 additions and 4 deletions
+1
View File
@@ -2967,6 +2967,7 @@ class ConfigView(drf.views.APIView):
"FRONTEND_THEME",
"MEDIA_BASE_URL",
"POSTHOG_KEY",
"POSTHOG_HOST",
"LANGUAGES",
"LANGUAGE_CODE",
"SENTRY_DSN",
+4 -2
View File
@@ -33,7 +33,8 @@ pytestmark = pytest.mark.django_db
FRONTEND_JS_URL="http://testjs/",
FRONTEND_THEME="test-theme",
MEDIA_BASE_URL="http://testserver/",
POSTHOG_KEY={"id": "132456", "host": "https://eu.i.posthog-test.com"},
POSTHOG_KEY="132456",
POSTHOG_HOST="https://eu.i.posthog-test.com",
RELEASE="1.0.0",
SENTRY_DSN="https://sentry.test/123",
THEME_CUSTOMIZATION_FILE_PATH="",
@@ -77,7 +78,8 @@ def test_api_config(is_authenticated):
],
"LANGUAGE_CODE": "en-us",
"MEDIA_BASE_URL": "http://testserver/",
"POSTHOG_KEY": {"id": "132456", "host": "https://eu.i.posthog-test.com"},
"POSTHOG_KEY": "132456",
"POSTHOG_HOST": "https://eu.i.posthog-test.com",
"RELEASE_VERSION": "1.0.0",
"SENTRY_DSN": "https://sentry.test/123",
"TRASHBIN_CUTOFF_DAYS": 30,
+8 -2
View File
@@ -17,6 +17,7 @@ from socket import gethostbyname, gethostname
from django.utils.translation import gettext_lazy as _
import dj_database_url
import posthog
import sentry_sdk
from configurations import Configuration, values
from corsheaders.defaults import default_headers
@@ -550,8 +551,9 @@ class Base(Configuration):
)
# Posthog
POSTHOG_KEY = values.DictValue(
None, environ_name="POSTHOG_KEY", environ_prefix=None
POSTHOG_KEY = SecretFileValue(None, environ_name="POSTHOG_KEY", environ_prefix=None)
POSTHOG_HOST = values.Value(
"https://eu.i.posthog.com", environ_name="POSTHOG_HOST", environ_prefix=None
)
# Crisp
@@ -1199,6 +1201,10 @@ class Base(Configuration):
"Both OPENAI_SDK and MISTRAL_SDK parameters can not be set simultaneously."
)
if cls.POSTHOG_KEY is not None:
posthog.api_key = cls.POSTHOG_KEY
posthog.host = cls.POSTHOG_HOST
class Build(Base):
"""Settings used when the application is built.
+1
View File
@@ -57,6 +57,7 @@ dependencies = [
"mozilla-django-oidc==5.0.2",
"nested-multipart-parser==1.6.0",
"openai==2.32.0",
"posthog==7.16.1",
"psycopg[binary,pool]==3.3.3",
"pycrdt==0.12.50",
"pydantic==2.13.3",
+17
View File
@@ -919,6 +919,7 @@ dependencies = [
{ name = "mozilla-django-oidc" },
{ name = "nested-multipart-parser" },
{ name = "openai" },
{ name = "posthog" },
{ name = "psycopg", extra = ["binary", "pool"] },
{ name = "pycrdt" },
{ name = "pydantic" },
@@ -994,6 +995,7 @@ requires-dist = [
{ name = "mozilla-django-oidc", specifier = "==5.0.2" },
{ name = "nested-multipart-parser", specifier = "==1.6.0" },
{ name = "openai", specifier = "==2.32.0" },
{ name = "posthog", specifier = "==7.16.1" },
{ name = "psycopg", extras = ["binary", "pool"], specifier = "==3.3.3" },
{ name = "pycrdt", specifier = "==0.12.50" },
{ name = "pydantic", specifier = "==2.13.3" },
@@ -1602,6 +1604,21 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" },
]
[[package]]
name = "posthog"
version = "7.16.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "backoff" },
{ name = "distro" },
{ name = "requests" },
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/b4/4f/a954175c862a3565d02c3f627874d85f18313472a0c4b08f45d84aaf3315/posthog-7.16.1.tar.gz", hash = "sha256:3619d3c619ad01f36c6d465e084950882417c63021eb3cfacacb23f900ec52d4", size = 226343, upload-time = "2026-05-27T18:46:20.129Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/3e/28/0f840699a1d0db3c1e5483c6208f0804a51f21ccfa34e6aa356161606adc/posthog-7.16.1-py3-none-any.whl", hash = "sha256:fd5aa4510033f3b039fda2fbfce45f493d140d4782f681e69639793dda317d67", size = 264231, upload-time = "2026-05-27T18:46:17.933Z" },
]
[[package]]
name = "pprintpp"
version = "0.4.0"