Bug 1223351 - Store a metrics event on the loop server if the data channel setup fails. r=Mardak

This commit is contained in:
Mark Banner 2015-11-10 21:25:51 +00:00
parent ea43365751
commit 75a2db2977
2 changed files with 62 additions and 1 deletions

View File

@ -507,7 +507,9 @@ loop.OTSdkDriver = (function() {
case "Session.forceDisconnected":
break;
default:
if (eventName.indexOf("sdk.exception") === -1) {
// We don't want unexpected events being sent to the server, so
// filter out the unexpected, and let the known ones through.
if (!/^sdk\.(exception|datachannel)/.test(eventName)) {
console.error("Unexpected event name", eventName);
return;
}
@ -676,6 +678,7 @@ loop.OTSdkDriver = (function() {
// Sends will queue until the channel is fully open.
if (err) {
console.error(err);
this._notifyMetricsEvent("sdk.datachannel.sub." + err.message);
return;
}
@ -726,6 +729,7 @@ loop.OTSdkDriver = (function() {
this.publisher._.getDataChannel("text", {}, function(err, channel) {
if (err) {
console.error(err);
this._notifyMetricsEvent("sdk.datachannel.pub." + err.message);
return;
}

View File

@ -1087,6 +1087,8 @@ describe("loop.OTSdkDriver", function() {
fakeChannel = _.extend({}, Backbone.Events);
fakeStream.connection = fakeConnection;
driver._useDataChannels = true;
sandbox.stub(console, "error");
});
it("should trigger a readyForDataChannel signal after subscribe is complete", function() {
@ -1122,6 +1124,33 @@ describe("loop.OTSdkDriver", function() {
sinon.assert.notCalled(fakeSubscriberObject._.getDataChannel);
});
it("should log an error if the data channel couldn't be obtained", function() {
var err = new Error("fakeError");
fakeSubscriberObject._.getDataChannel.callsArgWith(2, err);
session.trigger("streamCreated", { stream: fakeStream });
sinon.assert.calledOnce(console.error);
sinon.assert.calledWithMatch(console.error, err);
});
it("should dispatch ConnectionStatus if the data channel couldn't be obtained", function() {
fakeSubscriberObject._.getDataChannel.callsArgWith(2, new Error("fakeError"));
session.trigger("streamCreated", { stream: fakeStream });
sinon.assert.called(dispatcher.dispatch);
sinon.assert.calledWithExactly(dispatcher.dispatch,
new sharedActions.ConnectionStatus({
connections: 0,
event: "sdk.datachannel.sub.fakeError",
sendStreams: 0,
state: "receiving",
recvStreams: 1
}));
});
it("should dispatch `DataChannelsAvailable` if the publisher channel is setup", function() {
// Fake a publisher channel.
driver._publisherChannel = {};
@ -1549,6 +1578,7 @@ describe("loop.OTSdkDriver", function() {
beforeEach(function() {
driver.subscriber = subscriber;
driver._useDataChannels = true;
sandbox.stub(console, "error");
});
it("should not do anything if data channels are not wanted", function() {
@ -1566,6 +1596,33 @@ describe("loop.OTSdkDriver", function() {
sinon.assert.calledOnce(publisher._.getDataChannel);
});
it("should log an error if the data channel couldn't be obtained", function() {
var err = new Error("fakeError");
publisher._.getDataChannel.callsArgWith(2, err);
session.trigger("signal:readyForDataChannel");
sinon.assert.calledOnce(console.error);
sinon.assert.calledWithMatch(console.error, err);
});
it("should dispatch ConnectionStatus if the data channel couldn't be obtained", function() {
publisher._.getDataChannel.callsArgWith(2, new Error("fakeError"));
session.trigger("signal:readyForDataChannel");
sinon.assert.calledOnce(dispatcher.dispatch);
sinon.assert.calledWithExactly(dispatcher.dispatch,
new sharedActions.ConnectionStatus({
connections: 0,
event: "sdk.datachannel.pub.fakeError",
sendStreams: 0,
state: "starting",
recvStreams: 0
}));
});
it("should dispatch `DataChannelsAvailable` if the subscriber channel is setup", function() {
var fakeChannel = _.extend({}, Backbone.Events);