github-readme-stats: Waka time card broken range parameter broken

Describe the bug

It looks like the range parameter of the WakaTime card is no longer working due to some upstream changes. https://github.com/anuraghazra/github-readme-stats/pull/2670 fixed the card for the all_time range. For the other ranges, however, the 403 “Forbidden” error is thrown. The strange thing is that this error is not thrown when I directly try the generated WakaTime API link in the browser, but it only happens when I request it through Axios. This is strange as according to the documentation this should work.

https://github.com/anuraghazra/github-readme-stats/blob/688f4e497593d22d813423248bd96aaf0f0e495f/src/fetchers/wakatime-fetcher.js#L14-L20

Regular card

willianrod's wakatime stats

[![willianrod's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=Harlok&layout=compact)](https://github.com/anuraghazra/github-readme-stats)

*All time

willianrod's wakatime stats

[![willianrod's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=Harlok&layout=compact&range=all_time)](https://github.com/anuraghazra/github-readme-stats)

Last 7 days

willianrod's wakatime stats

[![willianrod's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=Harlok&layout=compact&range=last_7_days)](https://github.com/anuraghazra/github-readme-stats)

Last 30 days

willianrod's wakatime stats

[![willianrod's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=Harlok&layout=compact&range=last_30_days)](https://github.com/anuraghazra/github-readme-stats)

Expected behaviour

Should work according to the documentation

Screenshots / Live demo link

No response

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

You can check the range for a user with https://wakatime.com/api/v1/users/current looking at the user’s attribute public_profile_time_range. No loop necessary, just get the range for the user from that API endpoint.

From my perspective, first document this behavior in the documentation, recommending users to explicitly specify the range parameter according to their settings. Then to make it compatible with the former API, we implement some kind of loop if the user left it blank.

@hakula139 I just implemented https://github.com/anuraghazra/github-readme-stats/pull/2707 which automatically gets the right information, throws descriptive errors and documents the behaviour in the README. I would appreciate it if you could review this PR so that we can merge. I don’t use the WakaTime card myself, so a review of somebody who does would be great!

https://wakatime.com/api/v1/users/Hakula/stats/all_time?is_including_today=true

Thanks for looking into this issue 🚀. I checked the behaviour you described, and it seems to be correct. The new API behaviour is that if users are logged in, they can request all ranges from the API in the browser. If they are logged out or try to request stats from other users, they can only request the time range that is used on the profile. I think there are two ways to solve the behaviour:

  • We document this in the documentation.
  • We implement some kind of loop that tries the three options (“all time”, “last_7_days” and “last_year”) and updates the card tile based on that.

What option do you guys think is best?

Thanks, I’ve fixed that. It’s just validation on that page and doesn’t affect your dashboard or stats and doesn’t prevent saving your chosen default dashboard range.

For new issues like this we should continue chatting over email with support@wakatime.com to prevent taking over this thread.

I had a problem with my wakatime card as well and couldn’t fix it no matter what i tried. Then i visited the wakatime profile settings page and found out i had selected ‘last 14 days’ (as a free user), which is apparently not for free anymore. Changing it to last 7 days fixed it. (used url: https://github-readme-stats.vercel.app/api/wakatime?username=Pawele&theme=dark&range=last_year&is_including_today=true)

also (not related to the problem), i noticed that wakatime api call return different time values on my machine and on different machines (shows less time spent). It almost feels like it hides time stats from private repos, but I haven’t really worked on any since i started using it. Any ideas why would that be? (used url: https://wakatime.com/api/v1/users/Pawele/stats/last_year?is_including_today=true) also, somehow ‘last_7_days’ (publicly) is forbidden for me while ‘last_year’ (publicly) isn’t…