Skip to content

Commit 7ea93f3

Browse files
authored
Update user feedback to common (#3467)
* initial refactor to add http method to common * add dotnet * update stale link * modify include directory name * modify dotnet to point to aspnet and aspnetcore as needed * fix broken links
1 parent 0de601c commit 7ea93f3

File tree

18 files changed

+135
-166
lines changed

18 files changed

+135
-166
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Make sure you've got the JavaScript SDK available:
2+
3+
```html
4+
<script
5+
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/bundle.min.js"
6+
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'bundle.min.js', 'sha384-base64') }}"
7+
crossorigin="anonymous"
8+
></script>
9+
```
10+
11+
You'll then need to call `showReportDialog` and pass in the generated event ID.
12+
This event ID is returned from all calls to <PlatformIdentifier
13+
name="capture-event" /> and <PlatformIdentifier name="capture-exception" />.
14+
There is also a function called <PlatformIdentifier name="last-event-id" />
15+
that returns the ID of the most recently sent event.
16+
17+
```html
18+
<script>
19+
Sentry.init({ dsn: "___PUBLIC_DSN___" });
20+
Sentry.showReportDialog({
21+
eventId: "{{ event_id }}",
22+
});
23+
</script>
24+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```java
2+
import io.sentry.Sentry;
3+
import io.sentry.UserFeedback;
4+
5+
SentryId sentryId = Sentry.captureMessage("My message");
6+
7+
UserFeedback userFeedback = new UserFeedback(sentryId);
8+
userFeedback.setComments("It broke.");
9+
userFeedback.setEmail("[email protected]");
10+
userFeedback.setName("John Doe");
11+
Sentry.captureUserFeedback(userFeedback);
12+
```
13+
14+
```kotlin
15+
import io.sentry.Sentry
16+
import io.sentry.UserFeedback
17+
18+
val sentryId = Sentry.captureMessage("My message")
19+
20+
val userFeedback = UserFeedback(sentryId).apply {
21+
comments = "It broke."
22+
23+
name = "John Doe"
24+
}
25+
Sentry.captureUserFeedback(userFeedback)
26+
```

src/platforms/apple/common/enriching-events/user-feedback.mdx renamed to src/includes/user-feedback/sdk-api-example/apple.mdx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
---
2-
title: "User Feedback"
3-
sidebar_order: 105
4-
5-
description: "Learn more about the user feedback API, which provides the ability to collect user information when an event occurs. Sentry pairs the feedback with the original event, giving you additional insight into issues."
6-
---
7-
8-
The user feedback API provides the ability to collect user information when an event occurs. Sentry pairs the feedback with the original event, giving you additional insight into issues.
9-
Sentry needs the `eventId` to be able to associate the user feedback to the corresponding event. To get the `eventId`, for example, you can use the <PlatformLink to="/configuration/options/#before-send">beforeSend</PlatformLink> or the return value of the methods capturing an event.
10-
111
```swift {tabTitle:Swift}
122
import Sentry
133

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```java
2+
import io.sentry.Sentry;
3+
import io.sentry.UserFeedback;
4+
5+
SentryId sentryId = Sentry.captureMessage("My message");
6+
7+
UserFeedback userFeedback = new UserFeedback(sentryId);
8+
userFeedback.setComments("It broke.");
9+
userFeedback.setEmail("[email protected]");
10+
userFeedback.setName("John Doe");
11+
Sentry.captureUserFeedback(userFeedback);
12+
```
13+
14+
```kotlin {tabTitle:Kotlin}
15+
import io.sentry.Sentry
16+
import io.sentry.UserFeedback
17+
18+
val sentryId = Sentry.captureMessage("My message")
19+
20+
val userFeedback = UserFeedback(sentryId).apply {
21+
comments = "It broke."
22+
23+
name = "John Doe"
24+
}
25+
Sentry.captureUserFeedback(userFeedback)
26+
```

src/platforms/android/common/enriching-events/user-feedback.mdx

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/platforms/common/enriching-events/user-feedback.mdx

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,75 @@ title: "User Feedback"
33
sidebar_order: 105
44
redirect_from:
55
- /learn/user-feedback/
6-
description: "Learn more about the embeddable JavaScript widget, which requests and collects the user information when an event occurs. Sentry pairs the feedback with the original event, giving you additional insight into issues."
6+
description: "Learn more about collecting user feedback when an event occurs. Sentry pairs the feedback with the original event, giving you additional insight into issues."
77
notSupported:
8-
- android
9-
- apple
108
- native
11-
- native.breakpad
12-
- native.crashpad
13-
- native.minidumps
14-
- native.wasm
15-
- native.ue4
169
- dart
1710
- flutter
1811
- ruby
1912
---
2013

21-
When a user experiences an error, Sentry provides the ability to collect additional feedback. This type of feedback is useful when you may typically render a plain error page (the classic `500.html`).
14+
When a user experiences an error, Sentry provides the ability to collect additional feedback. You can collect feedback according to the method supported by the SDK.
2215

23-
To collect feedback, use the embeddable JavaScript widget, which requests and collects the user's name, email address, and a description of what occurred. When feedback is provided, Sentry pairs the feedback with the original event, giving you additional insights into issues.
16+
<PlatformSection supported={["java", "apple", "android"]} >
17+
18+
## User Feedback API
19+
20+
The user feedback API provides the ability to collect user information when an event occurs. You can use the same programming languge 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.
21+
22+
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. To get the `eventId`, for example, you can use the <PlatformLink to="/configuration/options/#before-send">beforeSend</PlatformLink> or the return value of the methods capturing an event.
23+
24+
<PlatformContent includePath="user-feedback/sdk-api-example" />
25+
26+
</PlatformSection>
27+
28+
<PlatformSection supported={["dotnet"]}>
29+
30+
## Use the .NET SDK
31+
32+
<Note>
33+
34+
User Feedback for **[ASP.NET](/platforms/dotnet/guides/aspnet/enriching-events/user-feedback/#integration)** or **[ASP.NET Core](/platforms/dotnet/guides/aspnetcore/enriching-events/user-feedback/#integration)** supply integrations specific to supporting those SDKs.
35+
36+
</Note>
37+
38+
You can create a form to collect the user input in your prefered framework, and use the SDK's API to send the information to Sentry. You can also use the widget, as described below. If you'd prefer an alternative to the widget or do not have a JavaScript frontend, you can use this API or a [Web API](/api/projects/submit-user-feedback/).
39+
40+
```csharp {tabTitle:C#}
41+
using Sentry;
42+
43+
var eventId = SentrySdk.CaptureMessage("An event that will receive user feedback.");
44+
45+
SentrySdk.CaptureUserFeedback(eventId, "[email protected]", "It broke.", "The User");
46+
```
47+
48+
```fsharp {tabTitle:F#}
49+
open Sentry
50+
51+
let eventId = SentrySdk.CaptureMessage("An event that will receive user feedback.")
52+
53+
SentrySdk.CaptureUserFeedback(eventId, "[email protected]", "It broke.", "The User")
54+
```
55+
56+
</PlatformSection>
57+
58+
<PlatformSection notSupported={["android", "apple", "java", "native", "dart", "flutter", "ruby"]}>
59+
60+
## Embeddable JavaScript Widget
61+
62+
Our embeddable JavaScript widget is useful when you may typically render a plain error page (the classic `500.html`) on your website.
63+
64+
To collect feedback, the widget requests and collects the user's name, email address, and a description of what occurred. When feedback is provided, Sentry pairs the feedback with the original event, giving you additional insights into issues.
2465

2566
The screenshot below provides an example of the User Feedback widget, though yours may differ depending on your customization:
2667

2768
![An example of a user feedback widget with text boxes for user name, email, and additional details about the break.](user_feedback_widget.png)
2869

29-
## Collecting Feedback
70+
### Integration
3071

3172
To integrate the widget, you'll need to be running version 2.1 or newer of our JavaScript SDK. The widget authenticates with your public DSN, then passes in the Event ID that was generated on your backend.
3273

33-
**If you'd prefer an alternative to the widget or do not have a JavaScript frontend, you can use the [User Feedback API](https://docs.sentry.io/api/projects/post-project-user-reports/).**
34-
35-
<PlatformContent includePath="user-feedback-example-widget" />
74+
<PlatformContent includePath="user-feedback/example-widget" />
3675

3776
## Customizing the Widget
3877

@@ -60,3 +99,9 @@ An override for Sentry’s automatic language detection (e.g. `lang=de`)
6099
| `errorFormEntry` | Some fields were invalid. Please correct the errors and try again. |
61100
| `successMessage` | Your feedback has been sent. Thank you! |
62101
| `onLoad` | n/a |
102+
103+
## User Feedback API
104+
105+
If you'd prefer an alternative to the widget or do not have a JavaScript frontend, you can use the [User Feedback API](/api/projects/submit-user-feedback/).
106+
107+
</PlatformSection>

src/platforms/dotnet/common/enriching-events/user-feedback.mdx

Lines changed: 0 additions & 70 deletions
This file was deleted.
Binary file not shown.

src/platforms/java/common/enriching-events/user-feedback.mdx

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)