Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sendReport: (report, cb = () => {}) => {
try {
const url = client.config.endpoints.notify
const req = new win.XMLHttpRequest()
req.onreadystatechange = function () {
if (req.readyState === win.XMLHttpRequest.DONE) cb(null)
}
req.open('POST', url)
req.setRequestHeader('Content-Type', 'application/json')
req.setRequestHeader('Bugsnag-Api-Key', report.apiKey || client.config.apiKey)
req.setRequestHeader('Bugsnag-Payload-Version', '4')
req.setRequestHeader('Bugsnag-Sent-At', isoDate())
req.send(payload.report(report, client.config.filters))
} catch (e) {
client._logger.error(e)
}
},
sendSession: (session, cb = () => {}) => {
sendReport: (report, cb = () => {}) => {
const _cb = err => {
if (err) client._logger.error(`Report failed to send…\n${(err && err.stack) ? err.stack : err}`, err)
cb(err)
}
try {
request({
url: client.config.endpoints.notify,
headers: {
'Content-Type': 'application/json',
'Bugsnag-Api-Key': report.apiKey || client.config.apiKey,
'Bugsnag-Payload-Version': '4',
'Bugsnag-Sent-At': isoDate()
},
body: payload.report(report, client.config.filters),
agent: client.config.agent
}, (err, body) => _cb(err))
} catch (e) {
_cb(e)
}
},
sendSession: (session, cb = () => {}) => {
sendReport: (report, cb = () => {}) => {
const url = client.config.endpoints.notify
let body, opts
try {
body = payload.report(report, client.config.filters)
opts = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Bugsnag-Api-Key': report.apiKey,
'Bugsnag-Payload-Version': '4',
'Bugsnag-Sent-At': isoDate()
},
body
}
if (!networkStatus.isConnected || report.events[0].attemptImmediateDelivery === false) {
enqueue('report', { url, opts })
return cb(null)
}
client._logger.info(`Sending report ${report.events[0].get('errorClass')}: ${report.events[0].get('errorMessage')}`)
send(url, opts, err => {
setTimeout(() => {
try {
req.send(payload.report(report, client.config.filters))
} catch (e) {
client._logger.error(e)
cb(e)
}
}, 0)
},
sendReport: (report, cb = () => {}) => {
const url = client.config.endpoints.notify
let body, opts
try {
body = payload.report(report, client.config.filters)
opts = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Bugsnag-Api-Key': report.apiKey || client.config.apiKey,
'Bugsnag-Payload-Version': '4',
'Bugsnag-Sent-At': isoDate()
},
body
}
if (!networkStatus.isConnected || report.attemptImmediateDelivery === false) {
enqueue('report', { url, opts })
return cb(null)
}
client._logger.info(`Sending report ${report.events[0].errorClass}: ${report.events[0].errorMessage}`)
send(url, opts, err => {