Skip to content

Commit 57d99e9

Browse files
committed
Loads current user data on form construction
1 parent 6e39119 commit 57d99e9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

packages/core/src/js/feedback/FeedbackForm.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { captureFeedback, lastEventId } from '@sentry/core';
1+
import { captureFeedback, getCurrentScope, lastEventId } from '@sentry/core';
22
import type { SendFeedbackParams } from '@sentry/types';
33
import * as React from 'react';
44
import type { KeyboardTypeOptions } from 'react-native';
@@ -29,7 +29,14 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
2929
public constructor(props: FeedbackFormProps) {
3030
super(props);
3131

32-
this._config = { ...defaultConfiguration, ...props };
32+
const currentUser = {
33+
useSentryUser: {
34+
email: getCurrentScope().getUser().email || '',
35+
name: getCurrentScope().getUser().name || '',
36+
}
37+
}
38+
39+
this._config = { ...defaultConfiguration, ...currentUser, ...props };
3340
this.state = {
3441
isVisible: true,
3542
name: this._config.useSentryUser.name,

packages/core/src/js/feedback/defaults.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getCurrentScope } from '@sentry/core';
21
import { Alert } from 'react-native';
32

43
import type { FeedbackFormProps } from './FeedbackForm.types';
@@ -35,10 +34,6 @@ export const defaultConfiguration: Partial<FeedbackFormProps> = {
3534
isNameRequired: false,
3635
showEmail: true,
3736
showName: true,
38-
useSentryUser: {
39-
email: getCurrentScope().getUser().email || '',
40-
name: getCurrentScope().getUser().name || '',
41-
},
4237

4338
// FeedbackTextConfiguration
4439
cancelButtonLabel: CANCEL_BUTTON_LABEL,

0 commit comments

Comments
 (0)