1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 20:12:39 +01:00

Disable auto session capture until analytics is disabled

This commit is contained in:
Allan Wang 2019-07-27 21:50:56 -07:00
parent d746e687b2
commit 1796aa0ee6
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56
4 changed files with 41 additions and 20 deletions

View File

@ -25,6 +25,7 @@ import android.widget.ImageView
import ca.allanwang.kau.logging.KL import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.utils.buildIsLollipopAndUp import ca.allanwang.kau.utils.buildIsLollipopAndUp
import com.bugsnag.android.Bugsnag import com.bugsnag.android.Bugsnag
import com.bugsnag.android.Configuration
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.signature.ApplicationVersionSignature import com.bumptech.glide.signature.ApplicationVersionSignature
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
@ -92,8 +93,12 @@ class FrostApp : Application() {
Prefs.verboseLogging = false Prefs.verboseLogging = false
L.i { "Begin Frost for Facebook" } L.i { "Begin Frost for Facebook" }
FrostPglAdBlock.init(this) FrostPglAdBlock.init(this)
if (Prefs.installDate == -1L) Prefs.installDate = System.currentTimeMillis() if (Prefs.installDate == -1L) {
if (Prefs.identifier == -1) Prefs.identifier = Random().nextInt(Int.MAX_VALUE) Prefs.installDate = System.currentTimeMillis()
}
if (Prefs.identifier == -1) {
Prefs.identifier = Random().nextInt(Int.MAX_VALUE)
}
Prefs.lastLaunch = System.currentTimeMillis() Prefs.lastLaunch = System.currentTimeMillis()
super.onCreate() super.onCreate()
@ -137,25 +142,32 @@ class FrostApp : Application() {
} }
}) })
startKoin { startKoin {
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG) {
androidLogger() androidLogger()
}
androidContext(this@FrostApp) androidContext(this@FrostApp)
modules(FrostDatabase.module(this@FrostApp)) modules(FrostDatabase.module(this@FrostApp))
} }
} }
private fun initBugsnag() { private fun initBugsnag() {
if (BuildConfig.DEBUG) return if (BuildConfig.DEBUG) {
Bugsnag.init(this) return
Bugsnag.disableExceptionHandler() }
if (!BuildConfig.APPLICATION_ID.startsWith("com.pitchedapps.frost")) return if (!BuildConfig.APPLICATION_ID.startsWith("com.pitchedapps.frost")) {
return
}
val version = BuildUtils.match(BuildConfig.VERSION_NAME) val version = BuildUtils.match(BuildConfig.VERSION_NAME)
?: return L.d { "Bugsnag disabled for ${BuildConfig.VERSION_NAME}" } ?: return L.d { "Bugsnag disabled for ${BuildConfig.VERSION_NAME}" }
Bugsnag.enableExceptionHandler() val config = Configuration("83cf680ed01a6fda10fe497d1c0962bb").apply {
Bugsnag.setNotifyReleaseStages(*BuildUtils.getAllStages()) enableExceptionHandler = true
Bugsnag.setAppVersion(version.versionName) appVersion = version.versionName
Bugsnag.setReleaseStage(BuildUtils.getStage(BuildConfig.BUILD_TYPE)) releaseStage = BuildUtils.getStage(BuildConfig.BUILD_TYPE)
Bugsnag.setAutoCaptureSessions(true) notifyReleaseStages = BuildUtils.getAllStages()
autoCaptureSessions = Prefs.analytics
}
Bugsnag.init(this, config)
L.bugsnagInit = true
Bugsnag.setUserId(Prefs.frostId) Bugsnag.setUserId(Prefs.frostId)
Bugsnag.addToTab("Build", "Application", BuildConfig.APPLICATION_ID) Bugsnag.addToTab("Build", "Application", BuildConfig.APPLICATION_ID)
Bugsnag.addToTab("Build", "Version", BuildConfig.VERSION_NAME) Bugsnag.addToTab("Build", "Version", BuildConfig.VERSION_NAME)

View File

@ -41,28 +41,35 @@ object L : KauLogger("Frost", {
} }
inline fun _i(message: () -> Any?) { inline fun _i(message: () -> Any?) {
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG) {
i(message) i(message)
}
} }
inline fun _d(message: () -> Any?) { inline fun _d(message: () -> Any?) {
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG) {
d(message) d(message)
}
} }
inline fun _e(e: Throwable?, message: () -> Any?) { inline fun _e(e: Throwable?, message: () -> Any?) {
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG) {
e(e, message) e(e, message)
}
} }
var bugsnagInit = false
override fun logImpl(priority: Int, message: String?, t: Throwable?) { override fun logImpl(priority: Int, message: String?, t: Throwable?) {
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG || !bugsnagInit || Prefs.analytics) {
super.logImpl(priority, message, t) super.logImpl(priority, message, t)
else { } else {
if (message != null) if (message != null) {
Bugsnag.leaveBreadcrumb(message) Bugsnag.leaveBreadcrumb(message)
if (t != null) }
if (t != null) {
Bugsnag.notify(t) Bugsnag.notify(t)
}
} }
} }
} }

View File

@ -1,4 +1,5 @@
v2.3.2 v2.3.2
* Disable auto feed refresh by default and add setting to re-enable it * Disable auto feed refresh by default and add setting to re-enable it
* Update theme * Update theme
* Disable bugsnag completely when opting out of analytics

View File

@ -3,6 +3,7 @@
## v2.3.2 ## v2.3.2
* Disable auto feed refresh by default and add setting to re-enable it * Disable auto feed refresh by default and add setting to re-enable it
* Update theme * Update theme
* Disable bugsnag completely when opting out of analytics
## v2.3.1 ## v2.3.1
* Hide all story panels if enabled * Hide all story panels if enabled