Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get combined badge and stats for same gh + npm package #10

Closed
metaist opened this issue May 17, 2018 · 3 comments
Closed

Get combined badge and stats for same gh + npm package #10

metaist opened this issue May 17, 2018 · 3 comments

Comments

@metaist
Copy link

metaist commented May 17, 2018

If I publish code on github and npm, I'd like the jsDelivr badge to report combined stats for both. (Yay vanity metrics!)

To avoid abuse (e.g., a badge that combines stats for an unknown project with the stats for an unrelated popular project), perhaps you could use the repository field in package.json to make the correlation. It appears that field is already extracted somewhere because it appears on the page for packages.

@MartinKolarik
Copy link
Member

We did consider doing this when designing the first API version (same problem applies to all stats endpoints, not just badges) and indeed, my idea was using the repository field from package.json to link the appropriate GitHub repo.

In the end we didn't do this because:

  • it would make the API more complex and more confusing for users
  • we don't have the package.json info available on the API side (our website takes it from a different source)

The third, and probably most important reason: We recommend that people always use npm links when possible, and as a package author you have the opportunity to put those links in the official documentation. If you do that, most of your users will just use the recommended links and the GitHub hits become so insignificant that combining them isn't necessary.

@metaist
Copy link
Author

metaist commented May 22, 2018

Thank you for getting back to me. These are all fair points. Obviously, not having the package.json on the API side makes this much more complicated than I imagined.

Just to be clear: I was inspired in part by the ability to request multiple packages with a single request (so that idiom kinda already exists) and by #9 to think of jsDelivr as delivering a package that happens to be hosted on npm or github or somewhere else in the future-- the stats simply reflect how many times that particular code has been delivered.

Feel free to close the issue if there's nothing else to consider; I'm totally fine just switching over to the npm links and ignoring the other traffic.

Thanks again and thank you to the whole team for making something that's absurdly useful.

@MartinKolarik
Copy link
Member

I was inspired in part by the ability to request multiple packages with a single request (so that idiom kinda already exists)

Indeed, after your first post I considered a similar /combine approach for the API, which would remove the problem of matching npm packages to the corresponding GitHub repos.

I'll close this for now and we may revisit the idea if it becomes more important in the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants