Report JS errors to backend (#842)

This commit is contained in:
Andrey 2018-01-27 21:50:13 +02:00 committed by Paulus Schoutsen
parent 13f8fa7e11
commit a1b578f81e
1 changed files with 10 additions and 0 deletions

View File

@ -31,3 +31,13 @@ if (window.noAuth === '1') {
} else {
window.hassConnection = null;
}
window.addEventListener('error', (e) => {
const homeAssistant = document.querySelector('home-assistant');
if (homeAssistant && homeAssistant.hass && homeAssistant.hass.callService) {
homeAssistant.hass.callService('system_log', 'write', {
logger: `frontend.${window.HASS_DEV ? 'js_dev' : 'js'}.${window.HASS_BUILD}.${window.HASS_VERSION.replace('.', '')}`,
message: `${e.filename}:${e.lineno}:${e.colno} ${e.message}`,
});
}
});