Last active
November 26, 2018 19:20
-
-
Save ndmanvar/7ae7b4db7bf1cda30545c1480fde77fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var request = require('request'); | |
function HTTPSProxyTransport() {} | |
HTTPSProxyTransport.prototype.send = function (client, message, headers, eventId, cb) { | |
var options = { | |
url: 'https://' + client.dsn.host + client.dsn.path + 'api/' + client.dsn.project_id + '/store/', | |
headers: headers, | |
method: 'POST', | |
ca: client.ca, | |
body: message | |
}; | |
request(options, function (error, response, body) { | |
if (!error && response.statusCode == 200 && response.statusCode < 300) { | |
client.emit('logged', eventId); | |
cb && cb(null, eventId); | |
} else { | |
var reason = response.headers['x-sentry-error']; | |
var e = new Error('HTTP Error (' + response.statusCode + '): ' + reason); | |
e.response = response; | |
e.statusCode = response.statusCode; | |
e.reason = reason; | |
e.sendMessage = message; | |
e.requestHeaders = headers; | |
e.eventId = eventId; | |
client.emit('error', e); | |
cb && cb(e); | |
} | |
}); | |
}; | |
module.exports.HTTPSProxyTransport = HTTPSProxyTransport; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@timwaddell we missed it, my bad. Here's a PR for it - getsentry/sentry-javascript#1761
Coming in the next release.