Skip to content

Commit

Permalink
use isBrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
billyvg committed Oct 25, 2023
1 parent 64b72b9 commit 21454dc
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions packages/feedback/src/integration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getCurrentHub } from '@sentry/core';
import type { Integration } from '@sentry/types';
import { isNodeEnv, logger } from '@sentry/utils';
import { isBrowser } from '@sentry/utils';
import { logger } from '@sentry/utils';

import {
ACTOR_LABEL,
Expand All @@ -25,20 +26,6 @@ import { createDialogStyles } from './widget/Dialog.css';
import { createMainStyles } from './widget/Main.css';
import { SuccessMessage } from './widget/SuccessMessage';

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';
}
/**
* Returns true if we are in the browser.
*/
function isBrowser(): boolean {
// eslint-disable-next-line no-restricted-globals
return typeof window !== 'undefined' && (!isNodeEnv() || isElectronNodeRenderer());
}

interface FeedbackConfiguration extends Partial<Omit<FeedbackConfigurationWithDefaults, 'theme'>> {
theme?: {
dark?: Partial<FeedbackTheme>;
Expand Down Expand Up @@ -271,7 +258,7 @@ export class Feedback implements Integration {

const userKey = this.options.useSentryUser;
const scope = getCurrentHub().getScope();
const user = scope && scope.getUser();
const user = scope.getUser();

this._dialog = Dialog({
defaultName: (userKey && user && user[userKey.name]) || '',
Expand Down

0 comments on commit 21454dc

Please sign in to comment.