fluttersentryerror-reporting

Flutter - Sentry how to send event and stop sending in debug mode


How to send specific information in Sentry ? There is Events in documentation but how to use them properly and where exactly to use them (EX: Send user email with the error) ?

Sentry provided this source code but where exactly I have to use it? :

 Sentry.configureScope(
      (scope) => scope.user = SentryUser(id: '1234', email: 'jane.doe@example.com'),
    );

And also how to stop sending reports in debug mode ?


Solution

  • Just to add an easy way to disable reporting in debugMode for anyone in the future:

    Pass an empty string to the dsn in SentryFlutter.init if it's not in Release or Profile.

    kDebugMode constant is available when importing Foundation

      await SentryFlutter.init(
        (options) {
          options.dsn = kDebugMode ? '' : sentryUrl;
        },
        appRunner: () => runApp(MyApp()),
      );