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
@@ -11,28 +11,33 @@ This SDK is **considered experimental and in an alpha state**. It may experience
11
11
12
12
## Pre-requisites
13
13
14
-
`@sentry/feedback` currently can only be used by browsers with [Shadow DOM](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM) support.
14
+
`@sentry-internal/feedback` currently can only be used by browsers with [Shadow DOM](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM) support.
15
15
16
16
## Installation
17
17
18
-
Feedback can be imported from `@sentry/browser`, or a respective SDK package like `@sentry/react` or `@sentry/vue`.
19
-
You don't need to install anything in order to use Feedback. The minimum version that includes Feedback is <<CHANGEME>>.
18
+
During the alpha phase, the feedback integration will need to be imported from `@sentry-internal/feedback`. This will be
19
+
changed for the general release.
20
20
21
-
For details on using Feedback when using Sentry via the CDN bundles, see [CDN bundle](#loading-feedback-as-a-cdn-bundle).
21
+
```shell
22
+
npm add @sentry-internal/feedback
23
+
```
22
24
23
25
## Setup
24
26
25
-
To set up the integration, add the following to your Sentry initialization. Several options are supported and passable via the integration constructor.
26
-
See the [configuration section](#configuration) below for more details.
27
+
To set up the integration, add the following to your Sentry initialization. This will inject a feedback button to the bottom right corner of your application. Users can then click it to open up a feedback form where they can submit feedback.
28
+
29
+
Several options are supported and passable via the integration constructor. See the [configuration section](#configuration) below for more details.
27
30
28
31
```javascript
29
32
import*asSentryfrom'@sentry/browser';
30
-
// or e.g. import * as Sentry from '@sentry/react';
33
+
// or from a framework specific SDK, e.g.
34
+
// import * as Sentry from '@sentry/react';
35
+
importFeedbackfrom'@sentry-internal/feedback';
31
36
32
37
Sentry.init({
33
38
dsn:'__DSN__',
34
39
integrations: [
35
-
newSentry.Feedback({
40
+
newFeedback({
36
41
// Additional SDK configuration goes in here, for example:
37
42
// See below for all available options
38
43
})
@@ -41,59 +46,159 @@ Sentry.init({
41
46
});
42
47
```
43
48
44
-
### Lazy loading Feedback
49
+
## Configuration
50
+
51
+
### General Integration Configuration
45
52
46
-
Feedback will start automatically when you add the integration.
47
-
If you do not want to start Feedback immediately (e.g. if you want to lazy-load it),
48
-
you can also use `addIntegration` to load it later:
53
+
The following options can be configured as options to the integration, in `new Feedback({})`:
49
54
50
-
```js
51
-
import*asSentryfrom"@sentry/react";
52
-
import { BrowserClient } from"@sentry/browser";
55
+
| key | type | default | description |
56
+
| --------- | ------- | ------- | ----------- |
57
+
|`autoInject`|`boolean`|`true`| Injects the Feedback widget into the application when the integration is added. This is useful to turn off if you bring your own button, or only want to show the widget on certain views. |
58
+
|`colorScheme`|`"system" \| "light" \| "dark"`|`"system"`| The color theme to use. `"system"` will follow your OS colorscheme. |
53
59
54
-
Sentry.init({
55
-
// Do not load it initially
56
-
integrations: []
60
+
### User/form Related Configuration
61
+
| key | type | default | description |
62
+
| --------- | ------- | ------- | ----------- |
63
+
|`showName`|`boolean`|`true`| Displays the name field on the feedback form, however will still capture the name (if available) from Sentry SDK context. |
64
+
|`showEmail`|`boolean`|`true`| Displays the email field on the feedback form, however will still capture the email (if available) from Sentry SDK context. |
65
+
|`isAnonymous`|`boolean`|`false`| Hides both name and email fields and does not use Sentry SDK's user context. |
66
+
|`useSentryUser`|`Record<string, string>`|`{ email: 'email', name: 'username'}`| Map of the `email` and `name` fields to the corresponding Sentry SDK user fields that were called with `Sentry.setUser`. |
67
+
68
+
By default the Feedback integration will attempt to fill in the name/email fields if you have set a user context via [`Sentry.setUser`](https://docs.sentry.io/platforms/javascript/enriching-events/identify-user/). By default it expects the email and name fields to be `email` and `username`. Below is an example configuration with non-default user fields.
Most text that you see in the default Feedback widget can be customized.
87
+
88
+
| key | default | description |
89
+
| --------- | ------- | ----------- |
90
+
|`buttonLabel`|`"Feedback"`| The label of the widget button. |
91
+
|`submitButtonLabel`|`"Send Feedback"`| The label of the submit button used in the feedback form dialog. |
92
+
|`cancelButtonLabel`|`"Cancel"`| The label of the cancel button used in the feedback form dialog. |
93
+
|`formTitle`|`"Send Feedback"`| The title at the top of the feedback form dialog. |
94
+
|`nameLabel`|`"Full Name"`| The label of the name input field. |
95
+
|`namePlaceholder`|`"Full Name"`| The placeholder for the name input field. |
96
+
|`emailLabel`|`"Email"`| The label of the email input field. ||
97
+
|`emailPlaceholder`|`"Email"`| The placeholder for the email input field. |
98
+
|`messageLabel`|`"Description"`| The label for the feedback description input field. |
99
+
|`messagePlaceholder`|`"What's the issue? What did you expect?"`| The placeholder for the feedback description input field. |
100
+
|`successMessageText`|`"Thank you for your report!"`| The message to be displayed after a succesful feedback submission. |
101
+
102
+
```javascript
103
+
newFeedback({
104
+
buttonLabel:'Bug Report',
105
+
submitButtonLabel:'Send Report',
106
+
formTitle:'Send Bug Report',
107
+
});
65
108
```
66
109
67
-
### Identifying Users
110
+
### Theme Customization
111
+
Colors can be customized via the Feedback constructor or by defining CSS variables on the widget button. If you use the default widget button, it will have an `id="sentry-feedback`, meaning you can use the `#sentry-feedback` selector to define CSS variables to override.
68
112
69
-
If you have only followed the above instructions to setup session feedbacks, you will only see IP addresses in Sentry's UI. In order to associate a user identity to a session feedback, use [`setUser`](https://docs.sentry.io/platforms/javascript/enriching-events/identify-user/).
|`background`|`--bg-color`|`#ffffff`|`#29232f`| Background color of the widget actor and dialog. |
116
+
|`backgroundHover`|`--bg-hover-color`|`#f6f6f7`|`#352f3b`| The background color of widget actor when in a hover state |
117
+
|`foreground`|`--fg-color`|`#2b2233`|`#ebe6ef`| The foreground color, e.g. text color |
118
+
|`error`|`--error-color`|`#df3338`|`#f55459`| Color used for error related components (e.g. text color when there was an error submitting feedback) |
119
+
|`success`|`--success-color`|`#268d75`|`#2da98c`| Color used for success-related components (e.g. text color when feedback is submitted successfully) |
120
+
|`border`|`--border`|`1.5px solid rgba(41, 35, 47, 0.13)`|`1.5px solid rgba(235, 230, 239, 0.15)`| The border style used for the widget actor and dialog |
121
+
|`boxShadow`|`--box-shadow`|`0px 4px 24px 0px rgba(43, 34, 51, 0.12)`|`0px 4px 24px 0px rgba(43, 34, 51, 0.12)`| The box shadow style used for the widget actor and dialog |
70
122
123
+
Here is an example of customizing only the background color for the light theme using the Feedback constructor configuration.
71
124
```javascript
72
-
import*asSentryfrom"@sentry/browser";
125
+
newFeedback({
126
+
themeLight: {
127
+
background:"#cccccc",
128
+
},
129
+
})
130
+
```
131
+
132
+
Or the same example above but using the CSS variables method:
Similar to theme customization above, these are additional CSS variables that can be overridden. Note these are not supported in the constructor.
78
142
79
-
As an alternative to the NPM package, you can use Feedback as a CDN bundle.
80
-
Please refer to the [Feedback installation guide](https://docs.sentry.io/platforms/javascript/session-feedback/#install) for CDN bundle instructions.
143
+
| Variable | Default | Description |
144
+
| --- | --- | --- |
145
+
|`--bottom`|`1rem`| By default the widget has a position of fixed, and is in the bottom right corner. |
146
+
|`--right`|`1rem`| By default the widget has a position of fixed, and is in the bottom right corner. |
147
+
|`--top`|`auto`| By default the widget has a position of fixed, and is in the bottom right corner. |
148
+
|`--left`|`auto`| By default the widget has a position of fixed, and is in the bottom right corner. |
149
+
|`--z-index`|`100000`| The z-index of the widget |
150
+
|`--font-family`|`"'Helvetica Neue', Arial, sans-serif"`| Default font-family to use|
151
+
|`--font-size`|`14px`| Font size |
81
152
153
+
### Event Callbacks
154
+
Sometimes it’s important to know when someone has started to interact with the feedback form, so you can add custom logging, or start/stop background timers on the page until the user is done.
82
155
83
-
## Configuration
156
+
Pass these callbacks when you initialize the Feedback integration:
84
157
85
-
### General Integration Configuration
158
+
```javascript
159
+
newFeedback({
160
+
onActorClick: () => {},
161
+
onDialogOpen: () => {},
162
+
onDialogClose: () => {},
163
+
onSubmitSuccess: () => {},
164
+
onSubmitError: () => {},
165
+
});
166
+
```
86
167
87
-
The following options can be configured as options to the integration, in `newFeedback({})`:
168
+
## Further Customization
169
+
There are two more methods in the integration that can help customization.
88
170
89
-
| key | type | default | description |
90
-
| --------- | ------- | ------- | ----------- |
91
-
| tbd | boolean | `true` | tbd |
171
+
### Bring Your Own Button
92
172
173
+
You can skip the default widget button and use your own button. Call `feedback.attachTo()` to have the SDK attach a click listener to your own button. You can additionally supply the same customization options that the constructor accepts (e.g. for text labels and colors).
0 commit comments