Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/replay/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
: `${this.recordingOptions.blockSelector},${MEDIA_SELECTORS}`;
}

if (isBrowser() && this._isInitialized) {
if (this._isInitialized && isBrowser()) {
throw new Error('Multiple Sentry Session Replay instances are not supported');
}

Expand Down
9 changes: 8 additions & 1 deletion packages/replay/src/util/isBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ 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() || isElectronNodeRenderer());
}

type ElectronProcess = { type?: string };

// Electron renderers with nodeIntegration enabled are detected as Node.js so we specifically test for them
function isElectronNodeRenderer(): boolean {
return typeof process !== 'undefined' && (process as ElectronProcess).type === 'renderer';
}