Skip to content

Commit 4db95b1

Browse files
committed
pass entire options object when reformatting include option
1 parent 8589145 commit 4db95b1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

packages/node/src/integrations/requestdata.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class RequestData implements Integration {
9292
// the moment it lives here, though, until https://github.com/getsentry/sentry-javascript/issues/5718 is addressed.
9393
// (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be clened up. Once
9494
// that's happened, it will be easier to add this logic in without worrying about unexpected side effects.)
95-
const { include, addRequestData, transactionNamingScheme } = this._options;
95+
const { addRequestData, transactionNamingScheme } = this._options;
9696

9797
addGlobalEventProcessor(event => {
9898
const hub = getCurrentHub();
@@ -105,7 +105,7 @@ export class RequestData implements Integration {
105105
return event;
106106
}
107107

108-
const processedEvent = addRequestData(event, req, { include: formatIncludeOption(include) });
108+
const processedEvent = addRequestData(event, req, convertReqDataIntegrationOptsToAddReqDataOpts(this._options));
109109

110110
// Transaction events already have the right `transaction` value
111111
if (event.type === 'transaction' || transactionNamingScheme === 'handler') {
@@ -139,12 +139,12 @@ export class RequestData implements Integration {
139139
}
140140
}
141141

142-
/** Convert `include` option to match what `addRequestDataToEvent` expects */
142+
/** Convert this integration's options to match what `addRequestDataToEvent` expects */
143143
/** TODO: Can possibly be deleted once https://github.com/getsentry/sentry-javascript/issues/5718 is fixed */
144-
function formatIncludeOption(
145-
integrationInclude: RequestDataIntegrationOptions['include'] = {},
146-
): AddRequestDataToEventOptions['include'] {
147-
const { ip, user, ...requestOptions } = integrationInclude;
144+
function convertReqDataIntegrationOptsToAddReqDataOpts(
145+
integrationOptions: RequestDataIntegrationOptions,
146+
): AddRequestDataToEventOptions {
147+
const { ip, user, ...requestOptions } = integrationOptions.include;
148148

149149
const requestIncludeKeys: string[] = [];
150150
for (const [key, value] of Object.entries(requestOptions)) {
@@ -169,9 +169,11 @@ function formatIncludeOption(
169169
}
170170

171171
return {
172-
ip,
173-
user: addReqDataUserOpt,
174-
request: requestIncludeKeys.length !== 0 ? requestIncludeKeys : undefined,
172+
include: {
173+
ip,
174+
user: addReqDataUserOpt,
175+
request: requestIncludeKeys.length !== 0 ? requestIncludeKeys : undefined,
176+
},
175177
};
176178
}
177179

0 commit comments

Comments
 (0)