Skip to content

Commit 4827b60

Browse files
authored
fix(replay): Fix missing fetch/xhr requests (#7134)
Logic was flipped for the filter function so fetch and xhr requests were not being recorded at all.
1 parent c3806eb commit 4827b60

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

packages/replay/src/util/shouldFilterRequest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ import { getCurrentHub } from '@sentry/core';
33
import type { ReplayContainer } from '../types';
44

55
/**
6-
* Check whether a given request URL should be filtered out.
6+
* Check whether a given request URL should be filtered out. This is so we
7+
* don't log Sentry ingest requests.
78
*/
89
export function shouldFilterRequest(replay: ReplayContainer, url: string): boolean {
910
// If we enabled the `traceInternals` experiment, we want to trace everything
1011
if (__DEBUG_BUILD__ && replay.getOptions()._experiments.traceInternals) {
1112
return false;
1213
}
1314

14-
return !_isSentryRequest(url);
15+
return _isSentryRequest(url);
1516
}
1617

1718
/**
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { shouldFilterRequest } from '../../src/util/shouldFilterRequest';
2+
import { mockSdk } from '../index';
3+
4+
describe('Integration | shouldFilterRequest', () => {
5+
beforeEach(() => {
6+
jest.resetModules();
7+
});
8+
9+
it('should not filter requests from non-Sentry ingest URLs', async () => {
10+
const { replay } = await mockSdk();
11+
12+
expect(shouldFilterRequest(replay, 'https://example.com/foo')).toBe(false);
13+
});
14+
15+
it('should filter requests for Sentry ingest URLs', async () => {
16+
const { replay } = await mockSdk();
17+
18+
expect(shouldFilterRequest(replay, 'https://03031aa.ingest.f00.f00/api/129312/')).toBe(true);
19+
});
20+
});

0 commit comments

Comments
 (0)