diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 0f018b4655..4213428091 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -69,6 +69,7 @@ import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.bugsnag.android.Bugsnag; import com.google.android.material.snackbar.Snackbar; import org.json.JSONArray; @@ -706,6 +707,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB prefs.edit().putBoolean("crash_reports", true).apply(); if (cbNotAgain.isChecked()) prefs.edit().putBoolean("crash_reports_confirmed", true).apply(); + Bugsnag.startSession(); } }) .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java index 9064f44c42..7b070eeae2 100644 --- a/app/src/main/java/eu/faircode/email/ApplicationEx.java +++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java @@ -108,6 +108,7 @@ public class ApplicationEx extends Application { else config.setReleaseStage(BuildConfig.PLAY_STORE_RELEASE ? "stable/play" : "stable"); + config.setAutoCaptureSessions(false); config.setIgnoreClasses(new String[]{"javax.mail.MessageRemovedException"}); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); @@ -115,11 +116,13 @@ public class ApplicationEx extends Application { config.beforeSend(new BeforeSend() { @Override public boolean run(@NonNull Report report) { - return prefs.getBoolean("crash_reports", false); // opt-out + return prefs.getBoolean("crash_reports", false); // opt-in } }); Bugsnag.init(this, config); + if (prefs.getBoolean("crash_reports", false)) + Bugsnag.startSession(); upgrade(this); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 3de11d2b4b..c3e47a1578 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -39,6 +39,8 @@ import androidx.appcompat.widget.SwitchCompat; import androidx.constraintlayout.widget.Group; import androidx.preference.PreferenceManager; +import com.bugsnag.android.Bugsnag; + import java.text.SimpleDateFormat; public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { @@ -164,6 +166,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("crash_reports", checked).apply(); + if (checked) + Bugsnag.startSession(); + else + Bugsnag.stopSession(); } });