wakatime / browser-wakatime

Chrome extension for automatic time tracking and metrics generated from your browsing activity.
https://wakatime.com
BSD 3-Clause "New" or "Revised" License
420 stars 99 forks source link

Extension is no longer tracking time #291

Closed fromage9747 closed 1 week ago

fromage9747 commented 2 weeks ago

Ever since the most recent update to the extension, it has stopped tracking time. I have tried removing it and configuring it all again, but the result is the same.

Are there any logs that I can look at to see why nothing is being logged? It worked well for months.

fromage9747 commented 2 weeks ago

Just had this error get spat out in my console from one of the sites its supposed to be tracking

image

Uncaught (in promise) Error: Extension context invalidated.
    at wakatimeScript.js:1:371252
    at wakatimeScript.js:1:371211
ouuan commented 1 week ago

I see "Cross-Origin Request Blocked" in the logs. I believe that https://github.com/wakatime/browser-wakatime/commit/88cd9943074d468359de98c551c6f964b0469191 caused the issue. That commit removed <all_urls> from permissions. <all_urls> was valid in manifest v2, but is now moved to host_permissions in manifest v3. So it is invalid as said in the commit on Chrome, but not on Firefox, which is still using manifest v2. Now on Firefox, the extension does not have permission to send cross-origin requests to the WakaTime server.

However, adding back <all_urls> would pose potential security risks. It would be better to only declare permissions for the WakaTime server. But in order to support custom servers, it should request permissions during runtime when the user sets the API URL in the settings.

By the way, I think we can use manifest v3 for Firefox to be consistent with Chrome.

ouuan commented 1 week ago

By the way, I think we can use manifest v3 for Firefox to be consistent with Chrome.

161 was opened just 2 days after Firefox 109 with MV3 support was released. I guess that was the reason to keep using MV2 for Firefox. Now it makes sense to migrate to MV3 for Firefox.

fromage9747 commented 1 week ago

@ouuan Is there any workaround to get this working for now? Surely I'm not the only one experiencing this issue?

ouuan commented 1 week ago

@ouuan Is there any workaround to get this working for now? Surely I'm not the only one experiencing this issue?

First, I want to make sure whether you are using the official WakaTime server (https://api.wakatime.com/) and whether you are using Chrome or Firefox. According to your screenshot, it seems that you are using Chrome. However, based on my experiments, the CORS request failure only happens for Firefox and custom WakaTime servers.

For further troubleshooting:

fromage9747 commented 1 week ago

@ouuan Thank you for getting back to me.

  1. I am using https://api.wakatime.com/api/v1:

image

  1. I am using Google Chrome Version 130.0.6723.117 (Official Build) (64-bit)
  2. Permissions Read and change all your data on all websites

image

  1. "Extension context invalidated" It was something that I noticed shortly after logging this in GitHub and I had just reinstalled the extension as a last resort to try and get it working again.
  2. If I click on just the service worker there is nothing, it is blank:

image

  1. If I click on the other link under the service worker I get the below:

image

Is there anything else I can look at to find the issue?

ouuan commented 1 week ago

3. Permissions Read and change all your data on all websites

What about the "Site Access" under "Permissions"? You can change the permissions there.

5. If I click on just the service worker there is nothing, it is blank:

Also check the Network tab. Switch between tabs and go back to the service worker inspector to see if heartbeats are sent.

fromage9747 commented 1 week ago

I have this:

image

Can't find anything regarding Site Access under: chrome://settings/content/siteDetails?site=chrome-extension://jnbbnacmeggbgdjgaoojpmhdlkkpblgi

Checking the network tab whilst flipping through a few sites I get the below:

image

This is all being performed whilst using Chrome on Windows. I thought I should give it a try using Chrome on Mac and its the same result.

I also tried using Chrome in Incognito mode with only the Wakatime extension enabled to remove any doubt of a conflicting extension, and it's the same outcome.

ouuan commented 1 week ago

Try clicking the extension icon. It should send requests to the WakaTime server to get and display the stats if working normally:

image

fromage9747 commented 1 week ago

This always shows me my current time from when I work and track time through VSCode. And when I inspect the extension and then click on the icon I get the same network result as per my previous screenshot.

When I reinstalled the extension, I also removed all of my included sites and tested with one site to track thinking that maybe one of my configured sites was causing an issue but even with just using once site, no tracking came through. I tried with a few sites individually to get a good sample set of tests and none of them worked.

Investigating a bit further, in the previous version when it did work. When you added a new site you needed to add "@@" after the URL to track so that it came up in Wakatime under the category/name you wanted. I just checked now, and the example provided no longer includes the "@@" perhaps this is my problem?

fromage9747 commented 1 week ago

@ouuan Alright, it's tracking it now, but it's not logging it under the correct Project. Now that the "@@" functionality has been removed... I see that I have to add it under projects in order to get it to correctly log under the right project as it was logging it under a completely irrelevant project name.

Looks like there was no issue with the extension, just configuration changes that I was unaware of after the most recent update.

I just double-checked the GitHub page and there isn't any reference to this configuration.

Anyway, glad its working now.

Thanks for the help.

ouuan commented 1 week ago

Fine, so we are encountering different issues. Glad to see yours is now resolved. I think you can close this issue as this thread is now off-topic for my issue on Firefox.

fromage9747 commented 1 week ago

Good luck!