Add telemetry

Expecting a future where clickstream data are more and more valuable because ranking will be moving from strict keyword based seeders sorted to fuzzy matching with machine learned sorting, I'll be adding limited anonymized telemetry to Torrent Paradise.

I will always keep updating the static IPFS version as long as Torrent Paradise is alive.

Urban Guacamole from Torrent Paradise: the most innovative torrent site
pull/12/head
Urban Guacamole 4 years ago
parent 9d50e3fbf3
commit 9b798c21a2

3
.gitignore vendored

@ -5,4 +5,5 @@ ipfs.html
about.html
copyright.html
torrent_dump_full.csv.gz
generate-top-torrents
generate-top-torrents
api/api

@ -0,0 +1,29 @@
Expecting a future where clickstream data are more and more important, because ranking will be moving from strict keyword based seeders sorted to fuzzy matching with machine learned sorting, I'll be adding limited anonymized telemetry to Torrent Paradise.
## Telemetry collected after searching
- query
- session id
- required to find out if this is a followup query (after not being able to find results with a previous query) or a first
- pseudorandom identifier generated on each visit, not persisted across browser tabs
- action #
- needed to find the order of actions
## Telemetry collected after clicking magnet link
- infohash
- query (once again)
- torrent name
- seeders
- leechers
- torrent size
- session id
- action #
- rank #
- screen resolution
- expected to be critical for ranking of video
- User Agent
- expected to be critical for ranking of software
- language
- could help for ranking video, might predict internet speed and thus required file size
Your IP address is never logged. Telemetry is always sent encrypted. HTTPS is terminated at the caddy web server.

@ -0,0 +1,13 @@
[Unit]
Description=Torrent Paradise API service
Requires=postgresql
[Service]
User=nextgen
WorkingDirectory=/home/nextgen
ExecStart=/home/nextgen/api
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target

@ -0,0 +1,45 @@
package main
import (
"database/sql"
"log"
"io/ioutil"
"net/http"
_ "github.com/lib/pq"
)
func initDb() *sql.DB {
connStr := "user=nextgen dbname=nextgen host=/var/run/postgresql"
db, err := sql.Open("postgres", connStr)
if err != nil {
log.Fatal(err)
}
_, err = db.Exec(`CREATE TABLE IF NOT EXISTS telemetry (
payload jsonb NOT NULL,
time timestamp DEFAULT current_timestamp
)`)
if err != nil {
log.Fatal(err)
}
return db
}
func main() {
db := initDb()
http.HandleFunc("/api/telemetry", func (w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
if err != nil{
log.Print(err)
}
_, err = db.Exec("INSERT INTO telemetry (payload) VALUES ($1)", string(body))
if err != nil {
log.Print(err)
w.WriteHeader(http.StatusInternalServerError)
}
w.WriteHeader(http.StatusOK)
})
http.ListenAndServe(":8000", nil)
}
Loading…
Cancel
Save