Coding Activity Tracker - VS Code Extension
A VS Code extension that tracks your coding activity and syncs it with a backend API for analytics and reporting.
Features
- Line Tracking: Monitors lines of code added/removed in real-time
- Commit Tracking: Automatically detects and tracks Git commits
- Active Time Tracking: Measures your active coding time vs idle time
- Real-time Status Bar: Shows current stats in the status bar
- Detailed Statistics: View comprehensive stats in a webview panel
- Automatic Sync: Syncs data with backend API every 10 minutes
- Multi-project Support: Tracks activity across different projects
Status Bar Display
The extension shows real-time stats in the VS Code status bar:
$(pencil) +120/-30 | $(git-commit) 2 | ⏱ 1h 15m
- Lines: Shows lines added/removed (net change)
- Commits: Number of commits made today
- Time: Active coding time in hours and minutes
Commands
Coding Activity: Show Coding Stats
- Opens the detailed stats view
Coding Activity: Configure Activity Tracker
- Configure API settings
Configuration
The extension can be configured through VS Code settings:
{
"codingActivityTracker.apiUrl": "https://gitxlogbackend.onrender.com/api",
"codingActivityTracker.syncInterval": 10,
"codingActivityTracker.idleTimeout": 5
}
Settings
apiUrl
: Backend API URL (default: https://gitxlogbackend.onrender.com/api
)
syncInterval
: Sync interval in minutes (default: 10
)
idleTimeout
: Idle timeout in minutes (default: 5
)
Installation
Development Installation
- Clone this repository
- Install dependencies:
npm install
- Compile the extension:
npm run compile
- Open the project in VS Code
- Press
F5
to run the extension in a new Extension Development Host window
Production Installation
- Package the extension:
npm install -g vsce
vsce package
- Install the generated
.vsix
file in VS Code
Backend Requirements
This extension requires a backend API with the following endpoints:
Authentication
POST /api/coding-activity/token
- Generate JWT token for machine
Data Sync
POST /api/coding-activity/sync
- Sync activity data
Statistics
GET /api/coding-activity/stats/:userId
- Get user stats for a date
GET /api/coding-activity/stats/:userId/range
- Get user stats for a date range
Data Structure
Sync Payload
{
"date": "2025-01-19",
"project": "my-project",
"lines": {
"added": 120,
"removed": 30,
"net": 90
},
"commits": [
{
"hash": "abc123",
"message": "fix: login bug",
"branch": "main",
"timestamp": "2025-01-19T13:45:00Z"
}
],
"time": {
"activeMinutes": 75,
"idleMinutes": 10
}
}
Privacy
- All data is stored locally and synced to your backend
- Machine ID is generated from system information for unique identification
- No data is sent to third-party services
- You control your own backend and data storage
Troubleshooting
Extension not tracking activity
- Check that the extension is activated
- Verify backend API is running and accessible
- Check VS Code output panel for error messages
Authentication issues
- Ensure backend API is running
- Check API URL configuration
- Verify network connectivity
Git tracking not working
- Ensure Git extension is installed and active
- Check that you're in a Git repository
- Verify Git repository has commits
Development
Project Structure
src/
├── extension.ts # Main extension entry point
├── activity-tracker.ts # Core activity tracking logic
├── api-client.ts # Backend API communication
├── status-bar-manager.ts # Status bar display
├── stats-view-provider.ts # Webview for detailed stats
└── utils.ts # Utility functions
Building
npm run compile # Compile TypeScript
npm run watch # Watch for changes and recompile
npm run lint # Run ESLint
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions:
- Check the troubleshooting section
- Review VS Code output panel for error messages
- Open an issue on GitHub with detailed information