callstats

This commit is contained in:
hristoterezov 2016-01-20 15:41:37 -06:00
parent 3cd549a758
commit 0d03a4fceb
7 changed files with 29 additions and 298 deletions

View File

@ -230,7 +230,26 @@ export default {
get startVideoMuted () { get startVideoMuted () {
return room && room.getStartMutedPolicy().video; return room && room.getStartMutedPolicy().video;
}, },
/**
* Returns true if the callstats integration is enabled, otherwise returns
* false.
*
* @returns true if the callstats integration is enabled, otherwise returns
* false.
*/
isCallstatsEnabled () {
return room.isCallstatsEnabled();
},
/**
* Sends the given feedback through CallStats if enabled.
*
* @param overallFeedback an integer between 1 and 5 indicating the
* user feedback
* @param detailedFeedback detailed feedback from the user. Not yet used
*/
sendFeedback (overallFeedback, detailedFeedback) {
return room.sendFeedback (overallFeedback, detailedFeedback);
},
// used by torture currently // used by torture currently
isJoined () { isJoined () {
return this._room return this._room
@ -292,10 +311,7 @@ export default {
this._setupListeners(); this._setupListeners();
}, },
_getConferenceOptions() { _getConferenceOptions() {
let options = { let options = config;
openSctp: config.openSctp,
disableAudioLevels: config.disableAudioLevels
};
if(config.enableRecording) { if(config.enableRecording) {
options.recordingType = (config.hosts && options.recordingType = (config.hosts &&
(typeof config.hosts.jirecon != "undefined"))? (typeof config.hosts.jirecon != "undefined"))?
@ -359,10 +375,8 @@ export default {
if(track.isLocal()){ if(track.isLocal()){
id = this.localId; id = this.localId;
if(track.getType() === "audio") { if(track.getType() === "audio") {
APP.statistics.onAudioMute(mute);
this.audioMuted = mute; this.audioMuted = mute;
} else { } else {
APP.statistics.onVideoMute(mute);
this.videoMuted = mute; this.videoMuted = mute;
} }
} else { } else {

View File

@ -245,7 +245,6 @@
<script type="text/javascript"> <script type="text/javascript">
if (!config.disableThirdPartyRequests) { if (!config.disableThirdPartyRequests) {
[ [
'https://api.callstats.io/static/callstats.min.js',
'analytics.js?v=1' 'analytics.js?v=1'
].forEach(function(extSrc) { ].forEach(function(extSrc) {
var extScript = document.createElement('script'); var extScript = document.createElement('script');

View File

@ -4,7 +4,6 @@
* Created by Yana Stamcheva on 2/10/15. * Created by Yana Stamcheva on 2/10/15.
*/ */
var messageHandler = require("./util/MessageHandler"); var messageHandler = require("./util/MessageHandler");
var callStats = require("../statistics/CallStats");
/** /**
* Constructs the html for the overall feedback window. * Constructs the html for the overall feedback window.
@ -78,7 +77,7 @@ var Feedback = {
init: function () { init: function () {
// CallStats is the way we send feedback, so we don't have to initialise // CallStats is the way we send feedback, so we don't have to initialise
// if callstats isn't enabled. // if callstats isn't enabled.
if (!callStats.isEnabled()) if (!APP.conference.isCallstatsEnabled())
return; return;
$("div.feedbackButton").css("display", "block"); $("div.feedbackButton").css("display", "block");
@ -92,7 +91,7 @@ var Feedback = {
* @return true if the feedback functionality is enabled, false otherwise. * @return true if the feedback functionality is enabled, false otherwise.
*/ */
isEnabled: function() { isEnabled: function() {
return callStats.isEnabled(); return APP.conference.isCallstatsEnabled();
}, },
/** /**
* Opens the feedback window. * Opens the feedback window.
@ -118,7 +117,7 @@ var Feedback = {
// If the feedback is less than 3 stars we're going to // If the feedback is less than 3 stars we're going to
// ask the user for more information. // ask the user for more information.
if (Feedback.feedbackScore > 3) { if (Feedback.feedbackScore > 3) {
callStats.sendFeedback(Feedback.feedbackScore, ""); APP.conference.sendFeedback(Feedback.feedbackScore, "");
if (feedbackWindowCallback) if (feedbackWindowCallback)
feedbackWindowCallback(); feedbackWindowCallback();
else else
@ -160,7 +159,7 @@ var Feedback = {
= document.getElementById("feedbackTextArea").value; = document.getElementById("feedbackTextArea").value;
if (feedbackDetails && feedbackDetails.length > 0) if (feedbackDetails && feedbackDetails.length > 0)
callStats.sendFeedback( Feedback.feedbackScore, APP.conference.sendFeedback( Feedback.feedbackScore,
feedbackDetails); feedbackDetails);
if (feedbackWindowCallback) if (feedbackWindowCallback)

View File

@ -177,6 +177,9 @@ UI.initConference = function () {
UI.setUserAvatar(id, settings.email); UI.setUserAvatar(id, settings.email);
Toolbar.checkAutoEnableDesktopSharing(); Toolbar.checkAutoEnableDesktopSharing();
if(!interfaceConfig.filmStripOnly) {
Feedback.init();
}
}; };
UI.mucJoined = function () { UI.mucJoined = function () {
@ -282,7 +285,6 @@ UI.start = function () {
// dump(event.target); // dump(event.target);
// FIXME integrate logs // FIXME integrate logs
}); });
Feedback.init();
} else { } else {
$("#header").css("display", "none"); $("#header").css("display", "none");
$("#bottomToolbar").css("display", "none"); $("#bottomToolbar").css("display", "none");

View File

@ -4,8 +4,6 @@ var email = '';
var displayName = ''; var displayName = '';
var userId; var userId;
var language = null; var language = null;
var callStatsUserName;
function supportsLocalStorage() { function supportsLocalStorage() {
try { try {
@ -30,22 +28,13 @@ if (supportsLocalStorage()) {
console.log("generated id", window.localStorage.jitsiMeetId); console.log("generated id", window.localStorage.jitsiMeetId);
} }
if (!window.localStorage.callStatsUserName) {
window.localStorage.callStatsUserName
= generateUsername();
console.log('generated callstats uid',
window.localStorage.callStatsUserName);
}
userId = window.localStorage.jitsiMeetId || ''; userId = window.localStorage.jitsiMeetId || '';
callStatsUserName = window.localStorage.callStatsUserName;
email = window.localStorage.email || ''; email = window.localStorage.email || '';
displayName = window.localStorage.displayname || ''; displayName = window.localStorage.displayname || '';
language = window.localStorage.language; language = window.localStorage.language;
} else { } else {
console.log("local storage is not supported"); console.log("local storage is not supported");
userId = generateUniqueId(); userId = generateUniqueId();
callStatsUserName = generateUsername();
} }
export default { export default {
@ -73,14 +62,6 @@ export default {
return displayName; return displayName;
}, },
/**
* Returns fake username for callstats
* @returns {string} fake username for callstats
*/
getCallStatsUserName: function () {
return callStatsUserName;
},
setEmail: function (newEmail) { setEmail: function (newEmail) {
email = newEmail; email = newEmail;
window.localStorage.email = newEmail; window.localStorage.email = newEmail;

View File

@ -1,218 +0,0 @@
/* global config, $, APP, Strophe, callstats */
var Settings = require('../settings/Settings');
var jsSHA = require('jssha');
var io = require('socket.io-client');
var callStats = null;
/**
* @const
* @see http://www.callstats.io/api/#enumeration-of-wrtcfuncnames
*/
var wrtcFuncNames = {
createOffer: "createOffer",
createAnswer: "createAnswer",
setLocalDescription: "setLocalDescription",
setRemoteDescription: "setRemoteDescription",
addIceCandidate: "addIceCandidate",
getUserMedia: "getUserMedia"
};
// some errors may happen before CallStats init
// in this case we accumulate them in this array
// and send them to callstats on init
var pendingErrors = [];
function initCallback (err, msg) {
console.log("CallStats Status: err=" + err + " msg=" + msg);
}
var callStatsIntegrationEnabled = config.callStatsID && config.callStatsSecret;
var CallStats = {
init: function (jingleSession) {
if(!callStatsIntegrationEnabled || callStats !== null) {
return;
}
callStats = new callstats($, io, jsSHA);
this.session = jingleSession;
this.peerconnection = jingleSession.peerconnection.peerconnection;
this.userID = Settings.getCallStatsUserName();
var location = window.location;
this.confID = location.hostname + location.pathname;
//userID is generated or given by the origin server
callStats.initialize(config.callStatsID,
config.callStatsSecret,
this.userID,
initCallback);
var usage = callStats.fabricUsage.multiplex;
callStats.addNewFabric(this.peerconnection,
Strophe.getResourceFromJid(jingleSession.peerjid),
usage,
this.confID,
this.pcCallback.bind(this));
// notify callstats about failures if there were any
if (pendingErrors.length) {
pendingErrors.forEach(function (error) {
this._reportError(error.type, error.error, error.pc);
}, this);
pendingErrors.length = 0;
}
},
/**
* Returns true if the callstats integration is enabled, otherwise returns
* false.
*
* @returns true if the callstats integration is enabled, otherwise returns
* false.
*/
isEnabled: function() {
return callStatsIntegrationEnabled;
},
pcCallback: function (err, msg) {
if (!callStats) {
return;
}
console.log("Monitoring status: "+ err + " msg: " + msg);
callStats.sendFabricEvent(this.peerconnection,
callStats.fabricEvent.fabricSetup, this.confID);
},
sendMuteEvent: function (mute, type) {
if (!callStats) {
return;
}
var event = null;
if (type === "video") {
event = (mute? callStats.fabricEvent.videoPause :
callStats.fabricEvent.videoResume);
}
else {
event = (mute? callStats.fabricEvent.audioMute :
callStats.fabricEvent.audioUnmute);
}
callStats.sendFabricEvent(this.peerconnection, event, this.confID);
},
sendTerminateEvent: function () {
if(!callStats) {
return;
}
callStats.sendFabricEvent(this.peerconnection,
callStats.fabricEvent.fabricTerminated, this.confID);
},
sendSetupFailedEvent: function () {
if(!callStats) {
return;
}
callStats.sendFabricEvent(this.peerconnection,
callStats.fabricEvent.fabricSetupFailed, this.confID);
},
/**
* Sends the given feedback through CallStats.
*
* @param overallFeedback an integer between 1 and 5 indicating the
* user feedback
* @param detailedFeedback detailed feedback from the user. Not yet used
*/
sendFeedback: function(overallFeedback, detailedFeedback) {
if(!callStats) {
return;
}
var feedbackString = '{"userID":"' + this.userID + '"' +
', "overall":' + overallFeedback +
', "comment": "' + detailedFeedback + '"}';
var feedbackJSON = JSON.parse(feedbackString);
callStats.sendUserFeedback(
this.confID, feedbackJSON);
},
/**
* Reports an error to callstats.
*
* @param type the type of the error, which will be one of the wrtcFuncNames
* @param e the error
* @param pc the peerconnection
* @private
*/
_reportError: function (type, e, pc) {
if (callStats) {
callStats.reportError(pc, this.confID, type, e);
} else if (callStatsIntegrationEnabled) {
pendingErrors.push({
type: type,
error: e,
pc: pc
});
}
// else just ignore it
},
/**
* Notifies CallStats that getUserMedia failed.
*
* @param {Error} e error to send
*/
sendGetUserMediaFailed: function (e) {
this._reportError(wrtcFuncNames.getUserMedia, e, null);
},
/**
* Notifies CallStats that peer connection failed to create offer.
*
* @param {Error} e error to send
* @param {RTCPeerConnection} pc connection on which failure occured.
*/
sendCreateOfferFailed: function (e, pc) {
this._reportError(wrtcFuncNames.createOffer, e, pc);
},
/**
* Notifies CallStats that peer connection failed to create answer.
*
* @param {Error} e error to send
* @param {RTCPeerConnection} pc connection on which failure occured.
*/
sendCreateAnswerFailed: function (e, pc) {
this._reportError(wrtcFuncNames.createAnswer, e, pc);
},
/**
* Notifies CallStats that peer connection failed to set local description.
*
* @param {Error} e error to send
* @param {RTCPeerConnection} pc connection on which failure occured.
*/
sendSetLocalDescFailed: function (e, pc) {
this._reportError(wrtcFuncNames.setLocalDescription, e, pc);
},
/**
* Notifies CallStats that peer connection failed to set remote description.
*
* @param {Error} e error to send
* @param {RTCPeerConnection} pc connection on which failure occured.
*/
sendSetRemoteDescFailed: function (e, pc) {
this._reportError(wrtcFuncNames.setRemoteDescription, e, pc);
},
/**
* Notifies CallStats that peer connection failed to add ICE candidate.
*
* @param {Error} e error to send
* @param {RTCPeerConnection} pc connection on which failure occured.
*/
sendAddIceCandidateFailed: function (e, pc) {
this._reportError(wrtcFuncNames.addIceCandidate, e, pc);
}
};
module.exports = CallStats;

View File

@ -6,7 +6,6 @@ var RTPStats = require("./RTPStatsCollector.js");
var EventEmitter = require("events"); var EventEmitter = require("events");
var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js"); var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var CallStats = require("./CallStats");
var RTCEvents = require("../../service/RTC/RTCEvents"); var RTCEvents = require("../../service/RTC/RTCEvents");
var StatisticsEvents = require("../../service/statistics/Events"); var StatisticsEvents = require("../../service/statistics/Events");
@ -32,7 +31,6 @@ function startRemoteStats (peerconnection) {
} }
function onDisposeConference(onUnload) { function onDisposeConference(onUnload) {
CallStats.sendTerminateEvent();
stopRemote(); stopRemote();
if (onUnload) { if (onUnload) {
eventEmitter.removeAllListeners(); eventEmitter.removeAllListeners();
@ -58,15 +56,6 @@ export default {
eventEmitter.removeAllListeners(); eventEmitter.removeAllListeners();
} }
}, },
onAudioMute (mute) {
CallStats.sendMuteEvent(mute, "audio");
},
onVideoMute (mute) {
CallStats.sendMuteEvent(mute, "video");
},
onGetUserMediaFailed (e) {
CallStats.sendGetUserMediaFailed(e);
},
start: function () { start: function () {
const xmpp = APP.conference._room.xmpp; const xmpp = APP.conference._room.xmpp;
xmpp.addListener( xmpp.addListener(
@ -77,41 +66,6 @@ export default {
// onnegotiationneeded // onnegotiationneeded
xmpp.addListener(XMPPEvents.CALL_INCOMING, function (event) { xmpp.addListener(XMPPEvents.CALL_INCOMING, function (event) {
startRemoteStats(event.peerconnection); startRemoteStats(event.peerconnection);
// CallStats.init(event);
}); });
xmpp.addListener(
XMPPEvents.PEERCONNECTION_READY,
function (session) {
CallStats.init(session);
}
);
xmpp.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
CallStats.sendSetupFailedEvent();
});
xmpp.addListener(RTCEvents.CREATE_OFFER_FAILED, function (e, pc) {
CallStats.sendCreateOfferFailed(e, pc);
});
xmpp.addListener(RTCEvents.CREATE_ANSWER_FAILED, function (e, pc) {
CallStats.sendCreateAnswerFailed(e, pc);
});
xmpp.addListener(
RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
function (e, pc) {
CallStats.sendSetLocalDescFailed(e, pc);
}
);
xmpp.addListener(
RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
function (e, pc) {
CallStats.sendSetRemoteDescFailed(e, pc);
}
);
xmpp.addListener(
RTCEvents.ADD_ICE_CANDIDATE_FAILED,
function (e, pc) {
CallStats.sendAddIceCandidateFailed(e, pc);
}
);
} }
}; };