https://github.com/FrigadeHQ/trench Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} FrigadeHQ / trench Public * Notifications You must be signed in to change notification settings * Fork 18 * Star 736 Trench -- Open-Source Analytics Infrastructure. A single production-ready Docker image built on ClickHouse, Kafka, and Node.js for tracking events, users, page views, and interactions. trench.dev License MIT license 736 stars 18 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 1 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights FrigadeHQ/trench main BranchesTags Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 91 Commits .changeset .changeset .github/workflows .github/workflows apps apps img img packages packages .gitignore .gitignore .prettierrc .prettierrc LICENSE LICENSE README.md README.md package.json package.json pnpm-lock.yaml pnpm-lock.yaml pnpm-workspace.yaml pnpm-workspace.yaml tsconfig.json tsconfig.json turbo.json turbo.json View all files Repository files navigation * README * MIT license Trench Logo Open-Source Analytics Infrastructure Documentation * Website * Join Our Slack What is Trench? Trench is an event tracking system built on top of Apache Kafka and Clickhouse. It can handle large event volumes and provides real-time analytics. Trench is no-cookie, GDPR, and PECR compliant. Users have full control to access, rectify, or delete their data. Our team built Trench to scale up the real-time event tracking pipeline at Frigade. Trench Code Snippet Features * Compliant with the Segment API (Track, Group, Identify) * Deploy quickly with a single production-ready Docker image * Process thousands of events per second on a single node * [?] Query data in real-time * Connect data to other destinations with webhooks * Open-source and MIT Licensed [?] Demo Watch the following demo to see how you can build a basic version of Google Analytics using Trench and Grafana. TrenchDemo.mp4 Quickstart Trench has two methods of deployment: 1. Trench Self-Hosted: An open-source version to deploy and manage Trench on your own infrastructure. 2. Trench Cloud: A fully-managed serverless solution with zero ops, autoscaling, 99.99% SLAs. 1. Trench Self-Hosted Follow our self-hosting instructions below and in our quickstart guide to begin using Trench Self-Hosted. If you have questions or need assistance, you can join our Slack group for support. Quickstart 1. Deploy Trench Dev Server: The only prerequisite for Trench is a system that has Docker and Docker Compose installed see installation guide. We recommend having at least 4GB of RAM and 4 CPU cores for optimal performance if you're running a production environment. After installing Docker, you can start the local development server by running the following commands: git clone https://github.com/frigadehq/trench.git cd trench/apps/trench cp .env.example .env docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build --force-recreate --renew-anon-volumes The above command will start the Trench server that includes a local Clickhouse and Kafka instance on http://localhost:4000. You can open this URL in your browser and you should see the message Trench server is running. You shouldupdate the .env file to change any of the configuration options. 2. Send a sample event: You can find and update the default public and private API key in the .env file. Using your public API key, you can send a sample event to Trench as such: curl -i -X POST \ -H "Authorization:Bearer public-d613be4e-di03-4b02-9058-70aa4j04ff28" \ -H "Content-Type:application/json" \ -d \ '{ "events": [ { "userId": "550e8400-e29b-41d4-a716-446655440000", "type": "track", "event": "ConnectedAccount", "properties": { "totalAccounts": 4, "country": "Denmark" }, }] }' \ 'http://localhost:4000/events' 3. Querying events: You can query events using the /events endpoint (see API reference for more details). You can also query events directly from your local Trench server. For example, to query events of type ConnectedAccount, you can use the following URL: curl -i -X GET \ -H "Authorization: Bearer private-d613be4e-di03-4b02-9058-70aa4j04ff28" \ 'http://localhost:4000/events?event=ConnectedAccount' This will return a JSON response with the event that was just sent: { "results": [ { "uuid": "25f7c712-dd86-4db0-89a8-d07d11b73e57", "type": "track", "event": "ConnectedAccount", "userId": "550e8400-e29b-41d4-a716-446655440000", "properties": { "totalAccounts": 4, "country": "Denmark" }, "timestamp": "2024-10-22T19:34:56.000Z", "parsedAt": "2024-10-22T19:34:59.530Z" } ], "limit": 1000, "offset": 0, "total": 1 } 4. Execute raw SQL queries: Use the queries endpoint to analyze your data. Example: curl -i -X POST \ -H "Authorization:Bearer public-d613be4e-di03-4b02-9058-70aa4j04ff28" \ -H "Content-Type:application/json" \ -d \ '{ "query": "SELECT COUNT(*) FROM events WHERE userId = '550e8400-e29b-41d4-a716-446655440000'" }' \ 'http://localhost:4000/queries' Sample query result: { "count": 5 } 2. Trench Cloud [?] If you don't want to selfhost, you can get started with Trench in a few minutes using our Cloud Quickstart Guide. Links * Website * Documentation * Slack community Authors Trench is a project built by Frigade. License MIT License About Trench -- Open-Source Analytics Infrastructure. A single production-ready Docker image built on ClickHouse, Kafka, and Node.js for tracking events, users, page views, and interactions. trench.dev Topics nodejs open-source tracking kafka analytics clickhouse self-hosting self-host product-analytics clickhouse-database clickhouse-server event-replay matomo posthog matomo-tracking plausible plausible-analytics matomo-analytics tracking-events kafka-engine Resources Readme License MIT license Activity Custom properties Stars 736 stars Watchers 8 watching Forks 18 forks Report repository Releases 7 trench-js@0.0.6 Latest Oct 29, 2024 + 6 releases Packages 0 No packages published Contributors 5 * * * * * Languages * TypeScript 77.5% * MDX 14.7% * JavaScript 4.0% * Dockerfile 2.7% * Other 1.1% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.