Whatsdog detects whether your victim is online or not. What are they doing in the background? We know that Whatsapp does not provide any API or SDK for this, so how can anyone monitor this type of sensitive activity?
It's actually by an undocumented API from whatsapp and you can communicate over Websockets to get the online status of people.
This article will show you how it is done and even provide a PoC for it to run in your own browser. So this PoC can be modified to be a PC application or a smartphone app.
While Whatsapp or Facebook Messenger don't provide an official API for online status, it's often easy to use their unofficial i.e internal API to determine it. I can't speak for Whatsapp as I'm not a user or much less familiar with their internal API, but I have played around with this in Messenger. The conceptual difference is negligible for any app that provides an online status feature so I'm going to use Facebook's Messenger as an example since I'm more familiar with it.
Here's a (comically written) blog post explaining how it's done with Facebook. If you don't feel like reading it and digging into the technical details or reading the whole thing, I'll provide a brief summary of how it works here.
On Facebook Messenger, there's a little green dot displayed beside their name which indicates that they're online, right? Just like this:
Well, the state of that dot, or rather the data that indicates their status, is fetched by an undocumented or unofficial API. That is, an API used internally which isn't intended to be used by anyone but facebook developers and thus holds no promises and will break all the time if you try to use it. That's aside the point though. The point is that there's a request that periodically goes out (i.e polled) which gives you the online status of your friends. If you poll it over time, you'll be able to tell when a user transitions from offline -> online or vice versa.
Third party applications use these APIs and poll them just as the official application does. They then, well, do whatever they want with that data. Be it logging it to graph their usage patterns, notifying you when they're online, you name it!
If this answer doesn't sate your curiosity, I encourage you to read the article I linked above. It's informative, engaging, funny, and(!) has a github repo which allows you to try it out yourself.
As Nico says they are using a WhatsApp API. The WhatsApp client is capable of checking if your contacts are online or not - meaning there has to be some way to do it.
It is easy enough for someone decompile the code or MitM their own connections to read what the application is doing. The only added risk over a pubished API is you have no obligation to notify other parties before you change or remove it.
You should never trust secrets to a client device!