Skip to content

Commit

Permalink
docs(feedback): Example docs on sendFeedback (#9560)
Browse files Browse the repository at this point in the history
  • Loading branch information
billyvg authored Nov 14, 2023
1 parent db127a3 commit 6d42457
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions packages/feedback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ import {BrowserClient, getCurrentHub} from '@sentry/react';
import {Feedback} from '@sentry-internal/feedback';

function MyFeedbackButton() {
const client = hub && getCurrentHub().getClient<BrowserClient>();
const client = getCurrentHub().getClient<BrowserClient>();
const feedback = client?.getIntegration(Feedback);

// Don't render custom feedback button if Feedback integration not installed
Expand All @@ -230,22 +230,40 @@ function MyFeedbackButton() {

### Bring Your Own Widget

You can also bring your own widget and UI and simply pass a feedback object to the `sendFeedback()` function.
You can also bring your own widget and UI and simply pass a feedback object to the `sendFeedback()` function. The `sendFeedback` function accepts two parameters:
* a feedback object with a required `message` property, and additionally, optional `name` and `email` properties
* an options object

```javascript
sendFeedback({
name: 'Jane Doe', // optional
email: '[email protected]', // optional
message: 'This is an example feedback', // required
}, {
includeReplay: true, // optional
})
```

Here is a simple example

```html
<form id="my-feedback-form">
<input name="name" />
<input name="email" />
<textarea name="message" placeholder="What's the issue?" />
</form>
```

```javascript
import {BrowserClient, getCurrentHub} from '@sentry/react';
import {Feedback} from '@sentry-internal/feedback';

<script>
document.getElementById('my-feedback-form').addEventListener('submit', (event) => {
const feedback = getCurrentHub().getClient<BrowserClient>()?.getIntegration(Feedback);
const formData = new FormData(event.currentTarget);
Feedback.sendFeedback(formData);
feedback.sendFeedback(formData);
event.preventDefault();
});
</script>
```
## Alerting on User Feedback Reports
Expand Down

0 comments on commit 6d42457

Please sign in to comment.