Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/replay/src/util/shouldFilterRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { getCurrentHub } from '@sentry/core';
import type { ReplayContainer } from '../types';

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

return !_isSentryRequest(url);
return _isSentryRequest(url);
}

/**
Expand Down
20 changes: 20 additions & 0 deletions packages/replay/test/integration/shouldFilterRequest.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { shouldFilterRequest } from '../../src/util/shouldFilterRequest';
import { mockSdk } from '../index';

describe('Integration | shouldFilterRequest', () => {
beforeEach(() => {
jest.resetModules();
});

it('should not filter requests from non-Sentry ingest URLs', async () => {
const { replay } = await mockSdk();

expect(shouldFilterRequest(replay, 'https://example.com/foo')).toBe(false);
});

it('should filter requests for Sentry ingest URLs', async () => {
const { replay } = await mockSdk();

expect(shouldFilterRequest(replay, 'https://03031aa.ingest.f00.f00/api/129312/')).toBe(true);
});
});