Skip to content

Need help: api/external/heartbeats usage #75

@griffith1deady

Description

@griffith1deady

Hi! I started creating simple application that will be something like wakatime-desktop, however, i can't figure how to get time tracking working.

I used that code for request sending:

proc sendHeartbeat() {.async.} =
  let httpSession = HttpSessionRef.new()
  let bodyJsonNode = %*{
    "timestamp": now().inZone(utc()).format("yyyy-MM-dd'T'HH:mm:sszzz"),
    "project": "ziit-desktop",
    "language": "nim",
    "editor": "Zed",
    "os": "Linux",
    "file": "main.nim"
  }

  echo bodyJsonNode
  let requestResult = HttpClientRequestRef.post(
    httpSession, "<myinstance>/api/external/heartbeats", headers = [
      ("Content-Type", "application/json"),
      ("Authorization", fmt"Bearer {API_KEY}")
    ], body = $bodyJsonNode
  )

  if requestResult.isErr:
    echo "Error sending heartbeat:", requestResult.error
    return


  let request = requestResult.value()
  let response = await request.send()
  let content = await response.getBodyReader().read()
  echo string.fromBytes(content).parseJson()

(or here)

i send request every second, i tried make it once in 1.2 minutes like your Jetbrains plugin does - nothing changed

{"timestamp":"2025-09-20T00:24:04Z","project":"ziit-desktop","language":"nim","editor":"Zed","os":"Linux","file":"main.nim"}
{"success":true,"id":"cmfrckj0z01rpnv40hb8zizpg"}

i just don't undestand why time spended does not showing?
i run this application for like 60 minutes, but still:
screenshot
i see nothing...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions