Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sendSession: (session, cb = () => {}) => {
try {
const url = client.config.endpoints.sessions
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', client.config.apiKey)
req.setRequestHeader('Bugsnag-Payload-Version', '1')
req.setRequestHeader('Bugsnag-Sent-At', isoDate())
req.send(payload.session(session, client.config.filters))
} catch (e) {
client._logger.error(e)
}
}
})
setTimeout(() => {
try {
req.send(payload.session(session, client.config.filters))
} catch (e) {
this._logger.error(e)
cb(e)
}
}, 0)
}
sendSession: (session, cb = () => {}) => {
const url = client.config.endpoints.sessions
let body, opts
try {
body = payload.session(session, client.config.filters)
opts = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Bugsnag-Api-Key': client.config.apiKey,
'Bugsnag-Payload-Version': '1',
'Bugsnag-Sent-At': isoDate()
},
body
}
if (!networkStatus.isConnected) {
enqueue('session', { url, opts })
return cb(null)
}
client._logger.info(`Sending session`)
send(url, opts, err => {
sendSession: (session, cb = () => {}) => {
const _cb = err => {
if (err) client._logger.error(`Session failed to send…\n${(err && err.stack) ? err.stack : err}`, err)
cb(err)
}
try {
request({
url: client.config.endpoints.sessions,
headers: {
'Content-Type': 'application/json',
'Bugsnag-Api-Key': client.config.apiKey,
'Bugsnag-Payload-Version': '1',
'Bugsnag-Sent-At': isoDate()
},
body: payload.session(session, client.config.filters),
agent: client.config.agent
}, err => _cb(err))
} catch (e) {
_cb(e)
}
}
})
sendSession: (session, cb = () => {}) => {
const url = client.config.endpoints.sessions
let body, opts
try {
body = payload.session(session, client.config.filters)
opts = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Bugsnag-Api-Key': client.config.apiKey,
'Bugsnag-Payload-Version': '1',
'Bugsnag-Sent-At': isoDate()
},
body
}
if (!networkStatus.isConnected) {
enqueue('session', { url, opts })
return cb(null)
}
client._logger.info(`Sending session`)
send(url, opts, err => {