A Cloudflare Worker that provides analytics and visualizations for conversation logs stored in KV storage.
- Fetches conversation log data from Cloudflare KV storage
- Displays key metrics like message counts, tool calls, and character usage
- Shows data grouped by day with interactive charts
- Includes a refresh button to manually update the data
- Provides a breakdown of tool usage across all conversations
- Clone this repository
- Install dependencies:
npm install - Configure the KV namespace in wrangler.jsonc (already set up with the provided namespace ID)
- Run locally:
npm run dev - Deploy to Cloudflare:
npm run deploy
The worker:
- Fetches all keys from the KV namespace
- Retrieves each log entry and processes the data
- Groups data by day based on the
updatedAttimestamp - Calculates aggregate metrics (total messages, tool calls, etc.)
- Generates HTML with embedded charts using Chart.js
- Returns a complete dashboard as a single HTML response
- Total conversations
- Total messages
- Average messages per conversation
- Total tool calls
- Unique users
- Input/output character counts
- Daily breakdown of messages, tool calls, and users
- Tool usage distribution
This project uses:
- TypeScript for type safety
- Chart.js for data visualization
- Cloudflare Workers KV for data storage
- Wrangler for local development and deployment