@@ -24,7 +24,7 @@ export class TryCatch implements Integration {
24
24
const originalCallback = args [ 0 ] ;
25
25
args [ 0 ] = wrap ( originalCallback , {
26
26
mechanism : {
27
- data : { function : original . name || '<anonymous>' } ,
27
+ data : { function : getFunctionName ( original ) } ,
28
28
handled : true ,
29
29
type : 'instrument' ,
30
30
} ,
@@ -41,7 +41,7 @@ export class TryCatch implements Integration {
41
41
mechanism : {
42
42
data : {
43
43
function : 'requestAnimationFrame' ,
44
- handler : ( original && original . name ) || '<anonymous>' ,
44
+ handler : getFunctionName ( original ) ,
45
45
} ,
46
46
handled : true ,
47
47
type : 'instrument' ,
@@ -74,7 +74,7 @@ export class TryCatch implements Integration {
74
74
mechanism : {
75
75
data : {
76
76
function : 'handleEvent' ,
77
- handler : ( fn && ( ( fn as any ) as SentryWrappedFunction ) . name ) || '<anonymous>' ,
77
+ handler : getFunctionName ( fn ) ,
78
78
target,
79
79
} ,
80
80
handled : true ,
@@ -129,7 +129,7 @@ export class TryCatch implements Integration {
129
129
mechanism : {
130
130
data : {
131
131
function : 'addEventListener' ,
132
- handler : ( fn && ( ( fn as any ) as SentryWrappedFunction ) . name ) || '<anonymous>' ,
132
+ handler : getFunctionName ( fn ) ,
133
133
target,
134
134
} ,
135
135
handled : true ,
@@ -209,3 +209,13 @@ export class TryCatch implements Integration {
209
209
] . forEach ( this . wrapEventTarget . bind ( this ) ) ;
210
210
}
211
211
}
212
+
213
+ function getFunctionName ( fn : any ) : string {
214
+ try {
215
+ return fn && fn . name || '<anonymous>' ;
216
+ } catch ( e ) {
217
+ // Just accessing custom props in some Selenium environments
218
+ // can cause a "Permission denied" exception (see raven-js#495).
219
+ return '<anonymous>' ;
220
+ }
221
+ }
0 commit comments