Skip to content

Commit

Permalink
fix(replay): Fix missing fetch/xhr requests (#7134)
Browse files Browse the repository at this point in the history
Logic was flipped for the filter function so fetch and xhr requests were not being recorded at all.
  • Loading branch information
billyvg committed Feb 10, 2023
1 parent c3806eb commit 4827b60
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
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);
});
});

0 comments on commit 4827b60

Please sign in to comment.