djangoflow_sentry_reporter 0.2.0 copy "djangoflow_sentry_reporter: ^0.2.0" to clipboard
djangoflow_sentry_reporter: ^0.2.0 copied to clipboard

A library that allows you to report errors to `Sentry` using the `djangoflow_error_reporter` pacakge.

djangoflow_sentry_reporter #

Djangoflow Sentry Reporter is a library that allows you to report errors to Sentry using the DjangoflowErrorReporter class. It is built on top of the sentry_flutter package and provides a simple and easy to use class for reporting errors to Sentry.

Installation #

Add the package to your pubspec.yaml file:

dependencies:
djangoflow_sentry_reporter: <latest_version>
djangoflow_error_reporter: <latest_version> // Add this to use with DjangoflowErrorReporter
sentry_flutter: <latest_version> // Add this if you need other features from Sentry

Then run flutter pub get to install the package.

Usage #

To use the DjangoflowSentryReporter class, you need to create an instance of it by passing your Sentry DSN as a constructor argument.

final sentryReporter = DjangoflowSentryReporter("https://[email protected]/project_id");

Then you can add the DjangoflowSentryReporter class to the DjangoflowErrorReporter class

DjangoflowErrorReporter.instance.addAll([sentryReporter]);

Finally, you can report errors to Sentry by using the DjangoflowErrorReporter.instance.report(e, s) method

try {
// some code that throws an exception
} catch (e, s) {
  DjangoflowErrorReporter.instance.report(exception:e, stackTrace:s); // this will send error through Sentry
}

Enabling error reporting #

To enable the SentryErrorReporter, you can use the enableErrorReporting method of DjangoflowErrorReporter.instance. Disabled by default.

DjangoflowErrorReporter.instance.enableErrorReporting();

Initializing #

You can also initialize the DjangoflowSentryReporter instance by passing env and release values to DjangoflowErrorReporter.instance

DjangoflowErrorReporter.instance.initialize(env: 'production', release: '1.0.0');

Updating user information #

You can update the user information by passing id, email and name values to DjangoflowErrorReporter.instance

DjangoflowErrorReporter.instance.updateUserInformation(id: '123', email: '[email protected]', name: 'John Doe');

Example #

import 'package:djangoflow_sentry_reporter/djangoflow_sentry_reporter.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final sentryReporter = DjangoflowSentryReporter("https://[email protected]/project_id");
    DjangoflowErrorReporter.instance.enableErrorReporting();
    DjangoflowErrorReporter.instance.addAll([sentryReporter]);
    DjangoflowErrorReporter.instance.initialize(env: 'production', release: '1.0.0');
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: RaisedButton(
            onPressed: () {
              try {
                throw Exception('Something went wrong');
              } catch (e, s) {
                DjangoflowErrorReporter.instance.report(exception:e, stackTrace:s);
              }
            },
            child: Text('Throw Exception'),
          ),
        ),
      ),
    );
  }
}
0
likes
130
pub points
39%
popularity

Publisher

verified publisherapexive.com

A library that allows you to report errors to `Sentry` using the `djangoflow_error_reporter` pacakge.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

djangoflow_error_reporter, flutter, sentry_flutter

More

Packages that depend on djangoflow_sentry_reporter