Git Product home page Git Product logo

flutter_sentry's People

Contributors

dotdoom avatar fzyzcjy avatar jayjun avatar ksheremet avatar kuhnroyal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_sentry's Issues

Supporting UserContext in bug reports

It would be nice to have UserContext as part of bug reports. This could probably be achieved by passing an async user context generator function to FlutterSentry.wrap.

I am open to making a PR adding this support. Please let me know if I should go ahead.

Android native test crash not reported to Sentry

Describe the bug
Android native test crash not being reported. Instead PlatformException(FAILED_PRECONDITION, Failed to cause a native crash., null) is reported to Sentry.

An Abort is sometimes reported to Sentry, probably caused by the OutOfMemory:

OS Version: Android 9 (PPR1.180610.011.T515XXS4ATE3)
Report Version: 104

Exception Type: Unknown (SIGABRT)

Application Specific Information:
Abort

Thread 0 Crashed:
0   libc.so                         0xec065ece          abort
1   libflutter.so                   0xcc66cc03          <unknown> + 3429288963
2   <unknown>                       0x8                 <unknown>



EOF

Changing the OutOfMemoryError to something else, like IllegalArgumentException also only reports PlatformException(FAILED_PRECONDITION, Failed to cause a native crash., null).

If I do something like:

    override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
        throw IllegalArgumentException("This is a nativeCrash method call.")
        if (firebaseTestLab == null) {
            // https://firebase.google.com/docs/test-lab/android/android-studio.
            val testLabSetting = Settings.System.getString(
                    flutterPluginBinding.applicationContext.contentResolver,
                    "firebase.test.lab")
            firebaseTestLab = "true" == testLabSetting
        }

        val channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flutter_sentry")
        channel.setMethodCallHandler(this)
    }

Then the error is reported to Sentry.
So it seems that exceptions thrown in onMethodCall are not reported, maybe for some threading reasons or something, dunno.

To Reproduce
Steps to reproduce the behavior:

  1. Checkout example
  2. Change DSN in main.dart and AndroidManifest.xml
  3. Click native Crash

Expected behavior
I would expect the native OutOfMemory crash to show up in Sentry.

Versions (If applicable):

  • Device: Samsung Galaxy Tab
  • OS: Android 9
  • Sentry: 20.7.0.dev0 on premise
  • Flutter: 1.17.5

Changing the OutOfMemory

WillPopScope Android crash

On android using the SystemNavigator.pop() to close the app causes a crash;

