Why and how to use WakaTime to monitor the time you spend on programming?¶
What is this weird idea?¶
A professional sportive tries to monitor precisely his daily training process, including his food, which muscle she/he is working on etc.
Well, similarly, developers and programmers might be interested to know on which projects they spend more time, on which files or directories they work on etc.
Why exactly?¶
Hum… in fact, the real reason seems to be pure ego: programmers are proud to see how much time they can work on each of their projects.
Avertissement
If you are concerned about your privacy, you should rather use a local-only tool such as the great ActivityWatch, which offers a « watcher » plugin to monitor your editing activity for a few editors, including VSCode that I use and advise to use! Your data remains local and no espionage is possible with ActivityWatch.
À faire
Try both all the month of April, then remove Wakatime if I’m happy with ActivityWatch?
With this in mind, let me present an interesting and peculiar tool that I have been using from a while.
How can we monitor our programming time?¶
The goal of WakaTime is to offer to any developer an easy, (relatively) « secured » and centralized way to monitor the time she/he spend on programming, on a daily, weekly or monthly basis.
And they do the job extremely well, because WakaTime offers three things:
a very nice web interface, well designed (responsive of course), to visualize your activity,
a really rich collection of plug-ins, you know, these small softwares that you can easily add to your favorite text editor,
and an easy way to embed some charts anywhere on the web.
The concept is quite simple after: your text editor is spying on you and each aspect of your programming activity, to send the data on-line on WakaTime servers, and then you (and their sys-admins, and the NSA of course) can easily read and use your personal data. Scary, right?
In my situation¶
Installation and use of WakaTime¶
I was using Sublime Text 3 almost exclusively for about 4 years. Without any surprise, the WakaTime team had written a plug-in for Sublime Text 3.
You can install it with two clicks, and the plug-in will integrate nicely in ST3 (discrete, minimal system workload, and it can even stores the data in order to send them later if your computer is temporarily disconnected from Internet).
I am now using Visual Studio Code, and of course it also has an extension for Wakatime which can be installed quickly too.
Overview of the statistics ?¶
During the first 8 days (after installing it, in January 2015), I was in a coding marathon to conclude some projects (StrapDown.js, my MEC Students Face-Book demo etc), but still, I was kind of scared to see that I used my text editor for 29 hours in 8 days!
It is also possible to see:
on which project do you spend the most of your time,
which file-types are the more used, on a daily basis,
and even on which files have you worked one (this last thing can be disabled).
For instance, during my first week of use, the repartition was about: 30% HTML, 29% Python, 15% reStructuredText, 6% Bash, 12% Markdown.
Let us finish on a bonus: read your WakaTime stats from the command line¶
It is easy to install the command line tool WakaTimeCLI,
with the command npm install wakatimecli
.
This tool is based on the officiel WakaTime API, and should be easy to use. The first command is wakatime -help which shows the different options that are accepted by the tool:
Please pass an option:
-? or -help
-u or -user
-t or -today
-y or -yesterday
-w or -week
The help (wakatime -help
) is not very clear, but we can guess its use by directly reading its source-code.
Note
This tool is writing its results with ANSI colors, sweet!
Yeah, but it is less sweet when we see that the colors are used even if the output is a terminal which does not support them, or if it is a file (but this is not the script’s fault but its a bug in the cli-color npm module that should have implemented a better detection of the output, like I did for ANSIColors a few years ago)
As this message explains it, this is NOT the good practice to follow. (I opened an issue about that on the GitHub repo for WakaTimeCLI)
But thanks to this sed command (` | sed -r « s:\x1B\[[0-9;]*[mK]::g ») I thought I would be able to include the output of a `wakatime command in this page.
Then, in order to be able to use the tool, you will need to add your API Key (available in the settings on WakaTime.com/settings) :
wakatime -api yourApiKeyHere
For instance, the command wakatime -w gives the total time spent in your text editor(s) during the last 7 days.
Avertissement
This tool seems broken, cf this bug (25/01/2021).
Another tool to read its WakaTime statistics from the command line: official wakatime Python client¶
Using pip install wakatime, you can install the official CLI client, which is this project on Pypi.
It does not allow any other visualisation except this –today, it’s quite disappointing.