Skip to content

Commit ae05400

Browse files
committed
fix linting & circular dependency check
1 parent 755e29b commit ae05400

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { ReplayContainer, ReplayPerformanceEntry } from '../types';
2+
import { createPerformanceSpans } from '../util/createPerformanceSpans';
3+
import { shouldFilterRequest } from '../util/shouldFilterRequest';
4+
5+
/** Add a performance entry breadcrumb */
6+
export function addNetworkBreadcrumb(replay: ReplayContainer, result: ReplayPerformanceEntry | null): void {
7+
if (!replay.isEnabled()) {
8+
return;
9+
}
10+
11+
if (result === null) {
12+
return;
13+
}
14+
15+
if (shouldFilterRequest(replay, result.name)) {
16+
return;
17+
}
18+
19+
replay.addUpdate(() => {
20+
createPerformanceSpans(replay, [result]);
21+
// Returning true will cause `addUpdate` to not flush
22+
// We do not want network requests to cause a flush. This will prevent
23+
// recurring/polling requests from keeping the replay session alive.
24+
return true;
25+
});
26+
}

packages/replay/src/coreHandlers/handleFetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { HandlerDataFetch } from '@sentry/types';
22

33
import type { ReplayContainer, ReplayPerformanceEntry } from '../types';
4-
import { addNetworkBreadcrumb } from './handleNetworkBreadcrumbs';
4+
import { addNetworkBreadcrumb } from './addNetworkBreadcrumb';
55

66
/** only exported for tests */
77
export function handleFetch(handlerData: HandlerDataFetch): null | ReplayPerformanceEntry {

packages/replay/src/coreHandlers/handleNetworkBreadcrumbs.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type {
55
FetchBreadcrumbData,
66
FetchBreadcrumbHint,
77
HandlerDataFetch,
8-
HandlerDataXhr,
98
SentryWrappedXMLHttpRequest,
109
TextEncoderInternal,
1110
XhrBreadcrumbData,
@@ -14,8 +13,7 @@ import type {
1413
import { addInstrumentationHandler, logger } from '@sentry/utils';
1514

1615
import type { ReplayContainer, ReplayPerformanceEntry } from '../types';
17-
import { createPerformanceSpans } from '../util/createPerformanceSpans';
18-
import { shouldFilterRequest } from '../util/shouldFilterRequest';
16+
import { addNetworkBreadcrumb } from './addNetworkBreadcrumb';
1917
import { handleFetchSpanListener } from './handleFetch';
2018
import { handleXhrSpanListener } from './handleXhr';
2119

@@ -244,29 +242,6 @@ function getFetchBody(fetchArgs: unknown[] = []): RequestInit['body'] | undefine
244242
return (fetchArgs[1] as RequestInit).body;
245243
}
246244

247-
/** Add a performance entry breadcrumb */
248-
export function addNetworkBreadcrumb(replay: ReplayContainer, result: ReplayPerformanceEntry | null): void {
249-
if (!replay.isEnabled()) {
250-
return;
251-
}
252-
253-
if (result === null) {
254-
return;
255-
}
256-
257-
if (shouldFilterRequest(replay, result.name)) {
258-
return;
259-
}
260-
261-
replay.addUpdate(() => {
262-
createPerformanceSpans(replay, [result]);
263-
// Returning true will cause `addUpdate` to not flush
264-
// We do not want network requests to cause a flush. This will prevent
265-
// recurring/polling requests from keeping the replay session alive.
266-
return true;
267-
});
268-
}
269-
270245
function _isXhrBreadcrumb(breadcrumb: Breadcrumb): breadcrumb is Breadcrumb & { data: XhrBreadcrumbData } {
271246
return breadcrumb.category === 'xhr';
272247
}

packages/replay/src/coreHandlers/handleXhr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { HandlerDataXhr } from '@sentry/types';
22

33
import type { ReplayContainer, ReplayPerformanceEntry } from '../types';
4-
import { addNetworkBreadcrumb } from './handleNetworkBreadcrumbs';
4+
import { addNetworkBreadcrumb } from './addNetworkBreadcrumb';
55

66
/** only exported for tests */
77
export function handleXhr(handlerData: HandlerDataXhr): ReplayPerformanceEntry | null {

packages/replay/test/unit/coreHandlers/handleNetworkBreadcrumbs.test.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1+
import type {
2+
Breadcrumb,
3+
BreadcrumbHint,
4+
FetchBreadcrumbHint,
5+
TextEncoderInternal,
6+
XhrBreadcrumbHint,
7+
} from '@sentry/types';
18
import { TextEncoder } from 'util';
29

10+
import { BASE_TIMESTAMP } from '../..';
311
import {
412
getBodySize,
5-
parseContentSizeHeader,
613
handleNetworkBreadcrumb,
14+
parseContentSizeHeader,
715
} from '../../../src/coreHandlers/handleNetworkBreadcrumbs';
8-
import {
9-
Breadcrumb,
10-
BreadcrumbHint,
11-
TextEncoderInternal,
12-
XhrBreadcrumbData,
13-
XhrBreadcrumbHint,
14-
FetchBreadcrumbHint,
15-
} from '@sentry/types';
16+
import type { EventBufferArray } from '../../../src/eventBuffer/EventBufferArray';
17+
import type { ReplayContainer } from '../../../src/types';
1618
import { setupReplayContainer } from '../../utils/setupReplayContainer';
17-
import { ReplayContainer } from '../../../src/types';
18-
import { EventBufferArray } from '../../../src/eventBuffer/EventBufferArray';
19-
import { BASE_TIMESTAMP } from '../..';
2019

2120
jest.useFakeTimers();
2221

0 commit comments

Comments
 (0)