diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a80c072e80af2ba636b9648b6fec5560278948b4..1ab615176a62f821b76ced1d73e5c8cee84f67fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,8 @@ image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release +variables: + SENTRY_DSN: $SENTRY_DSN + stages: - debug - release diff --git a/app/build.gradle b/app/build.gradle index b37cd54b52508f2de040189343c696b1e4a8bbcc..369f1e3b1edd38ae5cf2def3a67a91f465153863 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,6 +26,21 @@ def getDate = { -> return new Date().format('yyyyMMddHHmmss') } +def getSentryDsn = { -> + + def sentryDsnEnv = System.getenv("SENTRY_DSN") + if (sentryDsnEnv != null) { + return sentryDsnEnv + } + + Properties properties = new Properties() + def propertiesFile = project.rootProject.file('local.properties') + if (propertiesFile.exists()) { + properties.load(propertiesFile.newDataInputStream()) + } + return properties.getProperty('SENTRY_DSN') +} + android { compileSdk 31 @@ -37,6 +52,7 @@ android { versionName "${versionMajor}.${versionMinor}.${versionPatch}" buildConfigField "String", "BUILD_ID", "\"${getGitHash() + "." + getDate()}\"" + buildConfigField("String", "SENTRY_DSN", "\"${getSentryDsn()}\"") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -133,6 +149,8 @@ dependencies { // TODO: Add splitinstall-lib to a repo https://gitlab.e.foundation/e/os/backlog/-/issues/628 api files('libs/splitinstall-lib.jar') + implementation 'foundation.e.lib:telemetry:0.0.4-alpha' + implementation 'foundation.e:gplayapi:3.0.1' implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.4.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6cf905dd2403d6cf2e6e4364e19dd651fa8ea1bb..945d35eb97b72927033c6b14e4cf9052203984d8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,6 +43,7 @@ android:supportsRtl="true" android:theme="@style/Theme.Apps" android:usesCleartextTraffic="true"> + diff --git a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt index 6b8450742bf9c8fbf1e73701478ea23a414a51ce..08a58314575ea03268a0c6b941c3591e3b6dbd35 100644 --- a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt +++ b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt @@ -28,6 +28,7 @@ import foundation.e.apps.manager.pkg.PkgManagerModule import foundation.e.apps.manager.workmanager.InstallWorkManager import foundation.e.apps.setup.tos.TOS_VERSION import foundation.e.apps.utils.modules.DataStoreModule +import foundation.e.lib.telemetry.Telemetry import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch @@ -63,14 +64,20 @@ class AppLoungeApplication : Application(), Configuration.Provider { dataStoreModule.saveTOCStatus(false, "") } } + if (BuildConfig.DEBUG) { plant(Timber.DebugTree()) } else { + // Allow enabling telemetry only for release builds. + Telemetry.init(BuildConfig.SENTRY_DSN, this) plant(object : Timber.Tree() { override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { - if (priority == Log.DEBUG || priority == Log.VERBOSE) { + if (priority < Log.WARN) { return } + if (priority == Log.ERROR) { + Telemetry.reportMessage("$tag: $message") + } Log.println(priority, tag, message) } })