0.0.3 • Published 3 years ago

tracie-server v0.0.3

Weekly downloads
143
License
MIT
Repository
github
Last release
3 years ago

Tracie Server

A minimal, self-hosted event tracking services, built with SQLite (Knex), using NodeJS.

Setup

Asume you have clone or download the project to your machine. Once your server is running, the server should be accessable via //localhost:8080 or as configed.

You can run using pm2, or as a node application as below:

Run using PM2

PM2 is a node process manager. A ecosystem.config.js config file should be ready to use. You can also customize as you want. Once completed, start the pm2 process:

$ pm2 start

Run as a Node application

  1. Setup enviroment variables by copy .env.blank content to a new .env file
  2. Setup connection by run yarn setup or npm run setup
  3. Start server by run yarn start or npm start

Server (APIs):

Server APIs are exposed through TRACIE_ENDPOINT path setup on the .env file.

Create an event:

[POST] /tc

Body content must contains a name property

{
    "name": "string"
}

Query data

[GET] /tc?{query}={value}

Available queries params:

NameType and valueDefinition
$namestringevent names, separate by a comma (.ie signup,hits)
$intervalmonth, week, day, hour, minutegroup result by an interval unit
$intervalValuenumberperiod of $interval i.e 2 days, 3 weeks
$startnumber, stringstarting time in milliseconds or a valid JS date string
$endnumber, stringending time in milliseconds or a valid JS date string

Query output

{ 
    data: [{
        name: string,
        result: {
            [date: string]: number
        }
    }]
}

Where

  • name: event name
  • date: ISODate format string
  • date's value: the frequency number