Created
October 4, 2020 18:21
-
-
Save mrgulshanyadav/596c21f9adaa2f670a23a126e963469a to your computer and use it in GitHub Desktop.
Sentry Integration example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:sentry/sentry.dart'; | |
final sentry = SentryClient(dsn: "https://[email protected]/1951746"); // change dsn with your own | |
void main() async { | |
runZonedGuarded( | |
() => runApp(MyApp()), | |
(error, stackTrace) async { | |
await sentry.captureException( | |
exception: error, | |
stackTrace: stackTrace, | |
); | |
}, | |
); | |
FlutterError.onError = (details, {bool forceReport = false}) { | |
sentry.captureException( | |
exception: details.exception, | |
stackTrace: details.stack, | |
); | |
}; | |
} | |
class MyApp extends StatefulWidget { | |
@override | |
_MyAppState createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
body: Container(), | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment