-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from getsentry/feature/unified-api
feature: Unified API
- Loading branch information
Showing
69 changed files
with
3,374 additions
and
965 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CHANGELOG.md merge=union |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,6 @@ ios/ | |
build/ | ||
.cxx/ | ||
|
||
|
||
.test_coverage.dart | ||
dart/coverage/* |
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<p align="center"> | ||
<a href="https://sentry.io" target="_blank" align="center"> | ||
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280"> | ||
</a> | ||
<br /> | ||
</p> | ||
|
||
Sentry SDK for Dart and Flutter | ||
=========== | ||
|
||
##### Usage | ||
|
||
Sign up for a Sentry.io account and get a DSN at http://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'; | ||
Sentry.init((options) => options.dsn = 'https://[email protected]/add-your-dsn-here'); | ||
``` | ||
|
||
In an exception handler, call `captureException()`: | ||
|
||
```dart | ||
import 'dart:async'; | ||
import 'package:sentry/sentry.dart'; | ||
void main() async { | ||
try { | ||
aMethodThatMightFail(); | ||
} catch (exception, stackTrace) { | ||
await Sentry.captureException( | ||
exception, | ||
stackTrace: stackTrace, | ||
); | ||
} | ||
} | ||
``` | ||
|
||
##### Tips for catching errors | ||
|
||
- Use a `try/catch` block, like in the example above. | ||
- Create a `Zone` with an error handler, e.g. using `runZonedGuarded`. | ||
|
||
```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`. For example: | ||
|
||
```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. | ||
|
||
#### Resources | ||
|
||
* [](https://docs.sentry.io/platforms/flutter/) | ||
* [](https://forum.sentry.io/c/sdks) | ||
* [](https://discord.gg/Ww9hbqr) | ||
* [](https://stackoverflow.com/questions/tagged/sentry) | ||
* [](https://twitter.com/intent/follow?screen_name=getsentry) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
include: package:pedantic/analysis_options.yaml | ||
include: package:pedantic/analysis_options.yaml | ||
|
||
analyzer: | ||
errors: | ||
# treat missing required parameters as a warning (not a hint) | ||
missing_required_param: error | ||
# treat missing returns as a warning (not a hint) | ||
missing_return: error | ||
# allow having TODOs in the code | ||
todo: ignore | ||
# allow self-reference to deprecated members (we do this because otherwise we have | ||
# to annotate every member in every test, assert, etc, when we deprecate something) | ||
deprecated_member_use_from_same_package: warning | ||
|
||
linter: | ||
rules: | ||
- prefer_relative_imports |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import 'package:sentry/src/protocol.dart'; | ||
|
||
final event = SentryEvent( | ||
logger: 'main', | ||
serverName: 'server.dart', | ||
release: '1.4.0-preview.1', | ||
environment: 'Test', | ||
message: Message('This is an example Dart event.'), | ||
tags: const <String, String>{'project-id': '7371'}, | ||
extra: const <String, String>{'section': '1'}, | ||
fingerprint: const <String>['example-dart'], | ||
user: const User( | ||
id: '800', | ||
username: 'first-user', | ||
email: '[email protected]', | ||
ipAddress: '127.0.0.1', | ||
extras: <String, String>{'first-sign-in': '2020-01-01'}, | ||
), | ||
breadcrumbs: [ | ||
Breadcrumb( | ||
message: 'UI Lifecycle', | ||
timestamp: DateTime.now().toUtc(), | ||
category: 'ui.lifecycle', | ||
type: 'navigation', | ||
data: {'screen': 'MainActivity', 'state': 'created'}, | ||
level: SentryLevel.info, | ||
) | ||
], | ||
contexts: Contexts( | ||
operatingSystem: const OperatingSystem( | ||
name: 'Android', | ||
version: '5.0.2', | ||
build: 'LRX22G.P900XXS0BPL2', | ||
kernelVersion: | ||
'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016', | ||
rooted: false, | ||
), | ||
runtimes: [const Runtime(name: 'ART', version: '5')], | ||
app: App( | ||
name: 'Example Dart App', | ||
version: '1.42.0', | ||
identifier: 'HGT-App-13', | ||
build: '93785', | ||
buildType: 'release', | ||
deviceAppHash: '5afd3a6', | ||
startTime: DateTime.now().toUtc(), | ||
), | ||
browser: const Browser(name: 'Firefox', version: '42.0.1'), | ||
device: Device( | ||
name: 'SM-P900', | ||
family: 'SM-P900', | ||
model: 'SM-P900 (LRX22G)', | ||
modelId: 'LRX22G', | ||
arch: 'armeabi-v7a', | ||
batteryLevel: 99, | ||
orientation: Orientation.landscape, | ||
manufacturer: 'samsung', | ||
brand: 'samsung', | ||
screenResolution: '2560x1600', | ||
screenDensity: 2.1, | ||
screenDpi: 320, | ||
online: true, | ||
charging: true, | ||
lowMemory: true, | ||
simulator: false, | ||
memorySize: 1500, | ||
freeMemory: 200, | ||
usableMemory: 4294967296, | ||
storageSize: 4294967296, | ||
freeStorage: 2147483648, | ||
externalStorageSize: 8589934592, | ||
externalFreeStorage: 2863311530, | ||
bootTime: DateTime.now().toUtc(), | ||
timezone: 'America/Toronto', | ||
), | ||
), | ||
); |
Oops, something went wrong.