diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cdb53b009103ca116c19ba4611ba2048f05f6dda..830ab5d9d14004b052e7e3ac4f9f9c3f0dd9b090 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,8 @@ image: "registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:latest" +variables: + SENTRY_DSN: "${SENTRY_DSN}" + stages: - test - build diff --git a/app/build.gradle b/app/build.gradle index eefe18c4f8fd0e21adf208c286f74156238ce322..94555cb9264bf2c2d807b6f48ca6039cae8a2fb8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,6 @@ def versionMajor = 1 def versionMinor = 3 def versionPatch = 2 - - def getTestProp(String propName) { def result = "" if (project.hasProperty(propName)) { @@ -21,6 +19,20 @@ def getTestProp(String propName) { return result } +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 @@ -47,14 +59,15 @@ android { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + buildConfigField("String", "SENTRY_DSN", "\"${getSentryDsn()}\"") } debug { signingConfig signingConfigs.debugConfig + buildConfigField("String", "SENTRY_DSN", "\"dummy\"") } } - testOptions { unitTests { returnDefaultValues = true @@ -73,10 +86,8 @@ android { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } - } - dependencies { implementation 'com.github.nextcloud:android-library:2.13.0' implementation "commons-httpclient:commons-httpclient:3.1@jar" @@ -93,6 +104,7 @@ dependencies { implementation 'androidx.test:core:1.4.0' implementation 'com.jakewharton.timber:timber:5.0.1' implementation 'foundation.e:elib:0.0.1-alpha11' + implementation 'foundation.e.lib:telemetry:0.0.4-alpha' androidTestImplementation 'androidx.test:runner:1.4.0' androidTestImplementation 'androidx.test:rules:1.4.0' @@ -106,6 +118,5 @@ dependencies { testImplementation 'junit:junit:4.13.2' testImplementation 'org.robolectric:robolectric:4.4' testImplementation 'org.mockito:mockito-core:3.4.0' - //testImplementation 'org.mockito:mockito-inline:3.4.0' testImplementation 'androidx.work:work-testing:2.7.1' -} +} \ No newline at end of file diff --git a/app/src/main/java/foundation/e/drive/EdriveApplication.java b/app/src/main/java/foundation/e/drive/EdriveApplication.java index 5f1ac3c3a99251faf2a61c3315cca8681a84417b..0ba4332015df5519bc7cefe176af79481a9bf521 100644 --- a/app/src/main/java/foundation/e/drive/EdriveApplication.java +++ b/app/src/main/java/foundation/e/drive/EdriveApplication.java @@ -23,6 +23,7 @@ import foundation.e.drive.services.SynchronizationService; import foundation.e.drive.utils.AppConstants; import foundation.e.drive.utils.CommonUtils; import foundation.e.drive.utils.ReleaseTree; +import foundation.e.lib.telemetry.Telemetry; import timber.log.Timber; import static timber.log.Timber.DebugTree; @@ -43,7 +44,7 @@ public class EdriveApplication extends Application { if (BuildConfig.DEBUG) { Timber.plant(new DebugTree()); } else { - //Not handled yet + Telemetry.INSTANCE.init(BuildConfig.SENTRY_DSN, this); Timber.plant(new ReleaseTree()); } Timber.tag("EdriveApplication"); diff --git a/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java b/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java index e8d64cf9c1f355627064ee7e8d30296b063e6bcc..dbc19e127fe63ebe8344fdc19ead984c5eb645b8 100644 --- a/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java +++ b/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java @@ -12,6 +12,7 @@ import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import foundation.e.lib.telemetry.Telemetry; import timber.log.Timber; /** @@ -29,6 +30,11 @@ public class ReleaseTree extends Timber.DebugTree{ if (!debugEnable && priority < Log.INFO ) { return; } + + if (priority >= Log.WARN) { + Telemetry.INSTANCE.reportMessage(tag + " " + message); + } + super.log(priority, tag, message, throwable); } }