Skip to content

Trench — Open-source Infrastructure for Tracking Events

License

Notifications You must be signed in to change notification settings

FrigadeHQ/trench

Repository files navigation

Trench Code Snuppet

Trench
Open source infrastructure for tracking events.
Built with Kafka and Clickhouse for highly available and scalable tracking and analytics.

Introduction

Trench is a powerful event tracking system built with Kafka and Clickhouse. It's designed to handle event volumes at scale and provide real-time analytics.

Quickstart

To install and start the server, simply run the following command:

git clone git@github.com:FrigadeHQ/trench.git && cd trench/apps/trench && cp .env.example .env && docker-compose up --build --force-recreate --renew-anon-volumes -d

This will start the server on port 4000. You can now send your first event:

curl -i -X POST \
   -H "Authorization:Bearer my-public-api-key" \
   -H "Content-Type:application/json" \
   -d \
'{
  "events": [
    {
      "userId": "abc123",
      "event": "ConnectedAccount",
      "properties": {
        "totalAccounts": 4,
        "country": "Denmark"
      },
      "type": "track"
    }]
}' \
 'http://localhost:4000/events'

Now, you can query the data using SQL over HTTP (make sure to use your private API key):

curl -i -X POST \
   -H "Authorization:Bearer my-private-api-key" \
   -H "Content-Type:application/json" \
   -d \
'{
  "queries": [
  	"SELECT COUNT(*) as totalRows FROM events"
  ]
}' \
 'http://localhost:4000/queries'

This will example will return the total number of events in the system:

{
  "results": [
    {
      "totalRows": 1
    }
  ]
}

Documentation and going further

Trench can do a lot more than this. Check out the docs to learn more.

Authors

Trench is a project built by Frigade.

License

MIT License