From ed90ded51ea35e5e41c635ea70a0b9d8bc640187 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Thu, 16 Nov 2023 16:19:14 -0500 Subject: [PATCH 1/4] do not import window from browser pkg (circular import) --- packages/feedback/src/constants.ts | 7 +++++++ packages/feedback/src/integration.ts | 2 +- packages/feedback/src/widget/Icon.ts | 2 +- packages/feedback/src/widget/Logo.ts | 2 +- packages/feedback/src/widget/SuccessIcon.ts | 2 +- packages/feedback/src/widget/createShadowHost.ts | 2 +- packages/feedback/src/widget/util/createElement.ts | 2 +- 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/feedback/src/constants.ts b/packages/feedback/src/constants.ts index ea0db22525f4..491acfae90c8 100644 --- a/packages/feedback/src/constants.ts +++ b/packages/feedback/src/constants.ts @@ -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 replay 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)'; diff --git a/packages/feedback/src/integration.ts b/packages/feedback/src/integration.ts index 4a7bd2a7e10a..440dedbd8b78 100644 --- a/packages/feedback/src/integration.ts +++ b/packages/feedback/src/integration.ts @@ -1,4 +1,4 @@ -import { WINDOW } from '@sentry/browser'; +import { WINDOW } from './constants'; import type { Integration } from '@sentry/types'; import { isBrowser, logger } from '@sentry/utils'; diff --git a/packages/feedback/src/widget/Icon.ts b/packages/feedback/src/widget/Icon.ts index 998eaef1ebb8..863e9653ec35 100644 --- a/packages/feedback/src/widget/Icon.ts +++ b/packages/feedback/src/widget/Icon.ts @@ -1,4 +1,4 @@ -import { WINDOW } from '@sentry/browser'; +import { WINDOW } from '../constants'; import { setAttributesNS } from '../util/setAttributesNS'; diff --git a/packages/feedback/src/widget/Logo.ts b/packages/feedback/src/widget/Logo.ts index b8c7c72b1d39..4ecc5b4f7bd0 100644 --- a/packages/feedback/src/widget/Logo.ts +++ b/packages/feedback/src/widget/Logo.ts @@ -1,4 +1,4 @@ -import { WINDOW } from '@sentry/browser'; +import { WINDOW } from '../constants'; import type { FeedbackInternalOptions } from '../types'; import { setAttributesNS } from '../util/setAttributesNS'; diff --git a/packages/feedback/src/widget/SuccessIcon.ts b/packages/feedback/src/widget/SuccessIcon.ts index 672954eae864..6b2d552f743f 100644 --- a/packages/feedback/src/widget/SuccessIcon.ts +++ b/packages/feedback/src/widget/SuccessIcon.ts @@ -1,4 +1,4 @@ -import { WINDOW } from '@sentry/browser'; +import { WINDOW } from '../constants'; import { setAttributesNS } from '../util/setAttributesNS'; diff --git a/packages/feedback/src/widget/createShadowHost.ts b/packages/feedback/src/widget/createShadowHost.ts index bb8c0643900a..e597f9249e6f 100644 --- a/packages/feedback/src/widget/createShadowHost.ts +++ b/packages/feedback/src/widget/createShadowHost.ts @@ -1,4 +1,4 @@ -import { WINDOW } from '@sentry/browser'; +import { WINDOW } from '../constants'; import { logger } from '@sentry/utils'; import type { FeedbackInternalOptions } from '../types'; diff --git a/packages/feedback/src/widget/util/createElement.ts b/packages/feedback/src/widget/util/createElement.ts index bf5f81868d68..e070e9a9553f 100644 --- a/packages/feedback/src/widget/util/createElement.ts +++ b/packages/feedback/src/widget/util/createElement.ts @@ -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 From 8df7daa3180b9da488b0fd30a1aefe98ea23f2f6 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Mon, 20 Nov 2023 16:24:02 -0500 Subject: [PATCH 2/4] remove @sentry/browser from package.json --- packages/feedback/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/feedback/package.json b/packages/feedback/package.json index 522fcb5b4b90..0f28b1736ab7 100644 --- a/packages/feedback/package.json +++ b/packages/feedback/package.json @@ -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" From 6d648748754022296e6f4b33cfb157d1a93ec0b6 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Mon, 20 Nov 2023 16:26:21 -0500 Subject: [PATCH 3/4] Update packages/feedback/src/constants.ts --- packages/feedback/src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/feedback/src/constants.ts b/packages/feedback/src/constants.ts index 491acfae90c8..ebfdfeeb7046 100644 --- a/packages/feedback/src/constants.ts +++ b/packages/feedback/src/constants.ts @@ -2,7 +2,7 @@ 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 replay packages +// circular dependency between the browser and feedback packages export const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window; const LIGHT_BACKGROUND = '#ffffff'; From ef8b328cfe1b4918b13bff59131dd4e6483f6547 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Mon, 20 Nov 2023 16:32:25 -0500 Subject: [PATCH 4/4] lint --- packages/feedback/src/constants.ts | 2 +- packages/feedback/src/integration.ts | 2 +- packages/feedback/src/widget/Icon.ts | 1 - packages/feedback/src/widget/Logo.ts | 1 - packages/feedback/src/widget/SuccessIcon.ts | 1 - packages/feedback/src/widget/createShadowHost.ts | 2 +- 6 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/feedback/src/constants.ts b/packages/feedback/src/constants.ts index ebfdfeeb7046..48f699408762 100644 --- a/packages/feedback/src/constants.ts +++ b/packages/feedback/src/constants.ts @@ -1,4 +1,4 @@ -import { GLOBAL_OBJ } from "@sentry/utils"; +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 diff --git a/packages/feedback/src/integration.ts b/packages/feedback/src/integration.ts index 440dedbd8b78..cb27042c20fc 100644 --- a/packages/feedback/src/integration.ts +++ b/packages/feedback/src/integration.ts @@ -1,4 +1,3 @@ -import { WINDOW } from './constants'; import type { Integration } from '@sentry/types'; import { isBrowser, logger } from '@sentry/utils'; @@ -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'; diff --git a/packages/feedback/src/widget/Icon.ts b/packages/feedback/src/widget/Icon.ts index 863e9653ec35..29b2d25bee8d 100644 --- a/packages/feedback/src/widget/Icon.ts +++ b/packages/feedback/src/widget/Icon.ts @@ -1,5 +1,4 @@ import { WINDOW } from '../constants'; - import { setAttributesNS } from '../util/setAttributesNS'; const SIZE = 20; diff --git a/packages/feedback/src/widget/Logo.ts b/packages/feedback/src/widget/Logo.ts index 4ecc5b4f7bd0..17333bda87ed 100644 --- a/packages/feedback/src/widget/Logo.ts +++ b/packages/feedback/src/widget/Logo.ts @@ -1,5 +1,4 @@ import { WINDOW } from '../constants'; - import type { FeedbackInternalOptions } from '../types'; import { setAttributesNS } from '../util/setAttributesNS'; diff --git a/packages/feedback/src/widget/SuccessIcon.ts b/packages/feedback/src/widget/SuccessIcon.ts index 6b2d552f743f..6092481672b9 100644 --- a/packages/feedback/src/widget/SuccessIcon.ts +++ b/packages/feedback/src/widget/SuccessIcon.ts @@ -1,5 +1,4 @@ import { WINDOW } from '../constants'; - import { setAttributesNS } from '../util/setAttributesNS'; const WIDTH = 16; diff --git a/packages/feedback/src/widget/createShadowHost.ts b/packages/feedback/src/widget/createShadowHost.ts index e597f9249e6f..a418906d4b5a 100644 --- a/packages/feedback/src/widget/createShadowHost.ts +++ b/packages/feedback/src/widget/createShadowHost.ts @@ -1,6 +1,6 @@ -import { WINDOW } from '../constants'; import { logger } from '@sentry/utils'; +import { WINDOW } from '../constants'; import type { FeedbackInternalOptions } from '../types'; import { createDialogStyles } from './Dialog.css'; import { createMainStyles } from './Main.css';