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
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,7 @@ The following options can be configured for the integration in `feedbackIntegrat

If you have `autoInject: true` a button will be inserted into the page that triggers the form to pop up so the user can enter their feedback. If instead you want to control when this injection happens, call the `feedback.createWidget()` method to get a reference to an `Actor` object, and then call `appendToDom()` to insert it into the page.

```javascript
const feedback = feedbackIntegration({
// Disable injecting the default widget
autoInject: false,
});

// Create and render the button
const widget = feedback.createWidget();

// Later, when it's time to clean up:
widget.removeFromDom();
```
```typescript {tabTitle: NextJS}
function ToggleFeedbackButton() {
const [feedback, setFeedback] = useState();
// Read `getFeedback` on the client only, to avoid hydration errors when server rendering
useEffect(() => {
setFeedback(Sentry.getFeedback());
}, []);

const [widget, setWidget] = useState();
return (
<button
type="button"
onClick={async () => {
if (widget) {
widget.removeFromDom();
setWidget(null);
} else {
setWidget(feedback.createWidget());
}
}}
>
{widget ? "Remove Widget" : "Create Widget"}
</button>
);
}
```

<PlatformContent includePath="user-feedback/manual-injection" />

Read more about how to [use your own UI](#bring-your-own-button) below.

Expand Down Expand Up @@ -257,7 +219,7 @@ You can use your own button instead of the default injected button to trigger th

```javascript
const feedback = feedbackIntegration({
// Disable injecting the default widget
// Disable the injection of the default widget
autoInject: false,
});

Expand All @@ -268,7 +230,7 @@ feedback.attachTo(document.querySelector("#your-button"), {
```typescript {tabTitle: NextJs}
function AttachToFeedbackButton() {
const [feedback, setFeedback] = useState();
// Read `getFeedback` on the client only, to avoid hydration errors when server rendering
// Read `getFeedback` on the client only, to avoid hydration errors during server rendering
useEffect(() => {
setFeedback(Sentry.getFeedback());
}, []);
Expand All @@ -294,7 +256,7 @@ Alternatively, you can call `feedback.createForm()` and have full control over w

```javascript
const feedback = feedbackIntegration({
// Disable injecting the default widget
// Disable the injection of the default widget
autoInject: false,
});

Expand All @@ -305,7 +267,7 @@ form.open();
```typescript {tabTitle: NextJS}
function CreateFeedbackFromButton() {
const [feedback, setFeedback] = useState();
// Read `getFeedback` on the client only, to avoid hydration errors when server rendering
// Read `getFeedback` on the client only, to avoid hydration errors during server rendering
useEffect(() => {
setFeedback(Sentry.getFeedback());
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ You can use your own button instead of the default injected button to trigger th

```javascript
const feedback = feedbackIntegration({
// Disable injecting the default widget
// Disable the injection of the default widget
autoInject: false,
});

Expand Down
12 changes: 12 additions & 0 deletions platform-includes/user-feedback/manual-injection/javascript.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```javascript
const feedback = feedbackIntegration({
// Disable the injection of the default widget
autoInject: false,
});

// Create and render the button
const widget = feedback.createWidget();

// Later, when it's time to clean up:
widget.removeFromDom();
```
Copy link
Member

@ryan953 ryan953 Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably copy this file for javascript.remix.mdx too

i'm not talking about flavors for Vue, Svelte, Solid right now tho.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
```jsx {tabTitle: NextJS}
function ToggleFeedbackButton() {
const [feedback, setFeedback] = useState();
// Read `getFeedback` on the client only, to avoid hydration errors during server rendering
useEffect(() => {
setFeedback(Sentry.getFeedback());
}, []);

const [widget, setWidget] = useState();
return (
<button
type="button"
onClick={async () => {
if (widget) {
widget.removeFromDom();
setWidget(null);
} else {
setWidget(feedback.createWidget());
}
}}
>
{widget ? "Remove Widget" : "Create Widget"}
</button>
);
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
```jsx {tabTitle: React}
function ToggleFeedbackButton() {
const [feedback, setFeedback] = useState();
// Read `getFeedback` on the client only, to avoid hydration errors during server rendering
useEffect(() => {
setFeedback(Sentry.getFeedback());
}, []);

const [widget, setWidget] = useState();
return (
<button
type="button"
onClick={async () => {
if (widget) {
widget.removeFromDom();
setWidget(null);
} else {
setWidget(feedback.createWidget());
}
}}
>
{widget ? "Remove Widget" : "Create Widget"}
</button>
);
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
```jsx {tabTitle: Remix}
function ToggleFeedbackButton() {
const [feedback, setFeedback] = useState();
// Read `getFeedback` on the client only, to avoid hydration errors during server rendering
useEffect(() => {
setFeedback(Sentry.getFeedback());
}, []);

const [widget, setWidget] = useState();
return (
<button
type="button"
onClick={async () => {
if (widget) {
widget.removeFromDom();
setWidget(null);
} else {
setWidget(feedback.createWidget());
}
}}
>
{widget ? "Remove Widget" : "Create Widget"}
</button>
);
}
```
Loading