diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 62a91128103a7eb96e570dafcd6a93001db9a061..8fc2ecf4b3d8e632e372485f0c5c2d34cfca5647 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 42bfe6fe0cea0ace0f10948c73d26e6f8bf5fb52..3c90200eb162d38d7e240e986ff7722b2c06a6ab 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,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 @@ -36,6 +51,7 @@ android { versionName "${versionMajor}.${versionMinor}.${versionPatch}" buildConfigField "String", "BUILD_ID", "\"${getGitHash() + "." + getDate()}\"" + buildConfigField("String", "SENTRY_DSN", "\"${getSentryDsn()}\"") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -129,6 +145,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 c6155ab22b06ab8bdabe8a83d0e2a94e6491f6b9..8b7d6c5399f2372ea929fac94ebc4ea42de14dce 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -40,6 +40,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 fe0adc00990cfbb395f07357ae73068e31e6a85b..a74f85c77b105bfd9cd3eed3ff95d672a2afeeb0 100644 --- a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt +++ b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt @@ -27,6 +27,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 @@ -62,8 +63,17 @@ 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?) { + Telemetry.reportMessage("$tag: $message") + } + }) } }