Skip to content

Commit 7e6c23e

Browse files
authored
fix(feedback): Be consistent about whether screenshot should and can render (#11859)
This fixes the conditions for loading and rendering the screenshot integration.... also improves the conditions for not rendering it if we're on a mobile device. - We should check the local`options.showScreenshot` instead of the closed-over `showScreenshot` because the options might have changed for this instance of the widget - We should combine `options.showScreenshot` (the desire) with `isScreenshotSupported()` (the possibility) to set the right expectation
1 parent 3c95ac9 commit 7e6c23e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/feedback/src/core/integration.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,33 @@ export const buildFeedbackIntegration = ({
176176
};
177177

178178
const _loadAndRenderDialog = async (options: FeedbackInternalOptions): Promise<FeedbackDialog> => {
179+
const screenshotRequired = options.showScreenshot && isScreenshotSupported();
179180
const [modalIntegration, screenshotIntegration] = await Promise.all([
180181
_findIntegration<FeedbackModalIntegration>('FeedbackModal', getModalIntegration, 'feedbackModalIntegration'),
181-
showScreenshot && isScreenshotSupported()
182+
screenshotRequired
182183
? _findIntegration<FeedbackScreenshotIntegration>(
183184
'FeedbackScreenshot',
184185
getScreenshotIntegration,
185186
'feedbackScreenshotIntegration',
186187
)
187188
: undefined,
188189
]);
189-
if (!modalIntegration || (showScreenshot && !screenshotIntegration)) {
190+
if (!modalIntegration) {
190191
// TODO: Let the end-user retry async loading
191-
// Include more verbose logs so developers can understand the options (like preloading).
192-
throw new Error('Missing feedback helper integration!');
192+
DEBUG_BUILD &&
193+
logger.error(
194+
'[Feedback] Missing feedback modal integration. Try using `feedbackSyncIntegration` in your `Sentry.init`.',
195+
);
196+
throw new Error('[Feedback] Missing feedback modal integration!');
197+
}
198+
if (screenshotRequired && !screenshotIntegration) {
199+
DEBUG_BUILD &&
200+
logger.error('[Feedback] Missing feedback screenshot integration. Proceeding without screenshots.');
193201
}
194202

195203
return modalIntegration.createDialog({
196204
options,
197-
screenshotIntegration: showScreenshot ? screenshotIntegration : undefined,
205+
screenshotIntegration: screenshotRequired ? screenshotIntegration : undefined,
198206
sendFeedback,
199207
shadow: _createShadow(options),
200208
});

0 commit comments

Comments
 (0)