Skip to content

Commit ddf3ca4

Browse files
committed
move WINDOW to ./constants.ts
1 parent d480336 commit ddf3ca4

21 files changed

+27
-58
lines changed

packages/replay/src/createPerformanceEntry.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { browserPerformanceTimeOrigin } from '@sentry/utils';
22
import { record } from 'rrweb';
33

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

78
export interface ReplayPerformanceEntry {

packages/replay/src/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ import debounce from 'lodash.debounce';
66
import { PerformanceObserverEntryList } from 'perf_hooks';
77
import { EventType, record } from 'rrweb';
88

9-
import { breadcrumbHandler } from './coreHandlers/breadcrumbHandler';
10-
import { spanHandler } from './coreHandlers/spanHandler';
11-
import { createMemoryEntry, createPerformanceEntries, ReplayPerformanceEntry } from './createPerformanceEntry';
12-
import { createEventBuffer, IEventBuffer } from './eventBuffer';
139
import {
1410
DEFAULT_ERROR_SAMPLE_RATE,
1511
DEFAULT_SESSION_SAMPLE_RATE,
1612
MAX_SESSION_LIFE,
1713
REPLAY_EVENT_NAME,
1814
SESSION_IDLE_DURATION,
1915
VISIBILITY_CHANGE_TIMEOUT,
20-
} from './session/constants';
16+
WINDOW,
17+
} from './constants';
18+
import { breadcrumbHandler } from './coreHandlers/breadcrumbHandler';
19+
import { spanHandler } from './coreHandlers/spanHandler';
20+
import { createMemoryEntry, createPerformanceEntries, ReplayPerformanceEntry } from './createPerformanceEntry';
21+
import { createEventBuffer, IEventBuffer } from './eventBuffer';
2122
import { deleteSession } from './session/deleteSession';
2223
import { getSession } from './session/getSession';
2324
import { saveSession } from './session/saveSession';
@@ -33,7 +34,6 @@ import {
3334
ReplayConfiguration,
3435
ReplayPluginOptions,
3536
SendReplay,
36-
WINDOW,
3737
} from './types';
3838
import { addInternalBreadcrumb } from './util/addInternalBreadcrumb';
3939
import { captureInternalException } from './util/captureInternalException';

packages/replay/src/session/constants.ts

-18
This file was deleted.

packages/replay/src/session/deleteSession.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { WINDOW } from '../types';
2-
import { REPLAY_SESSION_KEY } from './constants';
1+
import { REPLAY_SESSION_KEY, WINDOW } from '../constants';
32

