2
2
import { Integration , Transaction } from '@sentry/types' ;
3
3
import { logger } from '@sentry/utils' ;
4
4
5
- // Have to manually set types because we are using package-alias
6
5
type Method =
7
6
| 'all'
8
7
| 'get'
@@ -30,7 +29,7 @@ type Method =
30
29
| 'unsubscribe'
31
30
| 'use' ;
32
31
33
- type Application = {
32
+ type Router = {
34
33
[ method in Method ] : ( ...args : any ) => any ;
35
34
} ;
36
35
@@ -80,13 +79,13 @@ export class Express implements Integration {
80
79
/**
81
80
* Express App instance
82
81
*/
83
- private readonly _app ?: Application ;
82
+ private readonly _app ?: Router ;
84
83
private readonly _methods ?: Method [ ] ;
85
84
86
85
/**
87
86
* @inheritDoc
88
87
*/
89
- public constructor ( options : { app ?: Application ; methods ?: Method [ ] } = { } ) {
88
+ public constructor ( options : { app ?: Router ; methods ?: Method [ ] } = { } ) {
90
89
this . _app = options . app ;
91
90
this . _methods = ( Array . isArray ( options . methods ) ? options . methods : [ ] ) . concat ( 'use' ) ;
92
91
}
@@ -224,7 +223,7 @@ function wrapMiddlewareArgs(args: unknown[], method: Method): unknown[] {
224
223
/**
225
224
* Patches original App to utilize our tracing functionality
226
225
*/
227
- function patchMiddleware ( app : Application , method : Method ) : Application {
226
+ function patchMiddleware ( app : Router , method : Method ) : Router {
228
227
const originalAppCallback = app [ method ] ;
229
228
230
229
app [ method ] = function ( ...args : unknown [ ] ) : any {
@@ -237,7 +236,7 @@ function patchMiddleware(app: Application, method: Method): Application {
237
236
/**
238
237
* Patches original application methods
239
238
*/
240
- function instrumentMiddlewares ( app : Application , methods : Method [ ] = [ ] ) : void {
239
+ function instrumentMiddlewares ( app : Router , methods : Method [ ] = [ ] ) : void {
241
240
methods . forEach ( ( method : Method ) => patchMiddleware ( app , method ) ) ;
242
241
}
243
242
0 commit comments