# 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:

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.

## Sharing these statistics ?¶

### Coding time over last 30 days¶

This first chart shows how much I type every day (it counts most of my emails, programming tasks and more):

### Languages over last 30 days¶

You can see that I mainly use Python and Bash, LaTeX and reStructuredText, and Markdown (or HTML when using StrapDown.js) :

And from the beginning of my use of WakaTime:

### Text editors¶

WakaTime thinks I only use (and it’s almost correct!): WakaTime detect that I am using the wonderful Visual Studio Code for about ~90% of my daily writing/coding/programing, and Sublime Text and PyCharm IDE for the remaining ~10% :

Note

WakaTime does not count GNU Nano, GNU Octave GUI, or Spyder for Python 2/3. However, now they offer a WakaTime plugin for Bash, Zsh and iTerm (terminal)!

### Sharing stats for a specific project?¶

It is also possible to share the stats of one project, with a dedicated obfuscated link, like https://wakatime.com/@lbesson/projects/qdkkfmhcoi for example (corresponding to that project).

### Include a graphic of these stats here, with an iframe?¶

Below is included that page https://wakatime.com/@lbesson, with an iframe:

Note

I would love to find an easy way to just include the pie chart, and not the entire page. Edit: On December 19th (2015), I got a personal email from Alan Hamlet, CEO and founder of WakaTime, to inform me of the new charts share feature. The charts displayed above are good examples of what brings this very new WakaTime feature (I find it very cool!).

### Overview of my coding time in 2017¶

• Like in 2015, about 600 hours in 2017 entirely (611h), average for WakaTime users was 249h (and max 3468h !).

• Daily average about 2 hours 17 minutes in 2017, average for WakaTime users was 41 min (but the max was 9 h 30 min, this programmer is most surely a crazy dude!).

• I coded entirely under GNU/Linux (I am a big fan of XUbuntu, as always), and about 303h with Sublime Text, 282h with Visual Studio Code and 45h with PyCharm. GNU Nano, Firefox and Jupyter are not counted (but uLogMe tells me I don’t spend much time in them anyway).

• As for languages, I mainly used Python (277 h), Markdown (107 h), LaTeX (135 h), and reStructuredText (28 h); while other languages have less than 5h/year (Bash, OCaml, Octave/Matlab, HTML / CSS etc).

• For more details, see the screenshots in this folder (2017).

### Overview of my coding time in 2020¶

• Way less than in 2019, I coded about 128 hours in 2020, when the average of all WakaTime users was 313h (increasing).

• I can explain this drop of coding time by a few reasons a) I almost did not write any research articles this year, and I did not have to write my PhD thesis (i spent so much time on it in 2019!) b) I am no longer in active development of any personal programming project (as I was in the last two years with SMPyBandits, c) I almost did not have to write any slides or notebooks, d) most of my teaching material was already finished or almost ready, e) I still code, but often I just use GNU Nano in a terminal for quick and small edits, or Python in a Jupyter notebook (and this isn’t accounted for by WakaTime), f) for one course (INF1, introduction to programming using Java, at L1 level at University Rennes 1), I had to use Eclipse and didn’t think about installing the WakaTime plug-in.

• A daily average significantly reduced since 2019, with 1 hours and 2 minutes in 2020, in comparison to the average of 51 minutes a day for all WakaTime users (oh so I still code more than the average? interesting!).

• My most active day was November 4th 2020, with 5h 30 minutes (and its much less than in the previous years). I am not sure what I was doing exactly that day, but probably for these two projects: Discord-bot-to-add-spoiler-to-any-code-snippet, Generateur-attestation-de-sortie-automatique-COVID-19-confinement-en-France.

• As always, I entirely worked under GNU/Linux (I love XUbuntu as always, even if I installed GNOME 3 on my latest laptop), and 100% with Visual Studio Code… as far as WakaTime is aware! But I use GNU Nano, Firefox and Jupyter and they are not accounted for.

• Regarding projects, I used 26h of LaTeX and Java for a course I taught in Autumn 2020 (INF1 at L1 level at University Rennes 1), to write and update practical sessions sheets, project instructions and exam papers. I also worked about 20h for this map (mainly experimenting things), and less than 10 hours in every other projects.

• Regarding the choice of languages, this year I mainly used Markdown (53 h) even though I’m not sure for what projects, LaTeX (30 h) and both Java and Python are tight with 13h each (on VSCode, but by counting Eclipse and Jupyter notebooks I must have at least three time more !) ; and all the other languages are about 1-5 hours by year (Bash, OCaml, JavaScript, HTML / CSS etc). But it’s unfair, as I write a lot of one-liner bash script directly in a terminal, as I use GNU Nano for small bash files, Jupyter notebooks for Python and OCaml, etc.

### Short overview of my total coding time since 2015¶

Apparently, as of October 2018, I accumulated over 2529 hours of coding stats since 3 years and a half (January 2015). That’s a lot. In over 10+3*12=46 months, I lived about 33120 hours, and slept approximately 10000 hours. So 2500 hours of coding is about 7% of my life and about 11% of my awaken life. I spent 11% of my life coding. That’s a lot, I think (it does not count just office hours, but ALL MY LIFE since 3 years). Oh boy.

## 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.

Note

nodejs and npm are needed.

This requires to have already installed nodejs on your machine, and its packet manager npm.

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.

\$ wakatime -w | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"
Traceback (most recent call last):
File "/usr/local/bin/wakatime", line 5, in <module>
from wakatime.__init__ import execute
ModuleNotFoundError: No module named 'wakatime'


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.

wakatime --today
bash: ligne 1: akatime : commande introuvable


It does not allow any other visualisation except this –today, it’s quite disappointing.