Skip to content

feat(replay): Allow to capture replays for electron #6653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/replay/src/util/isBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@ import { isNodeEnv } from '@sentry/utils';

export function isBrowser(): boolean {
// eslint-disable-next-line no-restricted-globals
return typeof window !== 'undefined' && !isNodeEnv();
return typeof window !== 'undefined' && (!isNodeEnv() || isElectron(window));
}

/*
Electron renderers with nodeIntegration enabled have process defined, which means they will trigger `isNodeEnv() === false`.
This has not been the default config for a couple of years and it's not recommended but it's still used a lot in real world applications.
So in order to ensure we can still capture for Electron apps, we need to check for the userAgent string.
*/
function isElectron(window: Window): boolean {
// See: https://github.com/electron/electron/issues/2288
return /electron/i.test(window.navigator.userAgent);
}