Skip to content
Snippets Groups Projects
Unverified Commit ddb16d0a authored by R Midhun Suresh's avatar R Midhun Suresh Committed by GitHub
Browse files

Merge pull request #87 from vector-im/get-logs

Add ability to export logs from the console
parents 6178c1cb b6197415
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,7 @@ async function main() {
}
const platform = new Platform({container: root, assetPaths, config: {}, options: { development: import.meta.env.DEV }});
attachLogExportToWindow(platform);
const navigation = new Navigation(allowsChild);
platform.setNavigation(navigation);
const urlRouter = createRouter({ navigation, history: platform.history });
......@@ -100,6 +101,30 @@ function allowsChild(parent, child) {
}
}
function attachLogExportToWindow(platform): void {
(window as any).downloadLogs = async () => {
const logs = await platform.logger.export();
if (!logs && import.meta.env.DEV) {
console.error(
"Dev mode is not currently configured to collect persistent logs! Change the 'development' flag passed to Platform constructor to false or run Chatterbox from a true build."
);
return;
}
const accepted = confirm(
"Debug logs contain application usage data including your username, " +
"the IDs or aliases of the rooms or groups you have visited, " +
"the usernames of other users and the names of files you send. " +
"They do not contain messages. For more information, review our " +
"privacy policy at https://element.io/privacy." +
"\n\n" +
"Continue to export logs?"
);
if (accepted) {
platform.saveFileAs(logs.asBlob(), "chatterbox-logs.json");
}
}
}
function hideOnError() {
// When an error occurs, log it and then hide everything!
const handler = e => {
......
......@@ -19,6 +19,7 @@ import { loadStartButton } from "./load";
import "./parent-style.css";
(window as any).isIframeLoaded = false;
(window as any).__chatterbox = () => (document.querySelector(".chatterbox-iframe") as HTMLIFrameElement)?.contentWindow;
function setUnreadCount(count) {
const notification = document.querySelector(".notification-badge") as HTMLSpanElement;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment