callstats
This commit is contained in:
parent
3cd549a758
commit
0d03a4fceb
|
@ -230,7 +230,26 @@ export default {
|
|||
get startVideoMuted () {
|
||||
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
|
||||
isJoined () {
|
||||
return this._room
|
||||
|
@ -292,10 +311,7 @@ export default {
|
|||
this._setupListeners();
|
||||
},
|
||||
_getConferenceOptions() {
|
||||
let options = {
|
||||
openSctp: config.openSctp,
|
||||
disableAudioLevels: config.disableAudioLevels
|
||||
};
|
||||
let options = config;
|
||||
if(config.enableRecording) {
|
||||
options.recordingType = (config.hosts &&
|
||||
(typeof config.hosts.jirecon != "undefined"))?
|
||||
|
@ -359,10 +375,8 @@ export default {
|
|||
if(track.isLocal()){
|
||||
id = this.localId;
|
||||
if(track.getType() === "audio") {
|
||||
APP.statistics.onAudioMute(mute);
|
||||
this.audioMuted = mute;
|
||||
} else {
|
||||
APP.statistics.onVideoMute(mute);
|
||||
this.videoMuted = mute;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -245,7 +245,6 @@
|
|||
<script type="text/javascript">
|
||||
if (!config.disableThirdPartyRequests) {
|
||||
[
|
||||
'https://api.callstats.io/static/callstats.min.js',
|
||||
'analytics.js?v=1'
|
||||
].forEach(function(extSrc) {
|
||||
var extScript = document.createElement('script');
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* Created by Yana Stamcheva on 2/10/15.
|
||||
*/
|
||||
var messageHandler = require("./util/MessageHandler");
|
||||
var callStats = require("../statistics/CallStats");
|
||||
|
||||
/**
|
||||
* Constructs the html for the overall feedback window.
|
||||
|
@ -78,7 +77,7 @@ var Feedback = {
|
|||
init: function () {
|
||||
// CallStats is the way we send feedback, so we don't have to initialise
|
||||
// if callstats isn't enabled.
|
||||
if (!callStats.isEnabled())
|
||||
if (!APP.conference.isCallstatsEnabled())
|
||||
return;
|
||||
|
||||
$("div.feedbackButton").css("display", "block");
|
||||
|
@ -92,7 +91,7 @@ var Feedback = {
|
|||
* @return true if the feedback functionality is enabled, false otherwise.
|
||||
*/
|
||||
isEnabled: function() {
|
||||
return callStats.isEnabled();
|
||||
return APP.conference.isCallstatsEnabled();
|
||||
},
|
||||
/**
|
||||
* Opens the feedback window.
|
||||
|
@ -118,7 +117,7 @@ var Feedback = {
|
|||
// If the feedback is less than 3 stars we're going to
|
||||
// ask the user for more information.
|
||||
if (Feedback.feedbackScore > 3) {
|
||||
callStats.sendFeedback(Feedback.feedbackScore, "");
|
||||
APP.conference.sendFeedback(Feedback.feedbackScore, "");
|
||||
if (feedbackWindowCallback)
|
||||
feedbackWindowCallback();
|
||||
else
|
||||
|
@ -160,7 +159,7 @@ var Feedback = {
|
|||
= document.getElementById("feedbackTextArea").value;
|
||||
|
||||
if (feedbackDetails && feedbackDetails.length > 0)
|
||||
callStats.sendFeedback( Feedback.feedbackScore,
|
||||
APP.conference.sendFeedback( Feedback.feedbackScore,
|
||||
feedbackDetails);
|
||||
|
||||
if (feedbackWindowCallback)
|
||||
|
@ -233,4 +232,4 @@ var Feedback = {
|
|||
};
|
||||
|
||||
// Exports the Feedback class.
|
||||
module.exports = Feedback;
|
||||
module.exports = Feedback;
|
||||
|
|
|
@ -177,6 +177,9 @@ UI.initConference = function () {
|
|||
UI.setUserAvatar(id, settings.email);
|
||||
|
||||
Toolbar.checkAutoEnableDesktopSharing();
|
||||
if(!interfaceConfig.filmStripOnly) {
|
||||
Feedback.init();
|
||||
}
|
||||
};
|
||||
|
||||
UI.mucJoined = function () {
|
||||
|
@ -282,7 +285,6 @@ UI.start = function () {
|
|||
// dump(event.target);
|
||||
// FIXME integrate logs
|
||||
});
|
||||
Feedback.init();
|
||||
} else {
|
||||
$("#header").css("display", "none");
|
||||
$("#bottomToolbar").css("display", "none");
|
||||
|
|
|
@ -4,8 +4,6 @@ var email = '';
|
|||
var displayName = '';
|
||||
var userId;
|
||||
var language = null;
|
||||
var callStatsUserName;
|
||||
|
||||
|
||||
function supportsLocalStorage() {
|
||||
try {
|
||||
|
@ -30,22 +28,13 @@ if (supportsLocalStorage()) {
|
|||
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 || '';
|
||||
callStatsUserName = window.localStorage.callStatsUserName;
|
||||
email = window.localStorage.email || '';
|
||||
displayName = window.localStorage.displayname || '';
|
||||
language = window.localStorage.language;
|
||||
} else {
|
||||
console.log("local storage is not supported");
|
||||
userId = generateUniqueId();
|
||||
callStatsUserName = generateUsername();
|
||||
}
|
||||
|
||||
export default {
|
||||
|
@ -73,14 +62,6 @@ export default {
|
|||
return displayName;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns fake username for callstats
|
||||
* @returns {string} fake username for callstats
|
||||
*/
|
||||
getCallStatsUserName: function () {
|
||||
return callStatsUserName;
|
||||
},
|
||||
|
||||
setEmail: function (newEmail) {
|
||||
email = newEmail;
|
||||
window.localStorage.email = newEmail;
|
||||
|
|
|
@ -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;
|
|
@ -6,7 +6,6 @@ var RTPStats = require("./RTPStatsCollector.js");
|
|||
var EventEmitter = require("events");
|
||||
var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
|
||||
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
||||
var CallStats = require("./CallStats");
|
||||
var RTCEvents = require("../../service/RTC/RTCEvents");
|
||||
var StatisticsEvents = require("../../service/statistics/Events");
|
||||
|
||||
|
@ -32,7 +31,6 @@ function startRemoteStats (peerconnection) {
|
|||
}
|
||||
|
||||
function onDisposeConference(onUnload) {
|
||||
CallStats.sendTerminateEvent();
|
||||
stopRemote();
|
||||
if (onUnload) {
|
||||
eventEmitter.removeAllListeners();
|
||||
|
@ -58,15 +56,6 @@ export default {
|
|||
eventEmitter.removeAllListeners();
|
||||
}
|
||||
},
|
||||
onAudioMute (mute) {
|
||||
CallStats.sendMuteEvent(mute, "audio");
|
||||
},
|
||||
onVideoMute (mute) {
|
||||
CallStats.sendMuteEvent(mute, "video");
|
||||
},
|
||||
onGetUserMediaFailed (e) {
|
||||
CallStats.sendGetUserMediaFailed(e);
|
||||
},
|
||||
start: function () {
|
||||
const xmpp = APP.conference._room.xmpp;
|
||||
xmpp.addListener(
|
||||
|
@ -77,41 +66,6 @@ export default {
|
|||
// onnegotiationneeded
|
||||
xmpp.addListener(XMPPEvents.CALL_INCOMING, function (event) {
|
||||
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);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue