diff --git a/CHANGELOG.md b/CHANGELOG.md index 326c337933..a0009e8cb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +* Fix: captureTransaction should return emptyId when transaction is discarded (#713) + # 6.3.0-beta.3 * Feat: Auto transactions duration trimming (#702) diff --git a/dart/lib/src/sentry_client.dart b/dart/lib/src/sentry_client.dart index a976b9b3d7..6e0a870627 100644 --- a/dart/lib/src/sentry_client.dart +++ b/dart/lib/src/sentry_client.dart @@ -261,7 +261,7 @@ class SentryClient { final id = await captureEnvelope( SentryEnvelope.fromTransaction(preparedTransaction, _options.sdk)); - return id!; + return id ?? SentryId.empty(); } /// Reports the [envelope] to Sentry.io. diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 6a9c6fdf31..b6d39958a0 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -346,6 +346,14 @@ void main() { expect(capturedEvent['exception'], isNull); }); + + test('should return empty for when transaction is discarded', () async { + final client = fixture.getSut(eventProcessor: DropAllEventProcessor()); + final tr = SentryTransaction(fixture.tracer); + final id = await client.captureTransaction(tr); + + expect(id, SentryId.empty()); + }); }); group('SentryClient : apply scope to the captured event', () {