Skip to content

Commit 3df3f69

Browse files
committed
Add Sentry
1 parent 8b7d82c commit 3df3f69

8 files changed

Lines changed: 82 additions & 21 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
local.properties
1212
/keys
1313
/release/yaba-release.jks
14+
sentry.properties

CHANGELOG.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [v1.0.1-alpha] - 2021-07-18
8+
#### Initial release
89
### Added
9-
- Settings screen
10-
- Logout button
11-
- Bottom app bar
12-
13-
## [1.0.0] - 2021-06-18
14-
### Added
15-
- Login flow
16-
- Registration flow
10+
- Sentry
11+
- function to generate android version code
1712

androidApp/build.gradle.kts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ plugins {
77
id("kotlin-parcelize")
88
kotlin("plugin.serialization")
99
id("com.google.gms.google-services")
10+
id("io.sentry.android.gradle") version "2.0.1"
1011
}
1112

1213
val hasReleaseKey: Boolean = project.rootProject.file("release/yaba-release.jks").exists()
@@ -51,17 +52,18 @@ dependencies {
5152
implementation(Lib.Firebase.messagingDirectBoot)
5253
implementation(Lib.Jetpack.work)
5354
implementation(Lib.Jetpack.workMultiProcess)
55+
implementation("io.sentry:sentry-android:5.0.1")
5456
}
5557

5658
android {
57-
compileSdk = 30
59+
compileSdk = AndroidConfig.compileSdk
5860
buildToolsVersion = "31.0.0"
5961
defaultConfig {
6062
applicationId = "tech.alexib.yaba"
61-
minSdk = 29
62-
targetSdk = 30
63-
versionCode = 1
64-
versionName = "1.0"
63+
minSdk = AndroidConfig.minSdk
64+
targetSdk = AndroidConfig.targetSdk
65+
versionCode = AndroidConfig.versionCode
66+
versionName = AndroidConfig.versionName
6567
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
6668
vectorDrawables {
6769
useSupportLibrary = true
@@ -175,3 +177,22 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
175177
jvmTarget = "11"
176178
}
177179
}
180+
181+
sentry {
182+
// Enables or disables the automatic upload of mapping files
183+
// during a build. If you disable this, you'll need to manually
184+
// upload the mapping files with sentry-cli when you do a release.
185+
autoUpload.set(true)
186+
187+
// Disables or enables the automatic configuration of Native Symbols
188+
// for Sentry. This executes sentry-cli automatically so
189+
// you don't need to do it manually.
190+
// Default is disabled.
191+
uploadNativeSymbols.set(true)
192+
193+
// Does or doesn't include the source code of native code for Sentry.
194+
// This executes sentry-cli with the --include-sources param. automatically so
195+
// you don't need to do it manually.
196+
// Default is disabled.
197+
includeNativeSources.set(true)
198+
}

androidApp/src/main/AndroidManifest.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
android:value="false" />
2626
<meta-data
2727
android:name="base_url"
28-
android:value="${serverUrl}"/>
28+
android:value="${serverUrl}" />
29+
<meta-data
30+
android:name="io.sentry.dsn"
31+
android:value="https://c88ec458703c475ea3ed62e68bb93ee8@o921828.ingest.sentry.io/5869695" />
2932
<service
3033
android:name=".fcm.FCMService"
3134
android:directBootAware="true"
@@ -48,7 +51,6 @@
4851
android:name="androidx.startup.InitializationProvider"
4952
android:authorities="${applicationId}.androidx-startup"
5053
android:exported="false"
51-
tools:node="merge">
52-
</provider>
54+
tools:node="merge"></provider>
5355
</application>
5456
</manifest>

androidApp/src/main/kotlin/tech/alexib/yaba/android/MainActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import androidx.compose.runtime.staticCompositionLocalOf
2727
import androidx.core.view.WindowCompat
2828
import co.touchlab.kermit.Kermit
2929
import com.google.accompanist.insets.ProvideWindowInsets
30+
import io.sentry.Sentry
3031
import org.koin.core.component.KoinComponent
3132
import org.koin.core.component.inject
3233
import org.koin.core.parameter.parametersOf

androidApp/src/main/kotlin/tech/alexib/yaba/android/MainApp.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ import android.content.Context
2020
import android.content.pm.ApplicationInfo
2121
import android.content.pm.PackageManager
2222
import android.util.Log
23+
import io.sentry.SentryLevel
24+
import io.sentry.android.core.SentryAndroid
2325
import org.koin.androidx.viewmodel.dsl.viewModel
2426
import org.koin.core.qualifier.named
2527
import org.koin.dsl.module
2628
import tech.alexib.yaba.AppInfo
2729
import tech.alexib.yaba.android.fcm.PushTokenManagerImpl
28-
import tech.alexib.yaba.android.ui.accounts.detail.AccountDetailScreenViewModel
2930
import tech.alexib.yaba.android.ui.accounts.AccountsScreenViewModel
31+
import tech.alexib.yaba.android.ui.accounts.detail.AccountDetailScreenViewModel
3032
import tech.alexib.yaba.android.ui.auth.biometric.BiometricSetupScreenViewModel
3133
import tech.alexib.yaba.android.ui.auth.login.LoginScreenViewModel
3234
import tech.alexib.yaba.android.ui.auth.register.RegisterScreenViewModel
@@ -89,6 +91,13 @@ class MainApp : Application() {
8991
e.printStackTrace()
9092
}
9193
initKoin(appModule)
94+
SentryAndroid.init(this) { options ->
95+
options.setBeforeSend { event, _ ->
96+
if (SentryLevel.DEBUG == event.level) {
97+
null
98+
} else event
99+
}
100+
}
92101
}
93102
}
94103

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2021 Alexi Bre
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
@file:SuppressWarnings()
17+
18+
object AndroidConfig {
19+
private const val versionMajor = 1
20+
private const val versionMinor = 0
21+
private const val versionPatch = 1
22+
const val minSdk = 29
23+
const val targetSdk = 30
24+
val versionCode = generateVersionCode()
25+
const val versionName = "$versionMajor.$versionMinor.$versionPatch"
26+
const val compileSdk = 30
27+
const val buildToolsVersion = "31.0.0"
28+
29+
private fun generateVersionCode(): Int {
30+
return minSdk * 10000000 + versionMajor * 10000 + versionMinor * 100 + versionPatch
31+
}
32+
}

shared/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ kotlin {
129129
}
130130

131131
android {
132-
compileSdk = 30
132+
compileSdk = AndroidConfig.compileSdk
133133

134134
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
135135
defaultConfig {
136-
minSdk = 29
137-
targetSdk = 30
136+
minSdk = AndroidConfig.minSdk
137+
targetSdk = AndroidConfig.targetSdk
138138
}
139139
lint {
140140
lintConfig = rootProject.file(".lint/config.xml")

0 commit comments

Comments
 (0)