diff --git a/.gitignore b/.gitignore index 5272c0c0..8a460f21 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ gps/ Clover/app/keys.properties Clover/app/version.properties Clover/captures/ - +Clover/sentry.properties #built application files # *.apk diff --git a/Clover/app/build.gradle b/Clover/app/build.gradle index a6678e31..5cb0cd11 100644 --- a/Clover/app/build.gradle +++ b/Clover/app/build.gradle @@ -1,5 +1,15 @@ apply plugin: 'com.android.application' +if (project.sentryMappingUploadingEnabled) { + apply plugin: 'io.sentry.android.gradle' + + sentry { + // We'll do this manually because we only enable the sentry plugin on + // the build server. + autoProguardConfig false + } +} + /** * Gets the version name from the latest Git tag */ @@ -81,7 +91,7 @@ android { resValue "string", "app_flavor_name", "" buildConfigField "String", "BUILD_HASH", "\"$hash\"" buildConfigField "String", "UPDATE_API_ENDPOINT", "\"https://build.floens.org/api/update\"" - buildConfigField "String", "CRASH_REPORT_ENDPOINT", "\"https://acra.floens.org/clover/report\"" + buildConfigField "String", "CRASH_REPORT_TOKEN", "\"https://d453201738b8469da2113a922c543a3b@sentry.io/1413946\"" } dev { @@ -91,7 +101,7 @@ android { resValue "string", "app_flavor_name", "" buildConfigField "String", "BUILD_HASH", "\"$hash\"" buildConfigField "String", "UPDATE_API_ENDPOINT", "\"https://build.floens.org/api/update_dev\"" - buildConfigField "String", "CRASH_REPORT_ENDPOINT", "\"https://acra.floens.org/clover/report\"" + buildConfigField "String", "CRASH_REPORT_TOKEN", "\"https://d453201738b8469da2113a922c543a3b@sentry.io/1413946\"" versionNameSuffix "-" + hash } @@ -103,7 +113,7 @@ android { resValue "string", "app_flavor_name", "F-Droid" buildConfigField "String", "BUILD_HASH", "\"$hash\"" buildConfigField "String", "UPDATE_API_ENDPOINT", "\"https://floens.github.io/Clover/api/update\"" - buildConfigField "String", "CRASH_REPORT_ENDPOINT", "\"https://acra.floens.org/clover/report\"" + buildConfigField "String", "CRASH_REPORT_TOKEN", "\"https://d453201738b8469da2113a922c543a3b@sentry.io/1413946\"" } } @@ -154,6 +164,5 @@ dependencies { implementation 'com.google.code.gson:gson:2.8.5' implementation 'me.xdrop:fuzzywuzzy:1.1.10' implementation 'org.codejargon.feather:feather:1.0' - - releaseImplementation 'ch.acra:acra-http:5.1.3' + implementation 'io.sentry:sentry-android:1.7.24' } diff --git a/Clover/app/proguard.cfg b/Clover/app/proguard.cfg index a3ac7361..b43e97c3 100644 --- a/Clover/app/proguard.cfg +++ b/Clover/app/proguard.cfg @@ -117,9 +117,7 @@ (); } -# ACRA stuff -# ACRA loads Plugins using reflection, so we need to keep all Plugin classes --keep class * extends @android.support.annotation.Keep org.acra.** {*;} - -# ACRA uses enum fields in annotations, so we have to keep those --keep enum org.acra.** {*;} +# Sentry +-dontwarn org.slf4j.** +-dontwarn javax.** +-keep class io.sentry.event.Event { *; } diff --git a/Clover/app/src/main/assets/html/licenses.html b/Clover/app/src/main/assets/html/licenses.html index 0c3bc6de..1cf20a12 100644 --- a/Clover/app/src/main/assets/html/licenses.html +++ b/Clover/app/src/main/assets/html/licenses.html @@ -290,5 +290,26 @@ limitations under the License.
+

sentry-java

