From fdf53e3318684459bb1b19153f120654b119a23c Mon Sep 17 00:00:00 2001 From: Catherine Lee <55311782+c298lee@users.noreply.github.com> Date: Mon, 18 Mar 2024 18:55:19 -0400 Subject: [PATCH] only enable screenshots in secure contexts --- packages/feedback/src/util/isScreenshotSupported.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/feedback/src/util/isScreenshotSupported.ts b/packages/feedback/src/util/isScreenshotSupported.ts index d4e27468fcb0..a486e8f91d99 100644 --- a/packages/feedback/src/util/isScreenshotSupported.ts +++ b/packages/feedback/src/util/isScreenshotSupported.ts @@ -8,10 +8,17 @@ import { NAVIGATOR } from '../constants'; * * https://stackoverflow.com/a/58879212 * https://stackoverflow.com/a/3540295 + * + * `mediaDevices.getDisplayMedia` is also only supported in secure contexts, and return a `mediaDevices is not supported` error, so we should also avoid loading the integration if we can. + * + * https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia */ export function isScreenshotSupported(): boolean { if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(NAVIGATOR.userAgent)) { return false; } + if (!isSecureContext) { + return false; + } return true; }