Skip to content

Commit

Permalink
use express handler request data options from sdkProcessingMetadata
Browse files Browse the repository at this point in the history
… if available
  • Loading branch information
lobsterkatie committed Oct 20, 2022
1 parent 9d14753 commit f6b93a7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/node/src/integrations/requestdata.ts
Expand Up @@ -108,15 +108,22 @@ export class RequestData implements Integration {
addGlobalEventProcessor(event => {
const hub = getCurrentHub();
const self = hub.getIntegration(RequestData);
const req = event.sdkProcessingMetadata && event.sdkProcessingMetadata.request;

const { sdkProcessingMetadata = {} } = event;
const req = sdkProcessingMetadata.request;

// If the globally installed instance of this integration isn't associated with the current hub, `self` will be
// undefined
if (!self || !req) {
return event;
}

const addRequestDataOptions = convertReqDataIntegrationOptsToAddReqDataOpts(this._options);
// The Express request handler takes a similar `include` option to that which can be passed to this integration.
// If passed there, we store it in `sdkProcessingMetadata`. TODO(v8): Force express people to use this
// integration, so that all of this passing and conversion isn't necessary
const addRequestDataOptions =
sdkProcessingMetadata.requestDataOptionsFromExpressHandler ||
convertReqDataIntegrationOptsToAddReqDataOpts(this._options);

const processedEvent = this._addRequestData(event, req, addRequestDataOptions);

Expand Down

0 comments on commit f6b93a7

Please sign in to comment.