@@ -331,10 +331,10 @@ class _SentryUserInteractionWidgetState
331
331
return ;
332
332
}
333
333
334
- Map <String , dynamic >? data;
335
- if ((_options ? .sendDefaultPii ?? false ) && info.description.isNotEmpty) {
336
- data = {};
337
- data['label' ] = info. description;
334
+ Map <String , dynamic >? data = {} ;
335
+ final description = _findDescriptionOf ( info.element);
336
+ if (description.isNotEmpty) {
337
+ data['label' ] = description;
338
338
}
339
339
340
340
final crumb = Breadcrumb .userInteraction (
@@ -417,42 +417,45 @@ class _SentryUserInteractionWidgetState
417
417
}
418
418
419
419
String _findDescriptionOf (Element element) {
420
- final widget = element.widget;
421
- final allowText = widget is ButtonStyleButton ||
422
- widget is MaterialButton ||
423
- widget is CupertinoButton ;
424
420
var description = '' ;
425
421
426
- // traverse tree to find a suiting element
427
- void descriptionFinder (Element element) {
428
- bool foundDescription = false ;
429
-
422
+ if (_options? .sendDefaultPii ?? false ) {
430
423
final widget = element.widget;
431
- if (allowText && widget is Text ) {
432
- final data = widget.data;
433
- if (data != null && data.isNotEmpty) {
434
- description = data;
435
- foundDescription = true ;
436
- }
437
- } else if (widget is Semantics ) {
438
- if (widget.properties.label? .isNotEmpty ?? false ) {
439
- description = widget.properties.label! ;
440
- foundDescription = true ;
424
+ final allowText = widget is ButtonStyleButton ||
425
+ widget is MaterialButton ||
426
+ widget is CupertinoButton ;
427
+
428
+ // traverse tree to find a suiting element
429
+ void descriptionFinder (Element element) {
430
+ bool foundDescription = false ;
431
+
432
+ final widget = element.widget;
433
+ if (allowText && widget is Text ) {
434
+ final data = widget.data;
435
+ if (data != null && data.isNotEmpty) {
436
+ description = data;
437
+ foundDescription = true ;
438
+ }
439
+ } else if (widget is Semantics ) {
440
+ if (widget.properties.label? .isNotEmpty ?? false ) {
441
+ description = widget.properties.label! ;
442
+ foundDescription = true ;
443
+ }
444
+ } else if (widget is Icon ) {
445
+ if (widget.semanticLabel? .isNotEmpty ?? false ) {
446
+ description = widget.semanticLabel! ;
447
+ foundDescription = true ;
448
+ }
441
449
}
442
- } else if (widget is Icon ) {
443
- if (widget.semanticLabel? .isNotEmpty ?? false ) {
444
- description = widget.semanticLabel! ;
445
- foundDescription = true ;
450
+
451
+ if (! foundDescription) {
452
+ element.visitChildren (descriptionFinder);
446
453
}
447
454
}
448
455
449
- if (! foundDescription) {
450
- element.visitChildren (descriptionFinder);
451
- }
456
+ element.visitChildren (descriptionFinder);
452
457
}
453
458
454
- element.visitChildren (descriptionFinder);
455
-
456
459
return description;
457
460
}
458
461
@@ -496,7 +499,6 @@ class _SentryUserInteractionWidgetState
496
499
if (type != null ) {
497
500
tappedWidget = UserInteractionInfo (
498
501
element: element,
499
- description: _findDescriptionOf (element),
500
502
type: type,
501
503
);
502
504
}
0 commit comments