getsentry / sentry-java

A Sentry SDK for Java, Android and other JVM languages.
https://docs.sentry.io/
MIT License
1.16k stars 435 forks source link

Improve inApp by default on Android #1327

Open marandaneto opened 3 years ago

marandaneto commented 3 years ago

https://github.com/getsentry/sentry-java/blob/main/sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java#L173-L177

what's about adding the first 2 or 3 parts of the App's package as inApp by default?

eg, App's package (3 parts): io.sentry.mobile.android

frames like io.sentry.mobile.shared won't be marked as inApp unless they add inAppIncludes manually, which is suboptimal. the idea would be to split it and take the very first 3 packages io.sentry.mobile.*

eg, App's package (2 parts): io.sentry.android.mobile

frames like io.sentry.shared.android won't be marked as inApp. the idea would be to split it and take the very first 2 packages io.sentry.*

it's a common pattern to have the company's domain in the very first 2 parts, so it'd not lead to that much false positive, but this would affect grouping and it'd require a major bump, I guess.

what do you think?

marandaneto commented 3 years ago

another option way less aggressive would be to be explicit about that on our docs and wizard, adding examples of that in the SDK setup instead of hidden in the config. options

bruno-garcia commented 3 years ago

@marandaneto It's a great idea to add it by default. We could add the first three levels:

I.e: App: io.sentry.app We add: io.sentry.app

If the app is: br.com.mycompany.myapp it would end up br.com.mycompany

marandaneto commented 3 years ago

depends on https://github.com/getsentry/sentry-native/pull/514

marandaneto commented 2 years ago

Let's cap at 3 levels at a minimum, otherwise, go one level less, e.g. br.com.mycompany keeps as it is, br.com.mycompany.android becomes br.com.mycompany.

marandaneto commented 2 years ago

Let's investigate if this is possible via the Gradle plugin before going ahead, we might be able to have the full list of package names and pass this to the SDK init., it'd be more accurate.

philipphofmann commented 2 years ago

We want to use the Sentry Android Gradle Plugin to get the full list of packages and add them to inAppIncludes.

bruno-garcia commented 2 years ago

According to @untitaker it's not a breaking change

marandaneto commented 1 year ago

Profiling is doing this server-side (for profiling specifically), align with them and @stefanosiano about how to do this.

markushi commented 1 year ago

Ideally we need some handling for this on the backend for obfuscated builds. Let's also make sure we handle basic cases right and e.g. do not mark com.* as in-app.

armenzg commented 6 days ago

FYI, for customers using GitHub for their Java/Android projects, I will be looking to create automatic code mappings and stack trace rules to mark frames as in-app.

This will be based on the system I created for other languages (link to list).

Related post: https://blog.sentry.io/code-mappings-and-why-they-matter/