feat: set up Sentry

This commit is contained in:
Harsh Shandilya 2023-03-03 01:43:03 +05:30
parent 62dd421cf4
commit 905c27fe84
No known key found for this signature in database
10 changed files with 130 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Copyright © 2022-2023 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
@ -59,6 +59,10 @@ gradlePlugin {
id = "dev.msfjarvis.claw.rename-artifacts"
implementationClass = "dev.msfjarvis.claw.gradle.RenameArtifactsPlugin"
}
register("sentry") {
id = "dev.msfjarvis.claw.sentry"
implementationClass = "dev.msfjarvis.claw.gradle.SentryPlugin"
}
register("spotless") {
id = "dev.msfjarvis.claw.spotless"
implementationClass = "dev.msfjarvis.claw.gradle.SpotlessPlugin"
@ -80,6 +84,7 @@ dependencies {
implementation(libs.build.detekt)
implementation(libs.build.kotlin.gradle)
implementation(libs.build.semver)
implementation(libs.build.sentry)
implementation(libs.build.spotless)
implementation(libs.build.vcu)
implementation(libs.build.versions)

View file

@ -0,0 +1,71 @@
/*
* Copyright © 2023 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.gradle
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import io.sentry.android.gradle.extensions.InstrumentationFeature
import io.sentry.android.gradle.extensions.SentryPluginExtension
import java.util.EnumSet
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.getByType
@Suppress("Unused")
class SentryPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.withPlugin("com.android.application") {
val catalog = project.extensions.getByType<VersionCatalogsExtension>()
val libs = catalog.named("libs")
project.extensions.configure<ApplicationAndroidComponentsExtension> {
onVariants(selector()) { variant ->
val sentryDsn = project.providers.environmentVariable(SENTRY_DSN_PROPERTY)
if (sentryDsn.isPresent) {
variant.manifestPlaceholders.put("sentryDsn", sentryDsn.get())
}
}
}
project.plugins.apply(io.sentry.android.gradle.SentryPlugin::class)
project.extensions.configure<SentryPluginExtension> {
val enableMappings =
project.providers.gradleProperty(SENTRY_UPLOAD_MAPPINGS_PROPERTY).isPresent
includeProguardMapping.set(enableMappings)
autoUploadProguardMapping.set(enableMappings)
uploadNativeSymbols.set(false)
autoUploadNativeSymbols.set(false)
includeNativeSources.set(false)
ignoredVariants.set(emptySet())
ignoredBuildTypes.set(setOf("debug"))
ignoredFlavors.set(emptySet())
tracingInstrumentation {
enabled.set(true)
debug.set(false)
forceInstrumentDependencies.set(false)
features.set(EnumSet.allOf(InstrumentationFeature::class.java))
}
experimentalGuardsquareSupport.set(false)
autoInstallation {
enabled.set(true)
sentryVersion.set(libs.findVersion("sentry-sdk").get().requiredVersion)
}
includeDependenciesReport.set(true)
}
with(project.dependencies) {
addProvider("implementation", platform(libs.findLibrary("sentry-bom").get()))
}
}
}
private companion object {
private const val SENTRY_DSN_PROPERTY = "SENTRY_DSN"
private const val SENTRY_UPLOAD_MAPPINGS_PROPERTY = "sentryUploadMappings"
}
}