Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: addBreadcrumb to the Sentry static API (#133)
  • Loading branch information
marandaneto authored Oct 26, 2020
commit 1794f048a02099096eae0b69c2fca6f3ae726803
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Ref: added Transport #123
- Feat: apply sample rate
- Ref: execute before send callback
- Feat: addBreadcrumb on Static API

# `package:sentry` changelog

Expand Down
4 changes: 3 additions & 1 deletion dart/example/event_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ final event = SentryEvent(
ipAddress: '127.0.0.1',
extras: <String, String>{'first-sign-in': '2020-01-01'}),
breadcrumbs: [
Breadcrumb('UI Lifecycle', DateTime.now().toUtc(),
Breadcrumb(
message: 'UI Lifecycle',
timestamp: DateTime.now().toUtc(),
category: 'ui.lifecycle',
type: 'navigation',
data: {'screen': 'MainActivity', 'state': 'created'},
Expand Down
25 changes: 25 additions & 0 deletions dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,31 @@ class Hub {
return sentryId;
}

/// Adds a breacrumb to the current Scope
void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) {
if (!_isEnabled) {
_options.logger(
SentryLevel.warning,
"Instance is disabled and this 'addBreadcrumb' call is a no-op.",
);
} else if (crumb == null) {
_options.logger(
SentryLevel.warning,
'addBreadcrumb called with null parameter.',
);
} else {
final item = _peek();
if (item != null) {
item.scope.addBreadcrumb(crumb, hint: hint);
} else {
_options.logger(
SentryLevel.fatal,
'Stack peek was null when addBreadcrumb',
);
}
}
}

/// Binds a different client to the hub
void bindClient(SentryClient client) {
if (!_isEnabled) {
Expand Down
5 changes: 5 additions & 0 deletions dart/lib/src/noop_hub.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:async';

import 'package:sentry/src/protocol/breadcrumb.dart';

import 'client.dart';
import 'hub.dart';
import 'protocol/sentry_event.dart';
Expand Down Expand Up @@ -54,4 +56,7 @@ class NoOpHub implements Hub {

@override
SentryId get lastEventId => SentryId.empty();

@override
void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) {}
}
6 changes: 3 additions & 3 deletions dart/lib/src/protocol/breadcrumb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import 'sentry_level.dart';
/// * https://docs.sentry.io/development/sdk-dev/event-payloads/breadcrumbs/
class Breadcrumb {
/// Creates a breadcrumb that can be attached to an [Event].
const Breadcrumb(
Breadcrumb({
this.message,
this.timestamp, {
DateTime timestamp,
this.category,
this.data,
this.level = SentryLevel.info,
this.type,
}) : assert(timestamp != null);
}) : timestamp = timestamp ?? getUtcDateTime();

/// Describes the breadcrumb.
///
Expand Down
5 changes: 5 additions & 0 deletions dart/lib/src/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class Sentry {
/// Check if the current Hub is enabled/active.
static bool get isEnabled => currentHub.isEnabled;

/// Adds a breacrumb to the current Scope
static void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) {
currentHub.addBreadcrumb(crumb, hint: hint);
}

static bool _setDefaultConfiguration(SentryOptions options) {
if (options.dsn == null) {
throw ArgumentError.notNull(
Expand Down
11 changes: 7 additions & 4 deletions dart/test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ void main() {
test('$Breadcrumb serializes', () {
expect(
Breadcrumb(
'example log',
DateTime.utc(2019),
message: 'example log',
timestamp: DateTime.utc(2019),
level: SentryLevel.debug,
category: 'test',
).toJson(),
Expand Down Expand Up @@ -63,8 +63,11 @@ void main() {
extras: <String, String>{'foo': 'bar'});

final breadcrumbs = [
Breadcrumb('test log', timestamp,
level: SentryLevel.debug, category: 'test'),
Breadcrumb(
message: 'test log',
timestamp: timestamp,
level: SentryLevel.debug,
category: 'test'),
];

final error = StateError('test-error');
Expand Down
11 changes: 11 additions & 0 deletions dart/test/hub_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ void main() {
true,
);
});

test('should add breadcrumb to current Scope', () {
hub.configureScope((Scope scope) {
expect(0, scope..breadcrumbs.length);
});
hub.addBreadcrumb(Breadcrumb(message: 'test'));
hub.configureScope((Scope scope) {
expect(1, scope..breadcrumbs.length);
expect('test', scope..breadcrumbs.first.message);
});
});
});

group('Hub Client', () {
Expand Down
4 changes: 3 additions & 1 deletion dart/test/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ final fakeEvent = SentryEvent(
ipAddress: '127.0.0.1',
extras: <String, String>{'first-sign-in': '2020-01-01'}),
breadcrumbs: [
Breadcrumb('UI Lifecycle', DateTime.now().toUtc(),
Breadcrumb(
message: 'UI Lifecycle',
timestamp: DateTime.now().toUtc(),
category: 'ui.lifecycle',
type: 'navigation',
data: {'screen': 'MainActivity', 'state': 'created'},
Expand Down
55 changes: 44 additions & 11 deletions dart/test/scope_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ void main() {
test('adds $Breadcrumb', () {
final sut = fixture.getSut();

final breadcrumb = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
sut.addBreadcrumb(breadcrumb);

expect(sut.breadcrumbs.last, breadcrumb);
Expand All @@ -53,7 +56,10 @@ void main() {
beforeBreadcrumbCallback: fixture.beforeBreadcrumbCallback,
);

final breadcrumb = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
sut.addBreadcrumb(breadcrumb);

expect(sut.breadcrumbs.length, 0);
Expand All @@ -71,9 +77,18 @@ void main() {
final maxBreadcrumbs = 2;
final sut = fixture.getSut(maxBreadcrumbs: maxBreadcrumbs);

final breadcrumb1 = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb2 = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb3 = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb1 = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
final breadcrumb2 = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
final breadcrumb3 = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
sut.addBreadcrumb(breadcrumb1);
sut.addBreadcrumb(breadcrumb2);
sut.addBreadcrumb(breadcrumb3);
Expand All @@ -84,9 +99,18 @@ void main() {
test('rotates $Breadcrumb', () {
final sut = fixture.getSut(maxBreadcrumbs: 2);

final breadcrumb1 = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb2 = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb3 = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb1 = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
final breadcrumb2 = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
final breadcrumb3 = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
sut.addBreadcrumb(breadcrumb1);
sut.addBreadcrumb(breadcrumb2);
sut.addBreadcrumb(breadcrumb3);
Expand All @@ -100,7 +124,10 @@ void main() {
final maxBreadcrumbs = 0;
final sut = fixture.getSut(maxBreadcrumbs: maxBreadcrumbs);

final breadcrumb1 = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb1 = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
sut.addBreadcrumb(breadcrumb1);

expect(sut.breadcrumbs.length, maxBreadcrumbs);
Expand All @@ -109,7 +136,10 @@ void main() {
test('clears $Breadcrumb list', () {
final sut = fixture.getSut();

final breadcrumb1 = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb1 = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
sut.addBreadcrumb(breadcrumb1);
sut.clear();

Expand Down Expand Up @@ -153,7 +183,10 @@ void main() {
test('clears $Scope', () {
final sut = fixture.getSut();

final breadcrumb1 = Breadcrumb('test log', DateTime.utc(2019));
final breadcrumb1 = Breadcrumb(
message: 'test log',
timestamp: DateTime.utc(2019),
);
sut.addBreadcrumb(breadcrumb1);

sut.level = SentryLevel.debug;
Expand Down