mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1165 App | Tech | Remove Crashlytics dependency + Setup Timber with Sentry (#3178)
This commit is contained in:
parent
492b657c45
commit
9ef07124ba
8 changed files with 35 additions and 74 deletions
|
@ -198,12 +198,9 @@ dependencies {
|
|||
implementation libs.preference
|
||||
implementation libs.activityCompose
|
||||
implementation libs.composeReorderable
|
||||
debugImplementation libs.composeTooling
|
||||
|
||||
implementation libs.room
|
||||
|
||||
implementation libs.crashlytics
|
||||
|
||||
implementation libs.exoPlayerCore
|
||||
implementation libs.exoPlayerUi
|
||||
|
||||
|
@ -217,6 +214,8 @@ dependencies {
|
|||
implementation libs.androidxSecurityCrypto
|
||||
implementation libs.middleware
|
||||
|
||||
implementation libs.wireRuntime
|
||||
|
||||
//Unit/Integration tests dependencies
|
||||
testImplementation libs.androidXTestCore
|
||||
testImplementation libs.junit
|
||||
|
@ -243,8 +242,7 @@ dependencies {
|
|||
}
|
||||
|
||||
debugImplementation libs.fragmentTesting
|
||||
|
||||
implementation libs.wireRuntime
|
||||
debugImplementation libs.composeTooling
|
||||
}
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
|
@ -5,7 +5,6 @@ import com.amplitude.api.Amplitude
|
|||
import com.anytypeio.anytype.BuildConfig
|
||||
import com.anytypeio.anytype.SentryCrashReporter
|
||||
import com.anytypeio.anytype.analytics.tracker.AmplitudeTracker
|
||||
import com.anytypeio.anytype.core_utils.tools.CrashlyticsTree
|
||||
import com.anytypeio.anytype.di.common.ComponentDependenciesProvider
|
||||
import com.anytypeio.anytype.di.common.ComponentManager
|
||||
import com.anytypeio.anytype.di.common.HasComponentDependencies
|
||||
|
@ -29,7 +28,7 @@ class AndroidApplication : Application(), HasComponentDependencies {
|
|||
lateinit var discoveryManager: MDNSProvider
|
||||
|
||||
@Inject
|
||||
lateinit var crashReporter: SentryCrashReporter
|
||||
lateinit var sentryCrashReporter: SentryCrashReporter
|
||||
|
||||
@Inject
|
||||
override lateinit var dependencies: ComponentDependenciesProvider
|
||||
|
@ -51,14 +50,18 @@ class AndroidApplication : Application(), HasComponentDependencies {
|
|||
main.inject(this)
|
||||
setupAnalytics()
|
||||
setupTimber()
|
||||
setupSentry()
|
||||
setupLocalNetworkAddressHandler()
|
||||
}
|
||||
|
||||
private fun setupTimber() {
|
||||
if (BuildConfig.DEBUG)
|
||||
Timber.plant(Timber.DebugTree())
|
||||
else
|
||||
Timber.plant(CrashlyticsTree())
|
||||
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
|
||||
}
|
||||
|
||||
private fun setupSentry() {
|
||||
sentryCrashReporter.init(
|
||||
withTimber = !BuildConfig.DEBUG
|
||||
)
|
||||
}
|
||||
|
||||
private fun setupAnalytics() {
|
||||
|
|
|
@ -26,7 +26,6 @@ dependencies {
|
|||
implementation libs.gson
|
||||
|
||||
implementation libs.timber
|
||||
implementation libs.crashlytics
|
||||
|
||||
implementation libs.constraintLayout
|
||||
implementation libs.recyclerView
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package com.anytypeio.anytype.core_utils.tools
|
||||
|
||||
import android.util.Log
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import timber.log.Timber
|
||||
|
||||
class CrashlyticsTree : Timber.Tree() {
|
||||
|
||||
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||
|
||||
if (priority == Log.VERBOSE || priority == Log.DEBUG || priority == Log.INFO) {
|
||||
return
|
||||
}
|
||||
|
||||
val crashlytics = FirebaseCrashlytics.getInstance()
|
||||
|
||||
crashlytics.setCustomKey(CRASHLYTICS_KEY_PRIORITY, priority)
|
||||
crashlytics.setCustomKey(CRASHLYTICS_KEY_MESSAGE, message)
|
||||
if (tag != null) crashlytics.setCustomKey(CRASHLYTICS_KEY_TAG, tag)
|
||||
|
||||
if (t == null) {
|
||||
crashlytics.recordException(Exception(message))
|
||||
} else {
|
||||
crashlytics.recordException(t)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val CRASHLYTICS_KEY_PRIORITY = "priority"
|
||||
private const val CRASHLYTICS_KEY_TAG = "tag"
|
||||
private const val CRASHLYTICS_KEY_MESSAGE = "message"
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
plugins {
|
||||
id "com.android.library"
|
||||
id "kotlin-android"
|
||||
id "io.sentry.android.gradle" version "3.4.2"
|
||||
id "io.sentry.android.gradle" version "3.6.0"
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -21,5 +21,6 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation libs.sentry
|
||||
implementation libs.sentryTimber
|
||||
implementation project(path: ':core-utils')
|
||||
}
|
|
@ -2,19 +2,31 @@ package com.anytypeio.anytype
|
|||
|
||||
import android.content.Context
|
||||
import com.anytypeio.anytype.core_utils.tools.AppInfo
|
||||
import io.sentry.SentryLevel
|
||||
import io.sentry.android.core.SentryAndroid
|
||||
import io.sentry.android.core.SentryAndroidOptions
|
||||
import io.sentry.android.timber.SentryTimberIntegration
|
||||
|
||||
class SentryCrashReporter(
|
||||
context: Context,
|
||||
appInfo: AppInfo
|
||||
private val context: Context,
|
||||
private val appInfo: AppInfo,
|
||||
) {
|
||||
|
||||
init {
|
||||
fun init(
|
||||
withTimber: Boolean
|
||||
) {
|
||||
SentryAndroid.init(context) { options: SentryAndroidOptions ->
|
||||
options.release = appInfo.versionName
|
||||
options.environment = appInfo.sentryEnvironment.value
|
||||
with(options) {
|
||||
release = appInfo.versionName
|
||||
environment = appInfo.sentryEnvironment.value
|
||||
if (withTimber) {
|
||||
addIntegration(
|
||||
SentryTimberIntegration(
|
||||
minEventLevel = SentryLevel.ERROR,
|
||||
minBreadcrumbLevel = SentryLevel.INFO
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -161,6 +161,7 @@ roomTesting = { module = "androidx.room:room-testing", version.ref = "roomVersio
|
|||
amplitude = { module = "com.amplitude:android-sdk", version.ref = "amplitudeVersion" }
|
||||
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttpVersion" }
|
||||
sentry = { module = "io.sentry:sentry-android", version.ref = "sentryVersion" }
|
||||
sentryTimber = { module = "io.sentry:sentry-android-timber", version.ref = "sentryVersion" }
|
||||
navigationCompose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationComposeVersion" }
|
||||
|
||||
[bundles]
|
||||
|
|
|
@ -1,25 +1,5 @@
|
|||
package com.anytypeio.anytype.sample
|
||||
|
||||
import android.app.Application
|
||||
import com.anytypeio.anytype.core_utils.tools.CrashlyticsTree
|
||||
import timber.log.Timber
|
||||
|
||||
class SampleApp : Application() {
|
||||
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
setupTimber()
|
||||
}
|
||||
|
||||
private fun setupTimber() {
|
||||
if (BuildConfig.DEBUG)
|
||||
Timber.plant(Timber.DebugTree())
|
||||
else
|
||||
Timber.plant(CrashlyticsTree())
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val BASE_URI = "content://com.agileburo.anytype"
|
||||
}
|
||||
}
|
||||
class SampleApp : Application()
|
Loading…
Add table
Add a link
Reference in a new issue