getsentry / sentry-dart

Sentry SDK for Dart and Flutter
https://sentry.io/for/flutter/
MIT License
761 stars 239 forks source link

Flutter Sentry exception not showing up in the issues of self hosted site. #963

Closed BrendanBasson4 closed 2 years ago

BrendanBasson4 commented 2 years ago

Platform:

IDE:

split-debug-info and obfuscate (Flutter Android or iOS) or CanvasKit (Flutter Web):

Platform installed with:

Output of the command flutter doctor -v below:

[✓] Flutter (Channel unknown, 2.10.2, on Ubuntu 20.04.4 LTS 5.15.0-41-generic, locale en_ZA.UTF-8) • Flutter version 2.10.2 at /home/brendan/snap/flutter/common/flutter • Upstream repository unknown • Framework revision 097d3313d8 (5 months ago), 2022-02-18 19:33:08 -0600 • Engine revision a83ed0e5e3 • Dart version 2.16.1 • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /home/brendan/Android/Sdk • Platform android-31, build-tools 31.0.0 • Java binary at: /snap/android-studio/123/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted.

[✓] Chrome - develop for the web • Chrome at google-chrome

[✓] Android Studio (version 2021.2) • Android Studio at /snap/android-studio/123/android-studio • Flutter plugin version 67.1.2 • Dart plugin version 212.5744 • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code • VS Code at /snap/code/current • Flutter extension version 3.44.0

[✓] Connected device (2 available) • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.134

[✓] HTTP Host Availability • All required HTTP hosts are available

• No issues found!

The version of the SDK (See pubspec.lock): 6.8.0


I have the following issue:

When our app logs an error it does not seem to appear in our self hosted site's issues. We previously ran through sentry's site but since the change no issues seem to be logging. I retested the app with the sentry site and it still works.

Future<void> main() async {
  await Hive.initFlutter();
 //Registering Hive Adapters

  runZonedGuarded(
    () async {
      WidgetsFlutterBinding.ensureInitialized();

      await SentryFlutter.init(
        (options) {
          options.dsn = 'dsn';
          options.sampleRate = 1.0;
          options.enableAutoSessionTracking = true;
        },
      );

      FlutterError.onError = (FlutterErrorDetails errorDetails) async {
        await Sentry.captureException(
          errorDetails.exception,
          stackTrace: errorDetails.stack,
        );
      };

      runApp(
        MultiProvider(
          providers: [
           // Providers
          ],
          child: MaterialApp(
            debugShowCheckedModeBanner: false,
            scaffoldMessengerKey: global.snackbarKey,
            navigatorKey: global.navigatorKey,
            initialRoute: '/',
            routes: {
            // Named Routes
            },
            builder: EasyLoading.init(),
          ),
        ),
      );
    },
    (exception, stackTrace) async {
      await Sentry.captureException(exception, stackTrace: stackTrace);
    },
  );
}
marandaneto commented 2 years ago

@BrendanBasson4 please enable options.debug = true; and check the console.

ueman commented 2 years ago

You can also simplify your init code to the following. That would also catch runZoneGuarded and FlutterErrors. It would also catch errors in the Hive Setup

Future<void> main() async {
  await SentryFlutter.init(
    (options) {
      options.dsn = 'dsn';
      options.sampleRate = 1.0;
      options.enableAutoSessionTracking = true;
    },
    appRunner: () {
      await Hive.initFlutter();
      //Registering Hive Adapters

      runApp(
        MultiProvider(
          providers: [
           // Providers
          ],
          child: MaterialApp(
            debugShowCheckedModeBanner: false,
            scaffoldMessengerKey: global.snackbarKey,
            navigatorKey: global.navigatorKey,
            initialRoute: '/',
            routes: {
            // Named Routes
            },
            builder: EasyLoading.init(),
          ),
        ),
      );
   },
  );
}
BrendanBasson4 commented 2 years ago

Ok so the problem was in my android manifest file needed to add the following:

<application android:usesCleartextTraffic="true">

Seems to work perfectly now, thanks guys.