wakapi/README.md

96 lines
5.2 KiB
Markdown
Raw Normal View History

2019-05-21 19:33:04 +03:00
# 📈 wakapi
2020-05-23 21:02:40 +03:00
[![](http://img.shields.io/liberapay/receives/muety.svg?logo=liberapay&style=flat-square)](https://liberapay.com/muety/)
2020-05-23 21:11:09 +03:00
[![Say thanks](https://img.shields.io/badge/SayThanks.io-%E2%98%BC-1EAEDB.svg?style=flat-square)](https://saythanks.io/to/n1try)
2020-05-23 21:02:40 +03:00
![](https://img.shields.io/github/license/muety/wakapi?style=flat-square)
2020-05-23 21:11:09 +03:00
[![Go Report Card](https://goreportcard.com/badge/github.com/muety/wakapi?style=flat-square)](https://goreportcard.com/report/github.com/muety/wakapi)
2020-05-23 21:02:40 +03:00
2020-05-23 21:04:48 +03:00
[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://buymeacoff.ee/n1try)
2020-05-23 21:02:40 +03:00
---
2019-05-22 16:32:13 +03:00
**A minimalist, self-hosted WakaTime-compatible backend for coding statistics**
2019-05-21 19:33:04 +03:00
2020-02-20 17:39:56 +03:00
![Wakapi screenshot](https://anchr.io/i/bxQ69.png)
2019-05-22 00:27:31 +03:00
2020-05-30 22:01:46 +03:00
If you like this project, please consider supporting it 🙂. You can donate either through [buying me a coffee](https://buymeacoff.ee/n1try) or becoming a GitHub sponsor. Every little donation is highly appreciated and boosts the developers' motivation to keep improving Wakapi!
2020-05-30 21:54:56 +03:00
## Demo
2020-05-30 22:01:46 +03:00
🔥 **New:** There is hosted [demo version](https://apps.muetsch.io/wakapi) available now. Go check it out! Please use responsibly.
2020-05-30 21:54:56 +03:00
2020-05-30 22:01:46 +03:00
To use the demo version set `api_url = https://apps.muetsch.io/wakapi/api/heartbeat`. However, this hosted instance might be taken down again in the future, so you might potentially lose your data ❕
2020-05-30 21:54:56 +03:00
2019-05-21 19:33:04 +03:00
## Prerequisites
2020-04-26 16:40:46 +03:00
**On the server side:**
* Go >= 1.13 (with `$GOPATH` properly set)
* gcc (to compile [go-sqlite3](https://github.com/mattn/go-sqlite3))
* Fedora / RHEL: `dnf install @development-tools`
* Ubuntu / Debian: `apt install build-essential`
2020-05-30 13:14:37 +03:00
* Windows: See [here](https://github.com/mattn/go-sqlite3/issues/214#issuecomment-253216476)
2020-04-26 16:40:46 +03:00
* _Optional_: A MySQL- or Postgres database
2019-05-06 01:58:01 +03:00
2020-04-26 16:40:46 +03:00
**On your local machine:**
2020-02-20 18:09:50 +03:00
* [WakaTime plugin](https://wakatime.com/plugins) for your editor / IDE
2020-05-24 21:28:12 +03:00
## Server Setup
### Run from source
2020-05-28 23:36:00 +03:00
1. Clone the project
2020-04-26 16:40:46 +03:00
1. Copy `.env.example` to `.env` and set database credentials
2020-05-24 21:28:12 +03:00
1. Adapt `config.ini` to your needs
2020-05-28 23:36:00 +03:00
1. Build executable: `GO111MODULE=on go build`
2020-04-26 16:40:46 +03:00
1. Run server: `./wakapi`
2019-05-22 00:09:47 +03:00
**As an alternative** to building from source you can also grab a pre-built [release](https://github.com/muety/wakapi/releases). Steps 2, 3 and 5 apply analogously.
**Note:** By default, the application is running in dev mode. However, it is recommended to set `ENV=production` in `.env` for enhanced performance and security. To still be able to log in when using production mode, you either have to run Wakapi behind a reverse proxy, that enables for HTTPS encryption (see [best practices](i#best-practices)) or set `insecure_cookies = true` in `config.ini`.
2020-05-24 21:28:12 +03:00
### Run with Docker
2020-04-26 16:40:46 +03:00
```
docker run -d -p 3000:3000 --name wakapi n1try/wakapi
```
By default, SQLite is used as a database. To run Wakapi in Docker with MySQL or Postgres, see [Dockerfile](https://github.com/muety/wakapi/blob/master/Dockerfile) and [.env.example](https://github.com/muety/wakapi/blob/master/.env.example) for further options.
2020-05-24 21:28:12 +03:00
## Client Setup
Wakapi relies on the open-source [WakaTime](https://github.com/wakatime/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](https://wakatime.com/plugins)
2. Make your local WakaTime client talk to Wakapi by **editing your local `~/.wakatime.cfg`** file as follows
2020-04-26 16:40:46 +03:00
```
api_url = https://your.server:someport/api/heartbeat`
api_key = the_api_key_printed_to_the_console_after_starting_the_server`
```
You can view your API Key after logging in to the web interface.
2019-10-08 01:48:28 +03:00
## Customization
2019-05-11 21:32:35 +03:00
### 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. For the above example, you would need to add two aliases, like this:
```sql
INSERT INTO aliases (`type`, `user_id`, `key`, `value`) VALUES (0, 'your_username', 'myapp-web', 'myapp-frontend');
```
#### Types
* Project ~ type **0**
* Language ~ type **1**
* Editor ~ type **2**
* OS ~ type **3**
* Machine ~ type **4**
**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](https://caddyserver.com) 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!**
2019-05-06 01:58:01 +03:00
## License
2019-05-22 16:32:13 +03:00
GPL-v3 @ [Ferdinand Mütsch](https://muetsch.io)