| 41 | * Implements a feedback form screen that sends feedback to Sentry using Sentry.captureFeedback. |
| 42 | */ |
| 43 | export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFormState> { |
| 44 | public static defaultProps = defaultConfiguration; |
| 45 | |
| 46 | private static _savedState: Omit<FeedbackFormState, 'isVisible'> = { |
| 47 | name: '', |
| 48 | email: '', |
| 49 | description: '', |
| 50 | filename: undefined, |
| 51 | attachment: undefined, |
| 52 | attachmentUri: undefined, |
| 53 | }; |
| 54 | |
| 55 | private _themeListener: NativeEventSubscription | undefined; |
| 56 | |
| 57 | private _didSubmitForm: boolean = false; |
| 58 | |
| 59 | public constructor(props: FeedbackFormProps) { |
| 60 | super(props); |
| 61 | |
| 62 | const currentUser = { |
| 63 | useSentryUser: { |
| 64 | email: this.props?.useSentryUser?.email || this._getUser()?.email || '', |
| 65 | name: this.props?.useSentryUser?.name || this._getUser()?.name || '', |
| 66 | }, |
| 67 | }; |
| 68 | |
| 69 | this.state = { |
| 70 | isVisible: true, |
| 71 | name: FeedbackForm._savedState.name || currentUser.useSentryUser.name, |
| 72 | email: FeedbackForm._savedState.email || currentUser.useSentryUser.email, |
| 73 | description: FeedbackForm._savedState.description || '', |
| 74 | filename: FeedbackForm._savedState.filename || undefined, |
| 75 | attachment: FeedbackForm._savedState.attachment || undefined, |
| 76 | attachmentUri: FeedbackForm._savedState.attachmentUri || undefined, |
| 77 | }; |
| 78 | |
| 79 | lazyLoadFeedbackIntegration(); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * For testing purposes only. |
| 84 | */ |
| 85 | public static reset(): void { |
| 86 | FeedbackForm._savedState = { |
| 87 | name: '', |
| 88 | email: '', |
| 89 | description: '', |
| 90 | filename: undefined, |
| 91 | attachment: undefined, |
| 92 | attachmentUri: undefined, |
| 93 | }; |
| 94 | } |
| 95 | |
| 96 | public handleFeedbackSubmit: () => void = () => { |
| 97 | const { name, email, description } = this.state; |
| 98 | const { onSubmitSuccess, onSubmitError, onFormSubmitted } = this.props; |
| 99 | const text = this.props; |
| 100 |
nothing calls this directly
no test coverage detected