VS Code Time Tracking Extension
Track time spent on different tasks, projects, and files within Visual Studio Code. This extension helps you monitor your productivity and provides insights into how you spend your time while coding.
Features
- Automatic Time Tracking: Tracks time spent on different files and projects
- Manual Control: Start, stop, or toggle time tracking with simple commands
- Activity View: Visualizes your time data in an easy-to-understand report view
- Categorization: Add categories to your time sessions for better organization
- Session Notes: Attach notes to your time tracking sessions for later reference
- Project Statistics: See time spent per project and per category
- Status Bar Integration: Shows current tracking status and elapsed time in the status bar
- SQLite Storage: Stores time tracking data in a SQLite database for better performance and reliability
Usage
Starting and Stopping Time Tracking
- Click the timer icon in the status bar to toggle tracking
- Run the command "Start Time Tracking" from the command palette
- Run the command "Stop Time Tracking" from the command palette
Categorizing Time
- Start time tracking on a file
- Run the command "Time Tracking: Add Category"
- Select a category from the dropdown list
Adding Notes to Sessions
- Start time tracking on a file
- Run the command "Time Tracking: Add Notes"
- Enter your notes in the input field
Viewing Reports
- Click on the clock icon in the activity bar to open the Time Tracking view
- View summaries of your time spent on different projects and files
- Click "Refresh Data" to update the reports with the latest tracking information
Extension Settings
This extension contributes the following settings:
timeTracking.autoTrack
: Enable/disable automatic time tracking when a file is opened
timeTracking.idleThreshold
: Time in seconds before considering the user idle
timeTracking.databasePath
: Path to the SQLite database file (default: ~/time-tracking.sql
)
Data Storage
The extension stores all time tracking data in a SQLite database:
- The default database location is
~/time-tracking.sql
- You can change the database location in the extension settings
- Data is automatically saved to the database when sessions end
- The database can be backed up like any other file on your system
Commands
time-tracking.startTracking
: Start tracking time for the current file
time-tracking.stopTracking
: Stop the current tracking session
time-tracking.toggleTracking
: Toggle time tracking on/off
time-tracking.addCategory
: Add a category to the current tracking session
time-tracking.addNotes
: Add notes to the current tracking session
Development
Prerequisites
Building the Extension
Clone the repository
git clone https://github.com/yourusername/vscode-time-tracking.git
cd vscode-time-tracking
Install dependencies
pnpm install
Build the extension
pnpm run compile
Publishing to VS Code Marketplace
This extension uses GitHub Actions for automated testing and publishing. To publish a new version:
- Update the version in
package.json
- Create and push a new tag that matches the version:
git tag v0.0.1
git push --tags
- GitHub Actions will automatically build, test, and publish the extension to the VS Code Marketplace
Manual Publishing
If you need to publish manually:
Install vsce
, the VS Code Extension Manager:
pnpm install -g @vscode/vsce
Package the extension:
pnpm run package
This will create a .vsix
file in the root directory.
Publish to the marketplace:
vsce publish
Note: This requires a Personal Access Token from the Azure DevOps organization.
Continuous Integration
The extension uses GitHub Actions for CI/CD:
- Every push to the main branch runs tests
- Tagged releases (starting with 'v') trigger an automatic build and publish
- Manual workflow runs can be triggered from GitHub Actions tab
Development Workflow
For active development with automatic rebuilding:
Start the watch process
pnpm run watch
This will start both TypeScript type checking and esbuild bundling in watch mode.
Press F5 in VS Code to launch a new Extension Development Host window with your extension loaded.
Make changes to the code and the extension will automatically rebuild. You may need to reload the Extension Development Host window (Ctrl+R or Cmd+R on macOS) to see your changes.
Installing the Extension Locally
Method 1: Using VSIX Package
Package the extension
pnpm run package
Install the generated VSIX file
code --install-extension time-tracking-0.0.1.vsix
Note: The exact filename may vary based on the version in package.json.
Method 2: Using Symbolic Links
Build the extension
pnpm run compile
Create a symbolic link in your VS Code extensions folder
For Linux/macOS:
ln -s /path/to/vscode-time-tracking ~/.vscode/extensions/time-tracking
For Windows (Run as Administrator):
mklink /D %USERPROFILE%\.vscode\extensions\time-tracking C:\path\to\vscode-time-tracking
Restart VS Code
Running Tests
Run pnpm run test
to execute the test suite.
Linting and Type Checking
- Run type checking:
pnpm run check-types
- Run linting:
pnpm run lint
Release Notes
0.0.1
Initial release of the Time Tracking extension with basic functionality:
- Track time spent on files
- View time reports
- Add categories and notes to sessions
License
This extension is licensed under the MIT License.