muety / wakapi

📊 A minimalist, self-hosted WakaTime-compatible backend for coding statistics
https://wakapi.dev
MIT License
2.68k stars 162 forks source link

User agent string from desktop-wakatime parsed improperly #686

Open Bashev opened 1 week ago

Bashev commented 1 week ago

From few months wakatime has desktop app (https://github.com/wakatime/desktop-wakatime) and it seems to works with wakapi, but ... data comes with some deviations in editors section.

Desktop App partially covered support of different apps which can be tracked and is useful workaround if your tool is not supported natively yet.

Wakapi image

Wakatime image

Is it a data "mapping" issue or something changed on the wakatime side? Can this be applied to wakapi?

muety commented 1 week ago

Didn't know about the desktop app, very interesting. Thanks for reporting this! I'll have an in-depth look soon and keep you posted.

muety commented 1 week ago

Unfortunately, I can't currently use the app due to https://github.com/wakatime/desktop-wakatime/issues/44. However, I dug through the code a bit and gathered a couple of hints.

Plugin user agent string is constructed in wakatime.ts#L244 with the versionString part being something like windows-wakatime/1.2.3. The user agent string then perhaps becomes something like <appName>/1.2.3 windows-wakatime/1.2.3. Wakapi uses the regex in http.go#L88 to parse that user agent string and default UA parsing as a fallback.´

Most probably, the issue lies somewhere in how we parse the user agent strings. To debug this further, however, I'd have to know exactly how the plugin constructs them and see some examples.

@Bashev, are you on Wakapi.dev? If yes, could you share your user name, please? If you're self-hosting instead, could you do me a favor and send some exemplary rows from your database's heartbeats table, that correspond to heartbeats sent by the desktop app?

Bashev commented 6 days ago

CSV wakapi-desktop-extracted-heartbeats.csv or SQL wakapi-desktop-extracted-heartbeats.zip

Looks like Editor is not recognized or overridden by 'Windows' for example: