The other week, I had one of our community developers reach out to me. He said:
Crap. I'm a Developer Relations Engineer. Arguably the most important part of my job is to make sure our community users feel heard when they find issues like this. Thankfully, that very same developer brought up this blog about ghapi, a third-party Python library to pull information from GitHub. The article immediately reminded me: GitHub has an awesome REST API! So, I built a solution that uses the GitHub REST API, Deephaven Community Core, and Slack to monitor and report on user-submitted issues any time I run it.
GitHub is an amazing tool for developers to collaborate, manage workloads, and share their work. It hosts over 28 million public repositories, each of which has a plethora of issues submitted by team members and community users alike. How can developers stay on top of the issues submitted to their projects? Surely, keeping track of issues submitted by their own developers isn't too hard, but what about those user-submitted issues? End users rarely know who to assign the issue to, so they can fall through the cracks if not monitored regularly.
In this blog, I'll discuss how I've created a solution to this problem for the Deephaven Community Core team, and how the solution can work for anyone who's a part of a public GitHub project.
The GitHub REST API
Two things must be tracked: issues in a specific repository, and the members of the organization that host the repository. The Deephaven org's deephaven-core repository is a great example. The repository has hundreds of issues, most of which have been created by the development team and are being tracked by one or more developers. But there are some smaller number of issues submitted by those not in the organization, and those likely haven't been assigned to anyone.
One way to pull all of the information would be to just scrape the GitHub pages for the org and repo, respectively. Not only would that be messy and ugly, but it would also break completely if GitHub changed any aspect of its web UI. So there needs to be a better solution. Thankfully, the GitHub REST API allows anyone to pull information from a repository or organization they have access to. That includes everything that's public, as well as anything private they've been granted access to. GitHub users with a Personal Access Token can make up to 5,000 requests/hour for free.
This script pulls GitHub credentials from environment variables and uses them as authorization headers to request information on all issues in a GitHub repository. It requests 100 issues at a time until a request returns no information. The issue number, creation date, most recent update time, title, filer, and assignee are extracted and written to a Deephaven table. It also pulls the username of every member in the organization into a separate table, then performs a couple of table operations to separate the issues filed by non-members. This final table has important information about each user-submitted issue, which is exactly what I need.
Here's what a slice of the table looks like:
In Deephaven's case, most of the externally submitted issues are from former team members, with interns leading the way. Our past interns were excellent for so many reasons, including their bug reports!
The Slack SDK
With all of the necessary information in hand, all that's left to do is report it to something or someone who cares. Deephaven uses Slack for internal communications. It's a highly popular platform for users and businesses alike. Not only that, but developing bots for Slack is made easy via Slack's own slack_sdk Python package.
To create a Slack bot that will work for this application, read this guide. Once you've created a Slack bot with the necessary permissions and added it to a channel you want to send messages to, all you need is the OAuth token in an environment variable. This script collects relevant information about each issue, and reports it to Slack with links so that anyone in the channel can click on them to see more.
Here's what the message looks like in Slack:
Each number is a clickable link that takes you directly to the issue in GitHub. Several of our developers have joined the channel so that they can keep a closer eye on tickets submitted by the most important people in our project: the users.
Questions? Feedback? Talk to us on Slack. Join us!