wakatime / texstudio-wakatime

TeXstudio macro for automatic time tracking and metrics generated from your TeXstudio usage.
https://wakatime.com/texstudio
BSD 3-Clause "New" or "Revised" License
10 stars 4 forks source link

No logging, no heartbeats, and texstudio's configuration is restored #2

Closed EllaShar closed 5 years ago

EllaShar commented 5 years ago

I have installed the plugin for texstudio for the first time. Other plugins (notepad++, pycharm) run just fine. I have the wakatime CLI installed. But on my dashboard, texstudio does not appear at all. I've checked - there are no heartbeats from texstudio. When setting debug to true in wakatime's configuration, I see logging events but no events related to texstudio. Now from what I see, after I install the plugin, texstudio.ini contains the macro related to wakatime. It also adds space around each "=" and changes file endings from PC to UNIX (thank you beyond compare). Then I run texstudio, and when I close it, the texstudio.ini is edited so there is no space around each "=", file endings are back to PC, and the wakatime macro is gone. Other configuration changes remain (I checked by changing the spelling check language to some other language).

I tried editing the configuration file manually and only adding the macro line without changing anything else and it didn't help.

Please help. Texstudio version is 2.12.14. I'm using Windows 10. wakatime --version ---> 12.0.0

EllaShar commented 5 years ago

I've managed to make it work! This is still a critical bug though.

Turns out that texstudio deletes the configuration line involving wakatime's macro because it has no related file in the "macro" folder which is in texstudio's folder. The easiest way (as a user) to create this file is to open texstudio, go to Macros, then Edit Macros. Name: WakaTime Trigger: ?txs-start|?save-file Type: Script

As for the content, go to the texstudio configuration file after you installed the plugin (and before texstudio deleted it). Look at the line related to wakatime. It is divided into 4 sections by commas, where the first section is WakaTime, the second section is the content in quotation marks, the third section is empty and the fourth section is the trigger which is ?txs-start|?save-file.

Copy the content section without the quotation marks. Paste it to Notepad++ and replace all (normal, not extended!) the \n by "ThisShouldBeANewline". Then replace all (extended, not normal!) "ThisShouldBeANewline" by \r\n. Now the content is actual JavaScript! Copy it and paste into the content section in the "Edit Macros" window. Save and that's it, you're done.

As the developer of this plugin (thank you!), please make the installation process create this file. Adding a line to the configuration file is not enough.

Thank you very much, Ella

gandarez commented 5 years ago

@EllaShar seems TeXstudio has changed the way of writing macros. I just realized a new folder macrowhich contains txsMacro files. So I assume the way we're installing this extension should be redefined to the new way, right?

~/.config/texstudio/macro

EllaShar commented 5 years ago

@gandarez Yes. You should still update texstudio's configuration file, and in addition, you should create the appropriate file in the macros folder. Thank you for the response.

EllaShar commented 5 years ago

Also, since there is no active cooperation with texstudio's developers, is there a way to keep things like this from happening in the future? So that if there is a breaking change in texstudio, you will be notified? Maybe like a test that runs periodically.

alanhamlett commented 5 years ago

Maybe like a test that runs periodically.

Great idea! I see the wakatime-desktop app as solving this. We're working on having it detect when plugins malfunction by checking the last time each editor was seen by WakaTime (https://wakatime.com/plugins/status) and cross-reference that with the editors it detects being used locally. When it finds an editor used locally but not seen by WakaTime's API, the desktop app can notify you via system tray or toast message.

EllaShar commented 5 years ago

@alanhamlett That's cool. But would it solve an installation problem? It seems that plugins that were never installed do not appear in https://wakatime.com/plugins/status (this makes sense). So to detect a plugin that cannot be installed, a different approach should be taken.

EllaShar commented 5 years ago

@gandarez @alanhamlett This is still a critical bug. Users cannot install the TexStudio plugin. Are you responsible for fixing it? Do you need help?

Ella

alanhamlett commented 5 years ago

So changing all newlines from Unix(\n) to Win(\r\n) style fixed it for you? So to be sure, the fix is to write the macro line in texstudio.ini using \r\n for the macro contents when installing with install.py? For ex, it would write this line to texstudio.ini:

Macros\0=WakaTime, "%SCRIPT\r\n\r\nvar utils = {};\r\n\r\nutil...

While currently it writes this line:

Macros\0=WakaTime, "%SCRIPT\n\nvar utils = {};\n\nutil...
EllaShar commented 5 years ago

@alanhamlett This won't solve the problem. The problem is that TexStudio now has a macros folder and it wants to have a file in there for each macro. So you need to create that file. To test whether you solved the bug, just remove the TexStudio macro entirely. Update TexStudio to the newest version. Then just try to install the TexStudio macro and see if you get any new data on WakaTime.

The newlines thing is a minor bug since it has no consequences. If you make that change, I think you should support linux and mac too. Use os.linesep since it's cross-platform.

giliam commented 5 years ago

Hi everyone, thank you for the fixed, I had the same problem on Windows 7 with TeXstudio 2.12.16. I had to do a slightly different process but still based on @EllaShar messages.

  1. Copy the Macro from the texstudio.ini file before it is deleted by TeXStudio
  2. Replace the \n by real new lines
  3. Change the wakatime command in the args by wakatime.exe (Windows issue)
  4. Add the path of wakatime.exe to the $PATH variable

And it worked! When I now look at texstudio.ini, I don't have the \r\n but \n. So I don't really know why the normal technique didn't work :S

gandarez commented 5 years ago

I just finished the fixing for textstudio plugin but it seems there's a bug that prevents loading any macro from macro folder.

Issue opened https://github.com/texstudio-org/texstudio/issues/663

gandarez commented 5 years ago

PR https://github.com/wakatime/texstudio-wakatime/pull/3

alanhamlett commented 5 years ago

Fixed with #3.

alanhamlett commented 5 years ago

Now you should be able to run install.py and it re-installs the macro correctly. Lemme know if it still needs any changes 👍