Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize Sentry #94

Merged
merged 2 commits into from
Oct 16, 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
10 changes: 5 additions & 5 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 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,23 @@ 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"))
Expand All @@ -80,6 +98,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 @@ -33,10 +33,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 @@ -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" }
Expand All @@ -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" }
Expand Down
Loading