@sentry/browser
Version:
Official Sentry SDK for browsers
36 lines (30 loc) • 951 B
JavaScript
Object.defineProperty(exports, '__esModule', { value: true });
var core = require('@sentry/core');
var utils = require('./utils.js');
/**
* Creates a Transport that uses the Fetch API to send events to Sentry.
*/
function makeFetchTransport(
options,
nativeFetch = utils.getNativeFetchImplementation(),
) {
function makeRequest(request) {
var requestOptions = {
body: request.body,
method: 'POST',
referrerPolicy: 'origin',
headers: options.headers,
...options.fetchOptions,
};
return nativeFetch(options.url, requestOptions).then(response => ({
statusCode: response.status,
headers: {
'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),
'retry-after': response.headers.get('Retry-After'),
},
}));
}
return core.createTransport(options, makeRequest);
}
exports.makeFetchTransport = makeFetchTransport;
//# sourceMappingURL=fetch.js.map