Skip to content

Commit d480336

Browse files
committed
ref(replay): Export WINDOW within Replay instead of importing it from Browser
1 parent da36b2a commit d480336

17 files changed

+24
-28
lines changed

packages/replay/src/createPerformanceEntry.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { WINDOW } from '@sentry/browser';
21
import { browserPerformanceTimeOrigin } from '@sentry/utils';
32
import { record } from 'rrweb';
43

5-
import { AllPerformanceEntry, PerformanceNavigationTiming, PerformancePaintTiming } from './types';
4+
import { AllPerformanceEntry, PerformanceNavigationTiming, PerformancePaintTiming, WINDOW } from './types';
65
import { isIngestHost } from './util/isIngestHost';
76

87
export interface ReplayPerformanceEntry {

packages/replay/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable max-lines */ // TODO: We might want to split this file up
2-
import { WINDOW } from '@sentry/browser';
32
import { addGlobalEventProcessor, getCurrentHub, Scope, setContext } from '@sentry/core';
43
import { Breadcrumb, Client, Event, Integration } from '@sentry/types';
54
import { addInstrumentationHandler, createEnvelope, logger } from '@sentry/utils';
@@ -23,7 +22,7 @@ import { deleteSession } from './session/deleteSession';
2322
import { getSession } from './session/getSession';
2423
import { saveSession } from './session/saveSession';
2524
import { Session } from './session/Session';
26-
import type {
25+
import {
2726
AllPerformanceEntry,
2827
InstrumentationTypeBreadcrumb,
2928
InstrumentationTypeSpan,
@@ -34,6 +33,7 @@ import type {
3433
ReplayConfiguration,
3534
ReplayPluginOptions,
3635
SendReplay,
36+
WINDOW,
3737
} from './types';
3838
import { addInternalBreadcrumb } from './util/addInternalBreadcrumb';
3939
import { captureInternalException } from './util/captureInternalException';

packages/replay/src/session/deleteSession.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { WINDOW } from '@sentry/browser';
2-
1+
import { WINDOW } from '../types';
32
import { REPLAY_SESSION_KEY } from './constants';
43

54
/**

packages/replay/src/session/fetchSession.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { WINDOW } from '@sentry/browser';
2-
3-
import { SampleRates } from '../types';
1+
import { SampleRates, WINDOW } from '../types';
42
import { REPLAY_SESSION_KEY } from './constants';
53
import { Session } from './Session';
64

packages/replay/src/session/saveSession.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { WINDOW } from '@sentry/browser';
2-
1+
import { WINDOW } from '../types';
32
import { REPLAY_SESSION_KEY } from './constants';
43
import { Session } from './Session';
54

packages/replay/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
import { GLOBAL_OBJ } from '@sentry/utils';
12
import type { eventWithTime, recordOptions } from 'rrweb/typings/types';
23

4+
// exporting WINDOW from within this package instead of importing it from @sentry/browser
5+
// this avoids the Browser package being bundled into the CDN bundle as well as a
6+
// circular dependency between the Browser and Replay packages in the future
7+
export const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;
8+
39
export type RecordingEvent = eventWithTime;
410
export type RecordingOptions = recordOptions<eventWithTime>;
511

packages/replay/src/util/isInternal.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { WINDOW } from '@sentry/browser';
2-
1+
import { WINDOW } from '../types';
32
import { isBrowser } from './isBrowser';
43

54
/**

packages/replay/test/unit/flush.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { WINDOW } from '@sentry/browser';
21
import * as SentryUtils from '@sentry/utils';
32
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from '@test';
43

4+
import { WINDOW } from '../../src/types';
55
import { Replay } from './../../src';
66
import { createPerformanceEntries } from './../../src/createPerformanceEntry';
77
import { SESSION_IDLE_DURATION } from './../../src/session/constants';

packages/replay/test/unit/index-errorSampleRate.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
jest.unmock('@sentry/browser');
22

3-
import { captureException, WINDOW } from '@sentry/browser';
3+
import { captureException } from '@sentry/browser';
44
import { BASE_TIMESTAMP, RecordMock } from '@test';
55
import { PerformanceEntryResource } from '@test/fixtures/performanceEntry/resource';
66
import { resetSdkMock } from '@test/mocks';
77
import { DomHandler, MockTransportSend } from '@test/types';
88

9+
import { WINDOW } from '../../src/types';
910
import { Replay } from './../../src';
1011
import { REPLAY_SESSION_KEY, VISIBILITY_CHANGE_TIMEOUT } from './../../src/session/constants';
1112
import { useFakeTimers } from './../utils/use-fake-timers';

packages/replay/test/unit/index.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
jest.mock('./../../src/util/isInternal', () => ({
22
isInternal: jest.fn(() => true),
33
}));
4-
import { WINDOW } from '@sentry/browser';
54
import { BASE_TIMESTAMP, RecordMock } from '@test';
65
import { PerformanceEntryResource } from '@test/fixtures/performanceEntry/resource';
76
import { resetSdkMock } from '@test/mocks';
@@ -10,7 +9,7 @@ import { EventType } from 'rrweb';
109

1110
import { Replay } from '../../src';
1211
import { MAX_SESSION_LIFE, REPLAY_SESSION_KEY, VISIBILITY_CHANGE_TIMEOUT } from '../../src/session/constants';
13-
import { RecordingEvent } from '../../src/types';
12+
import { RecordingEvent, WINDOW } from '../../src/types';
1413
import { useFakeTimers } from '../utils/use-fake-timers';
1514

1615
useFakeTimers();

0 commit comments

Comments
 (0)