A simple NodeJS script, intended to be run on a daily schedule (e.g. with cron), to collect "Starred" counts on specified GitHub respositories and "push" the resulting data to a Cyfe "Push API" widget for tracking in a Cyfe dashbord.
Cyfe is a handy SaaS utility to build metrics and KPI dashboards out of "widgets." Hubrix has no special relationship with Cyfe, we're just a happy customer. https://www.cyfe.com/
The Cyfe "Push API" is a straightforward specification for a JSON payload to be POSTed to an endpoint URL. This in turn updates a dashboard widget. Cyfe takes care of storing previous data so you can explore trends over an arbitrary date range. The JSON format is documented here: https://www.cyfe.com/api
This script assumes all referenced repositories are public, and therefore that no authentication is required to obtain the desired GitHub metrics. The only security feature on the Cyfe "Push API" is the secrecy of the (unique, generated) endpoint URL.
Here is the required contents and format of the .env variables:
ghuserthe GitHub username / owner of the reposghreposa comma-delimited list of repo namesghmetricthe (top-level) key in the JSON object returned by GitHub for which we want to collect tracking metrics. For GitHub Stars this isstargazers_countbut you could just as easily track Watchers withwatchers_countor Open Issues withopen_issues_countcyfendpointthe endpoint URL of the Cyfe "Push API" widget
-
The script depends on sync-request which is not recommended for production use. Then again, this is a
cronscript with a typically very short execution lifespan, not a complex service managing a bunch of asynchronous threads. -
The colors (for the Cyfe linechart) are hard-coded, limiting the number of repositories that can be "pushed" to Cyfe in a single widget to 12. However, you can run several instances of the script with different Cyfe endpoints to update several widgets.
