You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: All Sentry.feedbackIntegration examples include the Sentry.init() statement for clarity (#13247)
* fix: All Sentry.feedbackIntegration examples include the Sentry.init() statement for clarity
* account for getFeedback() possibly returning undefined
Copy file name to clipboardExpand all lines: docs/platforms/javascript/common/user-feedback/configuration/index.mdx
+98-40
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,8 @@ The following options can be configured for the integration in `feedbackIntegrat
28
28
29
29
### Auto-Inject vs. Manual Injection
30
30
31
+
Whether you want to use auto-injection, or manually control things, the integration must first be passed via the `integrations` array into `Sentry.init()`.
32
+
31
33
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.
@@ -95,10 +102,15 @@ The following options can be configured for the integration in `feedbackIntegrat
95
102
Example of customization:
96
103
97
104
```javascript
98
-
feedbackIntegration({
99
-
buttonLabel:"Feedback",
100
-
submitButtonLabel:"Send Feedback",
101
-
formTitle:"Send Feedback",
105
+
Sentry.init({
106
+
dsn:"___PUBLIC_DSN___",
107
+
integrations: [
108
+
Sentry.feedbackIntegration({
109
+
buttonLabel:"Feedback",
110
+
submitButtonLabel:"Send Feedback",
111
+
formTitle:"Send Feedback",
112
+
})
113
+
],
102
114
});
103
115
```
104
116
@@ -124,13 +136,18 @@ The example below shows how to customize the background color for the light and
124
136
Alternatively, you can also do the same thing by setting theme values in JavaScript:
125
137
126
138
```javascript
127
-
feedbackIntegration({
128
-
themeLight: {
129
-
background:"#cccccc",
130
-
},
131
-
themeDark: {
132
-
background:"#222222",
133
-
},
139
+
Sentry.init({
140
+
dsn:"___PUBLIC_DSN___",
141
+
integrations: [
142
+
Sentry.feedbackIntegration({
143
+
themeLight: {
144
+
background:"#cccccc",
145
+
},
146
+
themeDark: {
147
+
background:"#222222",
148
+
},
149
+
}),
150
+
],
134
151
});
135
152
```
136
153
@@ -163,19 +180,24 @@ CSS variables take priority over configuration values in `feedbackIntegration()`
163
180
164
181
```html
165
182
<script>
166
-
feedbackIntegration({
167
-
themeLight: {
168
-
foreground:"black",
169
-
},
170
-
themeDark: {
171
-
foreground:"white",
172
-
},
183
+
Sentry.init({
184
+
dsn:"___PUBLIC_DSN___",
185
+
integrations: [
186
+
Sentry.feedbackIntegration({
187
+
themeLight: {
188
+
foreground:"#000",
189
+
},
190
+
themeDark: {
191
+
foreground:"#fff",
192
+
},
193
+
}),
194
+
],
173
195
});
174
196
</script>
175
197
176
198
<style>
177
199
#sentry-feedback {
178
-
--foreground: "red"; /* overrides both `white` and `black` colors*/
200
+
--foreground: "red"; /* overrides both `#fff` and `#000` above*/
179
201
}
180
202
</style>
181
203
```
@@ -186,14 +208,19 @@ It’s possible to set the `id` configuration value to something other than the
186
208
187
209
```html
188
210
<script>
189
-
feedbackIntegration({
190
-
id:"feedback-theme", // The default is 'sentry-feedback'
211
+
Sentry.init({
212
+
dsn:"___PUBLIC_DSN___",
213
+
integrations: [
214
+
Sentry.feedbackIntegration({
215
+
id:"feedback-theme", // The default is 'sentry-feedback'
216
+
}),
217
+
],
191
218
});
192
219
</script>
193
220
194
221
<style>
222
+
/* Target the custom id */
195
223
#feedback-theme {
196
-
/* Target the custom id */
197
224
--foreground: "red";
198
225
}
199
226
</style>
@@ -206,11 +233,16 @@ Because it’s sometimes useful to know when a user started interacting with the
206
233
The following options can be configured for the integration in `feedbackIntegration({})`:
207
234
208
235
```javascript
209
-
feedbackIntegration({
210
-
onFormOpen: () => {},
211
-
onFormClose: () => {},
212
-
onSubmitSuccess: (data:FeedbackFormData) => {},
213
-
onSubmitError: (error:Error) => {},
236
+
Sentry.init({
237
+
dsn:"___PUBLIC_DSN___",
238
+
integrations: [
239
+
Sentry.feedbackIntegration({
240
+
onFormOpen: () => {},
241
+
onFormClose: () => {},
242
+
onSubmitSuccess: (data:FeedbackFormData) => {},
243
+
onSubmitError: (error:Error) => {},
244
+
}),
245
+
],
214
246
});
215
247
```
216
248
@@ -219,17 +251,35 @@ feedbackIntegration({
219
251
You can use your own button instead of the default injected button to trigger the form being displayed, by calling `feedback.attachTo()` to have the SDK attach a click listener to your button. You can also supply the same customization options that the constructor accepts (for example, for text labels and colors).
// Read `getFeedback` on the client only, to avoid hydration errors during server rendering
@@ -257,12 +307,20 @@ function AttachToFeedbackButton() {
257
307
Alternatively, you can call `feedback.createForm()` and have full control over when the form gets loaded, added to the dom, and finally shown to the user.
258
308
259
309
```javascript
260
-
constfeedback=feedbackIntegration({
261
-
// Disable the injection of the default widget
262
-
autoInject:false,
310
+
Sentry.init({
311
+
dsn:"___PUBLIC_DSN___",
312
+
integrations: [
313
+
Sentry.feedbackIntegration({
314
+
// Disable the injection of the default widget
315
+
autoInject:false,
316
+
})
317
+
],
263
318
});
264
319
265
-
constform=awaitfeedback.createForm();
320
+
// Get the instance returned by `feedbackIntegration()`
0 commit comments