git-time-metric / gtm

Simple, seamless, lightweight time tracking for Git
MIT License
979 stars 52 forks source link

Support for tracking apps #96

Closed desaroger closed 5 years ago

desaroger commented 5 years ago

Hi!

I am using this tool to estimate working hours for each branch/commit/issue, and is working fine. The problem is sometimes I spent time in things that are not files, like in the browser testing the web I am working on for example.

I saw it exists the "terminal" support. A way to track time spent in the terminal, not related to a given file. I checked the source code, and understood that it uses the file .gtm/terminal.app to track the time spent in the console. I did the same thing, adding .gtm/browser.app and recording events for that file. And works more or less fine.

The problem is that the time spent in "browser.app" is not added to the commit, never, because gtm only adds to the commit the time spent on the files staged to that commit (which is an awesome feature). But you can add the time spent in the terminal, so it is some support for that "terminal.app" type of files. But I looked through the code and seems that "terminal.app" is hardcoded to the code.

My suggestion is to add support for tracking apps, and modify the terminal implementation so it works as a generic app too:

  1. You can track apps running gtm record --app browser
  2. This creates (if it does not exists) a file in .gtm/{name}.app and adds a .event
  3. By default, as it is now with terminal, when you run gtm status all the time spent is shown. You have a new parameter, "-ignore-apps" which can indicate if ignore none, ignore all, or ignore some explicitly.
  4. gtm commit works as it works now, adds all the "apps" events into the commit time.
mschenk42 commented 5 years ago

Interesting idea. We were actually working on app tracking functionality but that work has stalled. The challenge is with the monitoring of the application events across platforms. Your idea would allow us to provide this capability to record application events but not have to necessarily solve cross platform the monitoring and recording of application events.

desaroger commented 5 years ago

Nice! How many time we can expect to wait until this feature is done? I thought, if I have time, to try to implement it myself and do a PR, but I never did nothing in go (but I can try). Are you already working on it?

Thank you very much!

mschenk42 commented 5 years ago

It's not currently on the short-list. It may be somewhat challenging to add this feature since the code wasn't initially implemented with this flexibility.

I'm also wondering about how the plugin for tracking apps would work. If you can easily add what you want to track, like browser.app, how would you trigger the recording of the browser events?

desaroger commented 5 years ago

Hi! I am already working on my own fork on this feature. My idea is to do a PR this week or so.

Mmm your idea was to create a plugin that tracks the app you are using in that moment? Sincerely I didn't look so much in the future, I only wanted to add to gtm support for tracking events not related with files, as I thought it would be useful and powerful, and will allow plugin creators to track anything they want. I already did an asp.net script that tracks the time I spent on the browser testing the page I am working on, that is a lot of time that was not being taken into account.

Also, I don't know if you see the problem in how the plugin will detect you are using the browser (I thought about a chrome plugin, but I don't know if you wanted a global plugin which detects any app) or how the plugin will send the command, but here devkabiir proposed a good idea about creating a lightweight http server. I share to you in case you didn't see it. I think it's a good idea to add more ways the plugins can communicate with gtm.

PS: Sorry for my unstructured response, english is not my first language and I didn't know how to organize the ideas hah