1- import { captureFeedback , getCurrentScope , lastEventId } from '@sentry/core' ;
1+ import { captureFeedback , getCurrentScope , lastEventId , logger } from '@sentry/core' ;
22import type { SendFeedbackParams } from '@sentry/types' ;
33import * as React from 'react' ;
44import type { KeyboardTypeOptions } from 'react-native' ;
@@ -19,6 +19,31 @@ import { defaultConfiguration } from './defaults';
1919import defaultStyles from './FeedbackForm.styles' ;
2020import type { FeedbackFormProps , FeedbackFormState , FeedbackFormStyles , FeedbackGeneralConfiguration , FeedbackTextConfiguration } from './FeedbackForm.types' ;
2121
22+ let feedbackFormHandler : ( ( ) => void ) | null = null ;
23+
24+ const setFeedbackFormHandler = ( handler : ( ) => void ) : void => {
25+ feedbackFormHandler = handler ;
26+ } ;
27+
28+ const clearFeedbackFormHandler = ( ) : void => {
29+ feedbackFormHandler = null ;
30+ } ;
31+
32+ type Navigation = {
33+ navigate : ( screen : string , params ?: Record < string , unknown > ) => void ;
34+ } ;
35+
36+ export const showFeedbackForm = ( navigation : Navigation ) : void => {
37+ setFeedbackFormHandler ( ( ) => {
38+ navigation ?. navigate ?.( 'FeedbackForm' ) ;
39+ } ) ;
40+ if ( feedbackFormHandler ) {
41+ feedbackFormHandler ( ) ;
42+ } else {
43+ logger . error ( 'FeedbackForm handler is not set. Please ensure it is initialized.' ) ;
44+ }
45+ } ;
46+
2247/**
2348 * @beta
2449 * Implements a feedback form screen that sends feedback to Sentry using Sentry.captureFeedback.
@@ -45,6 +70,13 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
4570 } ;
4671 }
4772
73+ /**
74+ * Clear the handler when the component unmounts
75+ */
76+ public componentWillUnmount ( ) : void {
77+ clearFeedbackFormHandler ( ) ;
78+ }
79+
4880 public handleFeedbackSubmit : ( ) => void = ( ) => {
4981 const { name, email, description } = this . state ;
5082 const { onFormClose } = this . _config ;
0 commit comments