Skip to content

ref(feedback): Do not import window from browser pkg to avoid circular import #9604

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

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
do not import window from browser pkg (circular import)
  • Loading branch information
billyvg committed Nov 20, 2023
commit ed90ded51ea35e5e41c635ea70a0b9d8bc640187
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 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)';
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,4 @@
import { WINDOW } from '@sentry/browser';
import { WINDOW } from './constants';
import type { Integration } from '@sentry/types';
import { isBrowser, logger } from '@sentry/utils';

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

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

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

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

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

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,4 +1,4 @@
import { WINDOW } from '@sentry/browser';
import { WINDOW } from '../constants';
import { logger } from '@sentry/utils';

import type { FeedbackInternalOptions } from '../types';
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