wakatime / vscode-wakatime

Visual Studio Code plugin for automatic time tracking and metrics generated from your programming activity.
https://wakatime.com/vs-code
BSD 3-Clause "New" or "Revised" License
1.21k stars 134 forks source link

VSCode always asks for API key after starting the docker container #315

Open yudi-azvd opened 1 year ago

yudi-azvd commented 1 year ago

I run

docker compose up -d

I open vscode and it asks me for the key:

image

Is there a way to save it on my machine so that the wakatime extension can read it from inside even for a remote workspace? Or any other way.

By remote workspace I mean I'm using VSCode connected to a docker container using the Dev Containers extension. This container runs in my local machine

alanhamlett commented 1 year ago

Possibly related to #180?

yudi-azvd commented 1 year ago

Yes it is related. I was searching the issues but I couldnt find. Thats why I opened this issue

I tried the suggestion in https://github.com/wakatime/vscode-wakatime/issues/180#issuecomment-832075272 but it didn't work:

[settings]
api_key = ...
standalone = false
alpha = true

# I've also tried like this:
standalone = false
alpha = true

[settings]
api_key = ...

None of this worked.

Should i move this to #180 and close this issue? Also, is there any logs I can provide?

alanhamlett commented 1 year ago

The standalone config option was removed in 17.0.0 and currently alpha is the same as stable because wakatime-cli has no pending alpha releases, so you can remove both those config lines.

Let's leave this open since #180 is already closed. Does adding your api key to a ~/.wakatime.cfg file in your container and your host machine make it stop prompting?

yudi-azvd commented 1 year ago

I don't think so. If I cat ~/.wakatime.cfg from inside my container it shows my API key. And when I reload the VSCode it still asks for the key.

alanhamlett commented 1 year ago

Oh, looks like this is related to #280?

yudi-azvd commented 1 year ago

Yeah, kinda related. Anyway, the suggestion seems to work. I added .vscode/devcontainer.json with the following content:

{
  "mounts": [
    "source=${localEnv:HOME}/.wakatime.cfg,target=/home/dev/.wakatime.cfg,type=bind,consistency=delegated"
  ]
}

For future readers: mind the path at target=.... It should be a path that makes sense in your container.

@alanhamlett thanks for the help 🤓

EDIT: after a few container restarts, VSCOde got back to prompting for the API key 😢 .

gandarez commented 1 year ago

We would update the documentation for that scenario.

yudi-azvd commented 1 year ago

Actually... after executing docker compose down and then docker compose up -d, VSCode stills prompts me for the key.

nelson6e65 commented 1 year ago

I'm not getting request for a new one, but just error instead: imagen

I have it set in my container's ~/wakatime.cfg, manually: imagen

Also, I added as a global in setting.json: imagen