Skip to content

Commit

Permalink
fix(feedback): Be consistent about whether screenshot should and can …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
ryan953 authored May 1, 2024
1 parent 3c95ac9 commit 7e6c23e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/feedback/src/core/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,33 @@ export const buildFeedbackIntegration = ({
};

const _loadAndRenderDialog = async (options: FeedbackInternalOptions): Promise<FeedbackDialog> => {
const screenshotRequired = options.showScreenshot && isScreenshotSupported();
const [modalIntegration, screenshotIntegration] = await Promise.all([
_findIntegration<FeedbackModalIntegration>('FeedbackModal', getModalIntegration, 'feedbackModalIntegration'),
showScreenshot && isScreenshotSupported()
screenshotRequired
? _findIntegration<FeedbackScreenshotIntegration>(
'FeedbackScreenshot',
getScreenshotIntegration,
'feedbackScreenshotIntegration',
)
: undefined,
]);
if (!modalIntegration || (showScreenshot && !screenshotIntegration)) {
if (!modalIntegration) {
// TODO: Let the end-user retry async loading
// Include more verbose logs so developers can understand the options (like preloading).
throw new Error('Missing feedback helper integration!');
DEBUG_BUILD &&
logger.error(
'[Feedback] Missing feedback modal integration. Try using `feedbackSyncIntegration` in your `Sentry.init`.',
);
throw new Error('[Feedback] Missing feedback modal integration!');
}
if (screenshotRequired && !screenshotIntegration) {
DEBUG_BUILD &&
logger.error('[Feedback] Missing feedback screenshot integration. Proceeding without screenshots.');
}

return modalIntegration.createDialog({
options,
screenshotIntegration: showScreenshot ? screenshotIntegration : undefined,
screenshotIntegration: screenshotRequired ? screenshotIntegration : undefined,
sendFeedback,
shadow: _createShadow(options),
});
Expand Down

0 comments on commit 7e6c23e

Please sign in to comment.