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.

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 am using Sublime Text 3 almost exclusively, and from now 1 year and a half. 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).

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 the wonderful Sublime Text 3 (and it's almost correct!):

Note

WakaTime does not count GNU Nano, GNU Octave GUI, or Spyder for Python 2/3.

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

:line:`I would love to find an easy way to just include the pie chart, and not the entire page.` :red:`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 2015

Small interlude (from XKCD.com)

Time-Tracking Software (https://xkcd.com/1690/)

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 lat 7 days.

Avis

I do not know why, but this small wakatime command line tool does not work anymore on my laptop (even after uninstalling and reinstalling)... Too bad :( !