Skip to content

Commit

Permalink
ref(feedback): Do not import window from browser pkg to avoid circula…
Browse files Browse the repository at this point in the history
…r import (#9604)

We will be exporting the Feedback package from the `@sentry/browser`
package, so to avoid circular imports when we do, we should remove
imports from `@sentry/browser`

(this is what we did in Replay)
  • Loading branch information
billyvg authored Nov 20, 2023
1 parent f24ea88 commit b46a1bb
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion packages/feedback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"access": "public"
},
"dependencies": {
"@sentry/browser": "7.81.0",
"@sentry/core": "7.81.0",
"@sentry/types": "7.81.0",
"@sentry/utils": "7.81.0"
Expand Down
7 changes: 7 additions & 0 deletions packages/feedback/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import { GLOBAL_OBJ } from '@sentry/utils';

// exporting a separate copy of `WINDOW` rather than exporting the one from `@sentry/browser`
// prevents the browser package from being bundled in the CDN bundle, and avoids a
// circular dependency between the browser and feedback packages
export const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;

const LIGHT_BACKGROUND = '#ffffff';
const INHERIT = 'inherit';
const SUBMIT_COLOR = 'rgba(108, 95, 199, 1)';
Expand Down
2 changes: 1 addition & 1 deletion packages/feedback/src/integration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { WINDOW } from '@sentry/browser';
import type { Integration } from '@sentry/types';
import { isBrowser, logger } from '@sentry/utils';

Expand All @@ -15,6 +14,7 @@ import {
NAME_PLACEHOLDER,
SUBMIT_BUTTON_LABEL,
SUCCESS_MESSAGE_TEXT,
WINDOW,
} from './constants';
import type { FeedbackInternalOptions, FeedbackWidget, OptionalFeedbackConfiguration } from './types';
import { mergeOptions } from './util/mergeOptions';
Expand Down
3 changes: 1 addition & 2 deletions packages/feedback/src/widget/Icon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { WINDOW } from '@sentry/browser';

import { WINDOW } from '../constants';
import { setAttributesNS } from '../util/setAttributesNS';

const SIZE = 20;
Expand Down
3 changes: 1 addition & 2 deletions packages/feedback/src/widget/Logo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { WINDOW } from '@sentry/browser';

import { WINDOW } from '../constants';
import type { FeedbackInternalOptions } from '../types';
import { setAttributesNS } from '../util/setAttributesNS';

Expand Down
3 changes: 1 addition & 2 deletions packages/feedback/src/widget/SuccessIcon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { WINDOW } from '@sentry/browser';

import { WINDOW } from '../constants';
import { setAttributesNS } from '../util/setAttributesNS';

const WIDTH = 16;
Expand Down
2 changes: 1 addition & 1 deletion packages/feedback/src/widget/createShadowHost.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WINDOW } from '@sentry/browser';
import { logger } from '@sentry/utils';

import { WINDOW } from '../constants';
import type { FeedbackInternalOptions } from '../types';
import { createDialogStyles } from './Dialog.css';
import { createMainStyles } from './Main.css';
Expand Down
2 changes: 1 addition & 1 deletion packages/feedback/src/widget/util/createElement.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WINDOW } from '@sentry/browser';
import { WINDOW } from '../../constants';

/**
* Helper function to create an element. Could be used as a JSX factory
Expand Down

0 comments on commit b46a1bb

Please sign in to comment.