Skip to content

kooparse/bast

Repository files navigation

Bast

CI

⚠️ This project is not maintained anymore.



Bast is an open sourced web analytics, giving simple informations about your site traffics.

I did this project for myself. It is currently used by a couple of friends so it might be useful for others (if you’re a small business, an indie, a blogger…). This project is free and you can do whatever you want with it.

The backend is made in Rust using actix-web web framework and diesel as PostgreSQL ORM. The frontend is (mostly) static and made in React with Next. I used chakra-ui for the interface (but the graph is custom).

Interface

preview


Tracking

We track all metrics over time, days as our atomic scale.

Pageviews are anonymous or identified visitors, so 3 visitors equals 3 pageviews. On each pageview we store the referrer, the current url, etc...

Users is the number of unique visitors to your website. We don’t rely on cookies to identify any particular user. We construct an identifier from his IP address and his user-agent (hashed and stored in the database), It’s really inspired by what Ackee does. So if a user visits two pages, you will see 2 pageviews but only 1 user.

A new session starts after 30 minutes of inactivity. So if a user opens your websites 3 times under 30 minutes, it counts as 1 session. If it's 1 time under 30 minutes and 1 time after; it counts as 2 sessions by the same user.

The average time is stored only if it’s between 5 secondes and 30 minutes on each sessions.

We use the woothee to parse and get information from user-agents; we get the browser name, operating system and other useful data.

And that’s it! Also, I would love to have the geolocation but not for now.


Contributing to the project

Don’t be shy about shooting any questions you may have. If you are a beginner/junior, don’t hesitate, I will always encourage you. It’s a safe place here. Also, I would be very happy to receive any kind of pull requests, you will have (at least) some feedback/guidance rapidly.

Behind screens, there are human beings, living any sort of story. So be always kind and respectful, because we all sheer to learn new things. See contributing file for more exhaustive details.


Deploy Bast with Heroku

Easiest way to deploy the project!

Deploy

Install on your machine

Unix and OS/X

For the api.

  • Fork or download this repository.
  • cd to the project's location.
  • cargo install diesel_cli --no-default-features --features "postgres".
  • diesel setup (You'll need postgres up and running).

For the front.

  • cd to website folder.
  • npm install

Running Bast with Docker on your machine

Once docker is installed on your machine, you just need to do:

  • docker-compose up
  • Live at http://localhost/3333

Also you could customize all environment variables from docker-compose.yml


Running the api in development

For the api.

First create a new .env file at the root. You should use .env.sample to get all required values.

If you want to watch the project while developping it, install cargo-watch first.

  • cargo install cargo-watch
  • run cargo watch -i "website/**/*" -x run
  • Live at http://localhost/3333.

Otherwise simply run cargo run.

For the front (website).

  • cd to website folder.
  • npm run dev
  • Live at http://localhost/3000.

Thanks

I read the Fathom codebase, it’s a pretty cool project made in Golang. If you don’t want to spend time on hosting your own web analytics and you would like to pay for a service, you should definitely check their plans.

To identify users without using cookies, I was inspired by Ackee. So don't hesitate to check this cool project; it's fully made in javascript.