Launching lib\main.dart on G6 in debug mode...
✓ Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:62634/_UpFuP1mSRo=/ws
D/ (22484): Gralloc Register w:720, h:1344, f:0x1, usage:0xb00, ui64Stamp:1762467, sSize:3870720, line = 2106
D/ (22484): Gralloc Register w:720, h:1344, f:0x1, usage:0xb00, ui64Stamp:1762492, sSize:3870720, line = 2106
D/ (22484): Gralloc UnRegister w:720, h:1344, f:0x1, usage:0xb00, ui64Stamp:1762409 line = 2218
D/ (22484): Gralloc UnRegister w:720, h:1344, f:0x1, usage:0xb00, ui64Stamp:1762492 line = 2218
D/ (22484): Gralloc UnRegister w:720, h:1440, f:0x1, usage:0xb00, ui64Stamp:1762411 line = 2218
D/ (22484): Gralloc UnRegister w:720, h:1440, f:0x1, usage:0xb00, ui64Stamp:1762428 line = 2218
D/AndroidRuntime(22484): Shutting down VM
E/AndroidRuntime(22484): FATAL EXCEPTION: main
E/AndroidRuntime(22484): Process: br.com.sisplansistemas.aplicativo, PID: 22484
E/AndroidRuntime(22484): java.lang.RuntimeException: Unable to destroy activity {br.com.sisplansistemas.aplicativo/br.com.sisplansistemas.aplicativo.MainActivity}: kotlin.UninitializedPropertyAccessException: lateinit property channel has not been initialized
E/AndroidRuntime(22484): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4535)
E/AndroidRuntime(22484): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4553)
E/AndroidRuntime(22484): at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:39)
E/AndroidRuntime(22484): at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
E/AndroidRuntime(22484): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
E/AndroidRuntime(22484): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
E/AndroidRuntime(22484): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(22484): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(22484): at android.app.ActivityThread.main(ActivityThread.java:6880)
E/AndroidRuntime(22484): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(22484): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:504)
E/AndroidRuntime(22484): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/AndroidRuntime(22484): Caused by: kotlin.UninitializedPropertyAccessException: lateinit property channel has not been initialized
E/AndroidRuntime(22484): at org.dasfoo.flutter_sentry.FlutterSentryPlugin.onDetachedFromEngine(FlutterSentryPlugin.kt:68)
E/AndroidRuntime(22484): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.remove(FlutterEnginePluginRegistry.java:252)
E/AndroidRuntime(22484): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.remove(FlutterEnginePluginRegistry.java:260)
E/AndroidRuntime(22484): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.removeAll(FlutterEnginePluginRegistry.java:268)
E/AndroidRuntime(22484): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.destroy(FlutterEnginePluginRegistry.java:112)
E/AndroidRuntime(22484): at io.flutter.embedding.engine.FlutterEngine.destroy(FlutterEngine.java:360)
E/AndroidRuntime(22484): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onDetach(FlutterActivityAndFragmentDelegate.java:522)
E/AndroidRuntime(22484): at io.flutter.embedding.android.FlutterActivity.onDestroy(FlutterActivity.java:578)
E/AndroidRuntime(22484): at android.app.Activity.performDestroy(Activity.java:8865)
E/AndroidRuntime(22484): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1331)
E/AndroidRuntime(22484): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4520)
E/AndroidRuntime(22484): ... 11 more
D/HprofFactory(22484): Create HprofDebugEx
I/Process (22484): Sending signal. PID: 22484 SIG: 9
Lost connection to device.
Exited (sigterm)

flutter_sentry is using deprecated Flutter API

My current Flutter version:

Flutter 1.12.13+hotfix.5 • channel unknown • unknown source
Framework • revision 27321ebbad (5 weeks ago) • 2019-12-10 18:15:01 -0800
Engine • revision 2994f7e1e6
Tools • Dart 2.7.0

Deprecation notice:

Note: /home/ksdme/Tools/flutter/.pub-cache/hosted/pub.dartlang.org/device_info-0.4.1+4/android/src/main/java/io/flutter/plugins/deviceinfo/DeviceInfoP
lugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.                    
Running Gradle task 'assembleDebug'...                                  
warning: the '-d' option with a directory destination is ignored because '-Xbuild-file' is specified
/home/ksdme/Tools/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_sentry-0.1.0/android/src/main/kotlin/org/dasfoo/flutter_sentry/FlutterSentryPlugi
n.kt:17:54: warning: 'getFlutterEngine(): FlutterEngine' is deprecated. Deprecated in Java
    val channel = MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "flutter_sentry")       

I don't want to see your logging in my app.

Sentry creates TONS of logging info.
This just creates noise in my app which is not welcome.
I love what sentry does, but I would prefer not seeing YOUR logging unless I turn on verbose mode.
Give me important milesstone, not all the details.
I am using sentry_flutter: ^6.2.0

