📊 A minimalist, self-hosted WakaTime-compatible backend for coding statistics
Go to file
Ferdinand Mütsch 2cca2cb0bb feat: display api key on user interface (resolve #24) 2020-05-24 21:19:05 +02:00
.github Update FUNDING.yml 2020-05-23 21:02:12 +02:00
data Resolve #7. 2020-03-31 11:24:44 +02:00
middlewares fix: base path for error redirects 2020-05-24 17:39:19 +02:00
migrations/sqlite3 style: keep small column definitions together 2020-04-25 13:52:43 -07:00
models feat: display api key on user interface (resolve #24) 2020-05-24 21:19:05 +02:00
routes feat: display api key on user interface (resolve #24) 2020-05-24 21:19:05 +02:00
scripts fix: fix build script to cross-compile with sqlite dependency 2020-04-26 14:35:53 +02:00
services feat: set html base path from server base path 2020-05-24 17:32:26 +02:00
static/assets feat: display api key on user interface (resolve #24) 2020-05-24 21:19:05 +02:00
utils feat: set html base path from server base path 2020-05-24 17:32:26 +02:00
views feat: display api key on user interface (resolve #24) 2020-05-24 21:19:05 +02:00
.dockerignore fix: docker build 2020-04-26 15:07:00 +02:00
.env.example feat: ability to set default username and password 2020-04-26 14:00:53 +02:00
.gitignore feat: add support for sqlite3 2020-04-19 16:58:54 -07:00
Dockerfile fix: update docekr file to include env vars and volume 2020-04-26 15:18:47 +02:00
LICENSE Add license. 2019-05-22 07:32:35 +02:00
README.md docs: update readme 2020-05-24 20:28:12 +02:00
config.ini feat: introduce base path config option to better support redirections behind a proxy 2020-05-24 17:08:44 +02:00
doap.rdf Add DOAP description. 2020-04-05 13:36:01 +02:00
go.mod refactor: middlewares and get rid of negroni 2020-05-24 14:50:04 +02:00
go.sum refactor: middlewares and get rid of negroni 2020-05-24 14:50:04 +02:00
main.go feat: display api key on user interface (resolve #24) 2020-05-24 21:19:05 +02:00
version.txt feat: display api key on user interface (resolve #24) 2020-05-24 21:19:05 +02:00
wait-for-it.sh fix: docker build 2020-04-26 15:07:00 +02:00

README.md

📈 wakapi

Say thanks Go Report Card

Buy me a coffee


A minimalist, self-hosted WakaTime-compatible backend for coding statistics

Wakapi screenshot

If you like this project, please consider supporting it 🙂. You can donate either through buying me a coffee or becoming a GitHub sponor. Every little donation is highly appreciated and boosts the developers' motivation to keep improving Wakapi!

Prerequisites

On the server side:

  • Go > 1.13 (with $GOPATH properly set)
  • Optional: A MySQL- or Postgres database

On your local machine:

Server Setup

Run from source

  1. Enable Go module support: export GO111MODULE=on
  2. Get code: go get github.com/muety/wakapi
  3. Go to project root: cd "$GOPATH/src/github.com/muety/wakapi"
  4. Copy .env.example to .env and set database credentials
  5. Adapt config.ini to your needs
  6. Build executable: go build
  7. Run server: ./wakapi

Run with Docker

docker run -d -p 3000:3000 --name wakapi n1try/wakapi

To get your API key, take a look into the logs docker logs wakapi | grep "API key"

In addition, you can specify several environment variables for configuration:

  • -e WAKAPI_DEFAULT_USER_NAME=admin
  • -e WAKAPI_DEFAULT_USER_PASSWORD=admin

By default, SQLite is used as a database. To run Wakapi in Docker with MySQL or Postgres, see Dockerfile and .env.example for further options.

Client Setup

Wakapi relies on the open-source WakaTime client tools. In order to collect statistics to Wakapi, you need to set them up.

  1. Set up WakaTime for your specific IDE or editor. Please refer to the respective plugin guide
  2. Make your local WakaTime client talk to Wakapi by editing your local ~/.wakatime.cfg file as follows
api_url = https://your.server:someport/api/heartbeat`
api_key = the_api_key_printed_to_the_console_after_starting_the_server`

Customization

User Accounts

  • When starting wakapi for the first time, a default user admin with password admin is created. The corresponding API key is printed to the console.
  • Additional users, at the moment, can be added only via SQL statements on your database, like this:
    • Connect to your database server: mysql -u yourusername -p -H your.hostname (alternatively use GUI tools like MySQL Workbench)
    • Select your database: USE yourdatabasename;
    • Add the new user: INSERT INTO users (id, password, api_key) VALUES ('your_nickname', MD5('your_password'), '728f084c-85e0-41de-aa2a-b6cc871200c1'); (the latter value should be a random UUIDv4, as can be found in your ~/.wakatime.cfg)

Aliases

There is an option to add aliases for project names, editors, operating systems and languages. For instance, if you want to map two projects myapp-frontend and myapp-backend two a common project name myapp-web in your statistics, you can add project aliases.

At the moment, this can only be done via raw database queries. See User Accounts section above on how to do such. For the above example, you would need to add two aliases, like this:

  • INSERT INTO aliases (type, user_id, key, value) VALUES (0, 'your_username', 'myapp-web', 'myapp-frontend') (analogously for myapp-backend)

Types

  • Project ~ type 0
  • Language ~ type 1
  • Editor ~ type 2
  • OS ~ type 3

NOTE: In order for the aliases to take effect for non-live statistics, you would either have to wait 24 hours for the cache to be invalidated or restart Wakapi.

Best Practices

It is recommended to use wakapi behind a reverse proxy, like Caddy or nginx to enable TLS encryption (HTTPS). However, if you want to expose your wakapi instance to the public anyway, you need to set listen = 0.0.0.0 in config.ini

Important Note

This is not an alternative to using WakaTime. It is just a custom, non-commercial, self-hosted application to collect coding statistics using the already existing editor plugins provided by the WakaTime community. It was created for personal use only and with the purpose of keeping the sovereignity of your own data. However, if you like the official product, please support the authors and buy an official WakaTime subscription!

License

GPL-v3 @ Ferdinand Mütsch