Skip to content

Commit c77555e

Browse files
authored
ref(replay): Remove circular dep in replay eventBuffer (#8389)
When running `yarn build:watch` I found some circular deps: ``` src/eventBuffer/index.ts -> src/eventBuffer/EventBufferArray.ts -> src/eventBuffer/index.ts src/eventBuffer/index.ts -> src/eventBuffer/EventBufferProxy.ts -> src/eventBuffer/EventBufferCompressionWorker.ts -> src/eventBuffer/index.ts ``` This refactors the `EventBufferSizeExceededError` export to remove that.
1 parent a34581d commit c77555e

File tree

7 files changed

+16
-14
lines changed

7 files changed

+16
-14
lines changed

packages/replay/src/eventBuffer/EventBufferArray.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { REPLAY_MAX_EVENT_BUFFER_SIZE } from '../constants';
22
import type { AddEventResult, EventBuffer, EventBufferType, RecordingEvent } from '../types';
33
import { timestampToMs } from '../util/timestampToMs';
4-
import { EventBufferSizeExceededError } from '.';
4+
import { EventBufferSizeExceededError } from './error';
55

66
/**
77
* A basic event buffer that does not do any compression.

packages/replay/src/eventBuffer/EventBufferCompressionWorker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ReplayRecordingData } from '@sentry/types';
33
import { REPLAY_MAX_EVENT_BUFFER_SIZE } from '../constants';
44
import type { AddEventResult, EventBuffer, EventBufferType, RecordingEvent } from '../types';
55
import { timestampToMs } from '../util/timestampToMs';
6-
import { EventBufferSizeExceededError } from '.';
6+
import { EventBufferSizeExceededError } from './error';
77
import { WorkerHandler } from './WorkerHandler';
88

99
/**
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { REPLAY_MAX_EVENT_BUFFER_SIZE } from '../constants';
2+
3+
/** This error indicates that the event buffer size exceeded the limit.. */
4+
export class EventBufferSizeExceededError extends Error {
5+
public constructor() {
6+
super(`Event buffer exceeded maximum size of ${REPLAY_MAX_EVENT_BUFFER_SIZE}.`);
7+
}
8+
}

packages/replay/src/eventBuffer/index.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { getWorkerURL } from '@sentry-internal/replay-worker';
22
import { logger } from '@sentry/utils';
33

4-
import { REPLAY_MAX_EVENT_BUFFER_SIZE } from '../constants';
54
import type { EventBuffer } from '../types';
65
import { EventBufferArray } from './EventBufferArray';
76
import { EventBufferProxy } from './EventBufferProxy';
@@ -31,10 +30,3 @@ export function createEventBuffer({ useCompression }: CreateEventBufferParams):
3130
__DEBUG_BUILD__ && logger.log('[Replay] Using simple buffer');
3231
return new EventBufferArray();
3332
}
34-
35-
/** This error indicates that the event buffer size exceeded the limit.. */
36-
export class EventBufferSizeExceededError extends Error {
37-
public constructor() {
38-
super(`Event buffer exceeded maximum size of ${REPLAY_MAX_EVENT_BUFFER_SIZE}.`);
39-
}
40-
}

packages/replay/src/util/addEvent.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { EventType } from '@sentry-internal/rrweb';
22
import { getCurrentHub } from '@sentry/core';
33
import { logger } from '@sentry/utils';
44

5-
import { EventBufferSizeExceededError } from '../eventBuffer';
5+
import { EventBufferSizeExceededError } from '../eventBuffer/error';
66
import type { AddEventResult, RecordingEvent, ReplayContainer, ReplayFrameEvent } from '../types';
77
import { timestampToMs } from './timestampToMs';
88

packages/replay/test/unit/eventBuffer/EventBufferArray.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { REPLAY_MAX_EVENT_BUFFER_SIZE } from '../../../src/constants';
2-
import { createEventBuffer, EventBufferSizeExceededError } from './../../../src/eventBuffer';
3-
import { BASE_TIMESTAMP } from './../../index';
2+
import { createEventBuffer } from '../../../src/eventBuffer';
3+
import { EventBufferSizeExceededError } from '../../../src/eventBuffer/error';
4+
import { BASE_TIMESTAMP } from '../../index';
45

56
const TEST_EVENT = { data: {}, timestamp: BASE_TIMESTAMP, type: 3 };
67

packages/replay/test/unit/eventBuffer/EventBufferCompressionWorker.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import pako from 'pako';
44

55
import { BASE_TIMESTAMP } from '../..';
66
import { REPLAY_MAX_EVENT_BUFFER_SIZE } from '../../../src/constants';
7+
import { createEventBuffer } from '../../../src/eventBuffer';
8+
import { EventBufferSizeExceededError } from '../../../src/eventBuffer/error';
79
import { EventBufferProxy } from '../../../src/eventBuffer/EventBufferProxy';
8-
import { createEventBuffer, EventBufferSizeExceededError } from './../../../src/eventBuffer';
910

1011
const TEST_EVENT = { data: {}, timestamp: BASE_TIMESTAMP, type: 3 };
1112

0 commit comments

Comments
 (0)