Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Unified API #117

Merged
merged 37 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
163cce7
Merge branch 'main' into feature/unified-api
marandaneto Oct 14, 2020
b91c954
Merge branch 'main' into feature/unified-api
marandaneto Oct 14, 2020
5018978
feat : static SDK main entry withSentry.init(options),... (#108)
rxlabz Oct 14, 2020
d577e35
Feat : add a Hub class (#113)
rxlabz Oct 19, 2020
fabf56f
feat: sentry options (#116)
marandaneto Oct 20, 2020
2b36bec
ref: Hub passes the Scope (#114)
marandaneto Oct 20, 2020
af3ecc0
Refacto : initialize SentryClient with SentryOptions (#118)
rxlabz Oct 20, 2020
19f5592
ref: SentryId generates UUID (#119)
marandaneto Oct 21, 2020
b51b0da
ref: Event now is SentryEvent and added GPU (#121)
marandaneto Oct 22, 2020
3fa0b79
feat: before breadcrumb and scope ref (#122)
marandaneto Oct 22, 2020
2cc1d78
Ref: Hint is passed across Sentry static class, Hub and Client (#124)
marandaneto Oct 22, 2020
11b821b
Ref: Remove stackFrameFilter in favor of beforeSendCallback (#125)
marandaneto Oct 22, 2020
ee737a2
Ref: Sentry init with null and empty DSN and close method (#126)
marandaneto Oct 22, 2020
eab4ccf
Refacto : add a Transport class (#123)
rxlabz Oct 23, 2020
c301ec6
Ref: execute before send callback (#128)
marandaneto Oct 24, 2020
1794f04
feat: addBreadcrumb to the Sentry static API (#133)
marandaneto Oct 26, 2020
e7db5d1
Feat: add lastEventId to the Sentry static API (#134)
marandaneto Oct 26, 2020
dc962ae
Fix: Breadcrumb data should accept serializable types and not only St…
marandaneto Oct 26, 2020
b9cd68b
Fix: NoOp encode for Web (#138)
marandaneto Oct 26, 2020
7b81890
Fix: execute Integrations on Hub creation (#136)
marandaneto Oct 26, 2020
b1761f4
unified api fixes and add web example (#137)
rxlabz Oct 27, 2020
d249c97
Ref/prepare event & scope.applyToEvent (#140)
rxlabz Oct 27, 2020
dc258d9
Ref : rename files accordely to their content (#141)
rxlabz Oct 27, 2020
c6669c3
rename the `throwable` argument to `exception` (#142)
rxlabz Oct 27, 2020
a0bb939
lint : prefer relative imports and show error when a @required argume…
rxlabz Oct 27, 2020
a7ca364
fix: Unified API code review (#144)
marandaneto Oct 28, 2020
56ac62a
Ref : remove dsn from Transport public API (#145)
rxlabz Oct 28, 2020
209f18a
Fix the pubspecs SDK constraints (#146)
rxlabz Oct 28, 2020
108ac6c
fix : throws on invalid dsn (#148)
rxlabz Oct 28, 2020
a81da3e
add comment to change the DSN
marandaneto Oct 28, 2020
c1812b7
update the workflow to run both on vm and on browser (#150)
rxlabz Oct 28, 2020
f597604
Bump sentry sdk to 4.0.0-alpha.1 (#151)
marandaneto Oct 28, 2020
6d9caff
remove TODOs
marandaneto Oct 28, 2020
32debd7
fix the web example pubspec (#153)
rxlabz Oct 28, 2020
c80365f
Ref: remove platform specific clients to use SentryClient (#152)
rxlabz Oct 29, 2020
2ed0f92
fix conflict
marandaneto Oct 29, 2020
c3ab59f
rewrite changelog
marandaneto Oct 29, 2020
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md merge=union
4 changes: 2 additions & 2 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
release-channel: ${{ matrix.sdk }}
- uses: actions/checkout@v2
- run: pub get
- name: Test on Chrome
run: pub run test -p chrome test
- name: Test (VM and browser)
run: pub run test test
- run: dartanalyzer --fatal-warnings ./
- run: dartfmt -n --set-exit-if-changed ./
package-analysis:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ ios/
build/
.cxx/


.test_coverage.dart
dart/coverage/*
31 changes: 30 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,45 @@
- BREAKING CHANGE: `package:http` min version bumped to 0.12.0 #104
- BREAKING CHANGE: replace the `package:usage` by `package:uuid` #94
- BREAKING CHANGE: `Event.message` must now be an instance of `Message`
- BREAKING CHANGE: SentryClient must now be initialized with a SentryOptions #118
- By default no logger it set #63
- Added missing Contexts to Event.copyWith() #62
- remove the `package:args` dependency #94
- move the `package:pedantic` to dev depencies #94
- Added GH Action Changelog verifier #95
- Added GH Action (CI) for Dart
- Added GH Action (CI) for Dart #97
- new Dart code file structure #96
- Base the sdk name on the platform (`sentry.dart` for io & flutter, `sentry.dart.browser` in a browser context) #103
- Single changelog and readme for both packages #105
- new static API : Sentry.init(), Sentry.captureEvent() #108
- expect a sdkName based on the test platform #105
- Added Scope and Breadcrumb ring buffer #109
- Added Hub to SDK #113
- Ref: Hub passes the Scope to SentryClient #114
- Feature: sentry options #116
- Ref: SentryId generates UUID #119
- Ref: Event now is SentryEvent and added GPU #121
- Feat: before breadcrumb and scope ref. #122
- Ref: Sentry init with null and empty DSN and close method #126
- Ref: Hint is passed across Sentry static class, Hub and Client #124
- Ref: Remove stackFrameFilter in favor of beforeSendCallback #125
- Ref: added Transport #123
- Feat: apply sample rate
- Ref: execute before send callback
- Feat: add lastEventId to the Sentry static API
- Feat: addBreadcrumb on Static API
- Add a Dart web example
- Fix: Integrations are executed on Hub creation
- Fix: NoOp encode for Web
- Fix: Breadcrumb data should accept serializable types and not only String values
- Ref: added Scope.applyToEvent
- Ref: rename sdk files accordely to their content
- chore: new analysis options rules
- Ref: rename the `throwable` argument name to `exception` in `captureEvents(...)`
- Ref : remove dsn from Transport public Api
- update the Dart sdk constraint
- fix : throws on invalid dsn
- GH Action ( CI ) run test on vm and on browser

# `package:sentry` changelog

Expand Down
18 changes: 17 additions & 1 deletion dart/analysis_options.yaml
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
77 changes: 77 additions & 0 deletions dart/example/event_example.dart
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',
),
),
);
172 changes: 67 additions & 105 deletions dart/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,133 +3,95 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:sentry/sentry.dart';

import 'event_example.dart';

/// Sends a test exception report to Sentry.io using this Dart client.
Future<void> main(List<String> rawArgs) async {
if (rawArgs.length != 1) {
stderr.writeln(
'Expected exactly one argument, which is the DSN issued by Sentry.io to your project.');
exit(1);
}
Future<void> main() async {
// Change the DSN
const dsn =
'https://[email protected]/5428562';

SentryEvent processTagEvent(SentryEvent event, Object hint) =>
event..tags.addAll({'page-locale': 'en-us'});

Sentry.init((options) => options
..dsn = dsn
..addEventProcessor(processTagEvent));

Sentry.addBreadcrumb(
Breadcrumb(
message: 'Authenticated user',
category: 'auth',
type: 'debug',
data: {
'admin': true,
'permissions': [1, 2, 3]
},
),
);

final dsn = rawArgs.single;
final client = SentryClient(dsn: dsn);
Sentry.configureScope((scope) {
scope
..user = User(
id: '800',
username: 'first-user',
email: '[email protected]',
ipAddress: '127.0.0.1',
extras: <String, String>{'first-sign-in': '2020-01-01'},
)
..fingerprint = ['example-dart']
..transaction = '/example/app'
..level = SentryLevel.warning
..setTag('build', '579')
..setExtra('company-name', 'Dart Inc');
});

print('\nReporting a complete event example: ');

// Sends a full Sentry event payload to show the different parts of the UI.
await captureCompleteExampleEvent(client);
final sentryId = await Sentry.captureEvent(event);

print('Capture event result : SentryId : ${sentryId}');

print('\nCapture message: ');

// Sends a full Sentry event payload to show the different parts of the UI.
final messageSentryId = await Sentry.captureMessage(
'Message 1',
level: SentryLevel.warning,
template: 'Message %s',
params: ['1'],
);

print('Capture message result : SentryId : ${messageSentryId}');

try {
await foo();
await loadConfig();
} catch (error, stackTrace) {
print('\nReporting the following stack trace: ');
print(stackTrace);
final response = await client.captureException(
exception: error,
final sentryId = await Sentry.captureException(
error,
stackTrace: stackTrace,
);

if (response.isSuccessful) {
print('SUCCESS\nid: ${response.eventId}');
} else {
print('FAILURE: ${response.error}');
}
print('Capture exception result : SentryId : ${sentryId}');
} finally {
await client.close();
}
}

Future<void> captureCompleteExampleEvent(SentryClient client) async {
final event = Event(
loggerName: 'main',
serverName: 'server.dart',
release: '1.4.0-preview.1',
environment: 'Test',
message: Message(formatted: 'This is an example Dart event.'),
transaction: '/example/app',
level: SeverityLevel.warning,
tags: const <String, String>{'project-id': '7371'},
extra: const <String, String>{'company-name': 'Dart Inc'},
fingerprint: const <String>['example-dart'],
userContext: 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('UI Lifecycle', DateTime.now().toUtc(),
category: 'ui.lifecycle',
type: 'navigation',
data: {'screen': 'MainActivity', 'state': 'created'},
level: SeverityLevel.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',
)));

final response = await client.captureEvent(event: event);

print('\nReporting a complete event example: ');
if (response.isSuccessful) {
print('SUCCESS\nid: ${response.eventId}');
} else {
print('FAILURE: ${response.error}');
await Sentry.close();
}
}

Future<void> foo() async {
await bar();
Future<void> loadConfig() async {
await parseConfig();
}

Future<void> bar() async {
await baz();
Future<void> parseConfig() async {
await decode();
}

Future<void> baz() async {
Future<void> decode() async {
throw StateError('This is a test error');
}
9 changes: 9 additions & 0 deletions dart/example_web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Files and directories created by pub
.dart_tool/
.packages

# Conventional directory for build outputs
build/

# Directory created by dartdoc
doc/api/
9 changes: 9 additions & 0 deletions dart/example_web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Sentry Dart : web example

```dart
pub get

# run the project ( see https://dart.dev/tools/webdev#serve )
webdev serve --release

```
Loading