sarriaroman / FabricPlugin

Fabric.io plugin for Cordova or Phonegap
MIT License
197 stars 157 forks source link

Crash is not being sent to fabric #29

Closed diegocvigil closed 8 years ago

diegocvigil commented 8 years ago

Hello,

If I use the sendCrash() command, the error is sent to fabric. But if I force an error in javascript, doing an while true, the error is not sent.

I think that I don´t need to handle the error, or else it won´t be a crash, right?

Could you give me some help?

Thanks!

abarranco commented 8 years ago

If you force an error in javascript this plugin it's not going to catch that error.

You have to put this js code anywhere in your app:

window.onerror = function(errorMsg, url, lineNumber) { window.fabric.Crashlytics.sendNonFatalCrash("Error "+ errorMsg+ ". Url " + url + ". Linenumber "+lineNumber); window.fabric.Crashlytics.sendCrash(); return true; }

The problem is that you have to put window.fabric.Crashlytics.sendCrash(). If you don't put it, the non fatal error is not sent to fabric, and this is so bad because i don't want a javascript error to close my app.

I will try to use answers with a custom event to handle this situations and we aware of javascript errors, but the sendNonFatalCrash should be sending a non fatal crash by itself, and not closing the app.

There was another issue related to this, but has been closed, and this is not working as it should, at least in my opinion, i may be wrong. If sendNonFatalCrash does not send, should be renamed to AsyncLogNonFatalCrash or something like that, the name is making me think it will send a non fatal crash.

Justin-Credible commented 8 years ago

The Crashlytics framework is for reporting native code crashes. In Cordova applications, a majority of your code is JavaScript running inside of a web view. When there is a JavaScript exception it is reported via the global onerror handler, but will never cash a native code crash.

If you want to be notified of your JavaScript code exceptions you'll need to use something else. Like @abarranco says, you can use another analytics package (like Answers or Google Analytics). I personally use LogEntries.com's JavaScript integration.

abarranco commented 8 years ago

Well, i finally figure it out.

All you have to do in order to see the javascripts errors in Crashlitics as non fatal errors is to put this function anywhere in the code.

window.onerror = function(errorMsg, url, lineNumber) { window.fabric.Crashlytics.sendNonFatalCrash("Error "+ errorMsg+ ". Url " + url + ". Linenumber "+lineNumber); return true; }

The non fatal crash would be send to Crashlitics if you close the application after the error occurs, and then start again the application. It's when you start the app again that all non-fatal error who where logged by the plugin are flushed and they are sent to Crashlitics.

It's a little weird that your have to close and start again the app, but it's working this way.

Michenux commented 7 years ago

Really weird...

bmwertman commented 6 years ago

@abarranco will this work with fatal errors such as window.fabric.Crashlytics.sendCrash()?