Skip to content

Commit 7579a06

Browse files
chore(feedback): Use Widget instead of Form (#4547)
* chore(feedback): Use `Widget` instead of `Form` * fix * fix lint --------- Co-authored-by: Antonis Lilis <[email protected]>
1 parent 874b2a2 commit 7579a06

15 files changed

+108
-109
lines changed

CHANGELOG.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
### Features
1212

13-
- User Feedback Form Component Beta ([#4435](https://github.com/getsentry/sentry-react-native/pull/4435))
13+
- User Feedback Widget Beta ([#4435](https://github.com/getsentry/sentry-react-native/pull/4435))
1414

15-
To collect user feedback from inside your application call `Sentry.showFeedbackForm()` or add the `FeedbackForm` component.
15+
To collect user feedback from inside your application call `Sentry.showFeedbackWidget()` or add the `FeedbackWidget` component.
1616

1717
```jsx
18-
import { FeedbackForm } from "@sentry/react-native";
18+
import { FeedbackWidget } from "@sentry/react-native";
1919
...
20-
<FeedbackForm/>
20+
<FeedbackWidget/>
2121
```
2222

2323
### Fixes

packages/core/src/js/feedback/FeedbackForm.styles.ts renamed to packages/core/src/js/feedback/FeedbackWidget.styles.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { ViewStyle } from 'react-native';
22

3-
import type { FeedbackFormStyles } from './FeedbackForm.types';
3+
import type { FeedbackWidgetStyles } from './FeedbackWidget.types';
44

55
const PURPLE = 'rgba(88, 74, 192, 1)';
66
const FORGROUND_COLOR = '#2b2233';
77
const BACKROUND_COLOR = '#ffffff';
88
const BORDER_COLOR = 'rgba(41, 35, 47, 0.13)';
99

10-
const defaultStyles: FeedbackFormStyles = {
10+
const defaultStyles: FeedbackWidgetStyles = {
1111
container: {
1212
flex: 1,
1313
padding: 20,

packages/core/src/js/feedback/FeedbackForm.tsx renamed to packages/core/src/js/feedback/FeedbackWidget.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ import {
1717
View
1818
} from 'react-native';
1919

20-
import { NATIVE } from './../wrapper';
20+
import { NATIVE } from '../wrapper';
2121
import { sentryLogo } from './branding';
2222
import { defaultConfiguration } from './defaults';
23-
import defaultStyles from './FeedbackForm.styles';
24-
import type { FeedbackFormProps, FeedbackFormState, FeedbackFormStyles, FeedbackGeneralConfiguration, FeedbackTextConfiguration, ImagePickerConfiguration } from './FeedbackForm.types';
23+
import defaultStyles from './FeedbackWidget.styles';
24+
import type { FeedbackGeneralConfiguration, FeedbackTextConfiguration, FeedbackWidgetProps, FeedbackWidgetState, FeedbackWidgetStyles, ImagePickerConfiguration } from './FeedbackWidget.types';
2525
import { isValidEmail } from './utils';
2626

2727
/**
2828
* @beta
2929
* Implements a feedback form screen that sends feedback to Sentry using Sentry.captureFeedback.
3030
*/
31-
export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFormState> {
32-
public static defaultProps: Partial<FeedbackFormProps> = {
31+
export class FeedbackWidget extends React.Component<FeedbackWidgetProps, FeedbackWidgetState> {
32+
public static defaultProps: Partial<FeedbackWidgetProps> = {
3333
...defaultConfiguration
3434
}
3535

36-
public constructor(props: FeedbackFormProps) {
36+
public constructor(props: FeedbackWidgetProps) {
3737
super(props);
3838

3939
const currentUser = {
@@ -159,7 +159,7 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
159159
const config: FeedbackGeneralConfiguration = this.props;
160160
const imagePickerConfiguration: ImagePickerConfiguration = this.props;
161161
const text: FeedbackTextConfiguration = this.props;
162-
const styles: FeedbackFormStyles = { ...defaultStyles, ...this.props.styles };
162+
const styles: FeedbackWidgetStyles = { ...defaultStyles, ...this.props.styles };
163163
const onCancel = (): void => {
164164
onFormClose();
165165
this.setState({ isVisible: false });

packages/core/src/js/feedback/FeedbackForm.types.ts renamed to packages/core/src/js/feedback/FeedbackWidget.types.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
44
/**
55
* The props for the feedback form
66
*/
7-
export interface FeedbackFormProps
7+
export interface FeedbackWidgetProps
88
extends FeedbackGeneralConfiguration,
99
FeedbackTextConfiguration,
1010
FeedbackCallbacks,
1111
ImagePickerConfiguration {
12-
styles?: FeedbackFormStyles;
12+
styles?: FeedbackWidgetStyles;
1313
}
1414

1515
/**
@@ -226,7 +226,7 @@ export interface ImagePicker {
226226
/**
227227
* The styles for the feedback form
228228
*/
229-
export interface FeedbackFormStyles {
229+
export interface FeedbackWidgetStyles {
230230
container?: ViewStyle;
231231
title?: TextStyle;
232232
label?: TextStyle;
@@ -245,7 +245,7 @@ export interface FeedbackFormStyles {
245245
/**
246246
* The state of the feedback form
247247
*/
248-
export interface FeedbackFormState {
248+
export interface FeedbackWidgetState {
249249
isVisible: boolean;
250250
name: string;
251251
email: string;

packages/core/src/js/feedback/FeedbackFormManager.tsx renamed to packages/core/src/js/feedback/FeedbackWidgetManager.tsx

+18-19
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import { logger } from '@sentry/core';
22
import * as React from 'react';
33
import { Animated, KeyboardAvoidingView, Modal, PanResponder, Platform } from 'react-native';
44

5-
import { FeedbackForm } from './FeedbackForm';
6-
import { modalBackground, modalSheetContainer, modalWrapper } from './FeedbackForm.styles';
7-
import type { FeedbackFormStyles } from './FeedbackForm.types';
5+
import { FeedbackWidget } from './FeedbackWidget';
6+
import { modalBackground, modalSheetContainer, modalWrapper } from './FeedbackWidget.styles';
7+
import type { FeedbackWidgetStyles } from './FeedbackWidget.types';
88
import { getFeedbackOptions } from './integration';
99
import { isModalSupported } from './utils';
1010

1111
const PULL_DOWN_CLOSE_THREESHOLD = 200;
1212
const PULL_DOWN_ANDROID_ACTIVATION_HEIGHT = 150;
1313

14-
class FeedbackFormManager {
14+
class FeedbackWidgetManager {
1515
private static _isVisible = false;
1616
private static _setVisibility: (visible: boolean) => void;
1717

@@ -38,25 +38,24 @@ class FeedbackFormManager {
3838
}
3939
}
4040

41-
interface FeedbackFormProviderProps {
41+
interface FeedbackWidgetProviderProps {
4242
children: React.ReactNode;
43-
styles?: FeedbackFormStyles;
43+
styles?: FeedbackWidgetStyles;
4444
}
4545

46-
interface FeedbackFormProviderState {
46+
interface FeedbackWidgetProviderState {
4747
isVisible: boolean;
4848
backgroundOpacity: Animated.Value;
4949
panY: Animated.Value;
5050
}
5151

52-
class FeedbackFormProvider extends React.Component<FeedbackFormProviderProps> {
53-
public state: FeedbackFormProviderState = {
52+
class FeedbackWidgetProvider extends React.Component<FeedbackWidgetProviderProps> {
53+
public state: FeedbackWidgetProviderState = {
5454
isVisible: false,
5555
backgroundOpacity: new Animated.Value(0),
5656
panY: new Animated.Value(0),
5757
};
5858

59-
6059
private _panResponder = PanResponder.create({
6160
onStartShouldSetPanResponder: (evt, _gestureState) => {
6261
// On Android allow pulling down only from the top to avoid breaking native gestures
@@ -88,15 +87,15 @@ class FeedbackFormProvider extends React.Component<FeedbackFormProviderProps> {
8887
},
8988
});
9089

91-
public constructor(props: FeedbackFormProviderProps) {
90+
public constructor(props: FeedbackWidgetProviderProps) {
9291
super(props);
93-
FeedbackFormManager.initialize(this._setVisibilityFunction);
92+
FeedbackWidgetManager.initialize(this._setVisibilityFunction);
9493
}
9594

9695
/**
9796
* Animates the background opacity when the modal is shown.
9897
*/
99-
public componentDidUpdate(_prevProps: any, prevState: FeedbackFormProviderState): void {
98+
public componentDidUpdate(_prevProps: any, prevState: FeedbackWidgetProviderState): void {
10099
if (!prevState.isVisible && this.state.isVisible) {
101100
Animated.timing(this.state.backgroundOpacity, {
102101
toValue: 1,
@@ -113,7 +112,7 @@ class FeedbackFormProvider extends React.Component<FeedbackFormProviderProps> {
113112
*/
114113
public render(): React.ReactNode {
115114
if (!isModalSupported()) {
116-
logger.error('FeedbackForm Modal is not supported in React Native < 0.71 with Fabric renderer.');
115+
logger.error('FeedbackWidget Modal is not supported in React Native < 0.71 with Fabric renderer.');
117116
return <>{this.props.children}</>;
118117
}
119118

@@ -140,7 +139,7 @@ class FeedbackFormProvider extends React.Component<FeedbackFormProviderProps> {
140139
style={[modalSheetContainer, { transform: [{ translateY: this.state.panY }] }]}
141140
{...this._panResponder.panHandlers}
142141
>
143-
<FeedbackForm {...getFeedbackOptions()}
142+
<FeedbackWidget {...getFeedbackOptions()}
144143
onFormClose={this._handleClose}
145144
onFormSubmitted={this._handleClose}
146145
/>
@@ -161,13 +160,13 @@ class FeedbackFormProvider extends React.Component<FeedbackFormProviderProps> {
161160
};
162161

163162
private _handleClose = (): void => {
164-
FeedbackFormManager.hide();
163+
FeedbackWidgetManager.hide();
165164
this.setState({ isVisible: false });
166165
};
167166
}
168167

169-
const showFeedbackForm = (): void => {
170-
FeedbackFormManager.show();
168+
const showFeedbackWidget = (): void => {
169+
FeedbackWidgetManager.show();
171170
};
172171

173-
export { showFeedbackForm, FeedbackFormProvider };
172+
export { showFeedbackWidget, FeedbackWidgetProvider };

packages/core/src/js/feedback/defaults.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Alert } from 'react-native';
22

3-
import type { FeedbackFormProps } from './FeedbackForm.types';
3+
import type { FeedbackWidgetProps } from './FeedbackWidget.types';
44

55
const FORM_TITLE = 'Report a Bug';
66
const NAME_PLACEHOLDER = 'Your Name';
@@ -20,7 +20,7 @@ const ADD_SCREENSHOT_LABEL = 'Add a screenshot';
2020
const REMOVE_SCREENSHOT_LABEL = 'Remove screenshot';
2121
const GENERIC_ERROR_TEXT = 'Unable to send feedback due to an unexpected error.';
2222

23-
export const defaultConfiguration: Partial<FeedbackFormProps> = {
23+
export const defaultConfiguration: Partial<FeedbackWidgetProps> = {
2424
// FeedbackCallbacks
2525
onFormOpen: () => {
2626
// Does nothing by default
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import type { Integration } from '@sentry/core';
22

3-
import type { FeedbackFormProps } from './FeedbackForm.types';
3+
import type { FeedbackWidgetProps } from './FeedbackWidget.types';
44

55
export const FEEDBACK_FORM_INTEGRATION_NAME = 'MobileFeedback';
66

77
type FeedbackIntegration = Integration & {
8-
options: Partial<FeedbackFormProps>;
8+
options: Partial<FeedbackWidgetProps>;
99
};
1010

11-
let savedOptions: Partial<FeedbackFormProps> = {};
11+
let savedOptions: Partial<FeedbackWidgetProps> = {};
1212

13-
export const feedbackIntegration = (initOptions: FeedbackFormProps = {}): FeedbackIntegration => {
13+
export const feedbackIntegration = (initOptions: FeedbackWidgetProps = {}): FeedbackIntegration => {
1414
savedOptions = initOptions;
1515

1616
return {
@@ -19,4 +19,4 @@ export const feedbackIntegration = (initOptions: FeedbackFormProps = {}): Feedba
1919
};
2020
};
2121

22-
export const getFeedbackOptions = (): Partial<FeedbackFormProps> => savedOptions;
22+
export const getFeedbackOptions = (): Partial<FeedbackWidgetProps> => savedOptions;

packages/core/src/js/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ export type { TimeToDisplayProps } from './tracing';
8585

8686
export { Mask, Unmask } from './replay/CustomMask';
8787

88-
export { FeedbackForm } from './feedback/FeedbackForm';
89-
export { showFeedbackForm } from './feedback/FeedbackFormManager';
88+
export { FeedbackWidget } from './feedback/FeedbackWidget';
89+
export { showFeedbackWidget } from './feedback/FeedbackWidgetManager';

packages/core/src/js/sdk.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import * as React from 'react';
99

1010
import { ReactNativeClient } from './client';
11-
import { FeedbackFormProvider } from './feedback/FeedbackFormManager';
11+
import { FeedbackWidgetProvider } from './feedback/FeedbackWidgetManager';
1212
import { getDevServer } from './integrations/debugsymbolicatorutils';
1313
import { getDefaultIntegrations } from './integrations/default';
1414
import type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';
@@ -164,9 +164,9 @@ export function wrap<P extends Record<string, unknown>>(
164164
return (
165165
<TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>
166166
<ReactNativeProfiler {...profilerProps}>
167-
<FeedbackFormProvider>
167+
<FeedbackWidgetProvider>
168168
<RootComponent {...appProps} />
169-
</FeedbackFormProvider>
169+
</FeedbackWidgetProvider>
170170
</ReactNativeProfiler>
171171
</TouchEventBoundary>
172172
);

0 commit comments

Comments
 (0)