feat: Add system information to all events

This commit is contained in:
Paul Gauthier (aider) 2024-08-12 16:21:46 -07:00
parent f110e8c8db
commit 48a344bc6d

View file

@ -1,5 +1,7 @@
import json
import uuid
import sys
import platform
from pathlib import Path
from mixpanel import Mixpanel
@ -17,6 +19,14 @@ class Analytics:
self.mp = Mixpanel(project_token) if project_token else None
self.user_id = self.get_or_create_uuid()
def get_system_info(self):
return {
"python_version": sys.version.split()[0],
"os_platform": platform.system(),
"os_release": platform.release(),
"machine": platform.machine()
}
def get_or_create_uuid(self):
uuid_file = Path.home() / ".aider" / "caches" / "mixpanel-uuid.json"
uuid_file.parent.mkdir(parents=True, exist_ok=True)
@ -36,6 +46,7 @@ class Analytics:
if properties is None:
properties = {}
properties.update(kwargs)
properties.update(self.get_system_info()) # Add system info to all events
# Handle numeric values
for key, value in properties.items():