From 386856b4a3bf9348c1b808d60ebd63442110302f Mon Sep 17 00:00:00 2001 From: Simone Stasi Date: Mon, 27 Mar 2023 17:06:12 +0200 Subject: [PATCH 1/3] SentryUserInteractionWidget: add support for PopupMenuButton and PopupMenuItem --- .../sentry_user_interaction_widget.dart | 20 ++++++++- .../sentry_user_interaction_widget_test.dart | 45 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart b/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart index 2e17b39578..f803ddb50d 100644 --- a/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart +++ b/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart @@ -219,7 +219,7 @@ Element? _clickTrackerElement; /// /// It's supported by the most common [Widget], for example: /// [ButtonStyleButton], [MaterialButton], [CupertinoButton], [InkWell], -/// and [IconButton]. +/// [IconButton], [PopupMenuButton] and [PopupMenuItem]. /// Mostly for onPressed, onTap, and onLongPress events /// /// Example on how to set up: @@ -539,6 +539,24 @@ class _SentryUserInteractionWidgetState eventType: 'onPressed', ); } + } else if (widget is PopupMenuButton) { + if (widget.enabled) { + return UserInteractionWidget( + element: element, + description: _findDescriptionOf(element, false), + type: 'PopupMenuButton', + eventType: 'onTap', + ); + } + } else if (widget is PopupMenuItem) { + if (widget.enabled) { + return UserInteractionWidget( + element: element, + description: _findDescriptionOf(element, false), + type: 'PopupMenuItem', + eventType: 'onTap', + ); + } } return null; diff --git a/flutter/test/user_interaction/sentry_user_interaction_widget_test.dart b/flutter/test/user_interaction/sentry_user_interaction_widget_test.dart index 5c6733bb47..e388a5b7f0 100644 --- a/flutter/test/user_interaction/sentry_user_interaction_widget_test.dart +++ b/flutter/test/user_interaction/sentry_user_interaction_widget_test.dart @@ -108,6 +108,42 @@ void main() { expect(crumb?.data?['label'], 'Button 5'); }); }); + + testWidgets('Add crumb for PopupMenuButton', (tester) async { + await tester.runAsync(() async { + final sut = fixture.getSut(); + + await tapMe(tester, sut, 'popup_menu_button'); + + Breadcrumb? crumb; + fixture.hub.configureScope((scope) { + crumb = scope.breadcrumbs.last; + }); + expect(crumb?.category, 'ui.click'); + expect(crumb?.data?['view.id'], 'popup_menu_button'); + expect(crumb?.data?['view.class'], 'PopupMenuButton'); + }); + }); + + testWidgets('Add crumb for PopupMenuItem', (tester) async { + await tester.runAsync(() async { + final sut = fixture.getSut(); + + // open the popup menu and wait for the animation to complete + await tapMe(tester, sut, 'popup_menu_button'); + await tester.pumpAndSettle(); + + await tapMe(tester, sut, 'popup_menu_item_1'); + + Breadcrumb? crumb; + fixture.hub.configureScope((scope) { + crumb = scope.breadcrumbs.last; + }); + expect(crumb?.category, 'ui.click'); + expect(crumb?.data?['view.id'], 'popup_menu_item_1'); + expect(crumb?.data?['view.class'], 'PopupMenuItem'); + }); + }); }); group('$SentryUserInteractionWidget performance', () { @@ -351,6 +387,15 @@ class Page1 extends StatelessWidget { }, child: const Text('Go to page 2'), ), + PopupMenuButton( + key: ValueKey('popup_menu_button'), + itemBuilder: (_) => [ + PopupMenuItem( + key: ValueKey('popup_menu_item_1'), + child: Text('first item'), + ), + ], + ), ], ), ), From 42919d9e120b84a55a1f2b2c05f24cde048e5682 Mon Sep 17 00:00:00 2001 From: Simone Stasi Date: Tue, 28 Mar 2023 11:27:06 +0200 Subject: [PATCH 2/3] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8384ac6e5..07df43f5fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Features - Sanitize sensitive data from URLs (span desc, span data, crumbs, client errors) ([#1327](https://github.com/getsentry/sentry-dart/pull/1327)) +- SentryUserInteractionWidget: add support for PopupMenuButton and PopupMenuItem ([#1361](https://github.com/getsentry/sentry-dart/pull/1361)) ### Dependencies From 9a0921c59e8b6a8df25f2be6a3925baa7eee8b2b Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 28 Mar 2023 12:45:50 +0200 Subject: [PATCH 3/3] fix changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5493054f13..a5ada1a558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,16 @@ # Changelog +## Unreleased + +### Features + +- SentryUserInteractionWidget: add support for PopupMenuButton and PopupMenuItem ([#1361](https://github.com/getsentry/sentry-dart/pull/1361)) + ## 7.3.0 ### Features - Sanitize sensitive data from URLs (span desc, span data, crumbs, client errors) ([#1327](https://github.com/getsentry/sentry-dart/pull/1327)) -- SentryUserInteractionWidget: add support for PopupMenuButton and PopupMenuItem ([#1361](https://github.com/getsentry/sentry-dart/pull/1361)) ### Dependencies