A NestJS backend for collecting analytics data.
-
Install Dependencies
pnpm install
-
Configure Environment
cp .env.example .env
Required:
DATABASE_URL(MongoDB) andJWT_SECRET. -
Initialize Database
pnpm run seed
Creates superadmin (
admin@webticks.com/supersecret) and a test app. -
Run Server
pnpm run dev
API runs at
http://localhost:3002/api
Send a POST request to /api/track with the webticks-app-id header.
Header: webticks-app-id: 97069816-8b25-4640-833f-f17259208a42 (default seed ID)
Body:
{
"uid": "user_123",
"sessionId": "session_456",
"datetime": "2024-01-01T00:00:00Z",
"events": [
{ "type": "pageview", "path": "/" }
]
}POST /api/auth/login with admin credentials to receive a JWT.
For full details on authentication and event types, refer to the source code in src/auth and src/track.
| Action | Endpoint | Auth | Body |
|---|---|---|---|
| Register | POST /api/auth/register |
None | { email, password } |
| User Login | POST /api/auth/user/login |
None | { email, password } |
| Admin Login | POST /api/auth/admin/login |
None | { email, password } |
Requires Bearer Token from Login
- Create Key:
POST /api/keys- Body:
{ "type": "backend" | "public", "name": "Key Name" } - Returns raw key once. Store securely!
- Body:
- List My Keys:
GET /api/keys