import { addInstrumentationHandler } from '../instrument' ; import { core , Event , Integration , utils } from '../shared' ; import { MPResource } from '../types/resource' ; const { getCurrentHub } = core ; const { uuid4 } = utils ; const hub = getCurrentHub ( ) ; export class ResourceErrorIntegration implements Integration { inheritDoc public static id : string = 'ResourceErrorIntegration' ; inheritDoc public name : string = ResourceErrorIntegration . id ; inheritDoc public setupOnce ( ) { addInstrumentationHandler ( { callback : this . _handleDownLoadOnError , type : 'resource' } ) ; } private _handleDownLoadOnError = ( handlerData ) : void => { const resourcesVal = { url : handlerData . url , category : 'downloadFile' , errMsg : handlerData . errMsg , eventId : uuid4 ( ) , statusCode : handlerData . statusCode || '' , timestamp : Date . now ( ) , } ; const payload = { resources : [ resourcesVal ] , type : 'resource' } ; hub . captureEvent ( { ... payload } ) ; } ; }