diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 19fd89326d..ea951b45ec 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -527,7 +527,8 @@ export default class MatrixChat extends React.PureComponent { "and contribute!", ); - console.log( + global.mx_rage_logger.bypassRageshake( + "log", `%c${waitText}\n%c${scamText}\n%c${devText}`, `font-size:${largeFontSize}; color:blue;`, `font-size:${normalFontSize}; color:red;`, diff --git a/src/rageshake/rageshake.ts b/src/rageshake/rageshake.ts index f275b15a41..5dcf8bc67b 100644 --- a/src/rageshake/rageshake.ts +++ b/src/rageshake/rageshake.ts @@ -45,9 +45,13 @@ const FLUSH_RATE_MS = 30 * 1000; // the length of log data we keep in indexeddb (and include in the reports) const MAX_LOG_SIZE = 1024 * 1024 * 5; // 5 MB +type LogFunction = (...args: (Error | DOMException | object | string)[]) => void; +type LogFunctionName = "log" | "info" | "warn" | "error"; + // A class which monkey-patches the global console and stores log lines. export class ConsoleLogger { private logs = ""; + private originalFunctions: {[key in LogFunctionName]?: LogFunction} = {}; public monkeyPatch(consoleObj: Console): void { // Monkey-patch console logging @@ -60,6 +64,7 @@ export class ConsoleLogger { Object.keys(consoleFunctionsToLevels).forEach((fnName) => { const level = consoleFunctionsToLevels[fnName]; const originalFn = consoleObj[fnName].bind(consoleObj); + this.originalFunctions[fnName] = originalFn; consoleObj[fnName] = (...args) => { this.log(level, ...args); originalFn(...args); @@ -67,6 +72,13 @@ export class ConsoleLogger { }); } + public bypassRageshake( + fnName: LogFunctionName, + ...args: (Error | DOMException | object | string)[] + ): void { + this.originalFunctions[fnName](...args); + } + private log(level: string, ...args: (Error | DOMException | object | string)[]): void { // We don't know what locale the user may be running so use ISO strings const ts = new Date().toISOString();