Skip to content

๐Ÿš€ Automatically logs daily โฐ work hours from ๐Ÿง  WakaTime & ๐Ÿงฎ Clockify into ๐Ÿ“Š Google Sheets! Tracks each ๐Ÿ‘ค user's productivity by ๐Ÿ“… date & ๐Ÿ—‚๏ธ project. Perfect for dev teams ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘ฉโ€๐Ÿ’ป who want effortless ๐Ÿ”„ time tracking & logging! ๐Ÿ“ฅ๐Ÿ“ˆโœจ

License

Notifications You must be signed in to change notification settings

muhammadIdhamMaarif/Connect-Wakatime-and-Clockify-to-Google-Spreadsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š Worktime Tracker Logger (WakaTime + Clockify)

This Google Apps Script automatically fetches and logs developer work hours from WakaTime and Clockify into a Google Spreadsheet. It calculates daily work durations, breaks them down by project/task, and logs them for each registered user.

โœ… Features

  • โฐ Collects yesterdayโ€™s worktime data automatically.
  • ๐Ÿ”„ Integrates with:
  • ๐Ÿ“ Stores daily total work hours in the Worktime sheet.
  • ๐Ÿ“„ Logs detailed per-project/task data in the WT_Log sheet.
  • ๐Ÿ›ก๏ธ Robust error handling for missing data or invalid API keys.

๐Ÿงช Example Output

Worktime Sheet

Name Date WakaTime (hrs) Clockify (hrs)
Idham 07/08/2025 2.3 1.5
Syafa 07/08/2025 0.5 0

WT_Log Sheet

Timestamp Name Source Date Activity Hours
2025-07-08 09:00:00 Idham WakaTime 07/08/2025 Project Alpha 1.3
2025-07-08 09:00:00 Idham Clockify 07/08/2025 Meeting / Review 1.5

๐Ÿ› ๏ธ How to Use

Follow these steps to install and run the script:


๐Ÿ“‚ 1. Open Google Spreadsheet

  1. Go to Google Sheets and open or create a new spreadsheet.
  2. Create these two sheets inside it:
    • Rename the first sheet to: Worktime
    • Add a second sheet and name it: WT_Log
      (Optional: If missing, the script will create it automatically)

๐Ÿง‘โ€๐Ÿ’ป 2. Open Apps Script Editor (Linked to Spreadsheet)

  1. Click Extensions โ†’ Apps Script.
  2. A script editor will open โ€” this script is now linked to your spreadsheet project.

๐Ÿ’พ 3. Paste the Script

  1. Delete any default code in the editor.
  2. Paste the full script from this repository.
  3. Click File โ†’ Save, and give your project a name (e.g., Worktime Tracker).

๐Ÿ”ง 4. Set Up Your Users and Keys

Inside the fetchWorkTimeData() function:

  • Replace the example users with your real user data.
  • Use the following placeholders:
const users = [
  { name: "YourName", wakaApiKey: "YOUR_WAKATIME_API_KEY", clockifyUserId: "YOUR_CLOCKIFY_USER_ID" },
  { name: "AnotherUser", wakaApiKey: null, clockifyUserId: null }
];

const CLOCKIFY_API_KEY = "YOUR_GLOBAL_CLOCKIFY_API_KEY";
const CLOCKIFY_WORKSPACE_ID = "YOUR_CLOCKIFY_WORKSPACE_ID";

You can leave wakaApiKey or clockifyUserId as null if not used by a particular user.

โฐ 5. Schedule Automatic Daily Updates (Recommended)

To automate fetching data daily:

  1. In the Apps Script editor, click the clock icon (๐Ÿ•’) or open Triggers from the left sidebar.

  2. Click + Add Trigger.

  3. Set it up like this:

    • Function to run: fetchWorkTimeData
    • Deployment: Head
    • Event source: Time-driven
    • Type of trigger: Day timer
    • Time of day: Pick your desired time (e.g., 6:00 AM)

โœ… 6. You're Done!

Now your spreadsheet will automatically track and log WakaTime and Clockify hours for each user โ€” daily, with detailed project/task breakdowns in WT_Log.


๐Ÿ”ง Configuration Variables

Variable Type Description
timezone string Timezone used for formatting date/time (Asia/Jakarta by default)
users array List of users to fetch data for, with their WakaTime and/or Clockify credentials
wakaApiKey string Individual userโ€™s WakaTime API Key
clockifyUserId string Individual userโ€™s Clockify user ID
CLOCKIFY_API_KEY string Global Clockify API Key for the account
CLOCKIFY_WORKSPACE_ID string Clockify workspace ID

๐Ÿ‘ค Adding a New User

  1. Add a new object inside the users array like so:
{ name: "NewUser", wakaApiKey: "your_waka_api", clockifyUserId: "your_clockify_user_id" }
  1. Leave either wakaApiKey or clockifyUserId as null if the user only uses one service.

๐Ÿ“ค API Permissions

  • WakaTime: Needs basic API access, use your secret API key from WakaTime settings.

  • Clockify: Needs X-Api-Key access (can be found in your Clockify account).

๐Ÿ›ก๏ธ Error Handling

  • If data cannot be fetched, it will log a fallback row in WT_Log with error notes.

  • Invalid or missing API credentials are safely ignored for each user.

๐Ÿ“… Scheduling Automation

To auto-run daily:

  • In Apps Script, click on the clock icon (Triggers).

  • Create a new trigger for fetchWorkTimeData.

  • Set it to run daily, preferably early in the morning (e.g. 6:00 AM).

๐Ÿ“œ License

MIT License โ€” Use this script freely, modify it as needed, and give credit when appropriate.

About

๐Ÿš€ Automatically logs daily โฐ work hours from ๐Ÿง  WakaTime & ๐Ÿงฎ Clockify into ๐Ÿ“Š Google Sheets! Tracks each ๐Ÿ‘ค user's productivity by ๐Ÿ“… date & ๐Ÿ—‚๏ธ project. Perfect for dev teams ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘ฉโ€๐Ÿ’ป who want effortless ๐Ÿ”„ time tracking & logging! ๐Ÿ“ฅ๐Ÿ“ˆโœจ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published