com.segment.analytics.BugsnagIntegration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
The hassle-free way to add analytics to your Android app.
package com.segment.analytics;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import com.bugsnag.android.Bugsnag;
import com.bugsnag.android.Client;
import java.util.Map;
/**
* Bugsnag is an error tracking service for websites and mobile apps. It automatically captures any
* errors in your code so that you can find them and resolve them as quickly as possible.
*
* @see Bugsnag
* @see Bugsnag Integration
* @see Bugsnag Android SDK
*/
class BugsnagIntegration extends AbstractIntegration {
static final String BUGSNAG_KEY = "Bugsnag";
@Override void initialize(Context context, JsonMap settings, boolean debuggingEnabled)
throws IllegalStateException {
Bugsnag.register(context, settings.getString("apiKey"));
Bugsnag.setUseSSL(settings.getBoolean("useSSL", true));
}
@Override Client getUnderlyingInstance() {
return Bugsnag.getClient();
}
@Override String key() {
return BUGSNAG_KEY;
}
@Override void onActivityCreated(Activity activity, Bundle savedInstanceState) {
super.onActivityCreated(activity, savedInstanceState);
Bugsnag.setContext(activity.getLocalClassName());
Bugsnag.onActivityCreate(activity);
}
@Override void onActivityResumed(Activity activity) {
super.onActivityResumed(activity);
Bugsnag.onActivityResume(activity);
}
@Override void onActivityPaused(Activity activity) {
super.onActivityPaused(activity);
Bugsnag.onActivityPause(activity);
}
@Override void onActivityDestroyed(Activity activity) {
super.onActivityDestroyed(activity);
Bugsnag.onActivityDestroy(activity);
}
@Override void identify(IdentifyPayload identify) {
super.identify(identify);
Traits traits = identify.traits();
Bugsnag.setUser(traits.userId(), traits.email(), traits.name());
final String userKey = "User";
for (Map.Entry entry : traits.entrySet()) {
Bugsnag.addToTab(userKey, entry.getKey(), entry.getValue());
}
}
}