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
127 stars 22 forks source link

Not tracking any app #208

Closed matronator closed 4 months ago

matronator commented 4 months ago

I downloaded, enabled everything in the Settings, but still I see no Xcode or any other of the tracked apps (they are turned on as to be tracked) in the dashboard. Every other plugin for every other IDE I use works, only this one is not tracking for some reason.

alanhamlett commented 4 months ago

Xcode should be working but the others not yet.

elaninhust commented 4 months ago

same issue here, my Xcode doesn't work either. Maybe it works with the M-chip ones

alanhamlett commented 4 months ago

same issue here, my Xcode doesn't work either. Maybe it works with the M-chip ones

I've tested on Intel chipset and M-chipset without finding any bugs. Can you build the app by cloning this repo then watch your Xcode console for debug messages and see if it's able to detect when you give Xcode focus, and when you move the cursor inside Xcode?

There was a similar issue we closed where it wasn't working on M1 #118.

matronator commented 4 months ago

I'm actually on an M2 MacBook Air. Sure, I'll try give it a go after work.

matronator commented 4 months ago

So I ran the project from Xcode, building it from source and there are no messages indicating when Xcode gets focus. So I guess it doesn't track it properly?

alanhamlett commented 4 months ago

Does the system tray icon show a warning?

Screenshot 2024-03-01 at 11 42 46 AM

When building from source, you need to delete WakaTime from the Privacy & Security → Accessibility settings (click the minus button), then click the WakaTime system tray icon and request a11y permission.

Without a11y permission, you should still see the App changed from... logs:

App changed from Xcode to Google Chrome (com.google.Chrome)
App changed from Google Chrome to Xcode (com.apple.dt.Xcode)

But you won't see file changed logs:

Document changed: /git/macos-wakatime/WakaTime/Watcher.swift

Do you see the App changed logs when switching between different apps?

Pia007 commented 4 months ago

Downloaded a few weeks ago and still have not seen any tracking from Xcode but I do see it when I use vs code. I have:

  1. download and installed wakatime for vscodes
  2. given the accessibility permission ton wakatime
  3. toggled wakatime as a monitored app

Still cannot see anything. Xcode 15.2 M3 chip

fstevens30 commented 4 months ago

I think I have a similar issue. M1 Pro Macbook. Checked wakatime accessibility and reinstalled as well. Log says the following:

{"caller":"cmd/run.go:158","func":"cmd.Run","level":"warning","message":"one of the following parameters has to be provided: --config-read, --config-write, --entity, --offline-count, --print-offline-heartbeats, --sync-offline-activity, --today, --today-goal, --useragent, --version","now":"2024-03-04T18:19:36+13:00","os/arch":"darwin/arm64","version":"v1.90.0"}
alanhamlett commented 4 months ago

Log says the following:

one of the following parameters has to be provided...

@fstevens30 I've released a new version (5.5.3) to prevent that log error, but that log wouldn't prevent tracking your code stats and is probably unrelated to this bug.

@Pia007 @fstevens30 it's really hard/impossible for me to reproduce this bug without an error message. Can you build the app from source and see if you're getting these expected app logs when changing the currently focused app? Those logs would be inside Xcode after building the app not in the ~/.wakatime/wakatime.log, but if you see any errors in that log file they're also helpful.

locke2a commented 4 months ago

I have the same issue. For what it's worth, if that's any help, I noticed that my "Monitored Apps" list is reset upon every launch. If I enable "Slack", "Terminal" & "Xcode", and then quit and re-open Wakatime, they are toggled off.

I'll try to make some time to build and run it on my machine, and see if I can produce some useful logs.

[Edit] Something ever more weird : I noticed that all of the apps listed in the Monitered Apps pane reset to "off" on Wakatime startup, except for a single one : Arc, which seems to remember its state between launches. And I just noticed that if I turn it to "on", it effectively tracks time spent using Arc.

alanhamlett commented 4 months ago

That must be the bug! It wasn't clearing the monitored apps list in previous releases, but now I can reproduce it on the latest version. I'll get a fix released soon.

locke2a commented 4 months ago

Alright, I just had a quick look at the code, so I'm not really sure but I think the bug goes back to https://github.com/wakatime/macos-wakatime/commit/3c8d600a29fbc9105c2f3ac814cfea931d1861e7

Seems to me that MonitoredAppsView/buildView(_:) was refactored into another method, but the NSSwitches created inside that new method don't have a tag anymore, so when switchToggled(_:) is called, it changes the state for the app at the index 0, which is currently Arc, hence why it is the only one persisting.

alanhamlett commented 4 months ago

It was broken with #203, fixed now in #213 and #216.

alanhamlett commented 4 months ago

I was never able to reproduce it because I already had Xcode enabled, and didn't modify my monitored apps recently.

alanhamlett commented 4 months ago

Fixed in v5.5.5.

elaninhust commented 3 months ago

same issue here, my Xcode doesn't work either. Maybe it works with the M-chip ones

I've tested on Intel chipset and M-chipset without finding any bugs. Can you build the app by cloning this repo then watch your Xcode console for debug messages and see if it's able to detect when you give Xcode focus, and when you move the cursor inside Xcode?

There was a similar issue we closed where it wasn't working on M1 #118.

@alanhamlett Sorry for the late. I've built the app and then it works fine. But what's really weird is that when I switch back to the release one (version 5.5.5), it fails again.

Now I am using the one I build locally and everything is fine for now.

alanhamlett commented 3 months ago

That's good, and make sure to check the monitored apps menu because the bug reset the toggle switches.

Pia007 commented 3 months ago

@alanhamlett Sorry about the late reply. I have built from sourse and here is an image of the logs, works:

Screenshot 2024-03-05 at 7 37 52 PM
alanhamlett commented 3 months ago

@Pia007 does it work with the latest version?

Pia007 commented 3 months ago

@Pia007 does it work with the latest version?

Yes. It works! I cloned main a few hours ago.

alanhamlett commented 3 months ago

Awesome! Then you can switch back to using the normal releases so you get updates automatically: https://github.com/wakatime/macos-wakatime/releases/latest/download/macos-wakatime.zip