Giter Club home page Giter Club logo

toggl-google-sheet's Introduction

Toggl Google Sheet Build Status

This Google Apps script imports time entries from Toggl.com into a Google Sheet using their Detailed Report API.

For a given month it aggregates the time entries per day and per customer.

Installation

Simple

Open this Google Sheet and make a copy in your Google Drive account.

From scratch

Create a new Google Sheet.

Create a new script in your newly created Google Sheet and paste the contents of all of the src/*.gs files in their respective script files.

Rename the first sheet as Config.

Add the following information in cell A1 of the Config sheet:

A: Variable B: Value C: Description
1 timesheetDate 01/01/2015 Timesheet Month
2 workspaceId workspaceId Toggl Workspace Id
3 apiToken your toggle api token Toggl API Token

To figure out your workspace_id: go to Team in toggl.com. The number at the end of the URL is the workspace id.

To figure out your api_token: go to your Profile in toggl.com, your API token is at the bottom of the page.

Usage

Re-open your Google Sheet. Now you will have a new menu called "Toggl" with a sub-menu "Get Timesheet for Month".

Fill a date of the month you want to import in cell B1. If you want your timesheet for December 2014, fill the date 01/12/2014 and click Toggl > Get Timesheet for Month.

It also calculates the number of days worked during that month.

Implementation

Google App Scripts only supports EcmaScript 5 because it is powered by Mozilla's Rhina Javascript Interpreter.

toggl-google-sheet is written in ES6 (aka EcmaScript2015). But the codebase still implements classes the old way using functions. That is because of historical reasons. The codebase started in full ES5 mode as a pure hack. Gradually, it got refactored by introducing classes, the hexagonal architecture and DDD concepts.

Webpack and Babel are used to transpile ES6 to ES5.

  • ./src/Code.js : contains the global functions required by Google Apps Script written in ES5.
  • ./src/App.js : entry point for Webpack bundle. Here we can use ES6 modules written in ES6. The bundle is exposed as a global variable app to Code.js.

Since early 2020, Google App Scripts is now supported by the V8 Runtime that powers Chrome and Node.js. But ES6 modules are not yet supported.

Because ES6 modules are not supported, there is still value in transpiling. And, the right now the Google Sheets still use the Rhino powered Google App Scripts.

Run tests

To run the tests:

npm install
npm test

Tests are implemented using Jest.

Build

To transpile the ES6 to ES5 for Google Apps Script:

npm run build

Acknowledgment

koen-github for providing an example on how to use the Toggl API with Google Sheet.

GSmart.in for providing an example of using ES6 and webpack/babel for Google Apps Script. See also Creating a complete web app on Google Apps Script using Google Sheet as database.

toggl-google-sheet's People

Contributors

andrelung avatar dependabot[bot] avatar tdpauw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

toggl-google-sheet's Issues

Generate a summary with the total hours and days per customer

For now I add manually a summary to the sheet that gives an overview of the total hours and days worked for a customer.

Customer Name Total hours Total days
Customer 1 122:53:29 16.39
Customer 2 40:47:18 5.10

This table should be generated automatically by the import.

More than one property into google sheets

Is it possible to pull more than one property into google sheets? At the moment the script imports "customer". I would like to import "project" and "description" as col 2 and 3?

UrlFetchApp Error

I have been getting an error code in my google sheets the last few days "Exception: Request failed for https://www.toggl.com returned code 410."

If I run a debug in google scripts it gets stuck at UrlFetchApp and the debugger says page: undefined under local variables?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.