43
/**
54
* Deletes a session from storage

packages/replay/src/session/fetchSession.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { SampleRates, WINDOW } from '../types';
2-
import { REPLAY_SESSION_KEY } from './constants';
1+
import { REPLAY_SESSION_KEY, WINDOW } from '../constants';
2+
import { SampleRates } from '../types';
33
import { Session } from './Session';
44

55
/**

packages/replay/src/session/saveSession.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { WINDOW } from '../types';
2-
import { REPLAY_SESSION_KEY } from './constants';
1+
import { REPLAY_SESSION_KEY, WINDOW } from '../constants';
32
import { Session } from './Session';
43

54
export function saveSession(session: Session): void {

packages/replay/src/types.ts

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
import { GLOBAL_OBJ } from '@sentry/utils';
21
import type { eventWithTime, recordOptions } from 'rrweb/typings/types';
32

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-
93
export type RecordingEvent = eventWithTime;
104
export type RecordingOptions = recordOptions<eventWithTime>;
115

packages/replay/src/util/isInternal.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WINDOW } from '../types';
1+
import { WINDOW } from '../constants';
22
import { isBrowser } from './isBrowser';
33

44
/**

packages/replay/src/util/isSessionExpired.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MAX_SESSION_LIFE } from '../session/constants';
1+
import { MAX_SESSION_LIFE } from '../constants';
22
import { Session } from '../session/Session';
33
import { isExpired } from './isExpired';
44

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as SentryUtils from '@sentry/utils';
22
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from '@test';
33

4-
import { WINDOW } from '../../src/types';
4+
import { SESSION_IDLE_DURATION, WINDOW } from '../../src/constants';
55
import { Replay } from './../../src';
66
import { createPerformanceEntries } from './../../src/createPerformanceEntry';
7-
import { SESSION_IDLE_DURATION } from './../../src/session/constants';
87
import { useFakeTimers } from './../../test/utils/use-fake-timers';
98

109
useFakeTimers();

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import { PerformanceEntryResource } from '@test/fixtures/performanceEntry/resour
66
import { resetSdkMock } from '@test/mocks';
77
import { DomHandler, MockTransportSend } from '@test/types';
88

9-
import { WINDOW } from '../../src/types';
9+
import { REPLAY_SESSION_KEY, VISIBILITY_CHANGE_TIMEOUT, WINDOW } from '../../src/constants';
1010
import { Replay } from './../../src';
11-
import { REPLAY_SESSION_KEY, VISIBILITY_CHANGE_TIMEOUT } from './../../src/session/constants';
1211
import { useFakeTimers } from './../utils/use-fake-timers';
1312

1413
useFakeTimers();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Error } from '@test/fixtures/error';
22
import { Transaction } from '@test/fixtures/transaction';
33
import { resetSdkMock } from '@test/mocks';
44

5+
import { REPLAY_EVENT_NAME } from '../../src/constants';
56
import { Replay } from './../../src';
6-
import { REPLAY_EVENT_NAME } from './../../src/session/constants';
77
import { useFakeTimers } from './../utils/use-fake-timers';
88

99
useFakeTimers();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Transport } from '@sentry/types';
33
import * as SentryUtils from '@sentry/utils';
44
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from '@test';
55

6+
import { SESSION_IDLE_DURATION, VISIBILITY_CHANGE_TIMEOUT } from '../../src/constants';
67
import { Replay } from './../../src';
7-
import { SESSION_IDLE_DURATION, VISIBILITY_CHANGE_TIMEOUT } from './../../src/session/constants';
88
import { useFakeTimers } from './../utils/use-fake-timers';
99

1010
useFakeTimers();

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { DomHandler, MockTransportSend } from '@test/types';
88
import { EventType } from 'rrweb';
99

1010
import { Replay } from '../../src';
11-
import { MAX_SESSION_LIFE, REPLAY_SESSION_KEY, VISIBILITY_CHANGE_TIMEOUT } from '../../src/session/constants';
12-
import { RecordingEvent, WINDOW } from '../../src/types';
11+
import { MAX_SESSION_LIFE, REPLAY_SESSION_KEY, VISIBILITY_CHANGE_TIMEOUT, WINDOW } from '../../src/constants';
12+
import { RecordingEvent } from '../../src/types';
1313
import { useFakeTimers } from '../utils/use-fake-timers';
1414

1515
useFakeTimers();

packages/replay/test/unit/session/Session.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jest.mock('@sentry/utils', () => {
2525

2626
import * as Sentry from '@sentry/browser';
2727

28+
import { WINDOW } from '../../../src/constants';
2829
import { Session } from '../../../src/session/Session';
29-
import { WINDOW } from '../../../src/types';
3030

3131
type CaptureEventMockType = jest.MockedFunction<typeof Sentry.captureEvent>;
3232

packages/replay/test/unit/session/createSession.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as Sentry from '@sentry/core';
22

3+
import { WINDOW } from '../../../src/constants';
34
import { createSession } from '../../../src/session/createSession';
45
import { saveSession } from '../../../src/session/saveSession';
5-
import { WINDOW } from '../../../src/types';
66

77
jest.mock('./../../../src/session/saveSession');
88

packages/replay/test/unit/session/deleteSession.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { REPLAY_SESSION_KEY } from '../../../src/session/constants';
1+
import { REPLAY_SESSION_KEY, WINDOW } from '../../../src/constants';
22
import { deleteSession } from '../../../src/session/deleteSession';
3-
import { WINDOW } from '../../../src/types';
43

54
const storageEngine = WINDOW.sessionStorage;
65

packages/replay/test/unit/session/fetchSession.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { REPLAY_SESSION_KEY } from '../../../src/session/constants';
1+
import { REPLAY_SESSION_KEY, WINDOW } from '../../../src/constants';
22
import { fetchSession } from '../../../src/session/fetchSession';
3-
import { WINDOW } from '../../../src/types';
43

54
const oldSessionStorage = WINDOW.sessionStorage;
65

packages/replay/test/unit/session/getSession.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { WINDOW } from '../../../src/constants';
12
import * as CreateSession from '../../../src/session/createSession';
23
import * as FetchSession from '../../../src/session/fetchSession';
34
import { getSession } from '../../../src/session/getSession';
45
import { saveSession } from '../../../src/session/saveSession';
56
import { Session } from '../../../src/session/Session';
6-
import { WINDOW } from '../../../src/types';
77

88
jest.mock('@sentry/utils', () => {
99
return {

packages/replay/test/unit/session/saveSession.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { REPLAY_SESSION_KEY } from '../../../src/session/constants';
1+
import { REPLAY_SESSION_KEY, WINDOW } from '../../../src/constants';
22
import { saveSession } from '../../../src/session/saveSession';
33
import { Session } from '../../../src/session/Session';
4-
import { WINDOW } from '../../../src/types';
54

65
beforeAll(() => {
76
WINDOW.sessionStorage.clear();

packages/replay/test/unit/stop.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import * as SentryUtils from '@sentry/utils';
22
// mock functions need to be imported first
33
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from '@test';
44

5-
import { WINDOW } from '../../src/types';
5+
import { SESSION_IDLE_DURATION, WINDOW } from '../../src/constants';
66
import { Replay } from './../../src';
7-
import { SESSION_IDLE_DURATION } from './../../src/session/constants';
87
import { useFakeTimers } from './../utils/use-fake-timers';
98

109
useFakeTimers();

0 commit comments

Comments
 (0)