Skip to content

Commit ec2a485

Browse files
authored
fix(feedback): show dev note when trying to retrieve image in ExpoGo (#4900)
* fix(feedback): show dev note when trying to retrieve image in ExpoGo * Fix alignment
1 parent df5da5d commit ec2a485

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/core/src/js/feedback/FeedbackWidget.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
View
1616
} from 'react-native';
1717

18-
import { isWeb, notWeb } from '../utils/environment';
18+
import { isExpoGo, isWeb, notWeb } from '../utils/environment';
1919
import type { Screenshot } from '../wrapper';
2020
import { getDataFromUri, NATIVE } from '../wrapper';
2121
import { sentryLogo } from './branding';
@@ -181,9 +181,11 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
181181
if (data != null) {
182182
this.setState({ filename, attachment: data, attachmentUri: imageUri });
183183
} else {
184+
this._showImageRetrievalDevelopmentNote();
184185
logger.error('Failed to read image data from uri:', imageUri);
185186
}
186187
}).catch((error) => {
188+
this._showImageRetrievalDevelopmentNote();
187189
logger.error('Failed to read image data from uri:', imageUri, 'error: ', error);
188190
});
189191
}
@@ -196,10 +198,11 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
196198
if (data != null) {
197199
this.setState({ filename: 'feedback_screenshot', attachment: data, attachmentUri: uri });
198200
} else {
201+
this._showImageRetrievalDevelopmentNote();
199202
logger.error('Failed to read image data from uri:', uri);
200203
}
201-
})
202-
.catch((error) => {
204+
}).catch((error) => {
205+
this._showImageRetrievalDevelopmentNote();
203206
logger.error('Failed to read image data from uri:', uri, 'error: ', error);
204207
});
205208
});
@@ -402,4 +405,13 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
402405
private _hasScreenshot = (): boolean => {
403406
return this.state.filename !== undefined && this.state.attachment !== undefined && this.state.attachmentUri !== undefined;
404407
}
408+
409+
private _showImageRetrievalDevelopmentNote = (): void => {
410+
if (isExpoGo()) {
411+
feedbackAlertDialog(
412+
'Development note',
413+
'The feedback widget cannot retrieve image data in Expo Go. Please build your app to test this functionality.',
414+
);
415+
}
416+
}
405417
}

0 commit comments

Comments
 (0)