com.segment.analytics.BugsnagIntegrationAdapter 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 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 BugsnagIntegrationAdapter extends AbstractIntegrationAdapter {
@Override void initialize(Context context, JsonMap settings)
throws InvalidConfigurationException {
Bugsnag.register(context, settings.getString("apiKey"));
Bugsnag.setUseSSL(settings.getBoolean("useSSL", true));
}
@Override Client getUnderlyingInstance() {
return Bugsnag.getClient();
}
@Override String key() {
return "Bugsnag";
}
@Override void onActivityStarted(Activity activity) {
super.onActivityStarted(activity);
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());
}
}
}