Skip to content

Commit 12f0b6d

Browse files
committed
Merge branch 'main' into feat/database-breadcrumbs
2 parents 347b8f4 + 21f1bf7 commit 12f0b6d

File tree

9 files changed

+16797
-16072
lines changed

9 files changed

+16797
-16072
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Features
6+
7+
- Breadcrumbs for file I/O operations ([#1649](https://github.com/getsentry/sentry-dart/pull/1649))
8+
9+
### Dependencies
10+
11+
- Enable compatibility with uuid v4 ([#1647](https://github.com/getsentry/sentry-dart/pull/1647))
12+
- Bump Cocoa SDK from v8.11.0 to v8.12.0 ([#1650](https://github.com/getsentry/sentry-dart/pull/1650))
13+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8120)
14+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.11.0...8.12.0)
15+
316
## 7.10.1
417

518
### Enhancements

dart/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
http: '>=0.13.0 <2.0.0'
1616
meta: ^1.3.0
1717
stack_trace: ^1.10.0
18-
uuid: ^3.0.0
18+
uuid: '>=3.0.0 <5.0.0'
1919

2020
dev_dependencies:
2121
mockito: ^5.1.0

file/lib/src/sentry_file.dart

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ import 'version.dart';
215215
typedef Callback<T> = FutureOr<T> Function();
216216

217217
/// The Sentry wrapper for the File IO implementation that creates a span
218-
/// out of the active transaction in the scope.
218+
/// out of the active transaction in the scope and a breadcrumb, which gets
219+
/// added to the hub.
219220
/// The span is started before the operation is executed and finished after.
220221
/// The File tracing isn't available for Web.
221222
///
@@ -228,7 +229,7 @@ typedef Callback<T> = FutureOr<T> Function();
228229
/// final sentryFile = SentryFile(file);
229230
/// // span starts
230231
/// await sentryFile.writeAsString('Hello World');
231-
/// // span finishes
232+
/// // span finishes, adds breadcrumb
232233
/// ```
233234
///
234235
/// All the copy, create, delete, open, rename, read, and write operations are
@@ -425,8 +426,13 @@ class SentryFile implements File {
425426

426427
span?.origin = SentryTraceOrigins.autoFile;
427428
span?.setData('file.async', true);
429+
430+
final Map<String, dynamic> breadcrumbData = {};
431+
breadcrumbData['file.async'] = true;
432+
428433
if (_hub.options.sendDefaultPii) {
429434
span?.setData('file.path', absolute.path);
435+
breadcrumbData['file.path'] = absolute.path;
430436
}
431437
T data;
432438
try {
@@ -453,6 +459,7 @@ class SentryFile implements File {
453459

454460
if (length != null) {
455461
span?.setData('file.size', length);
462+
breadcrumbData['file.size'] = length;
456463
}
457464

458465
span?.status = SpanStatus.ok();
@@ -462,6 +469,14 @@ class SentryFile implements File {
462469
rethrow;
463470
} finally {
464471
await span?.finish();
472+
473+
await _hub.addBreadcrumb(
474+
Breadcrumb(
475+
message: desc,
476+
data: breadcrumbData,
477+
category: operation,
478+
),
479+
);
465480
}
466481
return data;
467482
}
@@ -475,8 +490,12 @@ class SentryFile implements File {
475490
span?.origin = SentryTraceOrigins.autoFile;
476491
span?.setData('file.async', false);
477492

493+
final Map<String, dynamic> breadcrumbData = {};
494+
breadcrumbData['file.async'] = false;
495+
478496
if (_hub.options.sendDefaultPii) {
479497
span?.setData('file.path', absolute.path);
498+
breadcrumbData['file.path'] = absolute.path;
480499
}
481500

482501
T data;
@@ -504,6 +523,7 @@ class SentryFile implements File {
504523

505524
if (length != null) {
506525
span?.setData('file.size', length);
526+
breadcrumbData['file.size'] = length;
507527
}
508528

509529
span?.status = SpanStatus.ok();
@@ -513,6 +533,14 @@ class SentryFile implements File {
513533
rethrow;
514534
} finally {
515535
span?.finish();
536+
537+
_hub.addBreadcrumb(
538+
Breadcrumb(
539+
message: desc,
540+
data: breadcrumbData,
541+
category: operation,
542+
),
543+
);
516544
}
517545
return data;
518546
}

file/test/mock_sentry_client.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ class MockSentryClient with NoSuchMethodProvider implements SentryClient {
1414
SentryTraceContextHeader? traceContext,
1515
}) async {
1616
captureTransactionCalls
17-
.add(CaptureTransactionCall(transaction, traceContext));
17+
.add(CaptureTransactionCall(transaction, traceContext, scope));
1818
return transaction.eventId;
1919
}
2020
}
2121

2222
class CaptureTransactionCall {
2323
final SentryTransaction transaction;
2424
final SentryTraceContextHeader? traceContext;
25+
final Scope? scope;
2526

26-
CaptureTransactionCall(this.transaction, this.traceContext);
27+
CaptureTransactionCall(this.transaction, this.traceContext, this.scope);
2728
}

0 commit comments

Comments
 (0)