MixPanel for error monitoring

I am working on an Android application that integrates with MixPanel for analytics and BugSnag for error monitoring.

Recently, we found a crash in the application, and since we could not find the root cause of the failure, we added code to restart the application when an error occurred. Along with the restart, we also started tracking how many times the error occurs. My preference was to use Bugsnag for the same, but a couple of people on the team asked why we could not use MixPanel, because we can easily filter out the events with the parameters that we sent to MixPanel. But I believe that MixPanel should not be used as specifically for tracking user events. And neither an accident nor a restart occurs due to a user event, this happens simply by accident.

I would like to hear suggestions and thoughts from the community regarding the same.

+4
source share
1 answer

You can use it Thread.setDefaultUncaughtExceptionHandler(...)in your own Application.onCreateto set your own Thread.UncaughtExceptionHandler, which tracks MixPanel all UncaughtExceptions (Crashes) and set properties such as:

public class MyExceptionHandler implements UncaughtExceptionHandler
{
    private UncaughtExceptionHandler defaultExceptionHandler;

    public MyExceptionHandler (UncaughtExceptionHandler defaultExceptionHandler)
    {
        this.defaultExceptionHandler = defaultExceptionHandler;
    }

    public void uncaughtException(Thread thread, Throwable exception)
    {
        mMixPanelInstance.trackEvent("APP_CRASH", null);
        if (defaultExceptionHandler != null)
        {
            defaultExceptionHandler.uncaughtException(thread, exception);
        }

    }
}


MyApplication.onCreate(...)
{
    UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler();

    Thread.setDefaultUncaughtExceptionHandler(new MyExceptionHandler(currentHandler));
}
0
source

Source: https://habr.com/ru/post/1527292/


All Articles