(function() {
"use strict";
// Set me!
githubURL = "https://github.com/username/repo";
title = "[Bug Report]: Blah Blah Blah";
var errors = [];
window.onerror = function(error, url, line) {
error = {"error": error, "url": url, "line": line};
if (errors.length > 0) {
var lastError = errors[errors.length - 1];
if (error.error === lastError.error && error.url === lastError.url && error.line === lastError.line) {
typeof lastError.recurrences === "number" ? lastError.recurrences ++ : lastError.recurrences = 1;
return;
}
}
errors.push(error);
};
function bugReport() {
var url = githubURL + "/issues/new?title=" + encodeURIComponent(title) + "&body=" + encodeURIComponent("Explain your problem here: \n\n*Please leave this for the developers:*\n```json\nErrors: ");
if (errors.length > 0) {
for (var i = 0; i < errors.length; i++) {
url += encodeURIComponent(JSON.stringify(errors[i]));
}
} else {
url += encodeURIComponent("None. (Yay!)");
}
url += encodeURIComponent("\n\nUser-Agent: " + navigator.userAgent + "\n```");
var win = window.open(url, '_blank');
win.focus();
}
});
- Set
githubURL
- Add to your script or a
<script>
tag
- Call
bugReport();
in a script, in onclick, or in a href (with javascript:bugReport();
)
- This isn't automatic, that'd require
hub
and a script a server
- Users have to be signed in to GitHub or sign in after clicking the link
👍 Using this for everything