sentry-android-gradle-plugin icon indicating copy to clipboard operation
sentry-android-gradle-plugin copied to clipboard

Enable source context for non-release buildtype

Open Shadowsx3 opened this issue 1 year ago • 4 comments

Problem Statement

Currently by setting the includeSourceContext option to true, only the build type of release type automatically reports the source context during the assemble task. It would be great if other custom build types could have the ability to report it automatically by enabling the option. The documentation did not specify this detail and this change would be a great help in a variety of projects.

Solution Brainstorm

There are places in the code that even if you enable the option to do so, check that specifically the name of the build type is release. We could change that as in the following example and depend on the user configuration.

Example

Shadowsx3 avatar Feb 24 '24 02:02 Shadowsx3

hi @Shadowsx3 that's a good feature request, thank you! The reason we limited this to only release builds is to not regress build speed for debug builds, but having this configurable with a list of supported build types makes a lot of sense, we'll look into implementing this!

romtsn avatar Feb 26 '24 08:02 romtsn

Let's make this configurable:

  • by default do it only for release builds
  • if configured, you can define all required buildTypes (~sentry { sourceContext { enabled: true|false, buildTypes: []}})

markushi avatar Feb 28 '24 13:02 markushi

As of now, the sentry AGP doesn't upload Source Context files if we use plugins like https://github.com/Triple-T/gradle-play-publisher. The task to build (and publish) an AAB using that plugin is ./gradlew :app:publishReleaseBundle

Since the task mentioned above is not identified as an assemble/bundle task by Sentry AGP, the Sentry plugin skips uploading sources.

What's the recommended approach if we would like to force sentry AGP to run the Source Context related tasks for tasks other than assemble/bundle?

RationalRank avatar Mar 11 '24 16:03 RationalRank

Hey @RationalRank, thanks for the additional feedback!

You could always run the upload task (e.g. ./gradlew :app:sentryUploadSourceBundleRelease) manually to upload sources.

markushi avatar Mar 15 '24 11:03 markushi