Skip to content

Commit

Permalink
fix(feedback): Only allow screenshots in secure contexts (#11188)
Browse files Browse the repository at this point in the history
We use
[getDisplayMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia)
to take screenshots, which only works in secure contexts, so disable
screenshot when not a secure context.
  • Loading branch information
c298lee committed Mar 18, 2024
1 parent 8787900 commit b4d7701
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/feedback/src/util/isScreenshotSupported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit b4d7701

Please sign in to comment.