1- import { captureFeedback , lastEventId } from '@sentry/core' ;
1+ import { captureFeedback , lastEventId , logger } from '@sentry/core' ;
22import type { SendFeedbackParams } from '@sentry/types' ;
33import * as React from 'react' ;
44import type { KeyboardTypeOptions } from 'react-native' ;
@@ -8,6 +8,31 @@ import { defaultConfiguration } from './defaults';
88import defaultStyles from './FeedbackForm.styles' ;
99import type { FeedbackFormProps , FeedbackFormState , FeedbackFormStyles , FeedbackGeneralConfiguration , FeedbackTextConfiguration } from './FeedbackForm.types' ;
1010
11+ let feedbackFormHandler : ( ( ) => void ) | null = null ;
12+
13+ const setFeedbackFormHandler = ( handler : ( ) => void ) : void => {
14+ feedbackFormHandler = handler ;
15+ } ;
16+
17+ const clearFeedbackFormHandler = ( ) : void => {
18+ feedbackFormHandler = null ;
19+ } ;
20+
21+ type Navigation = {
22+ navigate : ( screen : string , params ?: Record < string , unknown > ) => void ;
23+ } ;
24+
25+ export const showFeedbackForm = ( navigation : Navigation ) : void => {
26+ setFeedbackFormHandler ( ( ) => {
27+ navigation ?. navigate ?.( 'FeedbackForm' ) ;
28+ } ) ;
29+ if ( feedbackFormHandler ) {
30+ feedbackFormHandler ( ) ;
31+ } else {
32+ logger . error ( 'FeedbackForm handler is not set. Please ensure it is initialized.' ) ;
33+ }
34+ } ;
35+
1136/**
1237 * @beta
1338 * Implements a feedback form screen that sends feedback to Sentry using Sentry.captureFeedback.
@@ -25,6 +50,13 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
2550 } ;
2651 }
2752
53+ /**
54+ * Clear the handler when the component unmounts
55+ */
56+ public componentWillUnmount ( ) : void {
57+ clearFeedbackFormHandler ( ) ;
58+ }
59+
2860 public handleFeedbackSubmit : ( ) => void = ( ) => {
2961 const { name, email, description } = this . state ;
3062 const { onFormClose } = { ...defaultConfiguration , ...this . props } ;
0 commit comments