mujx / hakatime

Wakatime server implementation & analytics dashboard
https://hakatime.mtx-dev.xyz
The Unlicense
610 stars 45 forks source link

Dockerized hakatime don't respond on projects menu #51

Closed tst32 closed 2 years ago

tst32 commented 2 years ago

i use docker image mujx/hakatime:v1.7.0

firstly it dosn't work with https but only http access work secondly, can't acess projects menu. many errors in dev console copied from firefox console


XHR 
GET
    http://127.0.0.1:8080/api/v1/projects?start=2021-10-19T19:46:54.556Z&end=2021-11-03T19:46:54.557Z
Status
403
Forbidden
VersionHTTP/1.1
Transferred214 B (56 B size)
Referrer Policystrict-origin-when-cross-origin

Content-Type
    application/json;charset=utf-8
Date
    Wed, 03 Nov 2021 19:46:54 GMT
Server
    Warp/3.3.13
Transfer-Encoding
    chunked

Accept
    application/json, text/*
Accept-Encoding
    gzip, deflate
Accept-Language
    en-US,en;q=0.5
authorization
    Basic
Connection
    keep-alive
Host
    127.0.0.1:8080
Referer
    http://127.0.0.1:8080/
Sec-Fetch-Dest
    empty
Sec-Fetch-Mode
    cors
Sec-Fetch-Site
    same-origin
User-Agent
    Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0

XHR 
GET http://127.0.0.1:8080/api/v1/users/current/projects/?start=2021-10-19T19:46:54.921Z&end=2021-11-03T19:46:54.921Z&timeLimit=15
[HTTP/1.1 404 Not Found 0ms]
Error: null
    onreadystatechange http://127.0.0.1:8080/#!/app/projects:72
    request http://127.0.0.1:8080/#!/app/projects:72
    s http://127.0.0.1:8080/#!/app/projects:72
    i http://127.0.0.1:8080/#!/app/projects:72
    g http://127.0.0.1:8080/#!/app/projects:90
    fetchProjectStats http://127.0.0.1:8080/#!/app/projects:115
    initProjectList http://127.0.0.1:8080/#!/app/projects:115
    initialize http://127.0.0.1:8080/#!/app/projects:115
    promise callback*initialize http://127.0.0.1:8080/#!/app/projects:115
    initialize http://127.0.0.1:8080/#!/app/projects:115
    a http://127.0.0.1:8080/#!/app/projects:117
    promise callback*a http://127.0.0.1:8080/#!/app/projects:72
    then http://127.0.0.1:8080/#!/app/projects:72
    a http://127.0.0.1:8080/#!/app/projects:117
    g http://127.0.0.1:8080/#!/app/projects:117
    initialize http://127.0.0.1:8080/#!/app/projects:115
    promise callback*initialize http://127.0.0.1:8080/#!/app/projects:115
    oninit http://127.0.0.1:8080/#!/app/projects:177
    a http://127.0.0.1:8080/#!/app/projects:58
    D http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    s http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    s http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    s http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    s http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    s http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    f http://127.0.0.1:8080/#!/app/projects:58
    m http://127.0.0.1:8080/#!/app/projects:58
    m http://127.0.0.1:8080/#!/app/projects:58
    v http://127.0.0.1:8080/#!/app/projects:58
    exports http://127.0.0.1:8080/#!/app/projects:58
    i http://127.0.0.1:8080/#!/app/projects:62
    m http://127.0.0.1:8080/#!/app/projects:82
    e http://127.0.0.1:8080/#!/app/projects:82
    L http://127.0.0.1:8080/#!/app/projects:82
    a http://127.0.0.1:8080/#!/app/projects:58
    exports http://127.0.0.1:8080/#!/app/projects:58
    mount http://127.0.0.1:8080/#!/app/projects:62
    w http://127.0.0.1:8080/#!/app/projects:82
    c http://127.0.0.1:8080/#!/app/projects:185
    t http://127.0.0.1:8080/#!/app/projects:187
    QvaY http://127.0.0.1:8080/#!/app/projects:187
    f http://127.0.0.1:8080/#!/app/projects:19
    parcelRequire http://127.0.0.1:8080/#!/app/projects:19
    <anonymous> http://127.0.0.1:8080/#!/app/projects:19

chrome autorize me then freeze (perpetual load js), console saying {"error":"Missing the 'Authorization' header field"} http://127.0.0.1:8080/api/v1/users/current/stats?start=2021-10-19T20%3A03%3A30.640Z&end=2021-11-03T20%3A03%3A30.640Z&timeLimit=15

mujx commented 2 years ago

How exactly did you start the server?

Could you paste the commands you used?

tst32 commented 2 years ago

docker-compose -f up

Im thinking CMD ["/app/start.sh"] start app.

tst32 commented 2 years ago

go also Error: [object Object] at XMLHttpRequest.f.onreadystatechange ((index):72) (index):117 call failed with {error: "The user admin doesn't have access to project null"} 404

i created user admin in web page http://127.0.0.1:8080/#!/register do i need any other user?

mujx commented 2 years ago

@tst32 The issue is that you don't have any projects to show. You'll have to first configure your wakatime client to send some data.

tst32 commented 2 years ago

cat .wakatime.cfg

[internal]
cli_version = v1.27.0
cli_version_last_modified = Wed, 22 Sep 2021 01:52:04 GMT
backoff_retries = 0
[settings]
api_key = ad6de9e5-d96c-4f56-965d-skip
api_url= http://127.0.0.1:8080/api/v1/users/current/heartbeats.bulk
[internal]
backoff_at = 2021-09-08T16:57:24+03:00

from .wakatime-cli.log


{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:199","func":"runCmd","level":"error","message":"failed to run command: today fetch failed: api error: failed fetching today from api: failed to make request to \"http://127.0.0.1:8080/api/v1/users/current/statusbar/today\": Get \"http://127.0.0.1:8080/api/v1/users/current/statusbar/today\": dial tcp 127.0.0.1:8080: connect: connection refused","now":"2021-11-05T16:43:48+03:00","version":"v1.28.1"}
{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:199","func":"runCmd","level":"error","message":"failed to run command: sending heartbeat(s) later due to api error: failed making request to \"http://127.0.0.1:8080/api/v1/users/current/heartbeats.bulk\": Post \"http://127.0.0.1:8080/api/v1/users/current/heartbeats.bulk\": dial tcp 127.0.0.1:8080: connect: connection refused","now":"2021-11-05T16:43:49+03:00","version":"v1.28.1"}
{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:199","func":"runCmd","level":"error","message":"failed to run command: sending heartbeat(s) later due to api error: won't send heartbeat due to backoff","now":"2021-11-05T17:00:21+03:00","version":"v1.28.1"}
{"caller":"/home/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:199","func":"runCmd","level":"error","message":"failed to run command: sending heartbeat(s) later due to api error: won't send heartbeat due to backoff","now":"2021-11-05T17:00:34+03:00","version":"v1.28.1"}
mujx commented 2 years ago

What if you use localhost instead of 127.0.0.1?

tst32 commented 2 years ago

Hurray! Everything works great. The thing was that I made a mistake in docker-compose.yml I wanted 8080 to be 8585, and unknowingly changed HAKA_PORT: 8080 to 8585 - this gave rise errors. I've fixed it now.: Thanks you so much!

version: "3"
services:
  server:
    container_name: hakatime
    image: mujx/hakatime:v1.7.0
    environment:
      # DB settings.
      HAKA_DB_HOST: haka_db
      HAKA_DB_PORT: 5432
      HAKA_DB_NAME: test
      HAKA_DB_PASS: test
      HAKA_DB_USER: test
      # Server settings.
      # Fill out this field if the api is behind another path (e.g behind a reverse proxy).
      # This will adjust the Set-Cookie path for all the /auth related API calls.
      HAKA_API_PREFIX: ""
      # Update this with the external endpoint that you use to access hakatime.
      HAKA_BADGE_URL: "http://localhost:8585"
      HAKA_PORT: 8080
      HAKA_SHIELDS_IO_URL: "https://img.shields.io"
      HAKA_ENABLE_REGISTRATION: "true" # Toggle after you've created your account.
      # Number of hours after which inactive browser sessions will expire (login required).
      HAKA_SESSION_EXPIRY: "24"
      HAKA_LOG_LEVEL: "info" # Control the verbosity of the logger.
      HAKA_ENV: "dev" # Use a json logger for production, otherwise key=value pairs.
      HAKA_HTTP_LOG: "true" # If you want to log http requests.
      GITHUB_TOKEN: "ghp_my_token_here" # If you want to retrieve time spent per commit. No extra scope is required.
      # Add the following variables if you want to forward any received heartbeats to another
      # Wakatime compatible server.
      HAKA_REMOTE_WRITE_URL: "https://wakatime.com/api/v1/users/current/heartbeats.bulk"
      HAKA_REMOTE_WRITE_TOKEN: "2-wakatime-token"
    ports:
      - "127.0.0.1:8585:8080"
  haka_db:
    container_name: haka_db
    image: postgres:12-alpine
    environment:
      POSTGRES_DB: test
      POSTGRES_PASSWORD: test
      POSTGRES_USER: test
    volumes:
      - deploy_db_data:/var/lib/postgresql/data

volumes:
  deploy_db_data: {}
tst32 commented 2 years ago

if you want i could help localize dashbord (js,css) to :ru:

mujx commented 2 years ago

Glad to hear that you fixed your issue.

Localization will be nice to have. Currently there isn't support for it but I'll open an issue to keep track.