Skip to content
This repository was archived by the owner on Dec 16, 2023. It is now read-only.

Commit 22f05c0

Browse files
committed
Add sentry logging
1 parent c094fb4 commit 22f05c0

5 files changed

Lines changed: 15 additions & 1 deletion

File tree

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33
apply plugin: 'kotlin-kapt'
44
apply plugin: 'kotlin-android-extensions'
5+
apply plugin: 'io.sentry.android.gradle'
56

67
// A properties file is located at projectFolder/keys.properties
78
def keysPropertiesFile = rootProject.file("keys.properties")
@@ -21,6 +22,7 @@ android {
2122
testInstrumentationRunner "com.marknkamau.justjava.testUtils.TestApplicationRunner"
2223

2324
buildConfigField("String", "googleClientId", '"565628649475-4vp8dm790n2kuuhqpu3o662e9odht703.apps.googleusercontent.com"')
25+
buildConfigField("String", "sentryDsn", keys['SENTRY_DSN'])
2426
resValue "string", "google_maps_key", keys['GOOGLE_MAPS_API_KEY'] // Generates @strings/google_maps_key
2527
}
2628
signingConfigs {
@@ -77,6 +79,7 @@ dependencies {
7779
implementation Dependencies.playServicesAuth
7880
implementation Dependencies.playServicesMaps
7981
implementation Dependencies.places
82+
implementation Dependencies.sentry
8083

8184
// Test libraries
8285
testImplementation Dependencies.junit

app/src/main/java/com/marknkamau/justjava/JustJavaApp.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import com.marknjunge.core.di.repositoriesModule
66
import com.marknkamau.justjava.di.appModule
77
import com.marknkamau.justjava.di.dbModule
88
import com.marknkamau.justjava.di.viewModelModule
9+
import io.sentry.Sentry
10+
import io.sentry.android.AndroidSentryClientFactory
911
import org.koin.android.ext.koin.androidContext
1012
import org.koin.core.context.startKoin
1113
import timber.log.Timber
@@ -22,6 +24,8 @@ open class JustJavaApp : Application() {
2224
return "Timber ${super.createStackElementTag(element)}.${element.methodName}"
2325
}
2426
})
27+
} else {
28+
Sentry.init(BuildConfig.sentryDsn, AndroidSentryClientFactory(this))
2529
}
2630

2731
startKoin {

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ buildscript {
1414
classpath Dependencies.googleServices
1515
classpath Dependencies.kotlinGradlePlugin
1616
classpath Dependencies.serializationPlugin
17+
classpath Dependencies.sentryGradlePlugin
1718

1819
// NOTE: Do not place your application dependencies here; they belong
1920
// in the individual module build.gradle files

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ object Versions {
3535
const val serialization = "0.13.0"
3636
const val retrofitSerialization = "0.4.0"
3737
const val places = "2.0.0"
38+
const val sentry = "1.7.27"
39+
const val sentryGradlePlugin = "1.7.27"
3840
}
3941

4042
object Dependencies {
@@ -82,6 +84,9 @@ object Dependencies {
8284
val koinViewModel = "org.koin:koin-androidx-viewmodel:${Versions.koin}"
8385
val shimmer = "com.facebook.shimmer:shimmer:${Versions.shimmer}"
8486

87+
val sentryGradlePlugin = "io.sentry:sentry-android-gradle-plugin:${Versions.sentryGradlePlugin}"
88+
val sentry = "io.sentry:sentry-android:${Versions.sentry}"
89+
8590
val mockk = "io.mockk:mockk:${Versions.mockk}"
8691
val mockAndroid = "io.mockk:mockk-android:${Versions.mockk}"
8792

keys.properties.sample

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
GOOGLE_MAPS_API_KEY="your_key"
1+
GOOGLE_MAPS_API_KEY="your_key"
2+
SENTRY_DSN="your_dsn"

0 commit comments

Comments
 (0)