UNPKG

1.26 kBJavaScriptView Raw
1Object.defineProperty(exports, "__esModule", { value: true });
2var tslib_1 = require("tslib");
3var core_1 = require("@sentry/core");
4var utils_1 = require("./utils");
5/**
6 * Creates a Transport that uses the Fetch API to send events to Sentry.
7 */
8function makeNewFetchTransport(options, nativeFetch) {
9 if (nativeFetch === void 0) { nativeFetch = utils_1.getNativeFetchImplementation(); }
10 function makeRequest(request) {
11 var requestOptions = tslib_1.__assign({ body: request.body, method: 'POST', referrerPolicy: 'origin' }, options.requestOptions);
12 return nativeFetch(options.url, requestOptions).then(function (response) {
13 return response.text().then(function (body) { return ({
14 body: body,
15 headers: {
16 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),
17 'retry-after': response.headers.get('Retry-After'),
18 },
19 reason: response.statusText,
20 statusCode: response.status,
21 }); });
22 });
23 }
24 return core_1.createTransport({ bufferSize: options.bufferSize }, makeRequest);
25}
26exports.makeNewFetchTransport = makeNewFetchTransport;
27//# sourceMappingURL=new-fetch.js.map
\No newline at end of file