@@ -36,6 +36,20 @@ void main() {
36
36
expect (span.origin, SentryTraceOrigins .autoFile);
37
37
}
38
38
39
+ void _asserBreadcrumb (bool async ) {
40
+ final call = fixture.client.captureTransactionCalls.first;
41
+ final breadcrumb = call.scope? .breadcrumbs.first;
42
+
43
+ expect (breadcrumb? .category, 'file.copy' );
44
+ expect (breadcrumb? .data? ['file.size' ], 7 );
45
+ expect (breadcrumb? .data? ['file.async' ], async );
46
+ expect (breadcrumb? .message, 'testfile.txt' );
47
+ expect (
48
+ (breadcrumb? .data? ['file.path' ] as String )
49
+ .endsWith ('test_resources/testfile.txt' ),
50
+ true );
51
+ }
52
+
39
53
test ('async' , () async {
40
54
final file = File ('test_resources/testfile.txt' );
41
55
@@ -56,6 +70,7 @@ void main() {
56
70
expect (sut.uri.toFilePath (), isNot (newFile.uri.toFilePath ()));
57
71
58
72
_assertSpan (true );
73
+ _asserBreadcrumb (true );
59
74
60
75
await newFile.delete ();
61
76
});
@@ -80,6 +95,7 @@ void main() {
80
95
expect (sut.uri.toFilePath (), isNot (newFile.uri.toFilePath ()));
81
96
82
97
_assertSpan (false );
98
+ _asserBreadcrumb (false );
83
99
84
100
newFile.deleteSync ();
85
101
});
@@ -107,6 +123,20 @@ void main() {
107
123
expect (span.origin, SentryTraceOrigins .autoFile);
108
124
}
109
125
126
+ void _assertBreadcrumb (bool async , {int ? size = 0 }) {
127
+ final call = fixture.client.captureTransactionCalls.first;
128
+ final breadcrumb = call.scope? .breadcrumbs.first;
129
+
130
+ expect (breadcrumb? .category, 'file.write' );
131
+ expect (breadcrumb? .data? ['file.size' ], size);
132
+ expect (breadcrumb? .data? ['file.async' ], async );
133
+ expect (breadcrumb? .message, 'testfile_create.txt' );
134
+ expect (
135
+ (breadcrumb? .data? ['file.path' ] as String )
136
+ .endsWith ('test_resources/testfile_create.txt' ),
137
+ true );
138
+ }
139
+
110
140
test ('async' , () async {
111
141
final file = File ('test_resources/testfile_create.txt' );
112
142
expect (await file.exists (), false );
@@ -126,6 +156,7 @@ void main() {
126
156
expect (await newFile.exists (), true );
127
157
128
158
_assertSpan (true );
159
+ _assertBreadcrumb (true );
129
160
130
161
await newFile.delete ();
131
162
});
@@ -149,6 +180,7 @@ void main() {
149
180
expect (sut.existsSync (), true );
150
181
151
182
_assertSpan (false );
183
+ _assertBreadcrumb (false );
152
184
153
185
sut.deleteSync ();
154
186
});
@@ -176,6 +208,20 @@ void main() {
176
208
expect (span.origin, SentryTraceOrigins .autoFile);
177
209
}
178
210
211
+ void _assertBreadcrumb (bool async , {int ? size = 0 }) {
212
+ final call = fixture.client.captureTransactionCalls.first;
213
+ final breadcrumb = call.scope? .breadcrumbs.first;
214
+
215
+ expect (breadcrumb? .category, 'file.delete' );
216
+ expect (breadcrumb? .data? ['file.size' ], size);
217
+ expect (breadcrumb? .data? ['file.async' ], async );
218
+ expect (breadcrumb? .message, 'testfile_delete.txt' );
219
+ expect (
220
+ (breadcrumb? .data? ['file.path' ] as String )
221
+ .endsWith ('test_resources/testfile_delete.txt' ),
222
+ true );
223
+ }
224
+
179
225
test ('async' , () async {
180
226
final file = File ('test_resources/testfile_delete.txt' );
181
227
await file.create ();
@@ -196,6 +242,7 @@ void main() {
196
242
expect (await newFile.exists (), false );
197
243
198
244
_assertSpan (true );
245
+ _assertBreadcrumb (true );
199
246
});
200
247
201
248
test ('sync' , () async {
@@ -218,6 +265,7 @@ void main() {
218
265
expect (sut.existsSync (), false );
219
266
220
267
_assertSpan (false );
268
+ _assertBreadcrumb (false );
221
269
});
222
270
});
223
271
@@ -243,6 +291,20 @@ void main() {
243
291
expect (span.origin, SentryTraceOrigins .autoFile);
244
292
}
245
293
294
+ void _assertBreadcrumb () {
295
+ final call = fixture.client.captureTransactionCalls.first;
296
+ final breadcrumb = call.scope? .breadcrumbs.first;
297
+
298
+ expect (breadcrumb? .category, 'file.open' );
299
+ expect (breadcrumb? .data? ['file.size' ], 3535 );
300
+ expect (breadcrumb? .data? ['file.async' ], true );
301
+ expect (breadcrumb? .message, 'sentry.png' );
302
+ expect (
303
+ (breadcrumb? .data? ['file.path' ] as String )
304
+ .endsWith ('test_resources/sentry.png' ),
305
+ true );
306
+ }
307
+
246
308
test ('async' , () async {
247
309
final file = File ('test_resources/sentry.png' );
248
310
@@ -261,6 +323,7 @@ void main() {
261
323
await newFile.close ();
262
324
263
325
_assertSpan ();
326
+ _assertBreadcrumb ();
264
327
});
265
328
});
266
329
@@ -286,6 +349,20 @@ void main() {
286
349
expect (span.origin, SentryTraceOrigins .autoFile);
287
350
}
288
351
352
+ void _assertBreadcrumb (String fileName, bool async , {int ? size = 0 }) {
353
+ final call = fixture.client.captureTransactionCalls.first;
354
+ final breadcrumb = call.scope? .breadcrumbs.first;
355
+
356
+ expect (breadcrumb? .category, 'file.read' );
357
+ expect (breadcrumb? .data? ['file.size' ], size);
358
+ expect (breadcrumb? .data? ['file.async' ], async );
359
+ expect (breadcrumb? .message, fileName);
360
+ expect (
361
+ (breadcrumb? .data? ['file.path' ] as String )
362
+ .endsWith ('test_resources/$fileName ' ),
363
+ true );
364
+ }
365
+
289
366
test ('as bytes async' , () async {
290
367
final file = File ('test_resources/sentry.png' );
291
368
@@ -302,6 +379,7 @@ void main() {
302
379
await tr.finish ();
303
380
304
381
_assertSpan ('sentry.png' , true , size: 3535 );
382
+ _assertBreadcrumb ('sentry.png' , true , size: 3535 );
305
383
});
306
384
307
385
test ('as bytes sync' , () async {
@@ -320,6 +398,7 @@ void main() {
320
398
await tr.finish ();
321
399
322
400
_assertSpan ('sentry.png' , false , size: 3535 );
401
+ _assertBreadcrumb ('sentry.png' , false , size: 3535 );
323
402
});
324
403
325
404
test ('lines async' , () async {
@@ -338,6 +417,7 @@ void main() {
338
417
await tr.finish ();
339
418
340
419
_assertSpan ('testfile.txt' , true , size: 7 );
420
+ _assertBreadcrumb ('testfile.txt' , true , size: 7 );
341
421
});
342
422
343
423
test ('lines sync' , () async {
@@ -356,6 +436,7 @@ void main() {
356
436
await tr.finish ();
357
437
358
438
_assertSpan ('testfile.txt' , false , size: 7 );
439
+ _assertBreadcrumb ('testfile.txt' , false , size: 7 );
359
440
});
360
441
361
442
test ('string async' , () async {
@@ -374,6 +455,7 @@ void main() {
374
455
await tr.finish ();
375
456
376
457
_assertSpan ('testfile.txt' , true , size: 7 );
458
+ _assertBreadcrumb ('testfile.txt' , true , size: 7 );
377
459
});
378
460
379
461
test ('string sync' , () async {
@@ -392,6 +474,7 @@ void main() {
392
474
await tr.finish ();
393
475
394
476
_assertSpan ('testfile.txt' , false , size: 7 );
477
+ _assertBreadcrumb ('testfile.txt' , false , size: 7 );
395
478
});
396
479
});
397
480
@@ -416,6 +499,20 @@ void main() {
416
499
expect (span.origin, SentryTraceOrigins .autoFile);
417
500
}
418
501
502
+ void _assertBreadcrumb (bool async , String name) {
503
+ final call = fixture.client.captureTransactionCalls.first;
504
+ final breadcrumb = call.scope? .breadcrumbs.first;
505
+
506
+ expect (breadcrumb? .category, 'file.rename' );
507
+ expect (breadcrumb? .data? ['file.size' ], 0 );
508
+ expect (breadcrumb? .data? ['file.async' ], async );
509
+ expect (breadcrumb? .message, name);
510
+ expect (
511
+ (breadcrumb? .data? ['file.path' ] as String )
512
+ .endsWith ('test_resources/$name ' ),
513
+ true );
514
+ }
515
+
419
516
test ('async' , () async {
420
517
final file = File ('test_resources/old_name.txt' );
421
518
await file.create ();
@@ -438,6 +535,7 @@ void main() {
438
535
expect (sut.uri.toFilePath (), isNot (newFile.uri.toFilePath ()));
439
536
440
537
_assertSpan (true , 'old_name.txt' );
538
+ _assertBreadcrumb (true , 'old_name.txt' );
441
539
442
540
await newFile.delete ();
443
541
});
@@ -464,6 +562,7 @@ void main() {
464
562
expect (sut.uri.toFilePath (), isNot (newFile.uri.toFilePath ()));
465
563
466
564
_assertSpan (false , 'old_name.txt' );
565
+ _assertBreadcrumb (false , 'old_name.txt' );
467
566
468
567
newFile.deleteSync ();
469
568
});
@@ -485,6 +584,14 @@ void main() {
485
584
expect (span.origin, SentryTraceOrigins .autoFile);
486
585
}
487
586
587
+ void _assertBreadcrumb (bool async ) {
588
+ final call = fixture.client.captureTransactionCalls.first;
589
+ final breadcrumb = call.scope? .breadcrumbs.first;
590
+
591
+ expect (breadcrumb? .data? ['file.async' ], async );
592
+ expect (breadcrumb? .data? ['file.path' ], null );
593
+ }
594
+
488
595
test ('does not add file path if sendDefaultPii is disabled async' ,
489
596
() async {
490
597
final file = File ('test_resources/testfile.txt' );
@@ -501,6 +608,7 @@ void main() {
501
608
await tr.finish ();
502
609
503
610
_assertSpan (true );
611
+ _assertBreadcrumb (true );
504
612
});
505
613
506
614
test ('does not add file path if sendDefaultPii is disabled sync' , () async {
@@ -518,6 +626,7 @@ void main() {
518
626
await tr.finish ();
519
627
520
628
_assertSpan (false );
629
+ _assertBreadcrumb (false );
521
630
});
522
631
523
632
test ('add SentryFileTracing integration' , () async {
0 commit comments