Fix build with telemetry
This commit is contained in:
parent
d8132eba1a
commit
06170a9d13
6 changed files with 14 additions and 11 deletions
2
.github/workflows/build_pull_request.yml
vendored
2
.github/workflows/build_pull_request.yml
vendored
|
|
@ -47,6 +47,7 @@ jobs:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
|
|
||||||
- name: Write google-services.json
|
- name: Write google-services.json
|
||||||
|
if: github.repository == github.event.pull_request.head.repo.full_name
|
||||||
uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 # v1.3
|
uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 # v1.3
|
||||||
with:
|
with:
|
||||||
path: app/google-services.json
|
path: app/google-services.json
|
||||||
|
|
@ -54,6 +55,7 @@ jobs:
|
||||||
write-mode: overwrite
|
write-mode: overwrite
|
||||||
|
|
||||||
- name: Write client_secrets.json
|
- name: Write client_secrets.json
|
||||||
|
if: github.repository == github.event.pull_request.head.repo.full_name
|
||||||
uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 # v1.3
|
uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 # v1.3
|
||||||
with:
|
with:
|
||||||
path: app/src/main/assets/client_secrets.json
|
path: app/src/main/assets/client_secrets.json
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||||
import eu.kanade.tachiyomi.util.system.animatorDurationScale
|
import eu.kanade.tachiyomi.util.system.animatorDurationScale
|
||||||
import eu.kanade.tachiyomi.util.system.cancelNotification
|
import eu.kanade.tachiyomi.util.system.cancelNotification
|
||||||
import eu.kanade.tachiyomi.util.system.isDebugBuildType
|
import eu.kanade.tachiyomi.util.system.isDebugBuildType
|
||||||
|
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
||||||
import eu.kanade.tachiyomi.util.system.notify
|
import eu.kanade.tachiyomi.util.system.notify
|
||||||
import eu.kanade.tachiyomi.util.system.telemetryIncluded
|
import eu.kanade.tachiyomi.util.system.telemetryIncluded
|
||||||
import exh.log.CrashlyticsPrinter
|
import exh.log.CrashlyticsPrinter
|
||||||
|
|
@ -109,7 +110,11 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super<Application>.onCreate()
|
super<Application>.onCreate()
|
||||||
patchInjekt()
|
patchInjekt()
|
||||||
TelemetryConfig.init(applicationContext)
|
TelemetryConfig.init(
|
||||||
|
applicationContext,
|
||||||
|
isPreviewBuildType,
|
||||||
|
BuildConfig.COMMIT_COUNT,
|
||||||
|
)
|
||||||
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
if (isDebugBuildType) Timber.plant(Timber.DebugTree())
|
if (isDebugBuildType) Timber.plant(Timber.DebugTree())
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package exh.log
|
||||||
import com.elvishew.xlog.printer.Printer
|
import com.elvishew.xlog.printer.Printer
|
||||||
import com.google.firebase.Firebase
|
import com.google.firebase.Firebase
|
||||||
import com.google.firebase.crashlytics.crashlytics
|
import com.google.firebase.crashlytics.crashlytics
|
||||||
import eu.kanade.tachiyomi.util.system.isDebugBuildType
|
|
||||||
|
|
||||||
class CrashlyticsPrinter(private val logLevel: Int) : Printer {
|
class CrashlyticsPrinter(private val logLevel: Int) : Printer {
|
||||||
/**
|
/**
|
||||||
|
|
@ -17,9 +16,7 @@ class CrashlyticsPrinter(private val logLevel: Int) : Printer {
|
||||||
if (logLevel >= this.logLevel) {
|
if (logLevel >= this.logLevel) {
|
||||||
try {
|
try {
|
||||||
Firebase.crashlytics.log("$logLevel/$tag: $msg")
|
Firebase.crashlytics.log("$logLevel/$tag: $msg")
|
||||||
} catch (t: Throwable) {
|
} catch (_: Throwable) {
|
||||||
// Crash in debug if shit like this happens
|
|
||||||
if (isDebugBuildType) throw t
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,18 @@ import android.content.Context
|
||||||
import com.google.firebase.FirebaseApp
|
import com.google.firebase.FirebaseApp
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
|
||||||
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
|
||||||
|
|
||||||
object TelemetryConfig {
|
object TelemetryConfig {
|
||||||
private lateinit var analytics: FirebaseAnalytics
|
private lateinit var analytics: FirebaseAnalytics
|
||||||
private lateinit var crashlytics: FirebaseCrashlytics
|
private lateinit var crashlytics: FirebaseCrashlytics
|
||||||
|
|
||||||
fun init(context: Context) {
|
fun init(context: Context, isPreviewBuildType: Boolean, commitCount: String) {
|
||||||
analytics = FirebaseAnalytics.getInstance(context)
|
analytics = FirebaseAnalytics.getInstance(context)
|
||||||
FirebaseApp.initializeApp(context)
|
FirebaseApp.initializeApp(context)
|
||||||
crashlytics = FirebaseCrashlytics.getInstance()
|
crashlytics = FirebaseCrashlytics.getInstance()
|
||||||
// KMK -->
|
// KMK -->
|
||||||
if (isPreviewBuildType) {
|
if (isPreviewBuildType) {
|
||||||
analytics.setUserProperty("preview_version", BuildConfig.COMMIT_COUNT)
|
analytics.setUserProperty("preview_version", commitCount)
|
||||||
}
|
}
|
||||||
// KMK <--
|
// KMK <--
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package exh.log
|
||||||
|
|
||||||
import com.elvishew.xlog.printer.Printer
|
import com.elvishew.xlog.printer.Printer
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER", "unused")
|
||||||
class CrashlyticsPrinter(private val logLevel: Int) : Printer {
|
class CrashlyticsPrinter(private val logLevel: Int) : Printer {
|
||||||
/**
|
/**
|
||||||
* Print log in new line.
|
* Print log in new line.
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ package mihon.telemetry
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER", "unused")
|
||||||
object TelemetryConfig {
|
object TelemetryConfig {
|
||||||
fun init(context: Context) = Unit
|
fun init(context: Context, isPreviewBuildType: Boolean, commitCount: String) = Unit
|
||||||
|
|
||||||
fun setAnalyticsEnabled(enabled: Boolean) = Unit
|
fun setAnalyticsEnabled(enabled: Boolean) = Unit
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue