Inject bug report endpoint URL from config.json

This commit is contained in:
Kegan Dougal 2017-01-19 16:49:25 +00:00
parent bf887e82fe
commit 3996d23b19
3 changed files with 12 additions and 2 deletions

View file

@ -4,6 +4,7 @@
"brand": "Riot", "brand": "Riot",
"integrations_ui_url": "https://scalar.vector.im/", "integrations_ui_url": "https://scalar.vector.im/",
"integrations_rest_url": "https://scalar.vector.im/api", "integrations_rest_url": "https://scalar.vector.im/api",
"bug_report_endpoint_url": "https://vector.im/bugs",
"enableLabs": true, "enableLabs": true,
"roomDirectory": { "roomDirectory": {
"servers": [ "servers": [

View file

@ -241,6 +241,7 @@ async function loadApp() {
let configError; let configError;
try { try {
configJson = await getConfig(); configJson = await getConfig();
rageshake.setBugReportEndpoint(configJson.bug_report_endpoint_url);
} catch (e) { } catch (e) {
configError = e; configError = e;
} }

View file

@ -251,7 +251,7 @@ class IndexedDBLogStore {
}, (err) => { }, (err) => {
console.error(err); console.error(err);
}) })
}console.log("async consumeeeee"); }
return logs; return logs;
} }
@ -296,6 +296,7 @@ function selectQuery(store, keyRange, resultMapper) {
let store = null; let store = null;
let logger = null; let logger = null;
let initPromise = null; let initPromise = null;
let bugReportEndpoint = null;
module.exports = { module.exports = {
/** /**
@ -339,6 +340,10 @@ module.exports = {
await store.consume(false); await store.consume(false);
}, },
setBugReportEndpoint: function(url) {
bugReportEndpoint = url;
},
/** /**
* Send a bug report. * Send a bug report.
* @param {string} userText Any additional user input. * @param {string} userText Any additional user input.
@ -348,6 +353,9 @@ module.exports = {
if (!logger) { if (!logger) {
throw new Error("No console logger, did you forget to call init()?"); throw new Error("No console logger, did you forget to call init()?");
} }
if (!bugReportEndpoint) {
throw new Error("No bug report endpoint has been set.");
}
// If in incognito mode, store is null, but we still want bug report sending to work going off // If in incognito mode, store is null, but we still want bug report sending to work going off
// the in-memory console logs. // the in-memory console logs.
let logs = []; let logs = [];
@ -364,7 +372,7 @@ module.exports = {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
request({ request({
method: "POST", method: "POST",
url: "http://localhost:1337", url: bugReportEndpoint,
body: { body: {
logs: logs, logs: logs,
text: userText || "User did not supply any additional text.", text: userText || "User did not supply any additional text.",