wakatime / macos-wakatime

Mac system tray app for automatic time tracking and metrics generated from your Xcode, Figma, Postman, etc. usage.
https://wakatime.com/mac
BSD 3-Clause "New" or "Revised" License
148 stars 23 forks source link

Detect and warn when browser extension installed #226

Closed alanhamlett closed 7 months ago

alanhamlett commented 7 months ago

If Chrome/Safari/Firefox is enabled for monitoring and the dev also has the browser WakaTime extension installed, we should warn them to choose one or the other not both. Either the Mac app or browser extension, but not both.

starbugs commented 7 months ago

Did you have an approach in mind for this? I guess it would technically be possible to detect whether an extension is installed by inspecting the filesystem. I am not sure though if this is what you had in mind since this could bring up technical challenges and privacy concerns. macOS might also show a warning when we try to access certain folders on the filesystem (but I didn't try yet).

There are multiple solutions that I could think of, but they come with different caveats:

  1. Have the WakaTime extensions communicate with the macos-wakatime process via some IPC mechanism (might be a lot of work).

  2. Implement a way for the macOS app to query the wakatime API for active usage of the extensions.

  3. Just put a warning somewhere in the UI and show it regardless of whether the extension is installed.

  4. Monitor the browser's extension folders (with the caveats from above).

I will move to the next issue for now since I am not sure what implementation you'd prefer and this may potentially be a lot of work.

alanhamlett commented 7 months ago

I like option 2 the best. We already have the API for it: https://wakatime.com/developers/#user_agents

Just look for any user agents with last_seen_at within the last 5 minutes and is_browser_extension set to true. Also filter by name matching enabled browsers so we don't show the warning to people using macos-wakatime to track Firefox but not Chrome, and only have the browser extension installed in Chrome not Firefox.