Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions frog/services/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,29 @@
class TelemetryService(GObject.GObject):
_gtype_name = 'TelemetryService'

posthog: Posthog | None
posthog: Posthog | None = None
installation_id: str | None
is_active: bool = True

def __init__(self):
super().__init__()
self.posthog = Posthog(project_api_key='phc_HpETCN6yQKZIr8gr6mBQTd3H0SjKUBrNMI3AizoX97f',
host='https://eu.posthog.com')

def set_installation_id(self, installation_id: str):
self.installation_id = installation_id

def set_is_active(self, is_active: bool):
self.is_active = is_active
if is_active and self.posthog is None:
self.posthog = Posthog(project_api_key='phc_HpETCN6yQKZIr8gr6mBQTd3H0SjKUBrNMI3AizoX97f',
host='https://eu.posthog.com')
elif (not is_active) and self.posthog is not None:
self.posthog.shutdown()
self.posthog = None

def capture(self, event: str, props: Any = None):
if self.posthog and self.is_active:
if self.posthog:
self.posthog.capture(self.installation_id, event, props)

def capture_page_view(self, page_name: str):
self.posthog.capture(self.installation_id, '$pageview', {'$current_url': page_name})
if self.posthog:
self.posthog.capture(self.installation_id, '$pageview', {'$current_url': page_name})


telemetry = TelemetryService()