Answer the question
In order to leave comments, you need to log in
How to send visitor browser console log to developer?
There is a JS web application with all the necessary personal belongings: AppCache, WebSQL and all that. Not the most difficult, lines that way for a couple of thousand.
The user complains that something does not work for him. The reasons for this can occur anywhere in the code, and this place will either throw an exception or give an error to the console.
How would I make it so that the console log for the last X minutes is sent to the developers when the user clicks on a special button?
Or even better: only what the developers indicate in advance was sent: potentially problematic places, uncaught errors, etc.?
Only interested in mobile Safari and mobile Chrome, other browsers are not needed.
Answer the question
In order to leave comments, you need to log in
I don’t know how to send a log on a button click, and if the error is critical, then it is likely that the js on the page is no longer working and no button clicks will be processed. I intercept and log all frontend errors on the backend. Before all the scripts connect on the page is https://github.com/darcyclarke/Detect.js and this
window.onerror = function(err, url, line, col, msg) {
var data = {
'Error': err,
'URL': url,
'Line': line,
'Column': null,
'Message': null,
'Browser': null,
'OS': null,
'Device': null
};
// HTML5 only
data['Column'] = !col ? '' : col;
data['Message'] = !msg ? '' : msg;
try {
var ua = detect.parse(navigator.userAgent);
data['Browser'] = !ua.browser.name ? '' : ua.browser.name;
data['OS'] = !ua.os.name ? '' : ua.os.name;
data['Device'] = !ua.device.name ? '' : ua.device.name;
}
catch(e) {}
console.groupCollapsed('Error: ' + data['Error']);
console.log('URL: ' + data['URL']);
console.log('Line: ' + data['Line']);
if(data['Column'])
console.log('Column: ' + data['Column']);
if(data['Message'])
console.log('Message: ' + data['Message']);
console.groupEnd();
try {
$.post('/frontend/error/', data);
}
catch(e) {}
return true; //suppressErrorAlert
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question