1
1
// TODO (v8 or v9): Whenever this becomes a default integration for `@sentry/browser`, move this to `@sentry/core`. For
2
2
// now, we leave it in `@sentry/integrations` so that it doesn't contribute bytes to our CDN bundles.
3
3
4
- import { EventProcessor , Hub , Integration , Transaction } from '@sentry/types' ;
4
+ import { Event , EventProcessor , Hub , Integration , PolymorphicRequest , Transaction } from '@sentry/types' ;
5
5
import { extractPathForTransaction } from '@sentry/utils' ;
6
6
7
7
import { addRequestDataToEvent , AddRequestDataToEventOptions , TransactionNamingScheme } from '../requestdata' ;
@@ -28,18 +28,9 @@ type RequestDataIntegrationOptions = {
28
28
29
29
/** Whether to identify transactions by parameterized path, parameterized path with method, or handler name */
30
30
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 ;
39
31
} ;
40
32
41
33
const DEFAULT_OPTIONS = {
42
- addRequestData : addRequestDataToEvent ,
43
34
include : {
44
35
cookies : true ,
45
36
data : true ,
@@ -69,12 +60,20 @@ export class RequestData implements Integration {
69
60
*/
70
61
public name : string = RequestData . id ;
71
62
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
+
72
70
private _options : RequestDataIntegrationOptions ;
73
71
74
72
/**
75
73
* @inheritDoc
76
74
*/
77
75
public constructor ( options : Partial < RequestDataIntegrationOptions > = { } ) {
76
+ this . _addRequestData = addRequestDataToEvent ;
78
77
this . _options = {
79
78
...DEFAULT_OPTIONS ,
80
79
...options ,
@@ -104,7 +103,7 @@ export class RequestData implements Integration {
104
103
// the moment it lives here, though, until https://github.com/getsentry/sentry-javascript/issues/5718 is addressed.
105
104
// (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be clened up. Once
106
105
// 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 ;
108
107
109
108
addGlobalEventProcessor ( event => {
110
109
const hub = getCurrentHub ( ) ;
@@ -119,7 +118,7 @@ export class RequestData implements Integration {
119
118
120
119
const addRequestDataOptions = convertReqDataIntegrationOptsToAddReqDataOpts ( this . _options ) ;
121
120
122
- const processedEvent = addRequestData ( event , req , addRequestDataOptions ) ;
121
+ const processedEvent = this . _addRequestData ( event , req , addRequestDataOptions ) ;
123
122
124
123
// Transaction events already have the right `transaction` value
125
124
if ( event . type === 'transaction' || transactionNamingScheme === 'handler' ) {
0 commit comments