import { core , Event , Response , Transport , utils } from '../shared' ; const { PromiseBuffer , BeidouError , } = utils ; const { getCurrentHub } = core ; /** Base Transport class implementation */ export abstract class BaseTransport implements Transport { deprecated public url : string = '' ; /** A simple buffer holding all requests. */ protected readonly _buffer : utils . PromiseBuffer < Response > = new PromiseBuffer ( 30 ) ; description returns public _getReportUrl ( ) { let client = getCurrentHub ( ) . getClient ( ) || { getOptions ( ) { return { projectId : '' , url : '' } ; } } ; const { url } = client . getOptions ( ) ; return url ; } inheritDoc public sendEvent ( _ ) { throw new BeidouError ( 'Transport Class has to implement `sendEvent` method' ) ; } inheritDoc public close ( timeout ? ) { return this . _buffer . drain ( timeout ) ; } public finalFomartData ( event ) { const { projectId , exceptions , apis , resources , performances , breadcrumbs , type , sdk , request } = event ; let content = { projectId , type , sdk , request , ... ( performances && { performances } ) , ... ( exceptions && { exceptions } ) , ... ( apis && { apis } ) , ... ( resources && { resources } ) , ... ( breadcrumbs && { breadcrumbs } ) , } ; if ( content . type === 'exception' && content . exceptions && content . exceptions [ 0 ] && content . exceptions [ 0 ] . stacktrace ) { try { content . exceptions [ 0 ] . stacktrace = JSON . stringify ( content . exceptions [ 0 ] . stacktrace ) ; } catch ( e ) { content . exceptions [ 0 ] . stacktrace = '[]' ; } } try { content = content ; } catch ( e ) { content = { } ; } return content ; } }