godbout / alfred-time

Start and stop tracking time with Toggl, Harvest, Everhour or Clockify through Alfred 4. ⏰️
MIT License
110 stars 8 forks source link

Clockify: ’Continue a timer‘ does not work #52

Closed domwass closed 2 years ago

domwass commented 2 years ago

I frequently make use of the ‘Continue a timer’ feature, but all of a sudden it does not work any more. The API is correctly set up and everything else works. (Timer 4.3.0 and Alfred 4.6.6 on OSX Monterey 12.4.) Here is the relevant bit of the debugging output:

STDERR: Time[Script Filter] PHP Warning: Undefined array key "" in […path…]/Alfred/Alfred.alfredpreferences/workflows/user.workflow.64635E72-D96C-48C1-AFAB-22132711B1AC/src/Services/Clockify.php on line 196

Any ideas how to resolve this?

Thanks, Dominik.-

godbout commented 2 years ago

haven't dealt with this for a long time, but my guess is that there's an empty tag or project name and that breaks something. different services have different rules. some allow empty tags or empty projects. this is handled for each service but they seem to be making boring changes from time to time. will have a look these days.

domwass commented 2 years ago

Thanks – Clockify does not allow entries without a project (at least in the basic settings). But that has not changed, as far as I know, and I don’t have recent entries without a project (as far as I can see). So this is strange – but now I know at least where to look.

godbout commented 2 years ago

what about tags/categories?

domwass commented 2 years ago

They are not mandatory (see attached screenshot). I cannot change the settings, as I have the free plan, and this is part of the basic plan. clockify

godbout commented 2 years ago

this is a problem with the tags: https://github.com/godbout/alfred-time/blob/7c983850e93d984f7e4d1d96cda919c7036a4fae/src/Services/Clockify.php#L196

or task. i don't remember what Clockify calls what. will see for a fix.

domwass commented 2 years ago

Yes, you are right – I had an entry with an empty tag. As soon as I added a tag to the entry, ‘Continue a timer’ worked. This is strange, though, since I often had entries without a tag in the past, but maybe Clockify has changed something under the hood? Anyhow, my problem is resolved for the moment, so thanks again.

godbout commented 2 years ago

the whole workflow doesn't even work anymore on my machine lol i don't really want to dig into it but at the same time i don't like keeping stuff dirty...

domwass commented 2 years ago

Interestingly, after I had added the tag, I deleted it again and tried the ‘Continue timer’ feature – and it worked! I don’t know where the workflow’s hickup came from, but from my point of view there’s no need to dig into it for the time being. If the problem occurs again, I’ll give you a shout.

godbout commented 2 years ago

but from my point of view there’s no need to dig into it for the time being

too late :D it needs an update anyways to handle PHP8.1.

godbout commented 2 years ago

Interestingly, after I had added the tag, I deleted it again and tried the ‘Continue timer’ feature – and it worked! I don’t know where the workflow’s hickup came from, but from my point of view there’s no need to dig into it for the time being. If the problem occurs again, I’ll give you a shout.

they may have changed how they return data. like if you didn't have a tag they would send an empty array before. now they may send nothing (nil). my tests are made with their API sending an empty array.

what may have happened is when you added a tag, it created a record, when you removed it, their API ended up with an empty array, rather than nil. but maybe i'm wrong. hopefully. coz else that would be quite dumb.

domwass commented 2 years ago

Just added a new entry without a tag and saved it. Then tried ‘Continued timer’, and it worked. So this seems not to have been the problem.

domwass commented 2 years ago

(Sorry, closing was accidental …)

godbout commented 2 years ago

(Sorry, closing was accidental …)

sad ☹️

i'll improve this anyway so that it doesn't happen again. (but probably it will.)

domwass commented 2 years ago

(Sorry, closing was accidental …)

sad ☹️

Well, as I said, the issue is resolved for me 😇. So if you’d like to close the issue, feel free to do so.

godbout commented 2 years ago

i don't like to have pending issues.

which is why it's really dumb that i'm owning 100+ repos... ☹️🥺️

godbout commented 2 years ago

strange, actually there's a check already:

        if (isset($clockifyTimer->tagIds[0])) {
            $pastTimer['tag_id'] = $clockifyTimer->tagIds[0];
            $pastTimer['tags'] = $tags[$clockifyTimer->tagIds[0]];
        }

so it seems that Clockify didn't return the tags, or not the right ones, or not enough? do you have many tags? did you try several time to continue the timer? maybe a bad record from their side? weird.

domwass commented 2 years ago

I don’t use more than one tag per entry. I tried to continue the timer several times, and the output was always the same. Now that it works again, I cannot reproduce the error, which is strange indeed.

godbout commented 2 years ago

ok i've made a new release: https://github.com/godbout/alfred-time/releases/tag/4.3.1 i hope i didn't fuck it up coz it's a manual process and my head is somewhere else. if it works then we can close ✌️

domwass commented 2 years ago

Tested with Alfred 4.6.7 and it worked. (See attached screenshot.) I had to update to php 8.1, though, and to enter the corresponding path in the workflow in order to get everything running again. clockify2

godbout commented 2 years ago

ha. i should have released this as v5. i drop PHP7.4 right before fixing but forgot about it. my bad.

the path thing is because you're on a M1? what would happen if you don't edit the path.

domwass commented 2 years ago

I’m on a Macbook Air. After upgrading to Monterey, Time (4.3.0) didn’t work, so I installed PHP 8 via homebrew, as suggested here: https://github.com/godbout/alfred-time/issues/46#issuecomment-991142891. With Time 4.3.1, there was an error because PHP 8.1 was needed, so I updated PHP (or rather, I ran brew install php, since I had only installed 8.0 via brew before).

I have now re-installed Time 4.3.1 and it still works without tweaking the PATH, so everything should be fine, I guess.

godbout commented 2 years ago

ah yes, it's the Monterey issue dropping interpreters by default. my bad again, sorry. been working for two years on my paid apps and i'm totally proficient in forgetting what i did a week before. anyways, great it all works good now.

godbout commented 2 years ago

if you're happy with the result we can close.

godbout commented 2 years ago

but you have to write "i am happy with the result".

domwass commented 2 years ago

I am happy with the result. :partying_face: