Skip to content

Commit e716777

Browse files
committed
make _addRequestData a private property rather than an option
1 parent 3a2a390 commit e716777

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

packages/node/src/integrations/requestdata.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// TODO (v8 or v9): Whenever this becomes a default integration for `@sentry/browser`, move this to `@sentry/core`. For
22
// now, we leave it in `@sentry/integrations` so that it doesn't contribute bytes to our CDN bundles.
33

4-
import { EventProcessor, Hub, Integration, Transaction } from '@sentry/types';
4+
import { Event, EventProcessor, Hub, Integration, PolymorphicRequest, Transaction } from '@sentry/types';
55
import { extractPathForTransaction } from '@sentry/utils';
66

77
import { addRequestDataToEvent, AddRequestDataToEventOptions, TransactionNamingScheme } from '../requestdata';
@@ -28,18 +28,9 @@ type RequestDataIntegrationOptions = {
2828

2929
/** Whether to identify transactions by parameterized path, parameterized path with method, or handler name */
3030
transactionNamingScheme: TransactionNamingScheme;
31-
32-
/**
33-
* Function for adding request data to event. Defaults to `addRequestDataToEvent` from `@sentry/node` for now, but
34-
* left injectable so this integration can be moved to `@sentry/core` and used in browser-based SDKs in the future.
35-
*
36-
* @hidden
37-
*/
38-
addRequestData: typeof addRequestDataToEvent;
3931
};
4032

4133
const DEFAULT_OPTIONS = {
42-
addRequestData: addRequestDataToEvent,
4334
include: {
4435
cookies: true,
4536
data: true,
@@ -69,12 +60,20 @@ export class RequestData implements Integration {
6960
*/
7061
public name: string = RequestData.id;
7162

63+
/**
64+
* Function for adding request data to event. Defaults to `addRequestDataToEvent` from `@sentry/node` for now, but
65+
* left as a property so this integration can be moved to `@sentry/core` as a base class in case we decide to use
66+
* something similar in browser-based SDKs in the future.
67+
*/
68+
protected _addRequestData: (event: Event, req: PolymorphicRequest, options?: { [key: string]: unknown }) => Event;
69+
7270
private _options: RequestDataIntegrationOptions;
7371

7472
/**
7573
* @inheritDoc
7674
*/
7775
public constructor(options: Partial<RequestDataIntegrationOptions> = {}) {
76+
this._addRequestData = addRequestDataToEvent;
7877
this._options = {
7978
...DEFAULT_OPTIONS,
8079
...options,
@@ -104,7 +103,7 @@ export class RequestData implements Integration {
104103
// the moment it lives here, though, until https://github.com/getsentry/sentry-javascript/issues/5718 is addressed.
105104
// (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be clened up. Once
106105
// that's happened, it will be easier to add this logic in without worrying about unexpected side effects.)
107-
const { addRequestData, transactionNamingScheme } = this._options;
106+
const { transactionNamingScheme } = this._options;
108107

109108
addGlobalEventProcessor(event => {
110109
const hub = getCurrentHub();
@@ -119,7 +118,7 @@ export class RequestData implements Integration {
119118

120119
const addRequestDataOptions = convertReqDataIntegrationOptsToAddReqDataOpts(this._options);
121120

122-
const processedEvent = addRequestData(event, req, addRequestDataOptions);
121+
const processedEvent = this._addRequestData(event, req, addRequestDataOptions);
123122

124123
// Transaction events already have the right `transaction` value
125124
if (event.type === 'transaction' || transactionNamingScheme === 'handler') {

packages/node/src/requestdata.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ export const DEFAULT_USER_INCLUDES = ['id', 'username', 'email'];
1515
/**
1616
* Options deciding what parts of the request to use when enhancing an event
1717
*/
18-
export interface AddRequestDataToEventOptions {
18+
export type AddRequestDataToEventOptions = {
1919
/** Flags controlling whether each type of data should be added to the event */
2020
include?: {
2121
ip?: boolean;
2222
request?: boolean | Array<typeof DEFAULT_REQUEST_INCLUDES[number]>;
2323
transaction?: boolean | TransactionNamingScheme;
2424
user?: boolean | Array<typeof DEFAULT_USER_INCLUDES[number]>;
2525
};
26-
}
26+
};
2727

2828
export type TransactionNamingScheme = 'path' | 'methodPath' | 'handler';
2929

0 commit comments

Comments
 (0)