mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 03:36:07 +03:00
Disable rageshake persistence if no logs would be submitted
This also delays the persistence until later in the app startup - this is fine for the reasons listed on the partner PR: https://github.com/matrix-org/matrix-react-sdk/pull/5767 Fixes https://github.com/vector-im/element-web/issues/16694
This commit is contained in:
parent
ba28c6d57a
commit
a76c4ae943
3 changed files with 24 additions and 2 deletions
|
@ -92,6 +92,7 @@ async function start() {
|
|||
// load init.ts async so that its code is not executed immediately and we can catch any exceptions
|
||||
const {
|
||||
rageshakePromise,
|
||||
setupLogStorage,
|
||||
preparePlatform,
|
||||
loadOlm,
|
||||
loadConfig,
|
||||
|
@ -138,6 +139,9 @@ async function start() {
|
|||
await settled(loadConfigPromise); // wait for it to settle
|
||||
// keep initialising so that we can show any possible error with as many features (theme, i18n) as possible
|
||||
|
||||
// now that the config is ready, try to persist logs
|
||||
const persistLogsPromise = setupLogStorage();
|
||||
|
||||
// Load language after loading config.json so that settingsDefaults.language can be applied
|
||||
const loadLanguagePromise = loadLanguage();
|
||||
// as quickly as we possibly can, set a default theme...
|
||||
|
@ -197,6 +201,11 @@ async function start() {
|
|||
await loadThemePromise;
|
||||
await loadLanguagePromise;
|
||||
|
||||
// We don't care if the log persistence made it through successfully, but we do want to
|
||||
// make sure it had a chance to load before we move on. It's prepared much higher up in
|
||||
// the process, making this the first time we check that it did something.
|
||||
await settled(persistLogsPromise);
|
||||
|
||||
// Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to
|
||||
// run on the components.
|
||||
await loadApp(fragparts.params);
|
||||
|
|
|
@ -33,7 +33,7 @@ import PlatformPeg from "matrix-react-sdk/src/PlatformPeg";
|
|||
import SdkConfig from "matrix-react-sdk/src/SdkConfig";
|
||||
import {setTheme} from "matrix-react-sdk/src/theme";
|
||||
|
||||
import { initRageshake } from "./rageshakesetup";
|
||||
import {initRageshake, initRageshakeStore} from "./rageshakesetup";
|
||||
|
||||
|
||||
export const rageshakePromise = initRageshake();
|
||||
|
@ -51,6 +51,14 @@ export function preparePlatform() {
|
|||
}
|
||||
}
|
||||
|
||||
export function setupLogStorage() {
|
||||
if (SdkConfig.get().bug_report_endpoint_url) {
|
||||
return initRageshakeStore();
|
||||
}
|
||||
console.warn("No bug report endpoint set - logs will not be persisted");
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
export async function loadConfig() {
|
||||
// XXX: We call this twice, once here and once in MatrixChat as a prop. We call it here to ensure
|
||||
// granular settings are loaded correctly and to avoid duplicating the override logic for the theme.
|
||||
|
|
|
@ -31,7 +31,8 @@ import SdkConfig from "matrix-react-sdk/src/SdkConfig";
|
|||
import sendBugReport from "matrix-react-sdk/src/rageshake/submit-rageshake";
|
||||
|
||||
export function initRageshake() {
|
||||
const prom = rageshake.init();
|
||||
// we manually check persistence for rageshakes ourselves
|
||||
const prom = rageshake.init(/*setUpPersistence=*/false);
|
||||
prom.then(() => {
|
||||
console.log("Initialised rageshake.");
|
||||
console.log("To fix line numbers in Chrome: " +
|
||||
|
@ -50,6 +51,10 @@ export function initRageshake() {
|
|||
return prom;
|
||||
}
|
||||
|
||||
export function initRageshakeStore() {
|
||||
return rageshake.tryInitStorage();
|
||||
}
|
||||
|
||||
window.mxSendRageshake = function(text: string, withLogs?: boolean) {
|
||||
const url = SdkConfig.get().bug_report_endpoint_url;
|
||||
if (!url) {
|
||||
|
|
Loading…
Reference in a new issue