diff --git a/app/build.gradle b/app/build.gradle index 60128206f..b9786930e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,6 +109,16 @@ android { dimension "api" versionCode 8 } + applicationVariants.all { variant -> + buildConfigField 'String', 'SENTRY_TOKEN', 'null' + if (variant.flavorName == "lumen" && variant.buildType.name == "release") { + def sentryToken = this.hasProperty("com.cliqz.lumen.sentryToken") ? + this.getProperty("com.cliqz.lumen.sentryToken") : System.getenv("SENTRY_TOKEN") + if (sentryToken) { + buildConfigField 'String', 'SENTRY_TOKEN', "\"${sentryToken}\"" + } + } + } // huawei { // dimension "api" // versionCode 5 @@ -260,6 +270,8 @@ dependencies { androidTestImplementation 'com.google.dexmaker:dexmaker:1.2' androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2' + // Sentry + implementation 'io.sentry:sentry-android:1.7.21' // Forcing version androidTestImplementation 'androidx.annotation:annotation:1.0.0' androidTestImplementation 'androidx.test:runner:1.1.0' diff --git a/app/src/lumen/java/com/cliqz/browser/app/BrowserApp.java b/app/src/lumen/java/com/cliqz/browser/app/BrowserApp.java index 6301833f3..de8cebf0b 100644 --- a/app/src/lumen/java/com/cliqz/browser/app/BrowserApp.java +++ b/app/src/lumen/java/com/cliqz/browser/app/BrowserApp.java @@ -1,6 +1,7 @@ package com.cliqz.browser.app; import android.net.Uri; +import android.text.TextUtils; import com.cliqz.browser.BuildConfig; import com.cliqz.browser.purchases.PurchasesManager; @@ -11,6 +12,8 @@ import de.blinkt.openvpn.ConfigConverter; import de.blinkt.openvpn.core.ProfileManager; import de.blinkt.openvpn.core.StatusListener; +import io.sentry.Sentry; +import io.sentry.android.AndroidSentryClientFactory; /** * @author Ravjit Uppal @@ -26,6 +29,8 @@ public void init() { final StatusListener mStatus = new StatusListener(); mStatus.init(getApplicationContext()); + setupCrashReporting(); + getAppComponent().inject(this); setupSubscriptionSDK(); } @@ -40,6 +45,12 @@ private void importVpnProfiles() { } } + private void setupCrashReporting() { + if (!TextUtils.isEmpty(BuildConfig.SENTRY_TOKEN)) { + Sentry.init(BuildConfig.SENTRY_TOKEN, new AndroidSentryClientFactory(this)); + } + } + private void setupSubscriptionSDK() { //noinspection ConstantConditions if (!BuildConfig.REVENUECAT_API_KEY.isEmpty()) {