Coder Social home page Coder Social logo

toggl2clockify's Introduction

toggl2clockify

Migrate data from toggl to clockify

No warranty that the tools works as expected. Read the following lines CAREFULLY and TEST it on a non productive system!

Quick start

Migration consists of six steps (which are described in detail below):

  1. Prepare clockify workspace
  2. Prepare Toggl workspace
  3. Modify config.json
  4. Run the migration tool bin/toggl2clockify.exe (or python toggl2clockify.py on other platforms)
  5. After the import go through log.txt and search for "WARNING" entries (if you're unsure post a bug report)
  6. Finalize migration (archive projects in clockify which were archived on toggl) by running bin/toggl2clockify.exe --skipClients --skipProjects --skipEntries --skipTags --doArchive

Migration Guide

Prepare clockify workspace

Prepare clockify workspace

Prepare Toggl workspace

Prepare Toggl workspace

Configure import process

Open the file config.json. The file already contains all required keywords (TogglKey , ClockifyKeys, ClockifyAdmin and StartTime).

Configure toggl and clockify API keys

You need your toggl API key (https://toggl.com/app/profile) and the clockify API keys of all users to be migrated (every clockify user has to open https://clockify.me/user/settings ). Put the keys in the file config.json.

Suppose your toggl API key is ABCDEF and you want to migrate yourself (clockify API key 123456) and a second user (clockify API key XYZCDF).

{
  "TogglKey": "ABCDEF",
  "ClockifyKeys": ["123456", "XYZCDF"]
}

Configure clockify admin mail address

You have to configure the mail address of one clockify workspace admin. Suppose you have admin rights on the clockify workspace and your clockify account mail is [email protected]

{
  "TogglKey": "ABCDEF",
  "ClockifyKeys": ["123456", "XYZCDF"],
  "ClockifyAdmin": "[email protected]"
}

Configure start time of import

Enter the start time from when you want to import your entries. This string is parsed by python's dateutil parser (details: https://dateutil.readthedocs.io/en/stable/parser.html).

Some valid examples:

  • "2012-01-19"
  • "2012-01-19 17:21:00"
  • "2012-01-19 17:21:00 CST"
{
  "TogglKey": "ABCDEF",
  "ClockifyKeys": ["123456", "XYZCDF"],
  "ClockifyAdmin": "[email protected]",
  "StartTime": "2019-01-19"
}

Configure end time of import (optional)

Entering an end time until when you want to import entries is optional. If not given, all time entries until NOW are imported. The EndTime string follows the same formation rules as the StartTime string.

{
  "TogglKey": "ABCDEF",
  "ClockifyKeys": ["123456", "XYZCDF"],
  "ClockifyAdmin": "[email protected]",
  "StartTime": "2019-01-19"
  "EndTime": "2019-05-14"
}

Configure workspace of import (optional)

The last step is to configure the workspace to be imported. You can also give a list of multplie workspaces, but this is an untested feature. Make sure that the toggl and clockify workspace names match exactly (no spaces, UPPER/lower case).

{
  "TogglKey": "ABCDEF",
  "ClockifyKeys": ["123456", "XYZCDF"],
  "ClockifyAdmin": "[email protected]",
  "StartTime": "2019-01-19",
  "Workspaces": ["myWorkspace"]
}

Clockify fallback user mail

If there are time entries in the toggl workspace that don't match to any clockify user, you can define a fallback user mail on the clockify workspace. All time entries with no clockify user match will than be assigned to this user on the clockify workspace. Let's assume that the fallback user has a mail address [email protected] and a ClockifyKeys "ABCDEF", than you have to add the Clockify API key to the ClockifyKeys and the mail address of the fallback user to the key FallbackUserMail:

{
  "TogglKey": "ABCDEF",
  "ClockifyKeys": ["123456", "XYZCDF", "ABCDEF"],
  "ClockifyAdmin": "[email protected]",
  "StartTime": "2019-01-19",
  "FallbackUserMail": "[email protected]",
  "Workspaces": ["myWorkspace"]
}

Run the import

Regular import

If you're on windows you can run the file directly:

bin/toggl2clockify.exe

Or through python by installing the requirements, and then running it.

pip install -r requirements.txt
python main.py

Make sure you have a file called config.json in the folder from where you invoke the program.

Run

bin/toggl2clockify.exe --help 

to get a list of all supported commands.

You can run the tool as often as you wish. All time entries, projects, clients and tags are checked for existance before being added to the clockify workspace

Remarks on archived projects

If you have archived projects in the toggl workspace, use the flag --doArchive at the very end when you are sure, that all data has been migrated successfully

Your very last invokation of the import tool should be

bin/toggl2clockify.exe --skipClients --skipProjects --skipTasks --skipEntries --skipTags --doArchive

When you try to add time entries for projects, which are already archived in clockify, the tool gets messed up:

  • the entries are added without project reference
  • the "entry exists" check doesn't work and the time entries will be added as duplicates on each invokation of the tool

Before you start the migration, you should unarchive all clockify projects first.

Check the log

The tool creates a file log.txt parse the contents for "INFO" and "WARNING" entries. Make sure to understand them or post a bug report if things don't work as expected.

What is migrated

  • All clients of the workspace

  • All tags of the workspace

  • The following project attributes are migrated:

    • name

    • client

    • isPublic

    • billable

    • color

    • membership

    • NOT MIRGATED: hourlyRate, estimate

  • The following time entry attributes are migrated:

    • start

    • billable

    • description

    • projectID

    • userID

    • end

    • tagIds

    • NOT MIGRATED: timeInterval (not sure what purpose this serves), isLocked

    • BUG: Duplicate entry detection has a bug unless setting timezone to "Z"

  • All tasks of the workspace

  • User groups

Clearing the workspace

You can use the --wipeAll flag to clear the entire workspace. This is useful for development/testing, since the duplication entry detection isn't perfect. This restores the workspace to a blank slate without having to create a new workspace. The program will wipe everything first, then immediately exit.

Development

After running pip install -r requirements.txt, run:

pre-commit install

This adds a small script that checks your code before commits. It will prevent you from committing unless your code passes formatting and pylint.

To run the commands individually:

Use black for auto-formatting

pip install black
black .

Use pylint_runner for linting code

pip install pylint
pip install pylint-runner
pylint_runner

Building a new version

For windows, simply navigate to the builder folder and run build_windows.bat

toggl2clockify's People

Contributors

acseven avatar alex-ong avatar coimbra1984 avatar julianscheel avatar kalebo avatar mkhon avatar perlexed avatar

Stargazers

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

Watchers

 avatar  avatar

toggl2clockify's Issues

Entries migrated on wrong project

Hello!

I have done the migration as per the instructions. After the migration, I have seen that some tasks are added on the wrong client and project. For example, I have one task "Calendario Social Media", on project "Social Media" on client "Cambia un Destino". and I have another exact same task and project, but on customer "PNA". So everything the same, except different client.

I have seen that almost all tasks on this combination from client "Cambia un Destino" were migrated as "PNA". This issue repeats itself not only on this specific instance of task-project-client, but on many others which task-project are the same but different client.

Let me know how I can help. Thanks so much.

Endpoint url changed

The endpoint url changed to end in /v1

I have added a pull request to fix this.

Error while checking Toggle API key

There's an error while checking Toggle API key

ERROR - migrator - something went wrong with your toggl key, msg=Login failed. Check your API key

This is because in the code there's an outdated API endpoint - https://www.toggl.com/api/v8, while Toggle now uses a new one - https://api.track.toggl.com/api/v8

Endtime is ignored

Using this config, "EndTime" gets ignored:

    "ClockifyAdmin": "[email protected]",
    "StartTime": "2019-05-02 08:00:00",
    "EndTime": "2019-05-03",
    "Workspaces": ["COMPANY"]

Also tried adding a specific timestamp, but it did not make a difference.

Log:

2019-06-16 14:21:24,586 - INFO - toggl2clockify - -------------------------------------------------------------
2019-06-16 14:21:24,588 - INFO - toggl2clockify - Phase 4 of 5: Import time entries
2019-06-16 14:21:24,590 - INFO - toggl2clockify - -------------------------------------------------------------
2019-06-16 14:21:24,591 - INFO - TogglAPI - fetching entries from 2019-05-02T08:00:00 to 2019-06-16T14:21:24.591475

Regards

Cannot execute final step (archive)

Hello!

I'm on windows 10, and cannot finalize the last step of the migration mentioned on the guide, which is referring to archive. Here are the logs. Can you please suggest next steps?

2019-11-10 20:50:00,491 - INFO - toggl2clockify - 'EndTime' not found in config file importing all entries until now

2019-11-10 20:50:00,494 - INFO - Clue - testing toggl API key XXXXXXXXXX
2019-11-10 20:50:02,935 - INFO - Clue - ...ok, togglKey resolved to email XXXXXXXXXX
2019-11-10 20:50:02,936 - INFO - ClockifyAPI - testing clockify APIKey XXXXXXXXXX
2019-11-10 20:50:03,419 - INFO - ClockifyAPI - ...ok, key resolved to email XXXXXXXXXX
2019-11-10 20:50:03,420 - INFO - ClockifyAPI - testing clockify APIKey XXXXXXXXXX
2019-11-10 20:50:03,701 - INFO - ClockifyAPI - ...ok, key resolved to email XXXXXXXXXX
2019-11-10 20:50:04,371 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,371 - INFO - toggl2clockify - Starting to import workspace 'EpicLemon' (1 of 1)
2019-11-10 20:50:04,373 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,373 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,374 - INFO - toggl2clockify - Phase 1 of 7: Import clients
2019-11-10 20:50:04,374 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,375 - INFO - toggl2clockify - ... skipping phase 1
2019-11-10 20:50:04,375 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,375 - INFO - toggl2clockify - Phase 1 of 7 (Import clients) completed (entries=0, ok=0, skips=0, err=0)
2019-11-10 20:50:04,376 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,376 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,377 - INFO - toggl2clockify - Phase 2 of 7: Import tags
2019-11-10 20:50:04,377 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,378 - INFO - toggl2clockify - ... skipping phase 2
2019-11-10 20:50:04,379 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,381 - INFO - toggl2clockify - Phase 2 of 7 (Import tags) completed (entries=0, ok=0, skips=0, err=0)
2019-11-10 20:50:04,386 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,386 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:04,387 - INFO - toggl2clockify - Phase 3 of 7: Import groups
2019-11-10 20:50:04,387 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:05,574 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:05,575 - INFO - toggl2clockify - Phase 3 of 7 (Import groups) completed (entries=0, ok=0, skips=0, err=0)
2019-11-10 20:50:05,576 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:05,577 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:05,577 - INFO - toggl2clockify - Phase 4 of 7: Import projects
2019-11-10 20:50:05,579 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:05,582 - INFO - toggl2clockify - ... skipping phase 3
2019-11-10 20:50:05,582 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:05,583 - INFO - toggl2clockify - Phase 4 of 7 (Import projects) completed (entries=0, ok=0, skips=0, err=0)
2019-11-10 20:50:05,584 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:05,585 - INFO - toggl2clockify - -------------------------------------------------------------
2019-11-10 20:50:05,588 - INFO - toggl2clockify - Phase 5 of 7: Import tasks
2019-11-10 20:50:05,588 - INFO - toggl2clockify - -------------------------------------------------------------
Traceback (most recent call last):
File "toggl2clockify.py", line 261, in
numEntries, numOk, numSkips, numErr = cl.syncTasks(ws)
File "Clue.py", line 112, in syncTasks
tProjs = self.toggl.projects
AttributeError: 'TogglAPI' object has no attribute 'projects'
[144456] Failed to execute script toggl2clockify

ERROR - toggl2clockify - json entry 'TogglKey' must be a strings

Hi,

Platform: Ubuntu 18.04 using python 2.7.15.

I was trying to run the app for a test migration and keep on getting the following error:
ERROR - toggl2clockify - json entry 'TogglKey' must be a strings

I have double-checked the format used for the API key in the config.json file and its complying 100% for the format indicated in your installation and preparation documentation. I have also done a Google search to check if someone else has maybe experienced the same problem but could not find any other related article.

Is this an app error or a config file error? The API key used was copied and pasted directly from the Toggl UI so I know it is correct.

Raise helpful error when trying to migrate project title of length 1

I have a(n archived) project called F in toggl, but when I try to migrate it, it always fails.

After a spot of investigation, I saw an error on Clockify's web interface that a project name must be 2-20 characters. This would have been nice to have known about.

I suppose I should have been suspicious when toggl2clockify repeatedly indicated F was new in the project sync step, but, as no errors were thrown, I thought nothing of it until I was 2000+ task entries in.

Duplicate check

Suggestion: A duplicate check for time entries and projects already in Clockify would be a very welcome addition, maybe even as a separate tool. After the many times I’ve done the process, I think some time entries got duplicated but I can’t say for sure.

Regards

Groups in Projects

Hi again

I was going through my final checks of the imported data and found quite a big issue. I'd read that Groups are not migrated, and that's ok as those are relatively easy to replicate manually.

However, I did not make that replication before starting the data migration, and now I've found that our 1600 projects do not have any Groups assigned, which is a very big issue. As expected, running the migration tool again skips all projects as those already exist.

So, my two questions are:

  • Does the tool migrate assigned Groups if they exist? If not, would that be feasible?
  • Considering my current situation and that the tool migrates Group assignments to Projects, is there a way to force overwriting existing projects (or any other data for that matter) - a command line parameter for example?

Cheers

Edit: I've just confirmed that the Groups aren't in fact migrated. Is there any possibility of adding this to the routines? I have 1600 projects, all based on group permissions!

API issue?

Hi,

Thanks for this tool. I'm using to test a potential moving to Clockify, but I haven't been able to finish the migration process so far.

Users check out, Clients and Tags migrated ok. Projects started to migrate ok, but eventually started to get some errors, which seem to be on Clockify's API side - maybe I'm hitting an API limit?

I'm getting these errors at ~300/1600 Projects:

2019-06-08 23:30:51,867 - INFO - Clue - project XYZ already exists, skip...
2019-06-08 23:30:51,868 - INFO - Clue - adding project XYZ (315 of 1604 projects)
Traceback (most recent call last):
  File "toggl2clockify.py", line 209, in <module>
  File "Clue.py", line 126, in syncProjects
  File "ClockifyAPI.py", line 326, in addProject
  File "ClockifyAPI.py", line 121, in _loadUser
RuntimeError: error loading user
[7476] Failed to execute script toggl2clockify

Or right off the bat after the previous error, if I don't wait some time:

 .\toggl2clockify.exe --skipClients --skipTags --reqTimeout 10
2019-06-08 23:36:45,191 - INFO - Clue - testing toggl API key (toggl-key)
2019-06-08 23:36:47,704 - INFO - Clue - ...ok, togglKey resolved to email (toggl-user)
2019-06-08 23:36:47,705 - INFO - ClockifyAPI - testing clockify APIKey (user 1 of 19 clockify-key)
Traceback (most recent call last):
  File "toggl2clockify.py", line 149, in <module>
  File "Clue.py", line 29, in __init__
  File "ClockifyAPI.py", line 82, in __init__
RuntimeError: error loading user
[2636] Failed to execute script toggl2clockify

The code line numbers vary every time I try this.

Edit:

After some more progress, one more issue (client appears to be present in both Clockify and Toggl):

2019-06-09 01:37:24,425 - INFO - Clue - adding project ABC (532 of 1604 projects)
Traceback (most recent call last):
  File "toggl2clockify.py", line 209, in <module>
  File "Clue.py", line 126, in syncProjects
  File "ClockifyAPI.py", line 331, in addProject
  File "ClockifyAPI.py", line 212, in getClientID
RuntimeError: Client ANS not found in workspace COMPANY
[24736] Failed to execute script toggl2clockify

Missing Module

Hi. Thank you for creating this tool. I would like to use it, but I'm running into an error. I know very little about Python, but I'm comfortable with the command line. I'm trying to run python3 toggl2clockify.py in Terminal on a MacBook Pro under Mojave (macOS 10.14). The error I'm getting is ModuleNotFoundError: No module named 'dateutil' immediately after invoking the command.

Digging a little deeper, it appears that toggl2clockify expects dateutil to be installed on my system. Where should I look to install that module?

Thanks

Task importer for inactive tasks

There was a fatal crash while importing the tasks.
See below:
2019-08-11 21:55:12,251 - INFO - Clue - adding xxx, project: yyyy (394 of 5883)
Traceback (most recent call last):
File "toggl2clockify.py", line 274, in
File "Clue.py", line 387, in syncEntries
File "TogglAPI.py", line 154, in getReports
File "TogglAPI.py", line 190, in _getReports
File "Clue.py", line 363, in onNewReports
File "ClockifyAPI.py", line 664, in addEntry
File "ClockifyAPI.py", line 279, in getTaskIdFromTasks
RuntimeError: Task zzzz not found.
[9896] Failed to execute script toggl2clockify

After reviewing the log and checking the workspaces. There are two issues:

the inactive (past) tasks are not imported - I checked the Toggl API and it should return all tasks (it returns a field called "active" which is a bool)
the script can do some validation before trying to write data to Clockify (or some try / catch statements or just continue even if a 400 status was reported by the api - I am not sure how it works)

Problem with Time records

Hi, I do have a problem with importing Time records from toggl to Clockify. I got imported all clients and projects but when it comes to Time records import, nothing really happen - see picture attached. Can you please help me with that? Thank you sooooo much :-)
log_PrtScr

Time entries duplicating unless timezone is set to 0:00 Zulu

Was having trouble with time entries duplicating on subsequent runs of the process when importing to Clockify. Determined that changing the time zone in Clockify to UTC 0:00 Zulu during the import allowed it to see that the entries were already there and skip them.

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.