Skip to content

Commit d24cb50

Browse files
authored
Merge pull request #117 from getsentry/feature/unified-api
feature: Unified API
2 parents 48368f8 + c3ab59f commit d24cb50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3374
-965
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGELOG.md merge=union

.github/workflows/dart.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
release-channel: ${{ matrix.sdk }}
3737
- uses: actions/checkout@v2
3838
- run: pub get
39-
- name: Test on Chrome
40-
run: pub run test -p chrome test
39+
- name: Test (VM and browser)
40+
run: pub run test test
4141
- run: dartanalyzer --fatal-warnings ./
4242
- run: dartfmt -n --set-exit-if-changed ./
4343
package-analysis:
@@ -53,10 +53,9 @@ jobs:
5353
env:
5454
TOTAL: ${{ steps.analysis.outputs.total }}
5555
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }}
56-
# TODO: Once 4.0.0 lands, change to 100
5756
run: |
5857
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
59-
if (( $PERCENTAGE < 90 ))
58+
if (( $PERCENTAGE < 100 ))
6059
then
6160
echo Score too low!
6261
exit 1

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ ios/
1515
build/
1616
.cxx/
1717

18+
1819
.test_coverage.dart
20+
dart/coverage/*

CHANGELOG.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# `package:sentry` and `package:sentry-flutter` changelog
22

33
## 4.0.0
4+
- Development
45

5-
- BREAKING CHANGE: Fixed context screenDensity is of type double #53
6-
- BREAKING CHANGE: Fixed context screenDpi is of type int #58
7-
- BREAKING CHANGE: Renamed capture method to captureEvent #64
8-
- BREAKING CHANGE: `package:http` min version bumped to 0.12.0 #104
9-
- BREAKING CHANGE: replace the `package:usage` by `package:uuid` #94
10-
- BREAKING CHANGE: `Event.message` must now be an instance of `Message`
11-
- By default no logger it set #63
12-
- Added missing Contexts to Event.copyWith() #62
13-
- remove the `package:args` dependency #94
14-
- move the `package:pedantic` to dev depencies #94
15-
- Added GH Action Changelog verifier #95
16-
- Added GH Action (CI) for Dart
17-
- new Dart code file structure #96
18-
- Base the sdk name on the platform (`sentry.dart` for io & flutter, `sentry.dart.browser` in a browser context) #103
19-
- Single changelog and readme for both packages #105
20-
- expect a sdkName based on the test platform #105
216

227
# `package:sentry` changelog
238

9+
## 4.0.0-alpha.1
10+
11+
First Release of Sentry's new SDK for Dart/Flutter.
12+
13+
New features not offered by <= v3.0.0:
14+
15+
- Sentry's [Unified API](https://develop.sentry.dev/sdk/unified-api/).
16+
- Complete Sentry [Protocol](https://develop.sentry.dev/sdk/event-payloads/) available.
17+
- Docs and Migration is under review on this [PR](https://github.com/getsentry/sentry-docs/pull/2599)
18+
- For all the breaking changes follow this [PR](https://github.com/getsentry/sentry-dart/pull/117), they'll be soon available on the Migration page.
19+
20+
Packages were released on [pubdev](https://pub.dev/packages/sentry)
21+
22+
We'd love to get feedback and we'll work in getting the GA 4.0.0 out soon.
23+
Until then, the stable SDK offered by Sentry is at version [3.0.1](https://github.com/getsentry/sentry-dart/releases/tag/3.0.1)
24+
2425
## 3.0.1
2526

2627
- Add support for Contexts in Sentry events

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ We also run CI against the Flutter `stable` and `beta` channels so you should be
3939

4040
##### Versions
4141

42-
Versions `3.0.1` and higher support [Flutter][flutter] (mobile, web, desktop),
43-
command-line/server Dart VM, and [AngularDart][angular_sentry].
42+
Versions `3.0.1` and higher support `Flutter` (mobile, web, desktop),
43+
command-line/server Dart VM, and `AngularDart`.
4444

4545
Versions below `3.0.1` are deprecated.
4646

@@ -81,7 +81,7 @@ main() async {
8181
##### Tips for catching errors
8282

8383
- Use a `try/catch` block, like in the example above.
84-
- Create a `Zone` with an error handler, e.g. using [runZonedGuarded][run_zoned_guarded].
84+
- Create a `Zone` with an error handler, e.g. using `runZonedGuarded`.
8585

8686
```dart
8787
var sentry = SentryClient(dsn: "https://...");
@@ -102,7 +102,7 @@ main() async {
102102
},
103103
);
104104
```
105-
- For Flutter-specific errors (such as layout failures), use [FlutterError.onError][flutter_error]. For example:
105+
- For Flutter-specific errors (such as layout failures), use `FlutterError.onError`. For example:
106106

107107
```dart
108108
var sentry = SentryClient(dsn: "https://...");
@@ -129,4 +129,4 @@ main() async {
129129
* [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks)
130130
* [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr)
131131
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](https://stackoverflow.com/questions/tagged/sentry)
132-
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)
132+
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)

dart/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

dart/README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<p align="center">
2+
<a href="https://sentry.io" target="_blank" align="center">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
4+
</a>
5+
<br />
6+
</p>
7+
8+
Sentry SDK for Dart and Flutter
9+
===========
10+
11+
##### Usage
12+
13+
Sign up for a Sentry.io account and get a DSN at http://sentry.io.
14+
15+
In your Dart code, import `package:sentry/sentry.dart` and initialize the Sentry SDK using the DSN issued by Sentry.io:
16+
17+
```dart
18+
import 'package:sentry/sentry.dart';
19+
20+
Sentry.init((options) => options.dsn = 'https://[email protected]/add-your-dsn-here');
21+
```
22+
23+
In an exception handler, call `captureException()`:
24+
25+
```dart
26+
import 'dart:async';
27+
import 'package:sentry/sentry.dart';
28+
29+
void main() async {
30+
try {
31+
aMethodThatMightFail();
32+
} catch (exception, stackTrace) {
33+
await Sentry.captureException(
34+
exception,
35+
stackTrace: stackTrace,
36+
);
37+
}
38+
}
39+
```
40+
41+
##### Tips for catching errors
42+
43+
- Use a `try/catch` block, like in the example above.
44+
- Create a `Zone` with an error handler, e.g. using `runZonedGuarded`.
45+
46+
```dart
47+
import 'dart:async';
48+
49+
import 'package:flutter/material.dart';
50+
51+
import 'package:sentry/sentry.dart';
52+
53+
// Wrap your 'runApp(MyApp())' as follows:
54+
55+
Future<void> main() async {
56+
runZonedGuarded<Future<void>>(() async {
57+
runApp(MyApp());
58+
}, (exception, stackTrace) async {
59+
await Sentry.captureException(
60+
exception,
61+
stackTrace: stackTrace,
62+
);
63+
});
64+
}
65+
```
66+
67+
- For Flutter-specific errors (such as layout failures), use `FlutterError.onError`. For example:
68+
69+
```dart
70+
import 'dart:async';
71+
import 'package:flutter/material.dart';
72+
import 'package:sentry/sentry.dart';
73+
74+
// Wrap your 'runApp(MyApp())' as follows:
75+
76+
Future<void> main() async {
77+
FlutterError.onError = (FlutterErrorDetails details) async {
78+
await Sentry.captureException(
79+
details.exception,
80+
stackTrace: details.stack,
81+
);
82+
};
83+
}
84+
```
85+
86+
- Use `Isolate.current.addErrorListener` to capture uncaught errors
87+
in the root zone.
88+
89+
#### Resources
90+
91+
* [![Documentation](https://img.shields.io/badge/documentation-sentry.io-green.svg)](https://docs.sentry.io/platforms/flutter/)
92+
* [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks)
93+
* [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr)
94+
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](https://stackoverflow.com/questions/tagged/sentry)
95+
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)

dart/analysis_options.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
include: package:pedantic/analysis_options.yaml
1+
include: package:pedantic/analysis_options.yaml
2+
3+
analyzer:
4+
errors:
5+
# treat missing required parameters as a warning (not a hint)
6+
missing_required_param: error
7+
# treat missing returns as a warning (not a hint)
8+
missing_return: error
9+
# allow having TODOs in the code
10+
todo: ignore
11+
# allow self-reference to deprecated members (we do this because otherwise we have
12+
# to annotate every member in every test, assert, etc, when we deprecate something)
13+
deprecated_member_use_from_same_package: warning
14+
15+
linter:
16+
rules:
17+
- prefer_relative_imports

dart/example/event_example.dart

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import 'package:sentry/src/protocol.dart';
2+
3+
final event = SentryEvent(
4+
logger: 'main',
5+
serverName: 'server.dart',
6+
release: '1.4.0-preview.1',
7+
environment: 'Test',
8+
message: Message('This is an example Dart event.'),
9+
tags: const <String, String>{'project-id': '7371'},
10+
extra: const <String, String>{'section': '1'},
11+
fingerprint: const <String>['example-dart'],
12+
user: const User(
13+
id: '800',
14+
username: 'first-user',
15+
16+
ipAddress: '127.0.0.1',
17+
extras: <String, String>{'first-sign-in': '2020-01-01'},
18+
),
19+
breadcrumbs: [
20+
Breadcrumb(
21+
message: 'UI Lifecycle',
22+
timestamp: DateTime.now().toUtc(),
23+
category: 'ui.lifecycle',
24+
type: 'navigation',
25+
data: {'screen': 'MainActivity', 'state': 'created'},
26+
level: SentryLevel.info,
27+
)
28+
],
29+
contexts: Contexts(
30+
operatingSystem: const OperatingSystem(
31+
name: 'Android',
32+
version: '5.0.2',
33+
build: 'LRX22G.P900XXS0BPL2',
34+
kernelVersion:
35+
'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016',
36+
rooted: false,
37+
),
38+
runtimes: [const Runtime(name: 'ART', version: '5')],
39+
app: App(
40+
name: 'Example Dart App',
41+
version: '1.42.0',
42+
identifier: 'HGT-App-13',
43+
build: '93785',
44+
buildType: 'release',
45+
deviceAppHash: '5afd3a6',
46+
startTime: DateTime.now().toUtc(),
47+
),
48+
browser: const Browser(name: 'Firefox', version: '42.0.1'),
49+
device: Device(
50+
name: 'SM-P900',
51+
family: 'SM-P900',
52+
model: 'SM-P900 (LRX22G)',
53+
modelId: 'LRX22G',
54+
arch: 'armeabi-v7a',
55+
batteryLevel: 99,
56+
orientation: Orientation.landscape,
57+
manufacturer: 'samsung',
58+
brand: 'samsung',
59+
screenResolution: '2560x1600',
60+
screenDensity: 2.1,
61+
screenDpi: 320,
62+
online: true,
63+
charging: true,
64+
lowMemory: true,
65+
simulator: false,
66+
memorySize: 1500,
67+
freeMemory: 200,
68+
usableMemory: 4294967296,
69+
storageSize: 4294967296,
70+
freeStorage: 2147483648,
71+
externalStorageSize: 8589934592,
72+
externalFreeStorage: 2863311530,
73+
bootTime: DateTime.now().toUtc(),
74+
timezone: 'America/Toronto',
75+
),
76+
),
77+
);

0 commit comments

Comments
 (0)