jsr icon indicating copy to clipboard operation
jsr copied to clipboard

Store download metrics + show most downloaded on home page

Open lucacasonato opened this issue 1 year ago • 3 comments

We already collect this information in GCP logs - we now need to aggregate & store it somewhere so we can display it.

lucacasonato avatar Feb 28 '24 14:02 lucacasonato

Requests for surfacing download metrics on package pages have been closed as duplicates of this:

  • #343
  • #383
  • edited to add #731

But this issue's title explicitly limits metrics' surfacing to showing on "the homepage", which given the "most downloaded" limit I take to mean the https://jsr.io/ homepage. Can we get an official comment on whether this issue includes support for surfacing download metrics on package pages?

edit: download metrics were added to package pages in April 2025

olets avatar Jun 25 '24 21:06 olets

I believe this issue is important, specially in the package page (pointed out as not included by @olets).

The number of weekly downloads on npm is a significant indicator of a package's credibility, particularly for developers who are in a hurry. It frequently becomes a decisive factor in determining whether they will choose the package.

I am sure JSR will want that in order to overtake npm, if not now, in the future.

felipezarco avatar Sep 06 '24 00:09 felipezarco

Now we already have Version Badge, JSR Score Badge and Scope Badge, it would be awesome to add Downloads (total/monthly/weekly) Badge! ❤️

cloydlau avatar Oct 07 '24 02:10 cloydlau

I would like to help with this feature. I've read the README but nothing about logs is mentioned and I wonder how could I read/parse them (real time and old ones) to count downloads and have a valid data source for this. Anyone can help?

Note: I guess productizing this would require to store those counters into the database, or other persistent storage, instead of logs. But at least reading old logs would be useful for initializing that storage.

sgmonda avatar Feb 06 '25 11:02 sgmonda

We already store download metrics and are available via an API endpoint, so the only thing needed to be added is the frontend

crowlKats avatar Feb 06 '25 11:02 crowlKats

@crowlKats oh that sounds great! I'll play with it. Thanks

sgmonda avatar Feb 06 '25 14:02 sgmonda

We already store download metrics and are available via an API endpoint

What endpoint is that?

tom-sherman avatar Mar 08 '25 19:03 tom-sherman

We already store download metrics and are available via an API endpoint

What endpoint is that?

I don't think there is any available documentation yet. So, I crawled the source code and found the following:

  • Global metrics: https://jsr.io/api/metrics

  • Package specific download metrics: https://jsr.io/api/scopes/{scope}/packages/{package}/downloads

    For example, to get the download metrics for the @std/assert package: https://jsr.io/api/scopes/std/packages/assert/downloads

foster-hangdaan avatar Mar 08 '25 21:03 foster-hangdaan

Would anyone know how to turn this package-specific downloads endpoint into a shields.io dynamic badge? I'm having a hard time understanding where's the total downloads and how to make that JSON path query work.

NatoBoram avatar Sep 01 '25 07:09 NatoBoram

@NatoBoram the endpoint in https://github.com/jsr-io/jsr/issues/14#issuecomment-2708489000 doesn't have precomputed "total downloads" or "weekly downloads" data points, and vanilla JSONPath doesn't have the functions needed to compute it in a shields query.

While waiting for #1182, you can fetch the data and reduce it to the value you're interested in. Then, you might be able to use that value directly in a static badge; or you could create your own API endpoint for that data (many popular frameworks support this) and use an endpoint badge.

olets avatar Sep 01 '25 18:09 olets