Skip to content

Commit 66ce092

Browse files
authored
fix(core): Use correct version of event when tagging normalization (#4780)
In #4425, various hacks were added to the SDK to try to diagnose the root cause of #2809. Unfortunately, one of those hacks (tagging when events are normalized) was applied to the pre-normalized version of the event rather than the normalized version that continues on through the event processing pipeline. This led to false positives, where events got tagged as if they'd skipped the normalization process even when they hadn't. This fixes that by adding the flag to the normalized version of the event instead.
1 parent 8efa39e commit 66ce092

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/core/src/baseclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
429429
normalized.contexts.trace = event.contexts.trace;
430430
}
431431

432-
event.sdkProcessingMetadata = { ...event.sdkProcessingMetadata, baseClientNormalized: true };
432+
normalized.sdkProcessingMetadata = { ...normalized.sdkProcessingMetadata, baseClientNormalized: true };
433433

434434
return normalized;
435435
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,13 @@ describe('BaseClient', () => {
879879
delete capturedEvent.sdkProcessingMetadata.normalizeDepth;
880880
}
881881
}
882+
if (capturedEvent.sdkProcessingMetadata?.baseClientNormalized) {
883+
if (Object.keys(capturedEvent.sdkProcessingMetadata).length === 1) {
884+
delete capturedEvent.sdkProcessingMetadata;
885+
} else {
886+
delete capturedEvent.sdkProcessingMetadata.baseClientNormalized;
887+
}
888+
}
882889

883890
expect(capturedEvent).toEqual(normalizedTransaction);
884891
// expect(TestBackend.instance!.event!).toEqual(normalizedTransaction);

packages/integration-tests/utils/helpers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ async function getMultipleRequests(
8282
// removed. See https://github.com/getsentry/sentry-javascript/pull/4425.
8383
const parsedRequest = requestParser(request);
8484
if (parsedRequest.tags) {
85-
if (parsedRequest.tags.skippedNormalization && Object.keys(parsedRequest.tags).length === 1) {
85+
if (
86+
Object.keys(parsedRequest.tags).length === 0 ||
87+
(Object.keys(parsedRequest.tags).length === 1 && 'skippedNormalization' in parsedRequest.tags)
88+
) {
8689
delete parsedRequest.tags;
8790
} else {
8891
delete parsedRequest.tags.skippedNormalization;

0 commit comments

Comments
 (0)