Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Commit

Permalink
Bug 1281252 - Add better logging for subscribing completing and impro…
Browse files Browse the repository at this point in the history
…ve exception logging. r=dmose
  • Loading branch information
Standard8 committed Jun 22, 2016
1 parent 1470b54 commit d572b37
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 7 deletions.
19 changes: 12 additions & 7 deletions shared/js/otSdkDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ loop.OTSdkDriver = (function() {
break;
case "Session.networkDisconnected":
case "Session.forceDisconnected":
case "Session.subscribeCompleted":
case "Session.screen.subscribeCompleted":
break;
default:
// We don't want unexpected events being sent to the server, so
Expand Down Expand Up @@ -622,6 +624,7 @@ loop.OTSdkDriver = (function() {
srcMediaElement: sdkSubscriberVideo
}));

this._notifyMetricsEvent("Session.subscribeCompleted");
this._subscribedRemoteStream = true;
if (this._checkAllStreamsConnected()) {
this.dispatcher.dispatch(new sharedActions.MediaConnected());
Expand Down Expand Up @@ -655,6 +658,7 @@ loop.OTSdkDriver = (function() {
receiving: true, srcMediaElement: sdkSubscriberVideo
}));

this._notifyMetricsEvent("Session.screen.subscribeCompleted");
},

/**
Expand Down Expand Up @@ -974,35 +978,36 @@ loop.OTSdkDriver = (function() {
* @param {OT.Event} event
*/
_onOTException: function(event) {
var baseException = "sdk.exception.";
if (event.target && event.target === this.screenshare) {
baseException += "screen.";
}

switch (event.code) {
case OT.ExceptionCodes.PUBLISHER_ICE_WORKFLOW_FAILED:
case OT.ExceptionCodes.SUBSCRIBER_ICE_WORKFLOW_FAILED:
this.dispatcher.dispatch(new sharedActions.ConnectionFailure({
reason: FAILURE_DETAILS.ICE_FAILED
}));
this._notifyMetricsEvent("sdk.exception." + event.code);
this._notifyMetricsEvent(baseException + event.code);
break;
case OT.ExceptionCodes.TERMS_OF_SERVICE_FAILURE:
this.dispatcher.dispatch(new sharedActions.ConnectionFailure({
reason: FAILURE_DETAILS.TOS_FAILURE
}));
// We still need to log the exception so that the server knows why this
// attempt failed.
this._notifyMetricsEvent("sdk.exception." + event.code);
this._notifyMetricsEvent(baseException + event.code);
break;
case OT.ExceptionCodes.UNABLE_TO_PUBLISH:
// Don't report errors for GetUserMedia events as these are expected if
// the user denies the prompt.
if (event.message !== "GetUserMedia") {
var baseException = "sdk.exception.";
if (event.target && event.target === this.screenshare) {
baseException += "screen.";
}
this._notifyMetricsEvent(baseException + event.code + "." + event.message);
}
break;
default:
this._notifyMetricsEvent("sdk.exception." + event.code);
this._notifyMetricsEvent(baseException + event.code);
break;
}
},
Expand Down
56 changes: 56 additions & 0 deletions shared/test/otSdkDriver_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,24 @@ describe("loop.OTSdkDriver", function() {
new sharedActions.MediaConnected({}));
});

it("should dispatch a connectionStatus action if both streams are up", function() {
driver._publishedLocalStream = true;

session.trigger("streamCreated", { stream: fakeStream });

// Called twice due to the VideoDimensionsChanged above.
sinon.assert.called(dispatcher.dispatch);
sinon.assert.calledWithMatch(dispatcher.dispatch,
new sharedActions.ConnectionStatus({
event: "Session.subscribeCompleted",
state: "receiving",
// Local stream connection is faked, so connections/sendStreams=0.
connections: 0,
sendStreams: 0,
recvStreams: 1
}));
});

describe("Data channel setup", function() {
var fakeChannel;

Expand Down Expand Up @@ -1169,6 +1187,44 @@ describe("loop.OTSdkDriver", function() {
sinon.assert.calledWithExactly(dispatcher.dispatch,
new sharedActions.ReceivingScreenShare({ receiving: true }));
});

describe("screen share subscribe completed", function() {
beforeEach(function() {
fakeStream.videoType = "screen";

session.subscribe.yieldsOn(driver, null, fakeSubscriberObject,
videoElement).returns(this.fakeSubscriberObject);
});

it("should dispatch ReceivingScreenShare on completion", function() {
fakeStream.connection = fakeConnection;
fakeStream.hasVideo = false;

session.trigger("streamCreated", { stream: fakeStream });

sinon.assert.called(dispatcher.dispatch);
sinon.assert.calledWithExactly(dispatcher.dispatch,
new sharedActions.ReceivingScreenShare({
receiving: true,
srcMediaElement: videoElement
}));
});

it("should dispatch a connectionStatus action", function() {
session.trigger("streamCreated", { stream: fakeStream });

// Called twice due to the VideoDimensionsChanged above.
sinon.assert.called(dispatcher.dispatch);
sinon.assert.calledWithMatch(dispatcher.dispatch,
new sharedActions.ConnectionStatus({
event: "Session.screen.subscribeCompleted",
state: "receiving",
connections: 0,
sendStreams: 0,
recvStreams: 1
}));
});
});
});
});

Expand Down

0 comments on commit d572b37

Please sign in to comment.