Skip to content

Commit 7d0463d

Browse files
committed
fix tests
1 parent 48c4897 commit 7d0463d

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

packages/core/src/request.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ export function eventToSentryRequest(event: Event, api: APIDetails): SentryReque
5959
const { method: samplingMethod, rate: sampleRate } = transactionSampling || {};
6060

6161
// TODO: Below is a temporary hack in order to debug a serialization error - see
62-
// https://github.com/getsentry/sentry-javascript/issues/2809 and
63-
// https://github.com/getsentry/sentry-javascript/pull/4425. TL;DR: even though we normalize all events (which should
64-
// prevent this), something is causing `JSON.stringify` to throw a circular reference error.
62+
// https://github.com/getsentry/sentry-javascript/issues/2809,
63+
// https://github.com/getsentry/sentry-javascript/pull/4425, and
64+
// https://github.com/getsentry/sentry-javascript/pull/4574.
65+
//
66+
// TL; DR: even though we normalize all events (which should prevent this), something is causing `JSON.stringify` to
67+
// throw a circular reference error.
6568
//
6669
// When it's time to remove it:
6770
// 1. Delete everything between here and where the request object `req` is created, EXCEPT the line deleting
6871
// `sdkProcessingMetadata`
6972
// 2. Restore the original version of the request body, which is commented out
70-
// 3. Search for `skippedNormalization` and pull out the companion hack in the browser playwright tests
73+
// 3. Search for either of the PR URLs above and pull out the companion hacks in the browser playwright tests and the
74+
// baseClient tests in this package
7175
enhanceEventWithSdkInfo(event, api.metadata.sdk);
7276
event.tags = event.tags || {};
7377
event.extra = event.extra || {};

packages/core/test/lib/base.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,21 @@ describe('BaseClient', () => {
867867

868868
client.captureEvent(transaction);
869869

870-
expect(TestBackend.instance!.event!).toEqual(normalizedTransaction);
870+
// TODO: This is to compensate for a temporary debugging hack which adds data the tests aren't anticipating to the
871+
// event. The code can be restored to its original form (the commented-out line below) once that hack is
872+
// removed. See https://github.com/getsentry/sentry-javascript/pull/4425 and
873+
// https://github.com/getsentry/sentry-javascript/pull/4574
874+
const capturedEvent = TestBackend.instance!.event!;
875+
if (capturedEvent.sdkProcessingMetadata?.normalizeDepth) {
876+
if (Object.keys(capturedEvent.sdkProcessingMetadata).length === 1) {
877+
delete capturedEvent.sdkProcessingMetadata;
878+
} else {
879+
delete capturedEvent.sdkProcessingMetadata.normalizeDepth;
880+
}
881+
}
882+
883+
expect(capturedEvent).toEqual(normalizedTransaction);
884+
// expect(TestBackend.instance!.event!).toEqual(normalizedTransaction);
871885
});
872886

873887
test('calls beforeSend and uses original event without any changes', () => {

0 commit comments

Comments
 (0)