I/Sentry ( 8145): Initializing SDK with DSN: ''
I/Sentry ( 8145): GlobalHubMode: 'true'
W/pool-4-thread-1( 8145): type=1400 audit(0.0:1818): avc: denied { read } for name="version" dev="proc" ino=4026532035 scontext=u:r:untrusted_app:s0:c121,c256,c512,c768 tcontext=u:object_r:proc_version:s0 tclass=file permissive=0 app=XXX.XXX
D/Sentry ( 8145): UncaughtExceptionHandlerIntegration enabled: true
D/Sentry ( 8145): default UncaughtExceptionHandler class='org.chromium.base.JavaExceptionReporter'
D/Sentry ( 8145): UncaughtExceptionHandlerIntegration installed.
D/Sentry ( 8145): ShutdownHookIntegration installed.
D/Sentry ( 8145): SendCachedEventFireAndForgetIntegration installed.
D/Sentry ( 8145): NdkIntegration enabled: true
D/Sentry ( 8145): Started processing cached files from /data/user/0/XXX.XXX/cache/sentry
D/Sentry ( 8145): Processing dir. /data/user/0XXX.XXX/cache/sentry
D/Sentry ( 8145): Processing 1 items from cache dir /data/user/0/XXX.XXX/cache/sentry
D/Sentry ( 8145): File /data/user/0/XXX.XXX/cache/sentry/outbox is not a File.
I/sentry-native( 8145): using database path "/data/data/XXX.XXX/cache/sentry/.sentry-native"
D/Sentry ( 8145): File /data/user/0/XXX.XXX/cache/sentry/.sentry-native is not a File.
D/Sentry ( 8145): Processing file: /data/user/0/XXX.XXX/cache/sentry/session.json
D/sentry-native( 8145): starting backend
D/Sentry ( 8145): File '/data/user/0/XXX.XXX/cache/sentry/session.json' doesn't match extension expected.
D/Sentry ( 8145): Processing file: /data/user/0/XXX.XXX/cache/sentry/3989cad9-a924-4e8d-a684-c9116df6536f.envelope
D/Sentry ( 8145): NdkIntegration installed.
D/Sentry ( 8145): Registering EnvelopeFileObserverIntegration for path: /data/user/0/XXX.XXX/cache/sentry/outbox
D/Sentry ( 8145): EnvelopeFileObserverIntegration installed.
D/Sentry ( 8145): SendCachedEventFireAndForgetIntegration installed.
D/Sentry ( 8145): AnrIntegration enabled: false
D/Sentry ( 8145): enableSessionTracking enabled: true
D/Sentry ( 8145): enableAppLifecycleBreadcrumbs enabled: true
D/Sentry ( 8145): Captured Envelope is already cached
D/Sentry ( 8145): AppLifecycleIntegration installed.
D/Sentry ( 8145): ActivityLifecycleIntegration enabled: true
D/Sentry ( 8145): ActivityLifecycleIntegration installed.
D/Sentry ( 8145): AppComponentsBreadcrumbsIntegration enabled: true
D/Sentry ( 8145): AppComponentsBreadcrumbsIntegration installed.
D/Sentry ( 8145): SystemEventsBreadcrumbsIntegration enabled: true
D/Sentry ( 8145): SystemEventsBreadcrumbsIntegration installed.
D/Sentry ( 8145): enableSystemEventsBreadcrumbs enabled: true
D/Sentry ( 8145): TempSensorBreadcrumbsIntegration installed.
D/Sentry ( 8145): enableSystemEventBreadcrumbs enabled: true
D/Sentry ( 8145): Envelope sent successfully.
D/Sentry ( 8145): Envelope flushed
D/Sentry ( 8145): Marking envelope submission result: true
W/Sentry ( 8145): Current session is not ended, we'd need to end it.
D/Sentry ( 8145): Deleted file /data/user/0/XXX.XXX/cache/sentry/3989cad9-a924-4e8d-a684-c9116df6536f.envelope.
D/Sentry ( 8145): Finished processing cached files from /data/user/0/XXX.XXX/cache/sentry
D/Sentry ( 8145): Started processing cached files from /data/user/0/XXX.XXX/cache/sentry/outbox
D/Sentry ( 8145): Processing dir. /data/user/0/XXX.XXX/cache/sentry/outbox
D/Sentry ( 8145): Processing 0 items from cache dir /data/user/0/XXX.XXX/cache/sentry/outbox
D/Sentry ( 8145): Finished processing cached files from /data/user/0/XXX.XXX/cache/sentry/outbox
D/Sentry ( 8145): Serializing object: {"sid":"b11b6f0f-04be-49b1-8487-2964ea91684f","did":"cca728fa-613d-447e-8d61-6e5d9a59f08d","started":"2022-01-05T18:57:56.383Z","status":"exited","seq":1641409101106,"duration":24.723,"timestamp":"2022-01-05T18:58:21.106Z","attrs":{"release":"[email protected]+20","environment":"debug"}}
D/Sentry ( 8145): Serializing object: {"sid":"0fcaba4c-a91c-416e-b3ad-74bb3a15ad82","did":"cca728fa-613d-447e-8d61-6e5d9a59f08d","init":true,"started":"2022-01-05T18:58:21.021Z","status":"ok","timestamp":"2022-01-05T18:58:21.021Z","attrs":{"release":"[email protected]+20","environment":"debug"}}
D/Sentry ( 8145): Serializing object: {"sid":"0fcaba4c-a91c-416e-b3ad-74bb3a15ad82","did":"cca728fa-613d-447e-8d61-6e5d9a59f08d","init":true,"started":"2022-01-05T18:58:21.021Z","status":"ok","timestamp":"2022-01-05T18:58:21.021Z","attrs":{"release":"[email protected]+20","environment":"debug"}}
D/Sentry ( 8145): Adding Envelope to offline storage: /data/user/0/XXX.XXX/cache/sentry/fe141b4c-a26b-4eef-b087-a433256253cb.envelope
D/Sentry ( 8145): Envelope sent successfully.
D/Sentry ( 8145): Discarding envelope from cache: /data/user/0/XXX.XXX/cache/sentry/fe141b4c-a26b-4eef-b087-a433256253cb.envelope
D/Sentry ( 8145): Envelope flushed

