getsentry / sentry-android-gradle-plugin

Gradle plugin for Sentry Android. Upload proguard, debug files, and more.
https://docs.sentry.io/platforms/android/gradle/
MIT License
141 stars 32 forks source link

Support multi-module Android projects when sending Source Context #685

Open wzieba opened 5 months ago

wzieba commented 5 months ago

Problem Statement

When sending Source Context via Sentry Gradle Plugin, I've noticed that the source is taken only from the main application module. This is problematic for multi-module setups, which are fairly common.

I've prepared a minimal reproduction project of what I have in mind.

Reproduction

An Android application with x app module and y its dependency: https://github.com/wzieba/SentrySourceContextMultiModule

Expected behavior

Running assembleRelease prepares source context bundle with all classes from x and all classes from y modules.

Current behavior

Running assembleRelease prepares source context bundle with only classes from x (proof: https://github.com/wzieba/SentrySourceContextMultiModule/actions/runs/8467510900/job/23198486580#step:5:20)

Solution Brainstorm

I think it could be addressed manually with additionalSourceDirsForSourceContext, but I haven't prepared a working solution yet. Ideally, It'd be great if SAGP could do this internally (maybe as a non-default option?).

kahest commented 5 months ago

Hey @wzieba thanks for the suggestion, I think this makes sense, but it's not our top priority at the moment

markushi commented 5 months ago

Let's investigate this first on our end, as in theory it should work:

  1. Apply plugin to library modules as well (and disable all other plugin features)
  2. Manually upload source context via gradle
  3. Verify asset merging combines all bundle IDs
  4. Ensure app sends proper bundle IDs
romtsn commented 5 months ago

The end goal would be for our gradle plugin to support applying on the root project level, so then we could have access to all modules, but this is a bit bigger initiative

prfarlow1 commented 3 months ago

So as of right now, if we use Sentry in a multi module Android project, we cannot have source context outside of the main app module which applies the Sentry Gradle Plugin? Meaning we also cannot use a CODEOWNERS file for ownership rules to auto-assign issues that exist outside of the app module?

romtsn commented 3 months ago

So as of right now, if we use Sentry in a multi module Android project, we cannot have source context outside of the main app module which applies the Sentry Gradle Plugin?

yes that's correct

Meaning we also cannot use a CODEOWNERS file for ownership rules to auto-assign issues that exist outside of the app module?

Nope, source context is not a prerequisite for code owners, stack trace linking is. However, if you have many modules, stacktrace linking is also not easy to set up, @wzieba came up with a nice solution in the other issue: https://github.com/getsentry/sentry-android-gradle-plugin/issues/546#issuecomment-2035085154

zsperske commented 1 month ago

I created a similar issue here: https://github.com/getsentry/sentry/issues/74435

IMHO this should be given higher priority. Most large/mature Android apps are multi-module.

We have hundreds of Gradle modules, I've heard of apps with thousands.