Skip to content

Instantly share code, notes, and snippets.

@Scub3d
Created May 25, 2018 09:50
Show Gist options
  • Save Scub3d/4bee73c067497b01659be2823653dd50 to your computer and use it in GitHub Desktop.
Save Scub3d/4bee73c067497b01659be2823653dd50 to your computer and use it in GitHub Desktop.
Allows Firebase to create a new GitHub issue when a new Crashlytics Issue occurs. WIP
// Put this file/code in your functions/index.js file
const functions = require('firebase-functions');
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
const OWNER_USERNAME = "<github_username>";
const REPO_NAME = "<github_repo_name>";
const ACCESS_TOKEN = "<github_personal_access_token>";
exports.newIssue = functions.crashlytics.issue().onNew(issue => {
var issueId = issue.issueId;
var issueTitle = issue.issueTitle;
var appInfo = issue.appInfo;
return createGitHubIssue(issueId, issueTitle, appInfo);
});
function createGitHubIssue(issueId, issueTitle, appInfo) {
xhr = new XMLHttpRequest();
var url = "https://api.github.com/repos/" + OWNER_USERNAME + "/" + REPO_NAME + "/issues";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.setRequestHeader("Authorization", "token " + ACCESS_TOKEN);
var jsonData = {
"title": issueTitle
"body": "This issue was generated automatically via crashlytics.\n\nCrashlytics Issue: " + issueId + "\nAppInfo:\n - App Name: " + appInfo.appName + "\n - Platform: " + appInfo.appPlatform + "\n - App Id: " + appId + "\n - App Version: " + appInfo.latestAppVersion + "\n\nIf this is a duplicate issue, please label 'duplicate' and close."
"lables": [
"bug"
]
};
var data = JSON.stringify(jsonData);
xhr.send(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment