diff --git a/CHANGELOG.md b/CHANGELOG.md index bcf0a567b7..3b35b89037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - Feat: addBreadcrumb on Static API # `package:sentry` changelog diff --git a/dart/lib/src/hub.dart b/dart/lib/src/hub.dart index ee6b5cf440..861dfd918b 100644 --- a/dart/lib/src/hub.dart +++ b/dart/lib/src/hub.dart @@ -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. diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index 495c9d1db3..fb1e54e952 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -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; + /// Adds a breacrumb to the current Scope static void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) { currentHub.addBreadcrumb(crumb, hint: hint); diff --git a/dart/test/hub_test.dart b/dart/test/hub_test.dart index 5c164f1d52..42ee5057b1 100644 --- a/dart/test/hub_test.dart +++ b/dart/test/hub_test.dart @@ -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', () {