Skip to content

Commit 382724f

Browse files
authored
docs(flutter): Update user feedback documentation (#12314)
1 parent f44ba4f commit 382724f

File tree

4 files changed

+55
-13
lines changed

4 files changed

+55
-13
lines changed
Loading

docs/platforms/flutter/user-feedback/index.mdx

+45-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,54 @@ When a user experiences an error, Sentry provides the ability to collect additio
88

99
## User Feedback API
1010

11-
The user feedback API allows you to collect user feedback while utilizing your own UI. You can use the same programming language you have in your app to send user feedback. In this case, the SDK creates the HTTP request so you don't have to deal with posting data via HTTP.
12-
13-
Sentry pairs the feedback with the original event, giving you additional insight into issues. Sentry needs the `eventId` to be able to associate the user feedback to the corresponding event. There are several ways to get the `eventId`:
11+
The user feedback API allows you to collect user feedback while utilizing your own UI. Sentry pairs the feedback with the original event, giving you additional insight into issues. Sentry needs the `associatedEventId` to be able to associate the user feedback to the corresponding event. There are several ways to get the `associatedEventId`:
1412

1513
- use {<PlatformLink to="/configuration/options/#before-send"><PlatformIdentifier name="before-send" /></PlatformLink>}
1614
- use the return value of any method capturing an event.
1715
- use `Sentry.lastEventId` to get the ID of the last event sent.
1816

1917
<PlatformContent includePath="user-feedback/sdk-api-example/" />
18+
19+
## SentryFeedbackWidget
20+
21+
Use the `SentryFeedbackWidget` to let users send feedback data to Sentry.
22+
23+
The widget requests and collects the user's name, email address, and a description of what occurred. When an event identifier is provided, Sentry pairs the feedback with the original event, giving you additional insights into issues. Additionally, you can provide a screenshot that will be sent to Sentry. Learn more about how to enable screenshots in our <PlatformLink to="/enriching-events/screenshots/">Screenshots documentation</PlatformLink>.
24+
25+
The image below provides an example of the widget, though yours may differ depending on your customization:
26+
27+
![SentryFeedbackWidget](./img/flutter_sentry_feedback_widget.png)
28+
29+
### Integration
30+
31+
One possible use for the `SentryFeedbackWidget` is to listen for specific Sentry events in the `beforeSend` callback and show the widget to users.
32+
33+
```dart
34+
// The example uses the `NavigatorState` to present the widget. Adapt as needed to your navigation stack.
35+
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
36+
37+
...
38+
39+
await SentryFlutter.init((options) {
40+
options.beforeSend = (event, hint) async {
41+
// Filter here what kind of events you want users to give you feedback.
42+
43+
final screenshot = await SentryFlutter.captureScreenshot();
44+
45+
final context = navigatorKey.currentContext;
46+
if (context == null) return;
47+
if (context.mounted) {
48+
Navigator.push(
49+
context,
50+
MaterialPageRoute(
51+
builder: (context) => SentryFeedbackWidget(
52+
associatedEventId: event.eventId,
53+
screenshot: screenshot,
54+
),
55+
fullscreenDialog: true,
56+
),
57+
);
58+
}
59+
};
60+
});
61+
```

platform-includes/user-feedback/sdk-api-example/dart.mdx

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ SentryId sentryId = Sentry.captureMessage("My message");
1515
// Option 3: Retrieving SentryId from the beforeSend callback
1616
SentryId sentryId = Sentry.lastEventId;
1717
18-
final userFeedback = SentryUserFeedback(
19-
eventId: sentryId,
20-
comments: 'Hello World!',
21-
18+
final feedback = SentryFeedback(
19+
message: 'Hello World!',
20+
contactEmail: '[email protected]',
2221
name: 'John Doe',
22+
associatedEventId: sentryId,
2323
);
2424
25-
Sentry.captureUserFeedback(userFeedback);
25+
Sentry.captureFeedback(feedback);
2626
```

platform-includes/user-feedback/sdk-api-example/flutter.mdx

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ SentryId sentryId = Sentry.captureMessage("My message");
1515
// Option 3: Retrieving SentryId from the beforeSend callback
1616
SentryId sentryId = Sentry.lastEventId;
1717
18-
final userFeedback = SentryUserFeedback(
19-
eventId: sentryId,
20-
comments: 'Hello World!',
21-
18+
final feedback = SentryFeedback(
19+
message: 'Hello World!',
20+
contactEmail: '[email protected]',
2221
name: 'John Doe',
22+
associatedEventId: sentryId,
2323
);
2424
25-
Sentry.captureUserFeedback(userFeedback);
25+
Sentry.captureFeedback(feedback);
2626
```

0 commit comments

Comments
 (0)