Adding PostHog telemetry of os and machine architecture (#1137)

This commit is contained in:
Raivis Dejus 2025-04-03 21:20:48 +03:00 committed by GitHub
commit c861675947
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 85 additions and 1 deletions

View file

@ -1,6 +1,7 @@
import enum
import typing
import logging
import uuid
from PyQt6.QtCore import QSettings
@ -48,12 +49,21 @@ class Settings:
UI_LOCALE = "ui-locale"
USER_IDENTIFIER = "user-identifier"
TRANSCRIPTION_TASKS_TABLE_COLUMN_VISIBILITY = (
"transcription-tasks-table/column-visibility"
)
MAIN_WINDOW = "main-window"
def get_user_identifier(self) -> str:
user_id = self.value(self.Key.USER_IDENTIFIER, "")
if not user_id:
user_id = str(uuid.uuid4())
self.set_value(self.Key.USER_IDENTIFIER, user_id)
return user_id
def set_value(self, key: Key, value: typing.Any) -> None:
self.settings.setValue(key.value, value)

View file

@ -1,6 +1,11 @@
import logging
import sys
import locale
import platform
import darkdetect
from posthog import Posthog
from PyQt6.QtGui import QFont
from PyQt6.QtWidgets import QApplication
from PyQt6.QtGui import QPalette, QColor
@ -175,6 +180,24 @@ class Application(QApplication):
self.window = MainWindow(transcription_service)
posthog = Posthog(project_api_key='phc_NqZQUw8NcxfSXsbtk5eCFylmCQpp4FuNnd6ocPAzg2f',
host='https://us.i.posthog.com')
posthog.capture(distinct_id=self.settings.get_user_identifier(), event="app_launched", properties={
"app": VERSION,
"locale": locale.getdefaultlocale(),
"system": platform.system(),
"release": platform.release(),
"machine": platform.machine(),
"version": platform.version(),
})
logging.debug(f"Launching Buzz: {VERSION}, "
f"locale: {locale.getdefaultlocale()}, "
f"system: {platform.system()}, "
f"release: {platform.release()}, "
f"machine: {platform.machine()}, "
f"version: {platform.version()}, ")
def show_main_window(self):
if not self.hide_main_window:
self.window.show()

52
poetry.lock generated
View file

@ -187,6 +187,18 @@ files = [
{file = "av-14.2.0.tar.gz", hash = "sha256:132b5d52ca262b97b0356e8f48cbbe54d0ac232107a722ab8cc8c0c19eafa17b"},
]
[[package]]
name = "backoff"
version = "2.2.1"
description = "Function decoration for backoff and retry"
optional = false
python-versions = ">=3.7,<4.0"
groups = ["main"]
files = [
{file = "backoff-2.2.1-py3-none-any.whl", hash = "sha256:63579f9a0628e06278f7e47b7d7d5b6ce20dc65c5e96a6f3ca99a6adca0396e8"},
{file = "backoff-2.2.1.tar.gz", hash = "sha256:03f829f5bb1923180821643f8753b0502c3b682293992485b0eef2807afa5cba"},
]
[[package]]
name = "backports-tarfile"
version = "1.2.0"
@ -1955,6 +1967,18 @@ files = [
{file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
]
[[package]]
name = "monotonic"
version = "1.6"
description = "An implementation of time.monotonic() for Python 2 & < 3.3"
optional = false
python-versions = "*"
groups = ["main"]
files = [
{file = "monotonic-1.6-py2.py3-none-any.whl", hash = "sha256:68687e19a14f11f26d140dd5c86f3dba4bf5df58003000ed467e0e2a69bca96c"},
{file = "monotonic-1.6.tar.gz", hash = "sha256:3a55207bcfed53ddd5c5bae174524062935efed17792e9de2ad0205ce9ad63f7"},
]
[[package]]
name = "more-itertools"
version = "10.6.0"
@ -2760,6 +2784,32 @@ files = [
{file = "polib-1.2.0.tar.gz", hash = "sha256:f3ef94aefed6e183e342a8a269ae1fc4742ba193186ad76f175938621dbfc26b"},
]
[[package]]
name = "posthog"
version = "3.23.0"
description = "Integrate PostHog into any python application."
optional = false
python-versions = "*"
groups = ["main"]
files = [
{file = "posthog-3.23.0-py2.py3-none-any.whl", hash = "sha256:2b07d06670170ac2e21465dffa8d356722834cc877ab34e583da6e525c1037df"},
{file = "posthog-3.23.0.tar.gz", hash = "sha256:1ac0305ab6c54a80c4a82c137231f17616bef007bbf474d1a529cda032d808eb"},
]
[package.dependencies]
backoff = ">=1.10.0"
distro = ">=1.5.0"
monotonic = ">=1.5"
python-dateutil = ">2.1"
requests = ">=2.7,<3.0"
six = ">=1.5"
[package.extras]
dev = ["black", "django-stubs", "flake8", "flake8-print", "isort", "lxml", "mypy", "mypy-baseline", "pre-commit", "pydantic", "types-mock", "types-python-dateutil", "types-requests", "types-setuptools", "types-six"]
langchain = ["langchain (>=0.2.0)"]
sentry = ["django", "sentry-sdk"]
test = ["anthropic", "coverage", "django", "flake8", "freezegun (==1.5.1)", "langchain-anthropic (>=0.2.0)", "langchain-community (>=0.2.0)", "langchain-openai (>=0.2.0)", "langgraph", "mock (>=2.0.0)", "openai", "parameterized (>=0.8.1)", "pydantic", "pylint", "pytest", "pytest-asyncio", "pytest-timeout"]
[[package]]
name = "pre-commit"
version = "2.21.0"
@ -4806,4 +4856,4 @@ type = ["pytest-mypy"]
[metadata]
lock-version = "2.1"
python-versions = ">=3.9,<3.13"
content-hash = "deb764edd760f9578f1c9f77621e459d755006e9066355b4f3311ce0f115ea34"
content-hash = "54b43566cebe502c9d7b2ca7c7a0694a15cb17891a8a1b981f249ea5442fb8c9"

View file

@ -79,6 +79,7 @@ treetable = "^0.2.5"
soundfile = "^0.13.1"
urllib3 = "^2.3.0"
demucs = {url = "https://github.com/raivisdejus/demucs/releases/download/4.1.0a3/demucs-4.1.0a3-py3-none-any.whl"}
posthog = "^3.23.0"
[tool.poetry.group.dev.dependencies]
autopep8 = "^1.7.0"