Pass `UserContext` information into Android/iOS

Thanks for the lib!

Is your feature request related to a problem? Please describe.
In flutter, we can do FlutterSentry.instance.userContext = xxx, so when exception happens in Flutter, we can see who the user is in Sentry.
However, in native android/ios exceptions, we do not have this feature yet. So I would appreciate it if this could be implemented.

Describe the solution you'd like
For example, by using a platform call from flutter into native which sets the user context.

Describe alternatives you've considered
N/A

Additional context
N/A

Maybe FlutterSentry.wrap() can await for the async inner function?

Describe the bug

Thanks for the library!

When reading the source code, I find FlutterSentry.wrap() doing things like -

T wrap(T Function() f){
    return runZoned<T>(() {
        ...
        return f();
    });
}

However, IMHO, in most of the cases, the f is async function. Thus I propose to do -

Future<T> wrap(Future<T> Function() f) async {
    return await runZoned<T>(() {
        ...
        return await f();
    });
}

(notice the await and the Futures)

To Reproduce
N/A

Expected behavior
N/A

Screenshots
N/A

Web (If applicable):
N/A

Smartphone (If applicable):
N/A

Additional context
N/A

Add pre-execute hook for `captureException`

Is your feature request related to a problem? Please describe.
When an exception occurs, the captureException will report to sentry. However, I need to transform or swallow the exception captured.

For example, a MobXCaughtException itself does not print something useful, and I actually need to extract the "inner" exception (which by default is not printed). As another example, a ApiException (e.g. 404) does not need to be reported.

Describe the solution you'd like
Change captureException to something like:


ExceptionAndStackTrace Function(Exception,StackTrace) exceptionTransformer; // let the users set it

Future<SentryResponse> captureException({
    @required dynamic exception,
    dynamic stackTrace,
    Map<String, dynamic> extra,
  }) {

final transformedExceptionAndStackTrace = exceptionTransformer(exception, stackTrace);

if(transformedExceptionAndStackTrace==null) return null; // swallow it

// ... then deal with exception/stacktrace, not the original one, but the transformed one

...
}

Describe alternatives you've considered
I have read the code without finding methods to do this...

Additional context
N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.