Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/flutter/lib/src/feedback/sentry_feedback_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import '../utils/internal_logger.dart';

/// A form for submitting user feedback to Sentry.
class SentryFeedbackForm extends StatefulWidget {
/// An empty [associatedEventId] (e.g. returned when the original event
/// could not be captured) is treated as no association.
SentryFeedbackForm({
super.key,
this.associatedEventId,
SentryId? associatedEventId,
this.screenshot,
@internal Hub? hub,
}) : assert(associatedEventId != const SentryId.empty()),
}) : associatedEventId = associatedEventId == const SentryId.empty()
? null
: associatedEventId,
_hub = hub ?? HubAdapter() {
assert(
_hub.options is SentryFlutterOptions,
Expand Down
42 changes: 42 additions & 0 deletions packages/flutter/test/feedback/sentry_feedback_form_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,48 @@ void main() {
),
).called(1);
});

testWidgets(
'submits feedback without association when associatedEventId is empty',
(tester) async {
await fixture.pumpFeedbackForm(
tester,
(hub) => SentryFeedbackForm(
hub: hub,
associatedEventId: const SentryId.empty(),
),
);

when(
fixture.hub.captureFeedback(
any,
hint: anyNamed('hint'),
withScope: anyNamed('withScope'),
),
).thenAnswer(
(_) async => SentryId.fromId('1988bb1b6f0d4c509e232f0cb9aaeaea'),
);

await tester.enterText(
find.byKey(ValueKey('sentry_feedback_message_textfield')),
"fixture-message",
);
await tester.tap(find.text('Send Bug Report'));
await tester.pumpAndSettle();

verify(
fixture.hub.captureFeedback(
argThat(
predicate<SentryFeedback>(
(feedback) => feedback.associatedEventId == null,
),
),
hint: anyNamed('hint'),
withScope: anyNamed('withScope'),
),
).called(1);
},
);
});

group('$SentryFeedbackForm localization', () {
Expand Down
Loading