Repository navigation
Conversation
Add SentryFlutterOptions.addUserInteractionWidget<T>() and addUserInteractionLabel<T>() so apps can name tappable widgets and label sources the SDK does not know, for example the widgets of the material_ui and cupertino_ui packages. The SDK matches them with type checks on T, so the reported names survive minification and obfuscation. Built-in widget types are checked first and keep their behavior. Text labels are opt-in per type with labelFromText, as for the built-in buttons. A callback that throws is logged and skipped. Co-Authored-By: Claude <noreply@anthropic.com>
Add material_ui and cupertino_ui as dev dependencies so the user interaction tests can pump the real widgets. Resolving them needs Flutter 3.47 or newer. Co-Authored-By: Claude <noreply@anthropic.com>
Resolve conflicts with the 10.0.0 merge: keep the labelFromText plumbing, take the new map syntax, and reformat the touched files in the tall style. Taps now start idle spans by default, so the tracing tests check the streaming span instead of a transaction. Co-Authored-By: Claude <noreply@anthropic.com>
buenaflor
left a comment
There was a problem hiding this comment.
Thanks, this looks good! Two things I'd change:
-
I'd drop
labelFromText. Custom types should just follow the same label rules as the built-in ones (sendDefaultPiifor now, maybe mask-aware later with #3770). Once #3772 lands it'd betrueeverywhere anyway, and it's easier to add a param later than to remove one. -
I think we can drop
addUserInteractionLabeltoo. Both the Material andmaterial_uiTooltipbuild aRawTooltip(semanticsTooltip: message), andRawTooltipis inpackage:flutter/widgets.dart(since 3.44). So if_getLabelchecksRawTooltipinstead ofTooltip, tooltip labels just work without any setup. Without that case I don't see a need for a custom label callback right now.
Drop labelFromText and addUserInteractionLabel, as suggested in review. Added widget types now read Text labels, which matches the planned default for all types. Tooltip labels come from RawTooltip.semanticsTooltip, which both the Flutter and the material_ui Tooltip build, so they work without any setup. Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks, @buenaflor! Both make sense! Done in 521df1a:
I also merged main (10.0.0) and updated the description. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4069 +/- ##
=======================================
Coverage 88.80% 88.81%
=======================================
Files 348 349 +1
Lines 12627 12637 +10
=======================================
+ Hits 11213 11223 +10
Misses 1414 1414
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
buenaflor
left a comment
There was a problem hiding this comment.
Thanks for the changes, looks good to me!
📜 Description
Adds
addUserInteractionWidget<T>(name, isEnabled:)toSentryFlutterOptionsso apps can track taps on widgets the SDK does not recognize. A tap on aT(or a subclass) adds aui.clickbreadcrumb and startsui.action.clicktracing, like the built-in widgets.nameis a plain string, soview.classstays readable in minified and obfuscated builds.sendDefaultPii, andTextinside the widget counts.RawTooltip.semanticsTooltip. Both the Flutter and thematerial_uiTooltipbuild aRawTooltip, somaterial_uitooltips work without setup.userInteractionWidgetTypesSDK feature.excludeFromSemanticsis set orTooltipVisibilityhides tooltips, andrichMessagetooltips now give one.Setup for material_ui and cupertino_ui
💡 Motivation and Context
Flutter is moving Material and Cupertino out of the SDK into
material_uiandcupertino_ui. The classes keep their names but are different types, soSentryUserInteractionWidgetmatches none of them. Apps migrated withdart fix --code=migrate_design_widgetslose all tap breadcrumbs and click spans (#4022).The SDK can't import these packages without raising the minimum Flutter version to 3.47, and type names are not reliable in release builds. So this adds an extension point instead, in the style of
options.privacy.mask<T>().Relates to #4048 and #4022. #3773 (more built-in types) and #3772 (
Textlabels for all types) are related but separate.💚 How did you test it?
material_ui1.6.0 andcupertino_ui1.1.2 widgets, added as dev dependencies only: names, text and tooltip labels, disabled buttons, idle spans, and no crumb by default.sendDefaultPiioff and a throwing callback. Unit tests for the type registry.flutter test,dart analyze --fatal-infos,dart formatanddart doc --dry-runpass on Flutter 3.47.7. The new dev dependencies need Flutter 3.47, which matches.fvmrc.📝 Checklist
sendDefaultPiiis enabled🔮 Next steps
material_uisetup on the user interaction docs page.material_uiandcupertino_uitypes out of the box.Changelog Entry
Add
addUserInteractionWidgettoSentryFlutterOptionsto track taps on widgets the SDK doesn't recognize, like those frommaterial_uiandcupertino_ui. Tooltip labels now come fromRawTooltip, somaterial_uitooltips get labels too.