Home > Uncategorized > Very simple, free phonegap app crash reporting

Very simple, free phonegap app crash reporting

App crashes are bad. They lead to negative app reviews, and often, the user does not, or cannot describe the exact actions taken just before the app crashed.

There are plenty of good app error reporting tools out there, such as exceptional, and airbrake, but lets say, we just want to have an email whenever a Javascript app crashes on a phonegap app. We want it free, and we want it as simple as possible. – But you’d like a stack trace of the error, and a decent description. – Oh, and let’s do it without requiring server-side code.

So, I set up a free account on FormToEmail.com, pressed the generate code button, and got my user_id and form_id, then I drop this function into my app:

function sendCrashReport(message, url , linenumber, column, errorObj)
{
var stack = “”;
if(errorObj !== undefined) //so it won’t blow up in the rest of the browsers
stack = errorObj.stack;
$.post(‘http://formtoemail.com/user_forms.php’,
{
“user_id” : “……”,
“form_id” : 1,
“message” : message,
“url” : url,
“linenumber” : linenumber,
“stack”: stack
},function(data)
{
console.log(data);
});
}

Then, as close as possible to the initialisation of the page, I write the code:

window.onerror = sendCrashReport;

– Of course, this may not catch compile errors or business logic mess ups, but It’ll catch serious runtime errors that could otherwise crash your app,

Advertisement
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: