import { Event , Response , Status } from "@sentry/types" ; import { sdk } from "../crossPlatform" ; import { BaseTransport } from "./base" ; /** `XHR` based transport */ export class XHRTransport extends BaseTransport { inheritDoc public sendEvent ( event ) { const request = sdk . request || sdk . httpRequest ; return this . _buffer . add ( new Promise < Response > ( ( resolve , reject ) => { request ( { url : this . url , method : "POST" , data : JSON . stringify ( event ) , header : { "content-type" : "application/json" } , success ( res ) { resolve ( { status : Status . fromHttpCode ( res . statusCode ) } ) ; } , fail ( error ) { reject ( error ) ; } } ) ; } ) ) ; } }