Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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: add lastEventId to the Sentry static API

# `package:sentry` changelog

Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Hub {

SentryId _lastEventId = SentryId.empty();

/// Last event id recorded in the current scope
/// Last event id recorded by the Hub
SentryId get lastEventId => _lastEventId;

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

/// Last event id recorded by the current Hub
static SentryId get lastEventId => currentHub.lastEventId;

static bool _setDefaultConfiguration(SentryOptions options) {
if (options.dsn == null) {
throw ArgumentError.notNull(
Expand Down
12 changes: 12 additions & 0 deletions dart/test/hub_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ void main() {
),
).called(1);
});

test('should save the lastEventId', () async {
final event = SentryEvent();
final eventId = event.eventId;
when(client.captureEvent(
event,
scope: anyNamed('scope'),
hint: anyNamed('hint'),
)).thenAnswer((_) => Future.value(event.eventId));
final returnedId = await hub.captureEvent(event);
expect(eventId.toString(), returnedId.toString());
});
});

group('Hub scope', () {
Expand Down