From 3f291aae5b01fe842757e1cce33dcc67025c3f68 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 12 Apr 2017 11:26:53 +0100 Subject: [PATCH] Use an opts arg for submit-rageshake --- src/components/views/dialogs/BugReportDialog.js | 7 ++++--- src/vector/submit-rageshake.js | 13 ++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/views/dialogs/BugReportDialog.js b/src/components/views/dialogs/BugReportDialog.js index 62424cb1bc..badc994bb9 100644 --- a/src/components/views/dialogs/BugReportDialog.js +++ b/src/components/views/dialogs/BugReportDialog.js @@ -48,9 +48,10 @@ export default class BugReportDialog extends React.Component { return; } this.setState({ busy: true, err: null }); - submit_rageshake( - SdkConfig.get().bug_report_endpoint_url, userText, sendLogs, - ).then(() => { + submit_rageshake(SdkConfig.get().bug_report_endpoint_url, { + userText: userText, + sendLogs: sendLogs, + }).then(() => { this.setState({ busy: false }); this.props.onFinished(false); }, (err) => { diff --git a/src/vector/submit-rageshake.js b/src/vector/submit-rageshake.js index 871888211c..8c07007698 100644 --- a/src/vector/submit-rageshake.js +++ b/src/vector/submit-rageshake.js @@ -24,15 +24,18 @@ import rageshake from './rageshake' /** * Send a bug report. * @param {string} bugReportEndpoint HTTP url to send the report to - * @param {string} userText Any additional user input. - * @param {boolean} sendLogs True to send logs + * @param {object} opts optional dictionary of options + * @param {string} opts.userText Any additional user input. + * @param {boolean} opts.sendLogs True to send logs * @return {Promise} Resolved when the bug report is sent. */ -export default async function sendBugReport(bugReportEndpoint, userText, sendLogs) { +export default async function sendBugReport(bugReportEndpoint, opts) { if (!bugReportEndpoint) { throw new Error("No bug report endpoint has been set."); } + opts = opts || {}; + let version = "UNKNOWN"; try { version = await PlatformPeg.get().getAppVersion(); @@ -47,7 +50,7 @@ export default async function sendBugReport(bugReportEndpoint, userText, sendLog console.log("Sending bug report."); let logs = []; - if (sendLogs) { + if (opts.sendLogs) { logs = await rageshake.getLogsForReport(); } @@ -58,7 +61,7 @@ export default async function sendBugReport(bugReportEndpoint, userText, sendLog body: { logs: logs, text: ( - userText || "User did not supply any additional text." + opts.userText || "User did not supply any additional text." ), app: 'riot-web', version: version,