Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Removing glean analytics, updating sentry init #570

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 34 additions & 30 deletions app/src/main/kotlin/social/firefly/MainApplication.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package social.firefly

import android.app.Application
import android.os.Build
import coil.ImageLoader
import coil.ImageLoaderFactory
import coil.decode.GifDecoder
import coil.decode.ImageDecoderDecoder
import coil.decode.VideoFrameDecoder
import coil.memory.MemoryCache
import io.sentry.SentryLevel
import io.sentry.android.core.SentryAndroid
import io.sentry.android.timber.SentryTimberIntegration
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import org.koin.android.ext.android.get
import org.koin.android.ext.android.inject
import org.koin.android.ext.koin.androidContext
Expand All @@ -34,9 +36,8 @@ import social.firefly.feature.report.reportModule
import social.firefly.feature.settings.settingsModule
import social.firefly.feature.thread.threadModule
import social.firefly.feature.feed.feedModule
import social.firefly.feature.post.newPostModule
import social.firefly.feature.search.searchModule
import social.firefly.BuildConfig
import social.firefly.core.datastore.AppPreferencesDatastore
import social.firefly.core.push.pushModule
import social.firefly.core.ui.chooseAccount.chooseAccountModule
import social.firefly.feature.bookmarks.bookmarksModule
Expand All @@ -47,38 +48,45 @@ class MainApplication : Application(), ImageLoaderFactory {

private lateinit var authCredentialObserver: AuthCredentialObserver
private val analytics: AppAnalytics by inject()
private val appPreferencesDatastore: AppPreferencesDatastore by inject()

override fun onCreate() {
super.onCreate()
initializeAppVersion()
initializeTimberAndSentry()
initializeKoin()
initializeTimberAndSentry()
initializeAnalytics()
initializeAuthCredentialInterceptor()
}

private fun initializeTimberAndSentry() {
SentryAndroid.init(this) { options ->
options.apply {
setDiagnosticLevel(SentryLevel.ERROR)
dsn = BuildConfig.sentryDsn
isDebug = BuildConfig.DEBUG
environment = BuildConfig.BUILD_TYPE
isEnableUserInteractionTracing = true
isAttachScreenshot = false
isAttachViewHierarchy = true
sampleRate = 1.0
profilesSampleRate = 1.0
if (!BuildConfig.DEBUG) {
addIntegration(
SentryTimberIntegration(
minEventLevel = SentryLevel.ERROR,
minBreadcrumbLevel = SentryLevel.INFO
)
)
} else {
Timber.plant(Timber.DebugTree())
CoroutineScope(Dispatchers.Default).launch {
if (appPreferencesDatastore.allowAnalytics.first()) {
SentryAndroid.init(this@MainApplication) { options ->
options.apply {
setDiagnosticLevel(SentryLevel.ERROR)
dsn = BuildConfig.sentryDsn
isDebug = BuildConfig.DEBUG
environment = BuildConfig.BUILD_TYPE
isEnableUserInteractionTracing = true
isAttachScreenshot = false
isAttachViewHierarchy = false
sampleRate = 1.0
profilesSampleRate = 1.0
if (!BuildConfig.DEBUG) {
addIntegration(
SentryTimberIntegration(
minEventLevel = SentryLevel.ERROR,
minBreadcrumbLevel = SentryLevel.INFO
)
)
} else {
Timber.plant(Timber.DebugTree())
}
}
}
} else if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
}
}
Expand Down Expand Up @@ -112,11 +120,7 @@ class MainApplication : Application(), ImageLoaderFactory {
override fun newImageLoader(): ImageLoader =
ImageLoader.Builder(this)
.components {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
add(ImageDecoderDecoder.Factory())
} else {
add(GifDecoder.Factory())
}
add(ImageDecoderDecoder.Factory())
add(VideoFrameDecoder.Factory())
}
.memoryCache {
Expand Down
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.secrets) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.glean) apply false
alias(libs.plugins.jetbrains.python) apply false
alias(libs.plugins.detekt) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.android.test) apply false
Expand Down
7 changes: 0 additions & 7 deletions core/analytics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
plugins {
id("social.firefly.android.library")
id("social.firefly.android.library.secrets")
alias(libs.plugins.jetbrains.python)
alias(libs.plugins.glean)
}

android {
Expand All @@ -19,9 +17,6 @@ dependencies {
implementation(project(":core:datastore"))
implementation(project(":core:common"))

implementation(libs.glean)
implementation(libs.mozilla.components.service.glean)

implementation(libs.androidx.navigation.compose)
implementation(libs.koin.core)
implementation(libs.koin.androidx.compose)
Expand All @@ -30,6 +25,4 @@ dependencies {
implementation(libs.protobuf.kotlin.lite)

implementation(libs.jakewharton.timber)

testImplementation(libs.glean.forUnitTests)
}
Loading