Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ jobs:
env:
TOTAL: ${{ steps.analysis.outputs.total }}
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }}
# TODO: Once 4.0.0 lands, change to 100
run: |
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
if (( $PERCENTAGE < 90 ))
if (( $PERCENTAGE < 100 ))
then
echo Score too low!
exit 1
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `package:sentry` and `package:sentry-flutter` changelog

## 4.0.0
## 4.0.0-alpha.1

- BREAKING CHANGE: Fixed context screenDensity is of type double #53
- BREAKING CHANGE: Fixed context screenDpi is of type int #58
Expand Down
90 changes: 48 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,29 @@ Add `sentry` dependency to your `pubspec.yaml`:

```yaml
dependencies:
sentry: ">=3.0.1 <4.0.0"
sentry: ^4.0.0
```

In your Dart code, import `package:sentry/sentry.dart` and create a `SentryClient` using the DSN issued by Sentry.io:
In your Dart code, import `package:sentry/sentry.dart` and initialize the Sentry SDK using the DSN issued by Sentry.io:

```dart
import 'package:sentry/sentry.dart';

final SentryClient sentry = new SentryClient(dsn: YOUR_DSN);
Sentry.init((options) => options.dsn = '___PUBLIC_DSN___');
```

In an exception handler, call `captureException()`:

```dart
main() async {
import 'dart:async';
import 'package:sentry/sentry.dart';

void main() async {
try {
doSomethingThatMightThrowAnError();
} catch(error, stackTrace) {
await sentry.captureException(
exception: error,
aMethodThatMightFail();
} catch (exception, stackTrace) {
await Sentry.captureException(
exception,
stackTrace: stackTrace,
);
}
Expand All @@ -83,43 +86,46 @@ main() async {
- Use a `try/catch` block, like in the example above.
- Create a `Zone` with an error handler, e.g. using [runZonedGuarded][run_zoned_guarded].

```dart
var sentry = SentryClient(dsn: "https://...");
// Run the whole app in a zone to capture all uncaught errors.
runZonedGuarded(
() => runApp(MyApp()),
(error, stackTrace) {
try {
sentry.captureException(
exception: error,
stackTrace: stackTrace,
);
print('Error sent to sentry.io: $error');
} catch (e) {
print('Sending report to sentry.io failed: $e');
print('Original error: $error');
}
},
);
```
```dart
import 'dart:async';

import 'package:flutter/material.dart';

import 'package:sentry/sentry.dart';

// Wrap your 'runApp(MyApp())' as follows:

Future<void> main() async {
runZonedGuarded<Future<void>>(() async {
runApp(MyApp());
}, (exception, stackTrace) async {
await Sentry.captureException(
exception,
stackTrace: stackTrace,
);
});
}
```

- For Flutter-specific errors (such as layout failures), use [FlutterError.onError][flutter_error]. For example:

```dart
var sentry = SentryClient(dsn: "https://...");
FlutterError.onError = (details, {bool forceReport = false}) {
try {
sentry.captureException(
exception: details.exception,
stackTrace: details.stack,
);
} catch (e) {
print('Sending report to sentry.io failed: $e');
} finally {
// Also use Flutter's pretty error logging to the device's console.
FlutterError.dumpErrorToConsole(details, forceReport: forceReport);
}
```dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:sentry/sentry.dart';

// Wrap your 'runApp(MyApp())' as follows:

Future<void> main() async {
FlutterError.onError = (FlutterErrorDetails details) async {
await Sentry.captureException(
details.exception,
stackTrace: details.stack,
);
};
```
}
```

- Use `Isolate.current.addErrorListener` to capture uncaught errors
in the root zone.

Expand Down
2 changes: 1 addition & 1 deletion dart/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'event_example.dart';

/// Sends a test exception report to Sentry.io using this Dart client.
Future<void> main() async {
// Change the DSN
// ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io
const dsn =
'https://[email protected]/5428562';

Expand Down
2 changes: 1 addition & 1 deletion dart/example_web/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:sentry/sentry.dart';

import 'event.dart';

// Change the DSN
// ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io
const dsn =
'https://[email protected]/5428562';

Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ library version;
import 'utils.dart';

/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '4.0.0';
const String sdkVersion = '4.0.0-alpha.1';

String get sdkName => isWeb ? _browserSdkName : _ioSdkName;

Expand Down
2 changes: 1 addition & 1 deletion dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sentry
version: 4.0.0
version: 4.0.0-alpha.1
description: >
A crash reporting library for Dart that sends crash reports to Sentry.io.
This library supports Dart Native, and Flutter for mobile, web, and desktop.
Expand Down
1 change: 1 addition & 0 deletions flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:universal_platform/universal_platform.dart';
const String _release =
String.fromEnvironment('SENTRY_RELEASE', defaultValue: 'unknown');

// ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io
const String exampleDsn =
'https://[email protected]/5428562';

Expand Down