@telytics/collector
v0.1.0-alpha.1
Published
Collector service for receiving telemetry logs from dApps.
Readme
@telytics/collector
Minimal telemetry ingestion API for dApps. Receives structured logs from clients and writes them to a newline-delimited JSON (.ndjson) log file.
Features
- Simple Express.js API (
POST /api/ingest) - Accepts structured telemetry events from clients
- Appends logs to a persistent
.ndjsonfile - Type-safe with full
LogPayloadvalidation - Suitable for local development, production tailing, or log forwarding
Installation
npm install
npm run dev --workspace=@telytics/collectorThe service starts on:
http://localhost:3000API endpoint
POST /api/ingest
Receives a structured log payload from the client.
Request Body:
{
"type": "error",
"message": "Something went wrong",
"timestamp": 1714430000000,
"app": "my-dapp",
"release": "v1.0.0"
}Success response:
204 No ContentInvalid payload:
400 Bad RequestLog storage
Logs are appended to:
packages/collector/logs/events.ndjsonEach line is a valid JSON object, separated by newlines:
{
"type": "error",
"message": "Something went wrong",
"timestamp": 1714430000000,
"app": "my-dapp",
"release": "v1.0.0"
}{
"type": "info",
"message": "User connected",
"timestamp": 1714430100000,
"app": "my-dapp",
"release": "v1.0.0"
}Development
npm run dev --workspace=@telytics/collector[!IMPORTANT] Uses
ts-node-devfor live reloading.
Example use
Paired with @telytics/client:
trackError(new Error("Something went wrong"), {
route: '/stake',
wallet: publicKey.toBase58()
});Collector will write that as a line in events.ndjson.
License
This project is licensed under the MIT License.
