11import type { SendFeedbackParams } from '@sentry/core' ;
2- import { captureFeedback , getCurrentScope , lastEventId } from '@sentry/core' ;
2+ import { captureFeedback , getCurrentScope , lastEventId , logger } from '@sentry/core' ;
33import * as React from 'react' ;
44import type { KeyboardTypeOptions } from 'react-native' ;
55import {
@@ -21,6 +21,31 @@ import { defaultConfiguration } from './defaults';
2121import defaultStyles from './FeedbackForm.styles' ;
2222import type { FeedbackFormProps , FeedbackFormState , FeedbackFormStyles , FeedbackGeneralConfiguration , FeedbackTextConfiguration } from './FeedbackForm.types' ;
2323
24+ let feedbackFormHandler : ( ( ) => void ) | null = null ;
25+
26+ const setFeedbackFormHandler = ( handler : ( ) => void ) : void => {
27+ feedbackFormHandler = handler ;
28+ } ;
29+
30+ const clearFeedbackFormHandler = ( ) : void => {
31+ feedbackFormHandler = null ;
32+ } ;
33+
34+ type Navigation = {
35+ navigate : ( screen : string , params ?: Record < string , unknown > ) => void ;
36+ } ;
37+
38+ export const showFeedbackForm = ( navigation : Navigation ) : void => {
39+ setFeedbackFormHandler ( ( ) => {
40+ navigation ?. navigate ?.( 'FeedbackForm' ) ;
41+ } ) ;
42+ if ( feedbackFormHandler ) {
43+ feedbackFormHandler ( ) ;
44+ } else {
45+ logger . error ( 'FeedbackForm handler is not set. Please ensure it is initialized.' ) ;
46+ }
47+ } ;
48+
2449/**
2550 * @beta
2651 * Implements a feedback form screen that sends feedback to Sentry using Sentry.captureFeedback.
@@ -48,6 +73,13 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
4873 } ;
4974 }
5075
76+ /**
77+ * Clear the handler when the component unmounts
78+ */
79+ public componentWillUnmount ( ) : void {
80+ clearFeedbackFormHandler ( ) ;
81+ }
82+
5183 public handleFeedbackSubmit : ( ) => void = ( ) => {
5284 const { name, email, description } = this . state ;
5385 const { onFormClose } = this . props ;
0 commit comments