Skip to content

Commit 6206e85

Browse files
authored
Fix: captureTransaction should return emptyId when transaction is discarded (#713)
1 parent ea5c733 commit 6206e85

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
22

3+
* Fix: captureTransaction should return emptyId when transaction is discarded (#713)
4+
35
# 6.3.0-beta.3
46

57
* Feat: Auto transactions duration trimming (#702)

dart/lib/src/sentry_client.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class SentryClient {
261261

262262
final id = await captureEnvelope(
263263
SentryEnvelope.fromTransaction(preparedTransaction, _options.sdk));
264-
return id!;
264+
return id ?? SentryId.empty();
265265
}
266266

267267
/// Reports the [envelope] to Sentry.io.

dart/test/sentry_client_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,14 @@ void main() {
346346

347347
expect(capturedEvent['exception'], isNull);
348348
});
349+
350+
test('should return empty for when transaction is discarded', () async {
351+
final client = fixture.getSut(eventProcessor: DropAllEventProcessor());
352+
final tr = SentryTransaction(fixture.tracer);
353+
final id = await client.captureTransaction(tr);
354+
355+
expect(id, SentryId.empty());
356+
});
349357
});
350358

351359
group('SentryClient : apply scope to the captured event', () {

0 commit comments

Comments
 (0)