diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a0bc37711..7daeea895 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -29,12 +29,12 @@ jobs: token: ${{ github.token }} submodules: recursive - # Setup Gradle and run Build + # Setup Gradle and Run tests - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build - # Run tests - - name: Run Unit tests + - name: Clean gradle cache + run: ./gradlew clean + + - name: Run unit tests run: ./gradlew testDebugUnitTest --stacktrace diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bb697e9e7..16a70c46c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -4,6 +4,7 @@ plugins { alias(libs.plugins.compose.compiler) alias(libs.plugins.kapt) alias(libs.plugins.hilt) + alias(libs.plugins.sentry) kotlin("plugin.serialization") version libs.versions.kotlin } @@ -63,6 +64,26 @@ kapt { correctErrorTypes = true } +sentry { + // Enables or disables the automatic upload of mapping files + // during a build. If you disable this, you'll need to manually + // upload the mapping files with sentry-cli when you do a release. + // Default is enabled. + autoUploadProguardMapping = true + + // Disables or enables the automatic configuration of Native Symbols + // for Sentry. This executes sentry-cli automatically so + // you don't need to do it manually. + // Default is disabled. + uploadNativeSymbols = true + + // Does or doesn't include the source code of native code for Sentry. + // This executes sentry-cli with the --include-sources param. automatically so + // you don't need to do it manually. + // Default is disabled. + includeNativeSources = true +} + dependencies { implementation(project(":FileTypes")) implementation(kotlin("reflect")) @@ -80,6 +101,7 @@ dependencies { implementation(libs.compose.material3.adaptative.navigation) implementation(libs.navigation.compose) implementation(libs.androidx.constraintlayout.compose) + implementation(libs.sentry.android) implementation(libs.androidx.adaptive) implementation(libs.androidx.adaptive.layout) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9173a6796..335fbb6e6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,10 +33,24 @@ android:theme="@style/Theme.AndroidSwissTransfer" android:usesCleartextTraffic="false" tools:targetApi="31"> + + + + + + + + diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt index ca2e2f661..e5f990138 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt @@ -19,7 +19,12 @@ package com.infomaniak.swisstransfer.ui import android.app.Application import com.infomaniak.multiplatform_swisstransfer.SwissTransferInjection +import com.infomaniak.swisstransfer.BuildConfig import dagger.hilt.android.HiltAndroidApp +import io.sentry.SentryEvent +import io.sentry.SentryOptions +import io.sentry.android.core.SentryAndroid +import io.sentry.android.core.SentryAndroidOptions import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import javax.inject.Inject @@ -36,5 +41,13 @@ class MainApplication : Application() { override fun onCreate() { super.onCreate() globalCoroutineScope.launch { swissTransferInjection.loadDefaultAccount() } + + SentryAndroid.init(this) { options: SentryAndroidOptions -> + // register the callback as an option + options.beforeSend = SentryOptions.BeforeSendCallback { event: SentryEvent?, _: Any? -> + //if the application is in debug mode discard the events + if (BuildConfig.DEBUG) null else event + } + } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9be8b5e2e..e94899bcf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,6 +16,8 @@ lifecycleRuntimeKtx = "2.8.6" navigation = "2.8.1" serialization = "1.7.1" swisstransfer = "0.1.1" +sentry = "4.12.0" +sentry-android = "7.15.0" [libraries] androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } @@ -40,11 +42,13 @@ hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", ve kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" } navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation" } swisstransfer-core = { module = "com.github.Infomaniak.multiplatform-SwissTransfer:STCore", version.ref = "swisstransfer" } +sentry-android = { module = "io.sentry:sentry-android", version.ref = "sentry-android" } # Tests androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } junit = { group = "junit", name = "junit", version.ref = "junit" } [plugins] +sentry = { id = "io.sentry.android.gradle", version.ref = "sentry" } android-application = { id = "com.android.application", version.ref = "agp" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }