Add database vendor, version and machine arch to phonehome message

See #226, in the context of which having some idea of the number of
installations on 2.x w/ mariadb would have been very useful
This commit is contained in:
Klaas van Schelven
2025-10-10 09:41:57 +02:00
parent 9cb89ecf46
commit d8fef759ca
2 changed files with 23 additions and 10 deletions

View File

@@ -1,11 +1,12 @@
import platform
import logging
import requests
import platform
import json
from django.conf import settings
from django.utils import timezone
from django.contrib.auth import get_user_model
from django.db import connection
from bugsink.transaction import durable_atomic, immediate_atomic
from bugsink.version import __version__
@@ -70,6 +71,11 @@ def send_if_due():
def _make_message_body():
database_vendor = connection.vendor
if database_vendor == "mysql":
if connection.mysql_is_mariadb:
database_vendor = "mariadb"
return {
"installation_id": str(Installation.objects.get().id),
"version": __version__,
@@ -81,14 +87,6 @@ def _make_message_body():
"SITE_TITLE": get_settings().SITE_TITLE,
"DEFAULT_FROM_EMAIL": settings.DEFAULT_FROM_EMAIL,
# we don't have these settings yet.
# LICENSE_KEY
# LICENSE_NAME
# LICENSE_EMAIL
# LICENSE_USERS
# LICENSE_EXPIRY
# LICENSE_TYPE
# Settings that tell us a bit about how Bugsink is actually deployed. Useful for support.
"SINGLE_USER": get_settings().SINGLE_USER,
"SINGLE_TEAM": get_settings().SINGLE_TEAM,
@@ -99,6 +97,13 @@ def _make_message_body():
"DATABASE_ENGINE": settings.DATABASES["default"]["ENGINE"],
},
# non-settings that tell us a bit about the environment
"runtime": {
"database_vendor": database_vendor,
"database_version": connection.get_database_version(),
"machine": platform.machine(),
},
"usage": {
"user_count": User.objects.count(),
"active_user_count": User.objects.filter(is_active=True).count(),

View File

@@ -1 +1,9 @@
# from django.test import TestCase
from django.test import TestCase
from .tasks import _make_message_body
class PhoneHomeTests(TestCase):
def test_make_message_body(self):
# simple "does not crash" test (at least tests the various database getter code paths don't crash)
_make_message_body()