Skip to content

Commit dbce251

Browse files
authored
Merge pull request #9602 from getsentry/remove-isanonymous
ref(feedback): Remove isAnonymous option from feedback
2 parents 205c1c9 + 76b136f commit dbce251

File tree

9 files changed

+10
-57
lines changed

9 files changed

+10
-57
lines changed

packages/feedback/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ The following options can be configured as options to the integration, in `new F
6565
| --------- | ------- | ------- | ----------- |
6666
| `showName` | `boolean` | `true` | Displays the name field on the feedback form, however will still capture the name (if available) from Sentry SDK context. |
6767
| `showEmail` | `boolean` | `true` | Displays the email field on the feedback form, however will still capture the email (if available) from Sentry SDK context. |
68-
| `isAnonymous` | `boolean` | `false` | Hides both name and email fields and does not use Sentry SDK's user context. |
68+
| `isNameRequired` | `boolean` | `false` | Requires the name field on the feedback form to be filled in. |
69+
| `isEmailRequired` | `boolean` | `false` | Requires the email field on the feedback form to be filled in. |
6970
| `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`. |
7071

7172
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.
@@ -133,7 +134,7 @@ Colors can be customized via the Feedback constructor or by defining CSS variabl
133134
| `submitForegroundHover` | `--submit-foreground-hover` | `#ffffff` | `#ffffff` | Foreground color for the submit button when hovering |
134135
| `cancelBackground` | `--cancel-background` | `transparent` | `transparent` | Background color for the cancel button |
135136
| `cancelBackgroundHover` | `--cancel-background-hover` | `var(--background-hover)` | `var(--background-hover)` | Background color when hovering over the cancel button |
136-
| `cancelBorder` | `--cancel-border` | `var(--border)` | `var(--border)` | Border style for the cancel button |
137+
| `cancelBorder` | `--cancel-border` | `var(--border)` | `var(--border)` | Border style for the cancel button |
137138
| `cancelOutlineFocus` | `--cancel-outline-focus` | `var(--input-outline-focus)` | `var(--input-outline-focus)` | Outline color for the cancel button, in the focused state |
138139
| `cancelForeground` | `--cancel-foreground` | `var(--foreground)` | `var(--foreground)` | Foreground color for the cancel button |
139140
| `cancelForegroundHover` | `--cancel-foreground-hover` | `var(--foreground)` | `var(--foreground)` | Foreground color for the cancel button when hovering |
@@ -270,7 +271,7 @@ document.getElementById('my-feedback-form').addEventListener('submit', (event) =
270271
271272
Note: The following instructions are to be followed in the Sentry product.
272273
273-
If you have Sentry's default issue alert ("Alert me on every new issue") turned on for the project you are setting up User Feedback on, no action is required to have alerting on each user feedback report.
274+
If you have Sentry's default issue alert ("Alert me on every new issue") turned on for the project you are setting up User Feedback on, no action is required to have alerting on each user feedback report.
274275
275276
If you don't have Sentry's default issue alert turned on, follow these steps:
276277

packages/feedback/src/integration.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export class Feedback implements Integration {
8080
email: 'email',
8181
name: 'username',
8282
},
83-
isAnonymous = false,
8483
isEmailRequired = false,
8584
isNameRequired = false,
8685

@@ -120,7 +119,6 @@ export class Feedback implements Integration {
120119
id,
121120
showBranding,
122121
autoInject,
123-
isAnonymous,
124122
isEmailRequired,
125123
isNameRequired,
126124
showEmail,

packages/feedback/src/types/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ export interface FeedbackGeneralConfiguration {
5252
*/
5353
autoInject: boolean;
5454

55-
/**
56-
* If true, will not collect user data (email/name).
57-
*/
58-
isAnonymous: boolean;
59-
6055
/**
6156
* Should the email field be required?
6257
*/

packages/feedback/src/widget/Dialog.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export function Dialog({
4848
isNameRequired,
4949
isEmailRequired,
5050
colorScheme,
51-
isAnonymous,
5251
defaultName,
5352
defaultEmail,
5453
onClosed,
@@ -103,7 +102,6 @@ export function Dialog({
103102
} = Form({
104103
showEmail,
105104
showName,
106-
isAnonymous,
107105
isEmailRequired,
108106
isNameRequired,
109107

packages/feedback/src/widget/Form.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export interface FormComponentProps
77
FeedbackInternalOptions,
88
| 'showName'
99
| 'showEmail'
10-
| 'isAnonymous'
1110
| 'isNameRequired'
1211
| 'isEmailRequired'
1312
| Exclude<keyof FeedbackTextConfiguration, 'buttonLabel' | 'formTitle' | 'successMessageText'>
@@ -59,7 +58,6 @@ export function Form({
5958

6059
showName,
6160
showEmail,
62-
isAnonymous,
6361
isNameRequired,
6462
isEmailRequired,
6563

@@ -166,8 +164,7 @@ export function Form({
166164
[
167165
errorEl,
168166

169-
!isAnonymous &&
170-
showName &&
167+
showName &&
171168
createElement(
172169
'label',
173170
{
@@ -184,10 +181,9 @@ export function Form({
184181
nameEl,
185182
],
186183
),
187-
!isAnonymous && !showName && nameEl,
184+
!showName && nameEl,
188185

189-
!isAnonymous &&
190-
showEmail &&
186+
showEmail &&
191187
createElement(
192188
'label',
193189
{
@@ -204,7 +200,7 @@ export function Form({
204200
emailEl,
205201
],
206202
),
207-
!isAnonymous && !showEmail && emailEl,
203+
!showEmail && emailEl,
208204

209205
createElement(
210206
'label',

packages/feedback/src/widget/createWidget.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function createWidget({
9999
if (!feedback.message) {
100100
emptyField.push(options.messageLabel);
101101
}
102-
if (emptyField.length != 0) {
102+
if (emptyField.length > 0) {
103103
dialog.showError(`Please enter in the following required fields: ${emptyField.join(', ')}`);
104104
return;
105105
}
@@ -159,7 +159,7 @@ export function createWidget({
159159
return;
160160
}
161161

162-
const userKey = !options.isAnonymous && options.useSentryUser;
162+
const userKey = options.useSentryUser;
163163
const scope = getCurrentHub().getScope();
164164
const user = scope && scope.getUser();
165165

@@ -168,7 +168,6 @@ export function createWidget({
168168
showBranding: options.showBranding,
169169
showName: options.showName || options.isNameRequired,
170170
showEmail: options.showEmail || options.isEmailRequired,
171-
isAnonymous: options.isAnonymous,
172171
isNameRequired: options.isNameRequired,
173172
isEmailRequired: options.isEmailRequired,
174173
formTitle: options.formTitle,

packages/feedback/test/widget/Dialog.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ function renderDialog({
99
showName = true,
1010
showEmail = true,
1111
showBranding = false,
12-
isAnonymous = false,
1312
isNameRequired = false,
1413
isEmailRequired = false,
1514
formTitle = 'Feedback',
@@ -29,7 +28,6 @@ function renderDialog({
2928
return Dialog({
3029
formTitle,
3130

32-
isAnonymous,
3331
showName,
3432
showEmail,
3533
isNameRequired,

packages/feedback/test/widget/Form.test.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ type NonNullableFields<T> = {
88
function renderForm({
99
showName = true,
1010
showEmail = true,
11-
isAnonymous = false,
1211
isNameRequired = false,
1312
isEmailRequired = false,
1413
defaultName = 'Foo Bar',
@@ -24,7 +23,6 @@ function renderForm({
2423
...rest
2524
}: Partial<FormComponentProps> = {}) {
2625
return Form({
27-
isAnonymous,
2826
showName,
2927
showEmail,
3028
isNameRequired,
@@ -138,33 +136,4 @@ describe('Form', () => {
138136
name: 'Foo Bar',
139137
});
140138
});
141-
142-
it('does not show name or email inputs for anonymous mode', () => {
143-
const onSubmit = jest.fn();
144-
const formComponent = renderForm({
145-
isNameRequired: true,
146-
isEmailRequired: true,
147-
isAnonymous: true,
148-
onSubmit,
149-
});
150-
const submitEvent = new Event('submit');
151-
152-
expect(formComponent.el).toBeInstanceOf(HTMLFormElement);
153-
const nameInput = formComponent.el.querySelector('[name="name"][type="text"]') as HTMLInputElement;
154-
const emailInput = formComponent.el.querySelector('[name="email"][type="text"]') as HTMLInputElement;
155-
expect(nameInput).toBeNull();
156-
expect(emailInput).toBeNull();
157-
expect(formComponent.el.querySelector('[name="message"]')).not.toBeNull();
158-
159-
const message = formComponent.el.querySelector('[name="message"]') as HTMLTextAreaElement;
160-
message.value = 'Foo (message)';
161-
message.dispatchEvent(new KeyboardEvent('keyup'));
162-
163-
formComponent.el.dispatchEvent(submitEvent);
164-
expect(onSubmit).toHaveBeenCalledWith({
165-
email: '',
166-
message: 'Foo (message)',
167-
name: '',
168-
});
169-
});
170139
});

packages/feedback/test/widget/createWidget.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const DEFAULT_OPTIONS = {
3030
email: 'email',
3131
name: 'username',
3232
},
33-
isAnonymous: false,
3433
isEmailRequired: false,
3534
isNameRequired: false,
3635

0 commit comments

Comments
 (0)