fixup! (summary) add hostname to analytics properties

This commit is contained in:
Florent Chehab
2026-08-20 10:41:56 +02:00
parent 13c75697c7
commit 1395db77ca
+6 -5
View File
@@ -4,7 +4,7 @@ import json
import socket
import time
from collections import Counter
from functools import lru_cache
from functools import cached_property, lru_cache
from urllib.parse import urlsplit, urlunsplit
import redis
@@ -34,6 +34,10 @@ class Analytics:
logger.info("Initialize analytics client")
self._client = Posthog(settings.posthog_api_key, settings.posthog_api_host)
@cached_property
def _hostname(self):
return socket.gethostname()
@property
def is_disabled(self):
"""Check if analytics client is disabled or not configured."""
@@ -44,10 +48,7 @@ class Analytics:
if self.is_disabled:
return
# We add hostname to help track down the source of events
properties = properties or {}
if not properties.get("hostname"):
properties = {**properties, "hostname": socket.gethostname()}
properties = {**(properties or {}), "_hostname": self._hostname}
try:
self._client.capture(