Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handleXHRError () {
if (includes(getIgnoredUrls, this[REQUEST_URL_KEY])) {
// don't leave a network breadcrumb from bugsnag notify calls
return
}
// failed to contact server
client.leaveBreadcrumb('XMLHttpRequest error', {
request: `${this[REQUEST_METHOD_KEY]} ${this[REQUEST_URL_KEY]}`
}, BREADCRUMB_TYPE)
}
function handleXHRLoad () {
if (includes(getIgnoredUrls(), this[REQUEST_URL_KEY])) {
// don't leave a network breadcrumb from bugsnag notify calls
return
}
const metadata = {
status: this.status,
request: `${this[REQUEST_METHOD_KEY]} ${this[REQUEST_URL_KEY]}`
}
if (this.status >= 400) {
// contacted server but got an error response
client.leaveBreadcrumb('XMLHttpRequest failed', metadata, BREADCRUMB_TYPE)
} else {
client.leaveBreadcrumb('XMLHttpRequest succeeded', metadata, BREADCRUMB_TYPE)
}
}
exports.init = (_client, _getIgnoredUrls = defaultIgnoredUrls, _win = window) => {
if (!_client._config.enabledBreadcrumbTypes || !includes(_client._config.enabledBreadcrumbTypes, 'request')) return
client = _client
win = _win
getIgnoredUrls = _getIgnoredUrls
monkeyPatchXMLHttpRequest()
monkeyPatchFetch()
}