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

Not working when Application name changed #277

Open mobile-sergey opened 4 months ago

mobile-sergey commented 4 months ago

I use several versions of XCode and change names for applications to use it. For example instead "XCode.app' I use 3 versions: "XCode 15.0.app", "XCode 15.4.app", "XCode 16.0.app" I working about week on project in XCode, and when I open Wakatime Dashbord I didn't see how hours I work on this project.

Please add feature to set Application name for collecting data from apps.

alanhamlett commented 4 months ago

It goes by the bundle-id of the app, the name of the .app folder shouldn't matter or affect tracking. If it does then it's a bug and we'll fix it soon!

mobile-sergey commented 4 months ago

May be this is bug. It's not working last week in XCode (green color), but it working in Android Studio (blue color - plugin in Android Studio) I working in XCode last week (06/19/2024 and 06/21/2024) - but no green color in this days.

Screenshot from 2024-06-24 17-30-28

alanhamlett commented 4 months ago

I verified we only check bundleIDs not app names when tracking, so the app folder's name makes no difference: https://github.com/wakatime/macos-wakatime/blob/c39db6959394672bad0687779e166eed47bfe370/WakaTime/Watchers/MonitoredApp.swift#L25

It must be something else. Please add this line to your ~/.wakatime.cfg file: debug = true

Then also check this box in the app's settings menu:

Screenshot 2024-06-24 at 11 02 35 PM

After doing that, type in any file and save the changes inside Xcode. Then share any error messages from your log files:

mobile-sergey commented 3 months ago

Sorry for long feedback - I haven't time to test debug mode. Now WakaTime plugin for macOS worked in XCode (I don't known why) I turn debug = true and find some errors and warnings in 2024-06-19 and 2024-06-21

~/.wakatime/wakatime.log no errors only warnings like this:

{"caller":"pkg/filestats/filestats.go:66","file":"/Users/sergey/Documents/FlexWave/AlarmPlus_iOS/AlarmPlus.xcodeproj","func":"heartbeat.initHandleOptions","level":"warning","message":"failed to detect the total number of lines in file \"/Users/sergey/Documents/FlexWave/AlarmPlus_iOS/AlarmPlus.xcodeproj\": read /Users/sergey/Documents/FlexWave/AlarmPlus_iOS/AlarmPlus.xcodeproj: is a directory","now":"2024-06-19T18:00:44+03:00","os/arch":"darwin/arm64","plugin":"Xcode/15.0.1-22266 macos-wakatime/5.16.0","time":1718809244.88797,"version":"v1.91.1"}

~/.wakatime/macos-wakatime.log Errors like this:

2024-06-19 18:45:12.124: App changed from Xcode to Finder (com.apple.finder)
**2024-06-19 18:45:12.126: Remove notification AXFocusedUIElementChanged failed: -25204
2024-06-19 18:45:12.126: Remove notification AXFocusedWindowChanged failed: -25204
2024-06-19 18:45:12.127: Remove notification AXSelectedTextChanged failed: -25204**
2024-06-19 18:45:14.304: App changed from Finder to Xcode (com.apple.dt.Xcode)
**2024-06-19 18:45:14.305: Add notification AXFocusedUIElementChanged failed: -25204**
**2024-06-19 18:45:14.306: Failed to setup AXObserver: The operation couldn’t be completed. (WakaTime.(unknown context at $101020c90).AXObserverError error 1.)**

2024-06-19 18:47:12.465: Sending heartbeat with: ["--entity", "/Users/sergey/Documents/FlexWave/AlarmPlus_iOS/AlarmPlus/View/Tabs/ScheduleTabView.swift", "--entity-type", "file", "--category", "coding", "--plugin", "Xcode/15.0.1-22266 macos-wakatime/5.16.0"]
2024-06-19 18:47:21.972: App changed from Xcode to Telegram (ru.keepcoder.Telegram)
**2024-06-19 18:47:21.973: Remove notification AXFocusedUIElementChanged failed: -25204
2024-06-19 18:47:21.974: Remove notification AXFocusedWindowChanged failed: -25204
2024-06-19 18:47:21.974: Remove notification AXSelectedTextChanged failed: -25204**
2024-06-19 18:47:23.117: App changed from Telegram to UserNotificationCenter (com.apple.UserNotificationCenter)
2024-06-19 18:47:27.413: App changed from UserNotificationCenter to Telegram (ru.keepcoder.Telegram)
2024-06-19 18:47:34.663: App changed from Telegram to Xcode (com.apple.dt.Xcode)
**2024-06-19 18:47:34.664: Add notification AXFocusedUIElementChanged failed: -25204**
**2024-06-19 18:47:34.665: Failed to setup AXObserver: The operation couldn’t be completed. (WakaTime.(unknown context at $101020c90).AXObserverError error 1.)**
2024-06-19 18:47:46.112: App changed from Xcode to Simulator (com.apple.iphonesimulator)
2024-06-19 18:47:49.405: App changed from Simulator to Finder (com.apple.finder)
2024-06-19 18:47:54.321: App changed from Finder to Xcode (com.apple.dt.Xcode)
**2024-06-19 18:47:55.824: Add notification AXFocusedUIElementChanged failed: -25204**
**2024-06-19 18:47:55.825: Failed to setup AXObserver: The operation couldn’t be completed. (WakaTime.(unknown context at $101020c90).AXObserverError error 1.)**
2024-06-19 18:48:35.298: App changed from Xcode to Google Chrome (com.google.Chrome)
2024-06-19 18:48:43.832: App changed from Google Chrome to Xcode (com.apple.dt.Xcode)

2024-06-22 20:24:20.677: App changed from Fork to Xcode (com.apple.dt.Xcode)
**2024-06-22 20:24:20.678: Add notification AXFocusedUIElementChanged failed: -25204**
**2024-06-22 20:24:20.679: Failed to setup AXObserver: The operation couldn’t be completed. (WakaTime.(unknown context at $102274c90).AXObserverError error 1.)**
2024-06-22 20:24:38.915: App changed from Xcode to Simulator (com.apple.iphonesimulator)
2024-06-22 20:24:41.071: App changed from Simulator to Finder (com.apple.finder)
2024-06-22 20:25:02.883: App changed from Finder to Simulator (com.apple.iphonesimulator)
2024-06-22 20:25:20.466: App changed from Simulator to Xcode (com.apple.dt.Xcode)
2024-06-22 20:25:20.536: Document changed: /Users/sergey/Documents/FlexWave/AlarmPlus_iOS/AlarmPlus/Data/Storage/Notification.swift
alanhamlett commented 2 months ago

I don't see anything abnormal in your logs. To confirm, it's tracking your time spent in Xcode.app but not XCode 15.0.app?