@@ -26,47 +26,34 @@ export class TimersWrap implements Integration {
26
26
const global = getGlobalObject ( ) ;
27
27
28
28
if ( this . _setTimeout ) {
29
- fill ( global , 'setTimeout' , this . _wrapTimeFunction . bind ( this ) ) ;
29
+ fill ( global , 'setTimeout' , this . _wrapTimerFunction . bind ( this ) ) ;
30
30
}
31
31
32
32
if ( this . _setInterval ) {
33
- fill ( global , 'setInterval' , this . _wrapTimeFunction . bind ( this ) ) ;
33
+ fill ( global , 'setInterval' , this . _wrapTimerFunction . bind ( this ) ) ;
34
34
}
35
35
36
36
if ( this . _requestAnimationFrame ) {
37
- fill ( global , 'requestAnimationFrame' , this . _wrapRAF . bind ( this ) ) ;
37
+ fill ( global , 'requestAnimationFrame' , this . _wrapTimerFunction . bind ( this ) ) ;
38
38
}
39
39
}
40
40
41
- private _wrapTimeFunction ( original : ( ) => void ) : ( ) => number {
42
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
- return function ( this : any , ...args : any [ ] ) : number {
44
- const originalCallback = args [ 0 ] ;
45
- args [ 0 ] = wrap ( originalCallback , {
46
- // TODO: Change to `handler` and add `setTimeout/setInterval` as function name.
47
- data : { function : getFunctionName ( original ) } ,
48
- handled : true ,
49
- type : 'instrument' ,
50
- } ) ;
51
- return original . apply ( this , args ) ;
52
- } ;
53
- }
54
-
55
41
// eslint-disable-next-line @typescript-eslint/no-explicit-any
56
- private _wrapRAF ( original : any ) : ( callback : ( ) => void ) => any {
42
+ private _wrapTimerFunction ( original : any ) : ( callback : ( ) => void ) => any {
57
43
// eslint-disable-next-line @typescript-eslint/no-explicit-any
58
- return function ( this : any , callback : ( ) => void ) : ( ) => void {
44
+ return function ( this : any , ... args : any [ ] ) : any {
59
45
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
60
46
return original . call (
61
47
this ,
62
- wrap ( callback , {
48
+ wrap ( args [ 0 ] , {
63
49
data : {
64
- function : 'requestAnimationFrame' ,
65
- handler : getFunctionName ( original ) ,
50
+ function : getFunctionName ( original ) ,
51
+ handler : getFunctionName ( args [ 0 ] ) ,
66
52
} ,
67
53
handled : true ,
68
54
type : 'instrument' ,
69
55
} ) ,
56
+ ...args . slice ( 0 ) ,
70
57
) ;
71
58
} ;
72
59
}
0 commit comments