From 87282e48fcb2148c155790f202e8b9cd01945684 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Fri, 15 Mar 2024 14:45:32 +0100 Subject: [PATCH 1/7] build: bump Sentry Gradle Plugin to 4.3.1 --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index e9b039575b1f..27c692cba546 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,7 @@ pluginManagement { gradle.ext.agpVersion = '8.1.0' gradle.ext.googleServicesVersion = '4.3.15' gradle.ext.navigationVersion = '2.7.7' - gradle.ext.sentryVersion = '3.14.0' + gradle.ext.sentryVersion = '4.3.1' gradle.ext.daggerVersion = "2.50" gradle.ext.detektVersion = '1.23.0' gradle.ext.violationCommentsVersion = '1.70.0' From 82d7aafcc97e578c2f5a333007e69907706e65fa Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Fri, 15 Mar 2024 14:46:40 +0100 Subject: [PATCH 2/7] style: improve formatting of Sentry configuration --- WordPress/build.gradle | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 019b399b0663..67914c65e70b 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -1,3 +1,4 @@ +import io.sentry.android.gradle.extensions.InstrumentationFeature import se.bjurr.violations.comments.github.plugin.gradle.ViolationCommentsToGitHubTask import se.bjurr.violations.lib.model.SEVERITY @@ -17,14 +18,10 @@ plugins { sentry { tracingInstrumentation { enabled = true - features = [io.sentry.android.gradle.extensions.InstrumentationFeature.DATABASE] - logcat { - enabled = false - } - } - autoInstallation { - enabled = false + features = [InstrumentationFeature.DATABASE] + logcat.enabled = false } + autoInstallation.enabled = false } repositories { From ab3bd41311787923f85c7835fac0946c09894ad4 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Fri, 15 Mar 2024 14:48:06 +0100 Subject: [PATCH 3/7] build: upload source context This will send source code to Sentry, so we can see the code that caused the issue directly on Sentry dashboard --- WordPress/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 67914c65e70b..5ad506ddfc6e 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -22,6 +22,8 @@ sentry { logcat.enabled = false } autoInstallation.enabled = false + includeSourceContext = true + autoUploadSourceContext = true } repositories { From 6c15db07817ce138eaef19cfa9ea48220d06005f Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Fri, 15 Mar 2024 14:49:18 +0100 Subject: [PATCH 4/7] build: do not generate list of dependencies for Sentry We know the list of dependencies as we attach information about release to each ticked. Disabling this feature improves build times. --- WordPress/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 5ad506ddfc6e..ec838fd4a1bf 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -24,6 +24,7 @@ sentry { autoInstallation.enabled = false includeSourceContext = true autoUploadSourceContext = true + includeDependenciesReport = false } repositories { From c2518f6415cd9b133f79662909e97252bf369118 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Fri, 15 Mar 2024 14:50:17 +0100 Subject: [PATCH 5/7] build: do not run any Sentry tasks in debug builds To save local build time --- WordPress/build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index ec838fd4a1bf..4bfa697f4b23 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -25,6 +25,11 @@ sentry { includeSourceContext = true autoUploadSourceContext = true includeDependenciesReport = false + /* Sentry won't send source context or add performance instrumentations for debug builds + so we can save build times. Sending events will still work in debug builds + (if enabled in WPCrashLoggingDataProvider). + */ + ignoredBuildTypes = ["debug"] } repositories { From 1387dd5371c5181ea5cf4a040aedbc26e625c7af Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Mon, 18 Mar 2024 18:28:00 +0100 Subject: [PATCH 6/7] fix: when copying React Native bundle source map, rely on input/output of copy task It worked previously, as Sentry Gradle plugin was making the mergeAssets run every time (breaking up to date state) --- WordPress/build.gradle | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 4bfa697f4b23..2b5816adfe43 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -723,18 +723,14 @@ if (project.hasProperty("debugStoreFile")) { // service during the build process. android { applicationVariants.all { variant -> - variant.mergeAssetsProvider.configure { - doLast { - // Copy bundle and source map files - copy { - from(outputDir) - into("${buildDir}/react-native-bundle-source-map") - include("*.bundle", "*.bundle.map") - } + tasks.register("copy${variant.name.capitalize()}ReactNativeBundleSourceMap", Copy) { + from("${buildDir}/intermediates/assets/${variant.name}") + into("${buildDir}/react-native-bundle-source-map") + include("*.bundle", "*.bundle.map") + } - // Delete source maps - delete(fileTree(dir: outputDir, includes: ['**/*.bundle.map'])) - } + variant.mergeAssetsProvider.configure { + finalizedBy("copy${variant.name.capitalize()}ReactNativeBundleSourceMap") } } } From 6c595645baacb0d33f1a53a8f8688304a5a0f245 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Wed, 20 Mar 2024 12:44:16 +0100 Subject: [PATCH 7/7] docs: add 'how to test Sentry' section to Test Instructions per Dependency Update --- ...test_instructions_per_dependency_update.md | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/docs/test_instructions_per_dependency_update.md b/docs/test_instructions_per_dependency_update.md index 60ef32eec1cc..fb2b328411a2 100644 --- a/docs/test_instructions_per_dependency_update.md +++ b/docs/test_instructions_per_dependency_update.md @@ -854,9 +854,58 @@ and [here](https://github.com/orgs/wordpress-mobile/projects/95)).
Why & How -- TODO -- TODO -- TODO +`sentryVersion` in this project relates to Sentry Gradle Plugin only. Sentry SDK is bundled with +[Automattic-Tracks-Android](https://github.com/Automattic/Automattic-Tracks-Android). + +#### Why? +We use Sentry Gradle Plugin to send ProGuard mapping files and source context files to Sentry. It +makes stacktrace readable on Sentry dashboard. This should be the main focus when testing after +bumping `sentryVersion`. + +#### To Test + +Please build the release variant (`vanillaRelease`) of both WordPress and Jetpack flavors and verify if issues are sent correctly. You can use the following snippet. + +
PATCH (warning: it'll probably have some conflicts in the future when `WPMainActivityViewModel` change. It's more for an idea: + +```PATCH +Subject: [PATCH] tests: add a test for features in development generation +--- +Index: WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt +--- a/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt (revision 806913d9fb807250cecd5b24b36001d55ea4c255) ++++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt (date 1710772966823) +@@ -5,6 +5,7 @@ + import androidx.lifecycle.LiveData + import androidx.lifecycle.MutableLiveData + import androidx.lifecycle.distinctUntilChanged ++import com.automattic.android.tracks.crashlogging.CrashLogging + import kotlinx.coroutines.CoroutineDispatcher + import kotlinx.coroutines.flow.firstOrNull + import org.wordpress.android.R +@@ -67,6 +68,7 @@ + private val bloggingPromptsStore: BloggingPromptsStore, + @Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher, + private val shouldAskPrivacyConsent: ShouldAskPrivacyConsent, ++ private val crashLogging: CrashLogging, + ) : ScopedViewModel(mainDispatcher) { + private var isStarted = false + +@@ -161,6 +163,7 @@ + launch { loadMainActions(site) } + + updateFeatureAnnouncements() ++ crashLogging.sendReport(Throwable("Test crash")) + } + + @Suppress("LongMethod") +``` +
+