wakatime-mode icon indicating copy to clipboard operation
wakatime-mode copied to clipboard

heartbeats are ignored for files loaded over tramp

Open amoore opened this issue 7 years ago • 7 comments

Wakatime does not appear to keep track of time spent in files loaded from remote machines via tramp.

For example, if I visit a file like "/ssh:remotehostname:/home/user/example.conf", then this appears in the log:

{"now": "2016/11/29 10:31:35 -0500", "version": "6.2.0", "plugin": "emacs-wakatime/1.0.2", "caller": "main.py", "lineno": 541, "file": "/ssh:remotehostname:/home/user/example.conf", "level": "DEBUG", "message": "File does not exist; ignoring this heartbeat."}

That file does exist, but I don't think that wakatime realizes that it's on a remote machine.

Perhaps it should be testing for file existence at all.

amoore avatar Nov 29 '16 15:11 amoore

Don't want to read a remote file every time a heartbeat is sent, for performance reasons. Could we pass wakatime-cli a local temporary file along with the "real path" of that file?

alanhamlett avatar Apr 11 '17 02:04 alanhamlett

Bumping this just to show there's still interest in this.

hofstee avatar Apr 10 '18 04:04 hofstee

How about this solution:

  1. When wakatime-mode detects a file doesn't exist, instead of noop it checks if that file is a remote tramp file.
  2. If it's a remote tramp file, it gets the file's contents from the local tramp buffer or cache. (this?)
  3. wakatime-mode sends the buffer/tmp file to wakatime-cli along with --real-entity <actual file path> so wakatime-cli reads the file's stats from the local file but uses <actual file path> for the name displayed on your dashboard.

The change to wakatime-cli is trivial, I just don't know where tramp stores it's local copy of a remote file.

alanhamlett avatar Apr 10 '18 05:04 alanhamlett

Looks like tramp uses generate-new-buffer-name to create a local buffer when editing files. If we can pass that local buffer file to wakatime-cli then we can track tramp files:

https://github.com/jwiegley/tramp/blob/master/lisp/tramp.el#L628

alanhamlett avatar Apr 10 '18 05:04 alanhamlett

I've just tested that on a few mechanisms, and tramp-temp-buffer-file-name doesn't seem to ever get a value, so I think that might be a bust.

jashank avatar Jul 07 '18 03:07 jashank

Related to wakatime/wakatime-cli#623, which added support for ssh:// and sftp:// remote files.

alanhamlett avatar Jan 08 '22 02:01 alanhamlett

Still having this issue using tramp on doom emacs

benwoosley avatar Oct 26 '22 17:10 benwoosley