go-tracker

command module
v0.0.0-...-e275940 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 4 Imported by: 0

README

Maintainability

Go-tracker

Smol project to learn Golang and Kafka.

What it does

Tl;dr: displays in your console the total amount of visitors on your websites.

The tracker starts an Echo server and listen to incoming websocket connections. We add +1 for every websocket opening and -1 for every websocket closing. Nothing else is logged.

This data does NOT constitute PII (Personally Identifiable Information). Therefore, from what I understand, it should not fall under the GDPR obligations of consent. (But maybe go and ask a real lawyer first.)

Install

Install Kafka
# Simple local install with yay package manager (Arch)
sudo yay kafka

For other distributions or for a production environment, refer to Kafka documentation

Setup and open Kafka
# Start the kafka service
sudo systemctl start kafka.service

# Go to this folder
cd go-tracker

# Setup kafka topic (only once)
sh scripts/create_kafka_topic.sh

# Start the kafka console consumer
sh scripts/start_kafka_consumer.sh

Kafka is now open, ready to receive information.

Install go-tracker

Run the go-tracker binary on your favorite server. You can configure the messenger module and the tracker port in main.go (TODO: Create a separate config file)

Install the client on your websites

Import the tracker_client.js file on your website's metadata. You done !

TODO (Most to least important)

  • Switch from ws to wss
  • Improve tests on package tracker.go
  • Configure CI
  • Create a config file to take configuration out of main.go
  • Add encrypted token system so we only log from trusted sources

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package messenger transmit a single int value to a topic
Package messenger transmit a single int value to a topic
Package tracker creates a websocket server and sends total amount of connections to a messenger module
Package tracker creates a websocket server and sends total amount of connections to a messenger module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL