Cursor Analytics Portal
A Python-based dashboard generator for analyzing Cursor AI usage within teams. Generate beautiful HTML reports showing usage statistics, trends, and team insights.
Screenshots
Here's what the dashboard looks like:
Main Dashboard Overview
Weekly Activity Trends
Performance Metrics & Leaderboards
Features
- Team Analytics: Generate comprehensive usage reports for your entire team
- Predefined Groups: Create reports for specific groups (AI Champions, Engineering, QA, etc.)
- Interactive Dashboards: Beautiful HTML reports with charts and visualizations
- Flexible Filtering: Include/exclude specific users, analyze custom date ranges
- Command Line Interface: Easy-to-use CLI for quick report generation
Quick Start
Prerequisites
- Python 3.8+
- uv package manager
Installation
-
Clone the repository:
gh repo clone galprz/cursor-analytics
cd cursor-analyticsOr using git directly:
git clone https://github.com/galprz/cursor-analytics.git
cd cursor-analytics -
Install dependencies:
uv sync -
Set up environment variables:
cp .env.example .envEdit
.envand add your configuration (see Environment Setup)
Basic Usage
uv run python generate_live_dashboard.py
# Generate report for AI Champions group
uv run python generate_live_dashboard.py --group ai_champs
# Generate report for specific group with custom time period
uv run python generate_live_dashboard.py --group engineering --days 14
# List all available groups
uv run python generate_live_dashboard.py --list-groups
Environment Setup
Create a .env file in the project root with the following variables:
# Required: Get this from your browser's developer tools when logged into Cursor Admin
CURSOR_COOKIE_STRING="your_cookie_string_here"
# Team Configuration
# Required: Your team ID from Cursor Admin
CURSOR_TEAM_ID=1234567
# Report Configuration (Optional)
# Default number of days to analyze
DEFAULT_DAYS=7
# Optional: Custom excluded emails (comma-separated)
EXCLUDED_EMAILS="user1@example.com,user2@example.com"
Getting Your Cookie String
- Log into Cursor Admin Dashboard
- Open Developer Tools (F12)
- Go to Network tab
- Refresh the page
- Find any request to
cursor.com - Copy the entire
Cookieheader value - Add it to your
.envfile asCURSOR_COOKIE_STRING
Finding Your Team ID
- In Cursor Admin Dashboard, check the URL
- The team ID appears in URLs like:
https://cursor.com/admin/team/1234567 - Use that number as your
CURSOR_TEAM_ID
Predefined Groups
Configure team groups in generate_live_dashboard.py:
"ai_champs": [
"user1@example.com",
"user2@example.com",
# Add your AI champions here
],
"engineering": [
# Add engineering team emails
],
"management": [
# Add management team emails
],
# ... other groups
}
Available Commands
Basic Commands
uv run python generate_live_dashboard.py
# Specific group
uv run python generate_live_dashboard.py --group ai_champs
uv run python generate_live_dashboard.py -g engineering
# Custom time period
uv run python generate_live_dashboard.py --days 30
uv run python generate_live_dashboard.py -d 14
# List available groups
uv run python generate_live_dashboard.py --list-groups
# Custom team ID
uv run python generate_live_dashboard.py --team-id 1234567
Combined Examples
uv run python generate_live_dashboard.py -g ai_champs -d 30
# Engineering team report for last 14 days
uv run python generate_live_dashboard.py -g engineering -d 14
# Management report with custom team ID
uv run python generate_live_dashboard.py -g management --team-id 1234567
Output
Reports are generated in the reports/ directory with timestamped filenames:
reports/
+-- cursor_analytics_live_ai_champs_20240705_1556.html
+-- cursor_analytics_live_engineering_20240705_1627.html
+-- cursor_analytics_live_all_20240705_1641.html
Dashboard Features
Key Metrics
- Lines of Agent: Total lines of AI-generated code
- Chat Interactions: Number of chat sessions with Cursor AI
- Tab Completions: Autocomplete suggestions accepted
- Active Users: Team members using Cursor regularly
Interactive Charts
- Weekly Trends: Line charts showing activity over time
- User Filtering: Toggle individual users on/off in charts
- Multiple Views: Switch between Lines, Chats, and Completions
- Growth Tracking: Week-over-week percentage changes
Leaderboards
- Top Performers: Ranked by total lines of agent code
- Growth Champions: Biggest week-over-week improvements
- Persistence Leaders: Most consistent daily usage (500+ lines/day)
Detailed Tables
- User Performance: Comprehensive metrics per team member
- Usage Distribution: Pie chart showing feature adoption
- Export Functionality: Download data as JSON for further analysis
Project Structure
cursor-analytics-portal/
+-- cursor_admin_sdk/ # Cursor Admin API SDK
| +-- client.py # Main API client
| +-- models.py # Data models
| +-- exceptions.py # Custom exceptions
+-- generate_live_dashboard.py # Main dashboard generator
+-- email_mapping.json # User email to ID mappings (auto-generated)
+-- reports/ # Generated HTML reports
+-- screenshots/ # Dashboard screenshots
+-- .env # Environment configuration
+-- pyproject.toml # Project dependencies
Troubleshooting
Authentication Issues
Error: CursorAuthError: Authentication failed
Solutions:
- Refresh your cookie string from browser
- Ensure you're logged into Cursor Admin
- Check cookie expiration
Group Not Found
Error: Group 'xyz' not found
Solutions:
- Run
--list-groupsto see available groups - Check spelling of group name
- Add the group to
PREDEFINED_GROUPSif needed
Empty Reports
Issue: Report shows no data
Solutions:
- Verify team ID is correct
- Check if users have any Cursor usage in the specified period
- Ensure email addresses in groups are correct
Development
Adding New Groups
- Edit
PREDEFINED_GROUPSingenerate_live_dashboard.py - Add group name and email list:
"new_group": [
"user1@example.com",
"user2@example.com"
]
Customizing Reports
- Modify HTML templates in
_generate_template_inline()method - Adjust chart configurations in the template
- Add new metrics by extending the analytics aggregation
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Support
For issues and questions:
- Check the troubleshooting section
- Review existing issues
- Create a new issue with detailed information