aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-07-27 22:02:33 -0700
committerAllan Wang <me@allanwang.ca>2019-07-27 22:02:33 -0700
commit65ad23e07634f2a1605dcc7768488d933a0aa6fb (patch)
tree0215371309f8bd97f86ce74512b4d41d74cfb7e2
parent25ad3000743b108f7018bae8fb65b4988d953c3c (diff)
downloadfrost-65ad23e07634f2a1605dcc7768488d933a0aa6fb.tar.gz
frost-65ad23e07634f2a1605dcc7768488d933a0aa6fb.tar.bz2
frost-65ad23e07634f2a1605dcc7768488d933a0aa6fb.zip
Toggle auto capture sessions
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt2
3 files changed, 8 insertions, 1 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index 65f7f495..a465eb7b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -160,11 +160,11 @@ class FrostApp : Application() {
val version = BuildUtils.match(BuildConfig.VERSION_NAME)
?: return L.d { "Bugsnag disabled for ${BuildConfig.VERSION_NAME}" }
val config = Configuration("83cf680ed01a6fda10fe497d1c0962bb").apply {
- enableExceptionHandler = true
appVersion = version.versionName
releaseStage = BuildUtils.getStage(BuildConfig.BUILD_TYPE)
notifyReleaseStages = BuildUtils.getAllStages()
autoCaptureSessions = Prefs.analytics
+ enableExceptionHandler = Prefs.analytics
}
Bugsnag.init(this, config)
L.bugsnagInit = true
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
index e5dd30e3..dd8cf594 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
@@ -61,6 +61,11 @@ object L : KauLogger("Frost", {
var bugsnagInit = false
override fun logImpl(priority: Int, message: String?, t: Throwable?) {
+ /*
+ * Debug flag is constant and should help with optimization
+ * bugsnagInit is changed per application and helps prevent crashes (if calling pre init)
+ * analytics is changed by the user, and may be toggled throughout the app
+ */
if (BuildConfig.DEBUG || !bugsnagInit || !Prefs.analytics) {
super.logImpl(priority, message, t)
} else {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
index c11583d1..0885109a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -160,8 +160,10 @@ object Prefs : KPref() {
var analytics: Boolean by kpref("analytics", false) {
if (!BuildConfig.DEBUG) {
if (it) {
+ Bugsnag.setAutoCaptureSessions(true)
Bugsnag.enableExceptionHandler()
} else {
+ Bugsnag.setAutoCaptureSessions(false)
Bugsnag.disableExceptionHandler()
}
}