Skip to content

Commit 825f7ee

Browse files
authored
ref(feedback): update JS SDK API example (#12409)
* ref(feedback): update JS SDK API example * Rm fdf * Review comments
1 parent 2b7705b commit 825f7ee

File tree

2 files changed

+19
-5
lines changed
  • docs/platforms/javascript/common/user-feedback
  • platform-includes/user-feedback/sdk-api-example

2 files changed

+19
-5
lines changed

docs/platforms/javascript/common/user-feedback/index.mdx

+4-3
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ The User Feedback widget integrates easily with <PlatformLink to="/session-repla
5151

5252
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.
5353

54-
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. For example, to get the `eventId`, you can use <PlatformLink to="/configuration/options/#before-send"><PlatformIdentifier name="before-send" /></PlatformLink> or the return value of the method capturing an event.
54+
You can optionally pass in an `associatedEventId` to associate user feedback with an error event, giving you additional insight into issues. To get an event ID, you have 2 options:
55+
1. Use the return value of a method capturing an event.
56+
2. Use <PlatformLink to="/configuration/options/#before-send"><PlatformIdentifier name="before-send" /></PlatformLink>{' '}and `Sentry.lastEventId()`.
5557

56-
<PlatformContent includePath="user-feedback/sdk-api-example/" />
5758

58-
Alternatively, you can use the [User Feedback API endpoint](/api/projects/submit-user-feedback/) directly.
59+
<PlatformContent includePath="user-feedback/sdk-api-example/" />
5960

6061
## Crash-Report Modal
6162

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
```javascript
1+
```javascript {tabTitle: JavaScript}
2+
import * as Sentry from "@sentry/browser";
3+
4+
// All feedback fields are optional, except `message`.
5+
const userFeedback = {
6+
name: "John Doe",
7+
8+
message: "I really like your App, thanks!",
9+
};
10+
Sentry.captureFeedback(userFeedback);
11+
```
12+
13+
```javascript {tabTitle: JavaScript with eventId}
214
import * as Sentry from "@sentry/browser";
315

4-
const eventId = Sentry.captureMessage("User Feedback");
16+
const eventId = Sentry.captureException(new Error("Something went wrong!"));
517
// OR: const eventId = Sentry.lastEventId();
618

19+
// All feedback fields are optional, except `message`.
720
const userFeedback = {
821
name: "John Doe",
922

0 commit comments

Comments
 (0)