DevSync - VS Code Activity Tracker
DevSync is a comprehensive VS Code extension that tracks your coding activity offline and syncs it when you're back online. Unlike other activity trackers that rely on constant internet connectivity, DevSync is designed to work fully offline-first, making it ideal for developers who work in environments with intermittent connectivity or prefer to code while traveling or disconnected.
By tracking your coding patterns, DevSync helps you gain insights into your productivity, identify time-consuming projects, and analyze your coding habits over time.
Features
- Seamless Activity Tracking: Automatically captures data when you open, edit, and save files without interrupting your workflow
- Hybrid Syncing Strategy:
- Instant Online Sync: Send data directly to backend when online for immediate updates (fast & responsive)
- Reliable Offline Storage: Store data locally in SQLite database when offline with no data loss
- Automatic Background Sync: Seamlessly sync offline data once internet connection is available
- Intelligent Debouncing: Prevents excessive data collection by limiting heartbeats to configurable intervals
- Performance Optimization: Minimal impact on editor performance through async operations and smart caching
- Smart Detection:
- Project Detection: Automatically identifies your project based on directory structure and git repos
- Language Detection: Supports all VS Code language modes with automatic detection
- Status Bar Integration: Quick access to toggle tracking and view status
- Detailed Statistics: View daily coding statistics directly within VS Code
Installation
- Open VS Code
- Press
Ctrl+Shift+X
(Windows/Linux) or Cmd+Shift+X
(Mac) to open the Extensions view
- Search for "DevSync"
- Click "Install"
Configuration
Set up your API key in one of these ways:
Through VS Code Settings:
- Open Settings (
Ctrl+,
or Cmd+,
)
- Search for "DevSync"
- Enter your API key in the "DevSync: API Key" field
Through settings.json:
{
"devsync.apiKey": "your_api_key_here"
}
Advanced Configuration
You can customize the extension behavior with these settings:
{
"devsync.enabled": true, // Enable/disable the extension
"devsync.debug": false, // Enable debug logging
"devsync.debounceTime": 120, // Seconds to wait before sending another heartbeat for the same file
"devsync.apiBaseUrl": "http://localhost:8081/api" // URL of your backend API
}
Usage
DevSync runs automatically in the background once installed and configured. When you open, edit, or save files, it will track your activity and:
If online: Send heartbeats immediately to the backend server
- Updates your dashboard in real-time
- Requires a valid API key and internet connection
- Connection timeout is 2 seconds to avoid UI freezes
If offline: Store heartbeats locally in SQLite database
- No data is lost when working offline
- Local storage is in
~/.devsync/heartbeats.db
- Database is created automatically
- Background thread syncs when connectivity is restored
Commands
DevSync provides several commands to interact with the extension:
DevSync: Show Status
- Show current status (enabled/disabled)
DevSync: Toggle Tracking
- Toggle the extension on/off
DevSync: Force Sync
- Force sync queued heartbeats to the server
DevSync: Show Today's Stats
- Show today's coding statistics in a webview
DevSync: Enable Debug
/ DevSync: Disable Debug
- Control debug mode
Viewing Statistics
- Open the Command Palette (
Ctrl+Shift+P
or Cmd+Shift+P
)
- Type "DevSync: Show Today's Stats"
- A new tab will open showing your coding statistics for the day
The statistics include:
- Total coding time
- Breakdown by language
- Breakdown by project
Data Structure
Local Database Schema
Heartbeats are stored locally at ~/.devsync/heartbeats.db
in an SQLite database with the following schema:
CREATE TABLE heartbeats (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp REAL NOT NULL,
file TEXT NOT NULL,
project TEXT,
language TEXT,
is_write BOOLEAN NOT NULL,
ide TEXT NOT NULL,
machine TEXT,
os TEXT,
synced BOOLEAN NOT NULL DEFAULT 0
);
When sending data to the backend API, heartbeats are formatted as:
{
"timestamp": "2023-05-20T14:30:25+00:00",
"duration": 30,
"filename": "/path/to/file.py",
"language": "Python",
"project_name": "devsync",
"editor_name": "VS Code",
"editor_version": "",
"machine_name": "laptop",
"machine_os": "Linux"
}
Troubleshooting
Common Issues and Solutions
Extension Not Working
Check API Key:
- Verify your API key is set correctly in VS Code settings
- Look for error messages in the Output panel (View > Output > DevSync)
Check Logs:
- Enable debug mode in settings
- Check the Output panel for detailed logs
Data Not Syncing
Check Connection:
- Ensure you have internet connectivity
- Verify your API endpoint URL is correct
Force Sync:
- Use the "DevSync: Force Sync" command to manually trigger a sync
Code Structure
DevSync is built with a modular architecture for better maintainability and extensibility:
- Models: Shared type definitions and interfaces
- Services: Core business logic components
ConfigService
: Manages configuration and API keys
DatabaseService
: Handles local data storage and retrieval
HeartbeatService
: Tracks coding activity and user interactions
SyncService
: Handles synchronization with the backend
- UI Components: User interface elements
StatusBarService
: Manages the VS Code status bar integration
StatsService
: Provides statistics visualization
For more detailed information about the code structure, review the source code in the src
directory.
Contributing
Contributions to DevSync are welcome! Here's how you can help:
- Bug Reports: Open issues on GitHub with detailed information
- Feature Requests: Suggest new features or improvements
- Code Contributions: Submit pull requests for bug fixes or features
- Follow the modular architecture when adding features
- Add new functionality to existing services where appropriate
- Create new services or UI components only when necessary
- Documentation: Help improve or translate documentation
License
MIT
Feel free to contribute or report issues at https://github.com/your-username/vscode-devsync