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,QAAA,EAAE,CAAC,CAAC;qBACxG;gBACH,CAAC,CAAC;gBAEF,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;gBACxC,KAAK,IAAM,MAAM,IAAI,KAAI,CAAC,OAAO,CAAC,OAAO,EAAE;oBACzC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;wBACtE,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;qBAChE;iBACF;gBACD,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC,CAAC;QApBF,CAoBE,CACL;aACA,IAAI,CAAC,SAAS,EAAE,UAAA,MAAM;YACrB,gGAAgG;YAChG,IAAI,MAAM,YAAY,mBAAW,EAAE;gBACjC,KAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAC5D;iBAAM;gBACL,KAAI,CAAC,eAAe,CAAC,eAAe,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAC3D;YACD,MAAM,MAAM,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC;IACH,mBAAC;AAAD,CAAC,AAxDD,CAAkC,oBAAa,GAwD9C;AAxDY,oCAAY","sourcesContent":["import { Event, Response, SentryRequest, Session } from '@sentry/types';\nimport { SentryError, SyncPromise } from '@sentry/utils';\n\nimport { BaseTransport } from './base';\n\n/** `XHR` based transport */\nexport class XHRTransport extends BaseTransport {\n /**\n * @param sentryRequest Prepared SentryRequest to be delivered\n * @param originalPayload Original payload used to create SentryRequest\n */\n protected _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<Response> {\n // eslint-disable-next-line deprecation/deprecation\n if (this._isRateLimited(sentryRequest.type)) {\n this.recordLostEvent('ratelimit_backoff', sentryRequest.type);\n\n return Promise.reject({\n event: originalPayload,\n type: sentryRequest.type,\n // eslint-disable-next-line deprecation/deprecation\n reason: `Transport for ${sentryRequest.type} requests locked till ${this._disabledUntil(\n sentryRequest.type,\n )} due to too many requests.`,\n status: 429,\n });\n }\n\n return this._buffer\n .add(\n () =>\n new SyncPromise<Response>((resolve, reject) => {\n const request = new XMLHttpRequest();\n\n request.onreadystatechange = (): void => {\n if (request.readyState === 4) {\n const headers = {\n 'x-sentry-rate-limits': request.getResponseHeader('X-Sentry-Rate-Limits'),\n 'retry-after': request.getResponseHeader('Retry-After'),\n };\n this._handleResponse({ requestType: sentryRequest.type, response: request, headers, resolve, reject });\n }\n };\n\n request.open('POST', sentryRequest.url);\n for (const header in this.options.headers) {\n if (Object.prototype.hasOwnProperty.call(this.options.headers, header)) {\n request.setRequestHeader(header, this.options.headers[header]);\n }\n }\n request.send(sentryRequest.body);\n }),\n )\n .then(undefined, reason => {\n // It's either buffer rejection or any other xhr/fetch error, which are treated as NetworkError.\n if (reason instanceof SentryError) {\n this.recordLostEvent('queue_overflow', sentryRequest.type);\n } else {\n this.recordLostEvent('network_error', sentryRequest.type);\n }\n throw reason;\n });\n }\n}\n"]}
\No newline at end of file