Skip to content

Commit

Permalink
Initialize Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
tevincent committed Oct 16, 2024
1 parent 7ae82f7 commit 384c50b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 7 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ jobs:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
access_token: ${ { github.token } }

- name: Checkout the code
uses: actions/[email protected]
with:
token: ${{ github.token }}
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
22 changes: 22 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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(kotlin("reflect"))

Expand All @@ -79,6 +100,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)
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,24 @@
android:theme="@style/Theme.AndroidSwissTransfer"
android:usesCleartextTraffic="false"
tools:targetApi="31">

<meta-data
android:name="io.sentry.anr.enable"
android:value="true" />

<meta-data
android:name="io.sentry.auto-init"
android:value="false" />

<meta-data
android:name="io.sentry.dsn"
android:value="https://[email protected]/18" />

<activity
android:name=".ui.MainActivity"
android:exported="true"
android:theme="@style/Theme.AndroidSwissTransfer">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
}
}
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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" }
Expand All @@ -38,11 +40,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" }
Expand Down

0 comments on commit 384c50b

Please sign in to comment.