Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 0 additions & 18 deletions .idea/sentry.iml

This file was deleted.

4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
sudo: required
addons:
chrome: stable

language: dart
dart:
- stable
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

Google Inc.
Simon Lightfoot <[email protected]>
Hadrien Lejard <[email protected]>
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# package:sentry changelog

## 3.0.0+1

- `pubspec.yaml` and example code clean-up.

## 3.0.0

- Support Web
- `SentryClient` from `package:sentry/sentry.dart` with conditional import
- `SentryBrowserClient` for web from `package:sentry/browser_client.dart`
- `SentryIOClient` for VM and Flutter from `package:sentry/io_client.dart`

## 2.3.1

- Support non-standard port numbers and paths in DSN URL.

## 2.3.0

- Add [breadcrumb](https://docs.sentry.io/development/sdk-dev/event-payloads/breadcrumbs/) support.

## 2.2.0

- Add a `stackFrameFilter` argument to `SentryClient`'s `capture` method (96be842).
Expand Down Expand Up @@ -33,7 +52,7 @@
## 1.0.0

- first and last Dart 1-compatible release (we may fix bugs on a separate branch if there's demand)
- fix code for Dart 2
- fix code for Dart 2

## 0.0.6

Expand Down
61 changes: 52 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

[![Build Status](https://travis-ci.org/flutter/sentry.svg?branch=master)](https://travis-ci.org/flutter/sentry)

Use this library in your Dart programs (Flutter, command-line and (TBD) AngularDart) to report errors thrown by your
program to https://sentry.io error tracking service.
Use this library in your Dart programs (Flutter for mobile, Flutter for web,
command-line, and AngularDart) to report errors thrown by your program to
https://sentry.io error tracking service.

## Versions

`>=0.0.0 <2.0.0` is the range of versions compatible with Dart 1.
Versions `3.0.0` and higher support Flutter for mobile, Flutter for web,
command-line, desktop, and AngularDart.

`>=2.0.0 <3.0.0` is the range of versions compatible with Dart 2.
`>=2.0.0 <3.0.0` is the range of versions that support Flutter for mobile and
Dart VM only.

Versions `<2.0.0` are deprecated.

## Usage

Expand All @@ -19,7 +24,7 @@ Add `sentry` dependency to your `pubspec.yaml`:

```yaml
dependencies:
sentry: any
sentry: >=3.0.0 <4.0.0
```

In your Dart code, import `package:sentry/sentry.dart` and create a `SentryClient` using the DSN issued by Sentry.io:
Expand Down Expand Up @@ -47,10 +52,48 @@ main() async {

## Tips for catching errors

- use a `try/catch` block
- create a `Zone` with an error handler, e.g. using [runZoned][run_zoned]
- in Flutter, use [FlutterError.onError][flutter_error]
- use `Isolate.current.addErrorListener` to capture uncaught errors in the root zone
- Use a `try/catch` block, like in the example above.
- Create a `Zone` with an error handler, e.g. using [runZoned][run_zoned].

```dart
var sentry = SentryClient(dsn: "https://...");
// Run the whole app in a zone to capture all uncaught errors.
runZoned(
() => runApp(MyApp()),
onError: (Object error, StackTrace 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');
}
},
);
```
- 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);
}
};
```
- Use `Isolate.current.addErrorListener` to capture uncaught errors
in the root zone.

[run_zoned]: https://api.dartlang.org/stable/dart-async/runZoned.html
[flutter_error]: https://docs.flutter.io/flutter/foundation/FlutterError/onError.html
Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:pedantic/analysis_options.yaml
12 changes: 12 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# `package:sentry` example

The example in this directory throws an error and sends it to Sentry.io. Use it
as a source of example code, or to smoke-test your Sentry.io configuration.

To use the example, create a Sentry.io account and get a DSN for your project.
Then run the following command, replacing "{DSN}" with the one you got from
Sentry.io:

```
dart example/main.dart {DSN}
```
4 changes: 2 additions & 2 deletions bin/test.dart → example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Future<Null> main(List<String> rawArgs) async {
}

final String dsn = rawArgs.single;
final SentryClient client = new SentryClient(dsn: dsn);
final SentryClient client = SentryClient(dsn: dsn);

try {
await foo();
Expand Down Expand Up @@ -47,5 +47,5 @@ Future<Null> bar() async {
}

Future<Null> baz() async {
throw new StateError('This is a test error');
throw StateError('This is a test error');
}
7 changes: 7 additions & 0 deletions lib/browser_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'src/base.dart';
export 'src/version.dart';
export 'src/browser.dart';
7 changes: 7 additions & 0 deletions lib/io_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'src/base.dart';
export 'src/version.dart';
export 'src/io.dart';
Loading