Sentry-dart: Better grouping / in-app detection

Created on 28 May 2021  路  12Comments  路  Source: getsentry/sentry-dart

Looking through a few errors of our own mobile app:

https://sentry.io/organizations/sentry/issues/2422252071/events/4beecc04944246ddaf284cb4119c5b1a/?project=5645511
https://sentry.io/organizations/sentry/issues/2339061202/events/41cea4bcd0384197b045f8a6db840bf7/?project=5645511
https://sentry.io/organizations/sentry/issues/2422252066/events/9db886252e5d418d846abfe372b60082/?project=5645511

The only difference is always the 3rd frame:
sentry_api.dart in SentryApi.organizations at line 31 within sentry_mobile
sentry_api.dart in SentryApi.sessions at line 190 within sentry_mobile
sentry_api.dart in SentryApi.projectIdsWithSessions at line 70 within sentry_mobile

CleanShot 2021-05-28 at 10 46 40
CleanShot 2021-05-28 at 10 46 53
CleanShot 2021-05-28 at 10 47 02

I understand that those are different error and therefore not grouped together but since we use the first frame to describe the issue in the list it looks like this:
CleanShot 2021-05-28 at 10 50 10

which is not helpful. If we would have better in-app frame detection this should be way more helpful.

enhancement

Most helpful comment

@denrase see @marandaneto last comment, can we add this to our mobile app?
inAppExcludes

All 12 comments

The last frame is also different.
io_client.dart and base_client.dart are definitely not in app because they're coming from http.

indeed, these 2 frames should not be considered inApp, something to be improved on https://github.com/getsentry/sentry-dart/blob/main/dart/lib/src/sentry_stack_trace_factory.dart#L145-L171

I'm not really sure we can do it 100% automatically here. I introduced loading of external packages in https://github.com/getsentry/sentry-dart/pull/452 which only works with Flutter and not with plain Dart without Flutter. I would guess that we can get a significant improvement by using the loaded external packages as inAppExcludes.

Edit: We need to test that with obfuscation.

Is there a way to exclude everything except the package(s) that I add to inAppInclude? I don't seem to be able to do achieve this.

No, that's currently not possible. I agree though, that would be nice to have. It seems easier to maintain what's in app than to remember to add every newly added library to the excludes.

Edit: A non-breaking way to add this could be an option for the default behavior. So if for example the default is to set every frame as in app, you only have to maintain an exclude list.

Yes, that is how it was with the old 3.x package.
I basically only care about my app package and max 3-5 other libraries. The rest I want to ignore.

the problem is that we'd like to have an ootb solution for inApp detection but it's not possible to identify the App's package at runtime and add it as inAppInclude by default, Android is like this but we're able to identify the App's package at runtime, not Dart/Flutter, if we go this way, it'd mean that setting the App's package inAppInclude would need to be part of the SDK init. which is also not that user-friendly, many people would miss/forget it or wonder where to get it from.

I'm not really sure we can do it 100% automatically here. I introduced loading of external packages in #452 which only works with Flutter and not with plain Dart without Flutter. I would guess that we can get a significant improvement by using the loaded external packages as inAppExcludes.

that's a good idea actually, it may work, we can experiment once #452 lands

meanwhile, @ueman would be possible to see what can be done automatically on https://github.com/getsentry/sentry-dart/blob/main/dart/lib/src/sentry_stack_trace_factory.dart#L145-L171 for now?

@HazAT a way to workaround this right now is to add the package http as inAppExcludes

@denrase see @marandaneto last comment, can we add this to our mobile app?
inAppExcludes

I think Platform.executable might be named after the package itself. I'll need to check that though. There's also https://github.com/flutter/flutter/issues/83921 which kinda stops us from using it.

@ueman should we close this after #482 ? it kinda fixes the problem, as there's no other way of detecting the app's package at runtime for now.

Yeah, we could still try with the loaded packages from the license workaround but it only works for Flutter anyway. I'm okay with closing it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MrMoronIV picture MrMoronIV  路  6Comments

bruno-garcia picture bruno-garcia  路  6Comments

ueman picture ueman  路  7Comments

bruno-garcia picture bruno-garcia  路  4Comments

philipphofmann picture philipphofmann  路  8Comments