Closed abrichr closed 2 weeks ago
Via ChatGPT:
class TrackingAction(QAction):
""" QAction subclass that automatically tracks its usage with PostHog. """
def __init__(self, title, parent=None):
super().__init__(title, parent)
self.triggered.connect(self.track_event)
def track_event(self, checked: bool):
""" Send event information to PostHog. """
posthog.capture('user-id', f'{self.text()} Clicked', {
'timestamp': datetime.now().isoformat(),
'checked': checked
})
class SystemTrayIcon:
def __init__(self) -> None:
self.app = QApplication([])
self.tray = QSystemTrayIcon(QIcon("path/to/icon.png"), self.app)
self.menu = QMenu()
self.setup_menu()
self.tray.setContextMenu(self.menu)
self.tray.show()
def setup_menu(self):
record_action = TrackingAction("Record", self)
record_action.triggered.connect(self.record) # Additional logic on trigger
self.menu.addAction(record_action)
quit_action = TrackingAction("Quit", self)
quit_action.triggered.connect(self.quit)
self.menu.addAction(quit_action)
def record(self):
print("Recording started...") # Your recording logic here
def quit(self):
self.app.quit()
def run(self):
self.app.exec_()
if __name__ == "__main__":
tray = SystemTrayIcon()
tray.run()
In addition to this it would be good to capture the following additional function calls (regardless of where they are called from):
openadapt.record
openadapt.replay
openadapt.visualize
openadapt.events.get_events
Feature request
We would like to view system tray events in posthog
Motivation
Understanding user activity