djangoflow_sentry_reporter

Creator: coderz1093

Last updated:

0 purchases

djangoflow_sentry_reporter Image
djangoflow_sentry_reporter Images

Languages

Categories

Add to Cart

Description:

djangoflow sentry reporter

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
copied to clipboard
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");
copied to clipboard
Then you can add the DjangoflowSentryReporter class to the DjangoflowErrorReporter class
DjangoflowErrorReporter.instance.addAll([sentryReporter]);
copied to clipboard
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
}
copied to clipboard
Enabling error reporting #
To enable the SentryErrorReporter, you can use the enableErrorReporting method of DjangoflowErrorReporter.instance. Disabled by default.
DjangoflowErrorReporter.instance.enableErrorReporting();
copied to clipboard
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');
copied to clipboard
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');
copied to clipboard
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'),
),
),
),
);
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.