Install the wakatime python command line tool.
Create a ~/.wakatime.cfg file with contents:
api_key = XXXX
Replace XXXX with your actual API key
Mac and Linux
curl -fsSL https://raw.githubusercontent.com/wakatime/texstudio-wakatime/master/install.py | python
Download and extract texstudio-wakatime-master.zip, then double click install.py.
Use TeXstudio like you normally do and your time will be tracked for you automatically.
Visit https://wakatime.com/dashboard to see your coding activity.