From bdcb3e182d3a36e289b42ba2d7e9f371a2d7d49e Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 20 Dec 2022 05:02:50 +0530 Subject: [PATCH 1/4] issue_854: Sentry setup. --- .gitlab-ci.yml | 3 +++ app/build.gradle | 18 ++++++++++++++++++ app/src/main/AndroidManifest.xml | 1 + .../foundation/e/apps/AppLoungeApplication.kt | 13 +++++++++++++ build.gradle | 4 ++++ 5 files changed, 39 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 62a911281..8fc2ecf4b 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 42bfe6fe0..3c90200eb 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 c6155ab22..8b7d6c539 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 fe0adc009..529a0f16b 100644 --- a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt +++ b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt @@ -26,7 +26,9 @@ import foundation.e.apps.manager.pkg.PkgManagerBR 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.Constants 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,9 +64,19 @@ 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") + } + }) } + } override fun getWorkManagerConfiguration() = @@ -72,4 +84,5 @@ class AppLoungeApplication : Application(), Configuration.Provider { .setWorkerFactory(workerFactory) .setExecutor(Executors.newSingleThreadExecutor()) .build() + } diff --git a/build.gradle b/build.gradle index 474556714..2a7885ede 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,10 @@ buildscript { repositories { google() mavenCentral() + + maven { + url 'https://gitlab.e.foundation/api/v4/projects/1391/packages/maven' + } } dependencies { classpath 'com.android.tools.build:gradle:7.1.0' -- GitLab From db22a456f2595931f21ecf496ba519dc7ed0c11b Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 17 Jan 2023 16:13:27 +0530 Subject: [PATCH 2/4] MR suggestion --- app/src/main/java/foundation/e/apps/AppLoungeApplication.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt index 529a0f16b..19c8c8cb7 100644 --- a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt +++ b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt @@ -26,7 +26,6 @@ import foundation.e.apps.manager.pkg.PkgManagerBR 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.Constants import foundation.e.apps.utils.modules.DataStoreModule import foundation.e.lib.telemetry.Telemetry import kotlinx.coroutines.DelicateCoroutinesApi -- GitLab From c80c086691f36955aa5ae9022e9cb5af84e09749 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 17 Jan 2023 16:29:38 +0530 Subject: [PATCH 3/4] ktlint fixes --- app/src/main/java/foundation/e/apps/AppLoungeApplication.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt index 19c8c8cb7..a74f85c77 100644 --- a/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt +++ b/app/src/main/java/foundation/e/apps/AppLoungeApplication.kt @@ -75,7 +75,6 @@ class AppLoungeApplication : Application(), Configuration.Provider { } }) } - } override fun getWorkManagerConfiguration() = @@ -83,5 +82,4 @@ class AppLoungeApplication : Application(), Configuration.Provider { .setWorkerFactory(workerFactory) .setExecutor(Executors.newSingleThreadExecutor()) .build() - } -- GitLab From b9e496e44c9a759ad3dd9068c8a90b691a2cd070 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 18 Jan 2023 14:44:14 +0530 Subject: [PATCH 4/4] remove maven repository defined for telemetry --- build.gradle | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build.gradle b/build.gradle index 2a7885ede..474556714 100644 --- a/build.gradle +++ b/build.gradle @@ -3,10 +3,6 @@ buildscript { repositories { google() mavenCentral() - - maven { - url 'https://gitlab.e.foundation/api/v4/projects/1391/packages/maven' - } } dependencies { classpath 'com.android.tools.build:gradle:7.1.0' -- GitLab