Answer: Automatic error reporting to GitHub issues

Automated error reports that push information into a bug-tracker are a very convenient method to collect exceptions from your plugin. There were a few discussions on this forum how this can be implemented. Over the years, I used an implementation of Jon Akhtar that created issues on YouTrack. Since my code is hosted on GitHub and I'm using the issues there for "real" user reports, I always wanted to have automatic errors there as well because let's face it: it is more likely that a user of your plugin knows GitHub and has an account there.

When my YouTrack error reporter stopped working, I finally decided that it is time to understand the GitHub API and rewrite the whole thing. There is already an implementation available from the Android Studio, so I did not have to start from zero. However, they implemented the communication with GitHub themselves which I did not want, because I aimed for something clearer with more features.

I want to give something back to the community that helped me a lot in the past, and therefore, I'm making this post about where you can find an implementation that is well documented and explains how it works. So if you are interested in creating a GitHub error reporter yourself, I highly welcome you to take a look at my implementation and steal everything you like. You can find the sources in the de.halirutan.mathematica.errorreporting package of my plugin on GitHub.

I won't discuss the details here, but I will give a short overview: The reporter will collect information about the running IDEA, the stack-trace and the details provided by the user. With this information, a new GitHub issue is created and the user will be notified with a balloon with a clickable link to the issue on GitHub. The user can use MarkDown in his description as he would usually do on GitHub and all this is merged into an issue that looks like this

One of the main features is that the hash of the stack trace is calculated and your existing issues are searched for duplicates. If a duplicate is found, then the description (if any) of the user is added as a comment which should keep your issue list from growing with many similar errors. If the user does not give a description, I'm still adding "Me too!" as a comment because then I have a feeling what exception hits many users.

One of the main drawbacks of providing comments is that they cannot be made anonymously. Therefore, you have to have a dedicated fake GitHub user that can create comments on public repositories. This is currently the main downside because no matter how you scramble/encode the GitHub credentials for your fake reporting user, you have to ship them with your plugin.

I used a fake user and created a fake repository only for collecting automatic reports. I then created a low-access personal token that can only access public repositories. The token is secured with an AES encryption so that it doesn't appear plain-text in the repository, but let me be clear: If the plugin has to decode it, everyone else can decode and use it to comment in public repositories in the name of your fake user.

If you are not OK with this, it will take only some minutes to remove the "search for duplicates and comment" feature from the code, and you can run the error reporter completely anonymously.

For communicating with GitHub I'm using the very small library org.eclipse.egit.github.core which (together with the required gson library) takes about 400K of space. The library provides you with a high-level way to connect to GitHub, create issues, label them, etc.

If you want to use this in your own plugin, a good starting point is the package-info.java where I put a description. Then you can go the GitHubErrorReporter.java and follow its track and you should be up and running in short time. I appreciate any feedback and suggestions.

3 comments
Comment actions Permalink

This looks great Patrick, thank you! I will definitely take a serious look at this - currently I'm using Rollbar, and it's less than ideal.

0
Comment actions Permalink

Did a little refactor to convert it into Kotlin, merged all classes into one file and kept the copyright and all function/class names.

https://github.com/ice1000/julia-intellij/blob/master/src/de/halirutan/mathematica/errorreporting/error-report.kt

It's much much shorter now.

1

Please sign in to leave a comment.