Skip to content

Commit fda739b

Browse files
committed
stop using existing request data event processors on transaction events
1 parent 4eccf35 commit fda739b

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

packages/nextjs/src/config/wrappers/wrapperUtils.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,16 @@ export function callTracedServerSideDataFetcher<F extends (...args: any[]) => Pr
122122
if (currentScope) {
123123
currentScope.setSpan(dataFetcherSpan);
124124
currentScope.addEventProcessor(event =>
125-
addRequestDataToEvent(event, req, {
126-
include: {
127-
// When the `transaction` option is set to true, it tries to extract a transaction name from the request
128-
// object. We don't want this since we already have a high-quality transaction name with a parameterized
129-
// route. Setting `transaction` to `true` will clobber that transaction name.
130-
transaction: false,
131-
},
132-
}),
125+
event.type !== 'transaction'
126+
? addRequestDataToEvent(event, req, {
127+
include: {
128+
// When the `transaction` option is set to true, it tries to extract a transaction name from the request
129+
// object. We don't want this since we already have a high-quality transaction name with a parameterized
130+
// route. Setting `transaction` to `true` will clobber that transaction name.
131+
transaction: false,
132+
},
133+
})
134+
: event,
133135
);
134136
}
135137

packages/nextjs/src/utils/instrumentServer.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ function makeWrappedReqHandler(origReqHandler: ReqHandler): WrappedReqHandler {
244244
const currentScope = getCurrentHub().getScope();
245245

246246
if (currentScope) {
247-
currentScope.addEventProcessor(event => addRequestDataToEvent(event, nextReq));
247+
currentScope.addEventProcessor(event =>
248+
event.type !== 'transaction' ? addRequestDataToEvent(event, nextReq) : event,
249+
);
248250

249251
// We only want to record page and API requests
250252
if (hasTracingEnabled() && shouldTraceRequest(nextReq.url, publicDirFiles)) {

packages/nextjs/src/utils/withSentry.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
4141
const currentScope = getCurrentHub().getScope();
4242

4343
if (currentScope) {
44-
currentScope.addEventProcessor(event => addRequestDataToEvent(event, req));
44+
currentScope.addEventProcessor(event =>
45+
event.type !== 'transaction' ? addRequestDataToEvent(event, req) : event,
46+
);
4547

4648
if (hasTracingEnabled()) {
4749
// If there is a trace header set, extract the data from it (parentSpanId, traceId, and sampling decision)

0 commit comments

Comments
 (0)