1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00
📊 A minimalist, self-hosted WakaTime-compatible backend for coding statistics
Go to file
2019-10-10 18:10:14 +02:00
middlewares Support for username-password authentication. 2019-05-21 22:40:59 +02:00
models Add database schema to persist summaries with their accompanying summary items. 2019-10-09 23:26:28 +02:00
routes Fix cache to be per user. 2019-10-09 21:57:43 +02:00
services First approach to generating, persisting, fetching and merging summaries. 2019-10-10 18:10:14 +02:00
static Merge branch 'master' of github.com:n1try/wakapi 2019-09-20 12:06:12 +02:00
utils Fix MySQL connection timezone. 2019-10-10 18:09:50 +02:00
.env.example Update config. 2019-05-19 22:23:51 +02:00
.gitignore Add ability to listen on public interface. 2019-05-21 14:02:04 +02:00
config.ini Add support for custom languages. 2019-05-21 17:16:46 +02:00
docker-compose.yml Add persistent volume to database container. 2019-10-08 09:29:31 +02:00
Dockerfile Update Readme. 2019-10-08 09:08:52 +02:00
go.mod Updated to use go modules and updated UUID libary 2019-10-07 23:39:43 +01:00
go.sum Updated to use go modules and updated UUID libary 2019-10-07 23:39:43 +01:00
LICENSE Add license. 2019-05-22 07:32:35 +02:00
main.go First approach to generating, persisting, fetching and merging summaries. 2019-10-10 18:10:14 +02:00
README.md Update Readme. 2019-10-08 09:08:52 +02:00
wait-for-it.sh Added Docker fixes issue #5 2019-10-07 23:41:00 +01:00

📈 wakapi

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

Wakapi screenshot

Buy me a coffee

Prerequisites

  • Go >= 1.13 (with $GOPATH properly set)
  • A MySQL database

Usage

  • Create an empty MySQL database
  • Get code: go get github.com/n1try/wakapi
  • Go to project root: cd "$GOPATH/src/github.com/n1try/wakapi"
  • Install dependencies: go get -d ./...
  • Copy .env.example to .env and set database credentials
  • Set target port in config.ini
  • Build executable: go build
  • Run server: ./wakapi
  • Edit your local ~/.wakatime.cfg file
    • api_url = https://your.server:someport/api/heartbeat
    • api_key = the_api_key_printed_to_the_console_after_starting_the_server
  • Open http://localhost:3000 in your browser

Run with Docker

  • Edit docker-compose.yml file and change passwords for the DB
  • Build the container docker-compose build
  • Start the application docker-compose up -d
  • To get the api key look in the logs docker-compose logs | grep "API key"
  • The application should now be running on localhost:3000

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

Todo

  • Persisted summaries / aggregations (for performance)
  • User sign up and log in
  • Additional endpoints for retrieving statistics data
  • Enhanced UI
    • Loading spinner
    • Responsiveness
  • Support for SQLite database
  • Dockerize
  • Unit tests

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