Allow local log downloads when a rageshake URL is not configured. (#31716)
* Add support for storing debug logs locally and allowing local downloads. * static * Comprehensive testing for bug report flow. * Driveby cleanup of typography * fix i18n * Improvements to UX * More testing * update snaps * linting * lint * Fix feedback * Fix boldnewss * fix bold * fix heading * Increase test coverage * remove focus * Don't show the FAQ depending on whether you can submit feedback. * move reset * fix err * Remove unused * update snap * Remove text * Bumping up that coverage * tidy * lint * update snap * Use a const * fix imports * Remove import in e2e test * whoops
This commit is contained in:
@@ -22,7 +22,8 @@ import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import * as rageshake from "../rageshake/rageshake";
|
||||
import SdkConfig from "../SdkConfig";
|
||||
import sendBugReport from "../rageshake/submit-rageshake";
|
||||
import sendBugReport, { loadBugReport } from "../rageshake/submit-rageshake";
|
||||
import { BugReportEndpointURLLocal } from "../IConfigOptions";
|
||||
|
||||
export function initRageshake(): Promise<void> {
|
||||
// we manually check persistence for rageshakes ourselves
|
||||
@@ -54,28 +55,40 @@ export function initRageshakeStore(): Promise<void> {
|
||||
return rageshake.tryInitStorage();
|
||||
}
|
||||
|
||||
window.mxSendRageshake = function (text: string, withLogs?: boolean): void {
|
||||
window.mxSendRageshake = async function (text: string, withLogs = true): Promise<void> {
|
||||
const url = SdkConfig.get().bug_report_endpoint_url;
|
||||
if (!url) {
|
||||
logger.error("Cannot send a rageshake - no bug_report_endpoint_url configured");
|
||||
return;
|
||||
}
|
||||
|
||||
if (withLogs === undefined) withLogs = true;
|
||||
if (!text || !text.trim()) {
|
||||
logger.error("Cannot send a rageshake without a message - please tell us what went wrong");
|
||||
return;
|
||||
}
|
||||
sendBugReport(url, {
|
||||
userText: text,
|
||||
sendLogs: withLogs,
|
||||
progressCallback: logger.log.bind(console),
|
||||
}).then(
|
||||
() => {
|
||||
if (url === BugReportEndpointURLLocal) {
|
||||
try {
|
||||
const tape = await loadBugReport({
|
||||
userText: text,
|
||||
sendLogs: withLogs,
|
||||
progressCallback: logger.log.bind(console),
|
||||
});
|
||||
const blob = new Blob([new Uint8Array(tape.out)], { type: "application/gzip" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
logger.log(`Your logs are available at ${url}`);
|
||||
} catch (err) {
|
||||
logger.error("Failed to load bug report", err);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await sendBugReport(url, {
|
||||
userText: text,
|
||||
sendLogs: withLogs,
|
||||
progressCallback: logger.log.bind(console),
|
||||
});
|
||||
logger.log("Bug report sent!");
|
||||
},
|
||||
(err) => {
|
||||
logger.error(err);
|
||||
},
|
||||
);
|
||||
} catch (err) {
|
||||
logger.error("Failed to send bug report", err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user