Skip to content

Commit eafbc1b

Browse files
committed
Merge pull request #381 from getsentry/pr/335
Can specify custom transport mechanism via globalOptions.transport
2 parents fe7b594 + 3c605d3 commit eafbc1b

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/raven.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ function send(data) {
740740

741741
if (!isSetup()) return;
742742

743-
makeRequest({
743+
(globalOptions.transport || makeRequest)({
744744
url: globalServer,
745745
auth: {
746746
sentry_version: '4',

test/raven.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,36 @@ describe('globals', function() {
11571157
assert.isFunction(opts.onError);
11581158
});
11591159

1160+
it('should call globalOptions.transport if specified', function() {
1161+
this.sinon.stub(window, 'isSetup').returns(true);
1162+
this.sinon.stub(window, 'getHttpData').returns({
1163+
url: 'http://localhost/?a=b',
1164+
headers: {'User-Agent': 'lolbrowser'}
1165+
});
1166+
1167+
globalProject = '2';
1168+
globalOptions = {
1169+
logger: 'javascript',
1170+
transport: sinon.stub()
1171+
};
1172+
1173+
send({foo: 'bar'});
1174+
assert.deepEqual(globalOptions.transport.lastCall.args[0].data, {
1175+
project: '2',
1176+
logger: 'javascript',
1177+
platform: 'javascript',
1178+
request: {
1179+
url: 'http://localhost/?a=b',
1180+
headers: {
1181+
'User-Agent': 'lolbrowser'
1182+
}
1183+
},
1184+
event_id: 'abc123',
1185+
foo: 'bar',
1186+
extra: {'session:duration': 100}
1187+
});
1188+
});
1189+
11601190
it('should check `isSetup`', function() {
11611191
this.sinon.stub(window, 'isSetup').returns(false);
11621192
this.sinon.stub(window, 'makeRequest');

0 commit comments

Comments
 (0)