enhance: read Sentry DSN from local.properties to support private configuration
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.androidApplication)
|
||||
@@ -50,6 +51,10 @@ android {
|
||||
.toInt()
|
||||
versionCode = 1
|
||||
versionName = "1.0.0-alpha01"
|
||||
|
||||
// Crash-reporting DSN, kept out of the public repo: read from local.properties
|
||||
// (glitchtip.dsn=...). Empty when absent, which disables the Sentry SDK.
|
||||
manifestPlaceholders["glitchtipDsn"] = localProperty("glitchtip.dsn") ?: ""
|
||||
}
|
||||
packaging {
|
||||
resources {
|
||||
@@ -67,3 +72,12 @@ android {
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads a key from the root local.properties, or null when the file or key is absent. */
|
||||
fun localProperty(key: String): String? {
|
||||
val file = rootProject.file("local.properties")
|
||||
if (!file.exists()) return null
|
||||
return Properties()
|
||||
.apply { file.inputStream().use { load(it) } }
|
||||
.getProperty(key)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<meta-data android:name="io.sentry.dsn" android:value="https://c7d665816e7f4823aa48c083b797e730@eu.glitchtip.com/255" />
|
||||
<!-- Injected from local.properties (glitchtip.dsn); an empty DSN disables the SDK. -->
|
||||
<meta-data android:name="io.sentry.dsn" android:value="${glitchtipDsn}" />
|
||||
<meta-data android:name="io.sentry.traces.sample-rate" android:value="0.01" />
|
||||
|
||||
</application>
|
||||
|
||||
Reference in New Issue
Block a user