From cec2eb5a10fe2137dba314f57507eaa49cbd9f9e Mon Sep 17 00:00:00 2001 From: Florent Chehab Date: Fri, 14 Aug 2026 14:39:06 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(summary)=20add=20hostname=20to=20anal?= =?UTF-8?q?ytics=20properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This helps track down what was the source of events. This can be usefull when checking perf of different workers for instance. --- CHANGELOG.md | 1 + src/summary/summary/core/analytics.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ff7947b..2a086cd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ and this project adheres to - 🔥(frontend) drop unused vendored ConnectionObserver - 🐛(frontend) vendor formatChatMessageLinks and trim surrounding newlines +- ✨(summary) add hostname to analytics properties ### Fixed diff --git a/src/summary/summary/core/analytics.py b/src/summary/summary/core/analytics.py index c1a9391e..d4f40c20 100644 --- a/src/summary/summary/core/analytics.py +++ b/src/summary/summary/core/analytics.py @@ -1,9 +1,10 @@ """Analytics classes.""" 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 @@ -33,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.""" @@ -43,6 +48,8 @@ class Analytics: if self.is_disabled: return + properties = {**(properties or {}), "_hostname": self._hostname} + try: self._client.capture( event_name, distinct_id=distinct_id, properties=properties