Add logger of messages to server

This commit is contained in:
Paulo Gustavo Veiga 2022-02-03 21:16:55 -08:00
parent 1cbd5d3f2e
commit 8dbd6a92b7

View File

@ -37,7 +37,28 @@ export function buildDesigner(options: DesignerOptions): Designer {
console.log('Map loadded successfully'); console.log('Map loadded successfully');
}); });
const onerrorFn = () => { const onerrorFn = (msg: string, url: string, lineNo: number, columnNo: number, error: Error) => {
const message = [
`Message: ${msg}`,
`URL: ${url}`,
`Line: ${lineNo}`,
`Column: ${columnNo}`,
].join(' - ');
console.log(message);
// Send error to server ...
$.ajax({
method: 'post',
url: '/c/restful/logger/editor',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
data: JSON.stringify({
jsErrorMsg: message,
jsStack: JSON.stringify(error),
userAgent: navigator.userAgent,
mapId: options.mapId,
}),
});
// Open error dialog only in case of mindmap loading errors. The rest of the error are reported but not display the dialog. // Open error dialog only in case of mindmap loading errors. The rest of the error are reported but not display the dialog.
// Remove this in the near future. // Remove this in the near future.
if (!globalThis.mindmapLoadReady) { if (!globalThis.mindmapLoadReady) {