ffxsam ffxsam - 1 year ago 72
Javascript Question

Any way to collect beta testers' console logs?

I plan on launching a closed beta of a web app I'm working on, and I'd like a way to easily collect console log data from the testers. By "easily" I mean easy for them, because most of them won't be technical enough to open up the console and copy/paste info and errors. Is there some way I can collect this, including all log/info/warn/error statements, and stack traces?

EDIT: I should clarify that it's mostly the unhandled exceptions I'm worried about, so overriding

will do nothing since that function is not being called.

Answer Source


You've edited your question saying that what you want is to log the errors, so, you must use the onerror event, available in the window object.

window.addEventListener('error', function(e) {
  // log whatever you want here

You can do something like that in your Javascript:

console.print = console.log;
console.log = function() {

  // collect your data here, for example, sending a XHR
  var params = "values=" + encodeURIComponent(JSON.stringify(arguments));
  var xhr = new XMLHttpRequest();
  xhr.open('POST', '/log-data');

You override the console.log functionality, and you can do whatever you want there.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download