@@ -40,6 +40,8 @@ interface BreadcrumbIntegrations {
40
40
xhr ?: boolean ;
41
41
}
42
42
43
+ type XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' ;
44
+
43
45
/** Default Breadcrumbs instrumentations */
44
46
export class Breadcrumbs implements Integration {
45
47
/**
@@ -80,8 +82,8 @@ export class Breadcrumbs implements Integration {
80
82
return ;
81
83
}
82
84
83
- fill ( global . console , level , function ( originalConsoleLevel : ( ) => any ) : any {
84
- return function ( ...args : any [ ] ) : any {
85
+ fill ( global . console , level , function ( originalConsoleLevel : ( ) => any ) : Function {
86
+ return function ( ...args : any [ ] ) : void {
85
87
const breadcrumbData = {
86
88
category : 'console' ,
87
89
data : {
@@ -151,7 +153,7 @@ export class Breadcrumbs implements Integration {
151
153
fn : EventListenerOrEventListenerObject ,
152
154
options ?: boolean | AddEventListenerOptions ,
153
155
) : ( eventName : string , fn : EventListenerOrEventListenerObject , capture ?: boolean , secure ?: boolean ) => void {
154
- if ( fn && ( fn as any ) . handleEvent ) {
156
+ if ( fn && ( fn as EventListenerObject ) . handleEvent ) {
155
157
if ( eventName === 'click' ) {
156
158
fill ( fn , 'handleEvent' , function ( innerOriginal : ( ) => void ) : ( caughtEvent : Event ) => void {
157
159
return function ( this : any , event : Event ) : ( event : Event ) => void {
@@ -195,7 +197,7 @@ export class Breadcrumbs implements Integration {
195
197
fn : EventListenerObject ,
196
198
options ?: boolean | EventListenerOptions ,
197
199
) : ( ) => void {
198
- let callback = ( fn as any ) as WrappedFunction ;
200
+ let callback = fn as WrappedFunction ;
199
201
try {
200
202
callback = callback && ( callback . __sentry_wrapped__ || callback ) ;
201
203
} catch ( e ) {
@@ -375,9 +377,8 @@ export class Breadcrumbs implements Integration {
375
377
/**
376
378
* @hidden
377
379
*/
378
- function wrapProp ( prop : string , xhr : XMLHttpRequest ) : void {
379
- // TODO: Fix XHR types
380
- if ( prop in xhr && typeof ( xhr as { [ key : string ] : any } ) [ prop ] === 'function' ) {
380
+ function wrapProp ( prop : XMLHttpRequestProp , xhr : XMLHttpRequest ) : void {
381
+ if ( prop in xhr && typeof xhr [ prop ] === 'function' ) {
381
382
fill ( xhr , prop , original =>
382
383
wrap ( original , {
383
384
mechanism : {
@@ -461,7 +462,8 @@ export class Breadcrumbs implements Integration {
461
462
}
462
463
}
463
464
464
- [ 'onload' , 'onerror' , 'onprogress' ] . forEach ( prop => {
465
+ const xmlHttpRequestProps : XMLHttpRequestProp [ ] = [ 'onload' , 'onerror' , 'onprogress' ] ;
466
+ xmlHttpRequestProps . forEach ( prop => {
465
467
wrapProp ( prop , xhr ) ;
466
468
} ) ;
467
469
@@ -534,7 +536,7 @@ export class Breadcrumbs implements Integration {
534
536
function addSentryBreadcrumb ( serializedData : string ) : void {
535
537
// There's always something that can go wrong with deserialization...
536
538
try {
537
- const event : { [ key : string ] : any } = JSON . parse ( serializedData ) ;
539
+ const event = JSON . parse ( serializedData ) ;
538
540
Breadcrumbs . addBreadcrumb (
539
541
{
540
542
category : 'sentry' ,
0 commit comments