+ https://github.com/getsentry/sentry-java +
+        
+Copyright (c) 2016 Functional Software, Inc.
+Copyright (c) 2012 Ken Cochrane and individual contributors.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+    3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+        
+    
+
+ diff --git a/Clover/app/src/debug/java/org/floens/chan/ChanApplication.java b/Clover/app/src/main/java/org/floens/chan/ChanApplication.java similarity index 63% rename from Clover/app/src/debug/java/org/floens/chan/ChanApplication.java rename to Clover/app/src/main/java/org/floens/chan/ChanApplication.java index ebad39ed..4acfc747 100644 --- a/Clover/app/src/debug/java/org/floens/chan/ChanApplication.java +++ b/Clover/app/src/main/java/org/floens/chan/ChanApplication.java @@ -17,10 +17,14 @@ */ package org.floens.chan; +import org.floens.chan.core.settings.ChanSettings; + +import io.sentry.Sentry; +import io.sentry.android.AndroidSentryClientFactory; + /** - * The ChanApplication belonging to the debug configuration. - * - * It does not have acra enabled, unlike the release version, and immediately calls initialize. + * The ChanApplication wrapping our Chan application. + * For historical reasons the main application class needs to be 'org.floens.chan.ChanApplication'. */ public class ChanApplication extends Chan { @Override @@ -28,5 +32,12 @@ public class ChanApplication extends Chan { super.onCreate(); initialize(); + + if (!ChanBuild.DEVELOPER_MODE && ChanSettings.isCrashReportingEnabled()) { + Sentry.init( + BuildConfig.CRASH_REPORT_TOKEN, + new AndroidSentryClientFactory(this) + ); + } } } diff --git a/Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java b/Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java index cb1624c0..0fc9128f 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java +++ b/Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java @@ -263,7 +263,8 @@ public class ChanSettings { } public static boolean isCrashReportingAvailable() { - return !BuildConfig.CRASH_REPORT_ENDPOINT.isEmpty(); + //noinspection ConstantConditions + return !BuildConfig.CRASH_REPORT_TOKEN.isEmpty(); } public static boolean isCrashReportingEnabled() { diff --git a/Clover/app/src/release/java/org/floens/chan/ChanApplication.java b/Clover/app/src/release/java/org/floens/chan/ChanApplication.java deleted file mode 100644 index 3bf8d65b..00000000 --- a/Clover/app/src/release/java/org/floens/chan/ChanApplication.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Clover - 4chan browser https://github.com/Floens/Clover/ - * Copyright (C) 2014 Floens - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.floens.chan; - -import android.content.Context; - -import org.acra.ACRA; -import org.acra.annotation.AcraCore; -import org.acra.annotation.AcraHttpSender; -import org.acra.data.StringFormat; -import org.acra.sender.HttpSender; -import org.floens.chan.core.settings.ChanSettings; - -import static org.acra.ReportField.ANDROID_VERSION; -import static org.acra.ReportField.APP_VERSION_CODE; -import static org.acra.ReportField.APP_VERSION_NAME; -import static org.acra.ReportField.AVAILABLE_MEM_SIZE; -import static org.acra.ReportField.BRAND; -import static org.acra.ReportField.BUILD; -import static org.acra.ReportField.BUILD_CONFIG; -import static org.acra.ReportField.LOGCAT; -import static org.acra.ReportField.MEDIA_CODEC_LIST; -import static org.acra.ReportField.PACKAGE_NAME; -import static org.acra.ReportField.PHONE_MODEL; -import static org.acra.ReportField.PRODUCT; -import static org.acra.ReportField.REPORT_ID; -import static org.acra.ReportField.STACK_TRACE; -import static org.acra.ReportField.TOTAL_MEM_SIZE; -import static org.acra.ReportField.USER_APP_START_DATE; -import static org.acra.ReportField.USER_CRASH_DATE; - -/** - * The ChanApplication belonging to the release configuration. - *

- * It has acra enabled. Acra unfortunately believes it needs to have annotations on our - * application class, which I find really intrusive. We already had ChanApplication pointing to - * Chan, so we now have a debug and release variant of ChanApplication. The real initialization - * is done with the {@link Chan#initialize()} method, which does not get called from acra - * processes. - */ -@AcraCore( - sharedPreferencesName = "acra_preferences", - alsoReportToAndroidFramework = true, - buildConfigClass = BuildConfig.class, - reportFormat = StringFormat.JSON, - reportContent = { - // Required - REPORT_ID, - - // What app version - APP_VERSION_CODE, - APP_VERSION_NAME, - PACKAGE_NAME, - BUILD_CONFIG, - - // What phone - PHONE_MODEL, - BRAND, - PRODUCT, - - // What Android version - ANDROID_VERSION, - BUILD, - - // Memory details - TOTAL_MEM_SIZE, - AVAILABLE_MEM_SIZE, - - // Useful for webm debugging - MEDIA_CODEC_LIST, - - // The error - STACK_TRACE, - LOGCAT, - USER_APP_START_DATE, - USER_CRASH_DATE - } -) -@AcraHttpSender( - httpMethod = HttpSender.Method.PUT, - uri = BuildConfig.CRASH_REPORT_ENDPOINT -) -public class ChanApplication extends Chan { - @Override - public void onCreate() { - super.onCreate(); - - // Do not initialize again if running from the crash reporting process. - if (!ACRA.isACRASenderServiceProcess()) { - initialize(); - } - } - - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(base); - - if (enableAcra()) { - ACRA.init(this); - } - } - - private boolean enableAcra() { - return ChanSettings.isCrashReportingEnabled(); - } -} diff --git a/Clover/build.gradle b/Clover/build.gradle index dcf3372b..cfe1dd31 100644 --- a/Clover/build.gradle +++ b/Clover/build.gradle @@ -1,4 +1,9 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. + +// This uploads the mapping files to sentry, only enabled when the properties file exists +// (on the build server). +project.ext.sentryMappingUploadingEnabled = file('sentry.properties').exists() + buildscript { repositories { google() @@ -6,6 +11,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'io.sentry:sentry-android-gradle-plugin:1.7.24' } }