mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-08 12:02:33 +01:00
Update when bugsnag gets added (#1128)
This commit is contained in:
parent
e113308923
commit
49d829355b
@ -10,7 +10,7 @@ android {
|
||||
|
||||
androidGitVersion {
|
||||
codeFormat = 'MMNNPPXX'
|
||||
format = '%tag%%.count%%-commit%'
|
||||
format = '%tag%%-count%%-commit%'
|
||||
prefix 'v'
|
||||
}
|
||||
|
||||
|
@ -64,32 +64,8 @@ class FrostApp : Application() {
|
||||
Prefs.initialize(this, "${BuildConfig.APPLICATION_ID}.prefs")
|
||||
// if (LeakCanary.isInAnalyzerProcess(this)) return
|
||||
// refWatcher = LeakCanary.install(this)
|
||||
if (!BuildConfig.DEBUG) {
|
||||
Bugsnag.init(this)
|
||||
val releaseStage = setOf(FLAVOUR_PRODUCTION,
|
||||
FLAVOUR_TEST,
|
||||
FLAVOUR_GITHUB,
|
||||
FLAVOUR_RELEASE)
|
||||
Bugsnag.setNotifyReleaseStages(*releaseStage.toTypedArray(), FLAVOUR_UNNAMED)
|
||||
val versionSegments = BuildConfig.VERSION_NAME.split("_")
|
||||
if (versionSegments.size > 1) {
|
||||
Bugsnag.setAppVersion(versionSegments.first())
|
||||
Bugsnag.setReleaseStage(if (versionSegments.last() in releaseStage) versionSegments.last()
|
||||
else FLAVOUR_UNNAMED)
|
||||
Bugsnag.setUserName(BuildConfig.VERSION_NAME)
|
||||
}
|
||||
|
||||
Bugsnag.setAutoCaptureSessions(true)
|
||||
Bugsnag.setUserId(Prefs.frostId)
|
||||
Bugsnag.beforeNotify { error ->
|
||||
when {
|
||||
error.exception is UndeliverableException -> false
|
||||
error.exception.stackTrace.any { it.className.contains("XposedBridge") } -> false
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
}
|
||||
KL.shouldLog = { BuildConfig.DEBUG }
|
||||
initBugsnag()
|
||||
Prefs.verboseLogging = false
|
||||
L.i { "Begin Frost for Facebook" }
|
||||
try {
|
||||
@ -152,5 +128,24 @@ class FrostApp : Application() {
|
||||
|
||||
}
|
||||
|
||||
private fun initBugsnag() {
|
||||
if (BuildConfig.DEBUG) return
|
||||
if (!BuildConfig.APPLICATION_ID.startsWith("com.pitchedapps.frost")) return
|
||||
val version = BuildUtils.match(BuildConfig.VERSION_NAME)
|
||||
?: return L.d { "Bugsnag disabled for ${BuildConfig.VERSION_NAME}" }
|
||||
Bugsnag.init(this)
|
||||
Bugsnag.setNotifyReleaseStages(*BuildUtils.getAllStages())
|
||||
Bugsnag.setAppVersion(version.versionName)
|
||||
Bugsnag.setReleaseStage(BuildUtils.getStage(BuildConfig.BUILD_TYPE))
|
||||
Bugsnag.setAutoCaptureSessions(true)
|
||||
Bugsnag.setUserId(Prefs.frostId)
|
||||
Bugsnag.beforeNotify { error ->
|
||||
when {
|
||||
error.exception is UndeliverableException -> false
|
||||
error.exception.stackTrace.any { it.className.contains("XposedBridge") } -> false
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
object BuildUtils {
|
||||
|
||||
data class Data(val versionName: String, val tail: String)
|
||||
|
||||
// Builds
|
||||
const val BUILD_PRODUCTION = "production"
|
||||
const val BUILD_TEST = "releaseTest"
|
||||
const val BUILD_GITHUB = "github"
|
||||
const val BUILD_RELEASE = "release"
|
||||
const val BUILD_UNNAMED = "unnamed"
|
||||
|
||||
fun match(version: String): Data? {
|
||||
val regex = Regex("([0-9]+\\.[0-9]+\\.[0-9]+)-?([0-9]*-?[0-9a-zA-Z]*)")
|
||||
val result = regex.matchEntire(version)?.groupValues ?: return null
|
||||
return Data(result[1], result[2])
|
||||
}
|
||||
|
||||
fun getAllStages(): Array<String> =
|
||||
arrayOf(BUILD_PRODUCTION, BUILD_TEST, BUILD_GITHUB, BUILD_RELEASE, BUILD_UNNAMED)
|
||||
|
||||
fun getStage(build: String): String = build.takeIf { it in getAllStages() } ?: BUILD_UNNAMED
|
||||
|
||||
}
|
@ -15,11 +15,4 @@ const val REQUEST_TEXT_ZOOM = 1 shl 14
|
||||
const val REQUEST_NAV = 1 shl 15
|
||||
const val REQUEST_SEARCH = 1 shl 16
|
||||
|
||||
const val MAIN_TIMEOUT_DURATION = 30 * 60 * 1000 // 30 min
|
||||
|
||||
// Flavours
|
||||
const val FLAVOUR_PRODUCTION = "production"
|
||||
const val FLAVOUR_TEST = "releaseTest"
|
||||
const val FLAVOUR_GITHUB = "github"
|
||||
const val FLAVOUR_RELEASE = "release"
|
||||
const val FLAVOUR_UNNAMED = "unnamed"
|
||||
const val MAIN_TIMEOUT_DURATION = 30 * 60 * 1000 // 30 min
|
@ -0,0 +1,22 @@
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import com.pitchedapps.frost.BuildConfig
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
|
||||
class BuildUtilsTest {
|
||||
|
||||
@Test
|
||||
fun matchingVersions() {
|
||||
assertNull(BuildUtils.match("unknown"))
|
||||
assertEquals(BuildUtils.Data("1.0.0", ""), BuildUtils.match("1.0.0"))
|
||||
assertEquals(BuildUtils.Data("1.0.1", "22-asdf"), BuildUtils.match("1.0.1-22-asdf"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun androidTests() {
|
||||
assertNotNull(BuildUtils.match(BuildConfig.VERSION_NAME))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user