Skip to content

Commit

Permalink
feat: add free and nonFree product flavors to use sentry (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash-Garg committed Mar 4, 2023
1 parent e34891d commit 33d9686
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/develop_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
env:
base_url: ${{ secrets.BASE_URL }}
password: ${{ secrets.PASSWORD }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

concurrency:
group: ${{ github.ref }}
Expand Down
30 changes: 30 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins {
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.hilt)
alias(libs.plugins.navigation.safeargs)
alias(libs.plugins.sentry)
}

android {
Expand Down Expand Up @@ -70,6 +71,35 @@ android {
}
}

flavorDimensions += listOf("app")
productFlavors {
create("nonFree") {
dimension = "app"
manifestPlaceholders["sentryDsn"] = System.getenv("SENTRY_DSN") ?: ""
}

create("free") {
dimension = "app"
isDefault = true
manifestPlaceholders["sentryDsn"] = ""
}
}

sentry {
ignoredBuildTypes.set(setOf("benchmark", "debug"))
ignoredFlavors.set(setOf("free"))
}

androidComponents {
beforeVariants { variant ->
when {
variant.name.contains("benchmark", ignoreCase = true) -> {
variant.enable = false
}
}
}
}

lint {
abortOnError = true
checkReleaseBuilds = false
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />

<application
Expand All @@ -23,7 +24,11 @@
tools:targetApi="33">
<profileable
android:shell="true"
tools:targetApi="29" />
tools:targetApi="33" />

<meta-data
android:name="io.sentry.dsn"
android:value="${sentryDsn}" />

<activity
android:name=".MainActivity"
Expand Down
38 changes: 38 additions & 0 deletions app/src/nonFree/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application android:icon="@mipmap/ic_launcher">

<!-- Required: set your sentry.io project identifier (DSN) -->
<meta-data
android:name="io.sentry.dsn"
android:value="${sentryDsn}"
tools:replace="android:value" />

<!-- enable automatic breadcrumbs for user interactions (clicks, swipes, scrolls) -->
<meta-data
android:name="io.sentry.traces.user-interaction.enable"
android:value="true" />

<!-- enable screenshot for crashes -->
<meta-data
android:name="io.sentry.attach-screenshot"
android:value="true" />

<!-- enable view hierarchy for crashes -->
<meta-data
android:name="io.sentry.attach-view-hierarchy"
android:value="true" />

<!-- enable the performance API by setting a sample-rate, adjust in production env -->
<meta-data
android:name="io.sentry.traces.sample-rate"
android:value="1.0" />

<!-- enable profiling when starting transactions, adjust in production env -->
<meta-data
android:name="io.sentry.traces.profiling.sample-rate"
android:value="1.0" />
</application>
</manifest>
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
alias(libs.plugins.navigation.safeargs) apply false
alias(libs.plugins.multiplatform) apply false
alias(libs.plugins.binaryCompat) apply false
alias(libs.plugins.sentry) apply false

id("dev.yashgarg.qbit.spotless")
id("dev.yashgarg.qbit.githooks")
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
navigation-safeargs = { id = "androidx.navigation.safeargs", version.ref = "axNavigation" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
sentry = "io.sentry.android.gradle:3.4.2"

[bundles]
compose = ["compose-theme-adapter", "compose-activity", "compose-foundation", "compose-material3"]
Expand Down
2 changes: 2 additions & 0 deletions sentry.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
defaults.project=qbittorrent-kt
defaults.org=yashgarg

0 comments on commit 33d9686

Please sign in to comment.