Skip to content

Commit

Permalink
Adds feedbackIntegration for configuring the feedback form
Browse files Browse the repository at this point in the history
  • Loading branch information
antonis committed Jan 27, 2025
1 parent 8071e8d commit caa1237
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/js/feedback/FeedbackFormManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Modal, View } from 'react-native';
import { FeedbackForm } from './FeedbackForm';
import defaultStyles from './FeedbackForm.styles';
import type { FeedbackFormStyles } from './FeedbackForm.types';
import { getFeedbackOptions } from './integration';
import { isModalSupported } from './utils';

class FeedbackFormManager {
Expand Down Expand Up @@ -70,7 +71,7 @@ class FeedbackFormProvider extends React.Component<FeedbackFormProviderProps> {
<View>
<Modal visible={isVisible} transparent animationType="slide" onRequestClose={this._handleClose} testID="feedback-form-modal">
<View style={styles.modalBackground}>
<FeedbackForm
<FeedbackForm {...getFeedbackOptions()}
onFormClose={this._handleClose}
onFormSubmitted={this._handleClose}
/>
Expand Down
31 changes: 31 additions & 0 deletions packages/core/src/js/feedback/integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Integration } from '@sentry/core';

import { defaultConfiguration } from './defaults';
import defaultStyles from './FeedbackForm.styles';
import type { FeedbackFormProps } from './FeedbackForm.types';

export const FEEDBACK_FORM_INTEGRATION_NAME = 'Feedback Form';

type FeedbackIntegration = Integration & {
options: Partial<FeedbackFormProps>;
};

let savedOptions: Partial<FeedbackFormProps> = {};

export const feedbackIntegration = (initOptions: FeedbackFormProps = {}): FeedbackIntegration => {
savedOptions = {
...defaultConfiguration,
...initOptions,
styles: {
...defaultStyles,
...initOptions.styles,
},
};

return {
name: FEEDBACK_FORM_INTEGRATION_NAME,
options: savedOptions,
};
};

export const getFeedbackOptions = (): Partial<FeedbackFormProps> => savedOptions;
1 change: 1 addition & 0 deletions packages/core/src/js/integrations/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export { viewHierarchyIntegration } from './viewhierarchy';
export { expoContextIntegration } from './expocontext';
export { spotlightIntegration } from './spotlight';
export { mobileReplayIntegration } from '../replay/mobilereplay';
export { feedbackIntegration } from '../feedback/integration';
export { browserReplayIntegration } from '../replay/browserReplay';
export { appStartIntegration } from '../tracing/integrations/appStart';
export { nativeFramesIntegration, createNativeFramesIntegrations } from '../tracing/integrations/nativeFrames';
Expand Down
12 changes: 12 additions & 0 deletions samples/react-native/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ Sentry.init({
? false
: true,
}),
Sentry.feedbackIntegration({
styles:{
submitButton: {
backgroundColor: '#6a1b9a',
paddingVertical: 15,
borderRadius: 5,
alignItems: 'center',
marginBottom: 10,
},
},
namePlaceholder: 'Fullname',
}),
);
return integrations.filter(i => i.name !== 'Dedupe');
},
Expand Down

0 comments on commit caa1237

Please sign in to comment.