Merge pull request #128 from jitsi/tracking

Tracking
This commit is contained in:
Philipp Hancke 2014-09-12 15:00:21 +02:00
commit e484e6e34f
3 changed files with 43 additions and 0 deletions

41
app.js
View File

@ -160,9 +160,17 @@ function obtainAudioAndVideoPermissions(callback) {
['audio', 'video'], ['audio', 'video'],
function (avStream) { function (avStream) {
callback(avStream); callback(avStream);
trackUsage('localMedia', {
audio: avStream.getAudioTracks().length,
video: avStream.getVideoTracks().length
});
}, },
function (error) { function (error) {
console.error('failed to obtain audio/video stream - stop', error); console.error('failed to obtain audio/video stream - stop', error);
trackUsage('localMediaError', {
media: error.media || 'video',
name : error.name
});
}, },
config.resolution || '360'); config.resolution || '360');
} }
@ -592,6 +600,39 @@ $(document).bind('setLocalDescription.jingle', function (event, sid) {
} }
}); });
$(document).bind('iceconnectionstatechange.jingle', function (event, sid, session) {
switch (session.peerconnection.iceConnectionState) {
case 'checking':
session.timeChecking = (new Date()).getTime();
session.firstconnect = true;
break;
case 'completed': // on caller side
case 'connected':
if (session.firstconnect) {
session.firstconnect = false;
var metadata = {};
metadata.setupTime = (new Date()).getTime() - session.timeChecking;
session.peerconnection.getStats(function (res) {
res.result().forEach(function (report) {
if (report.type == 'googCandidatePair' && report.stat('googActiveConnection') == 'true') {
metadata.localCandidateType = report.stat('googLocalCandidateType');
metadata.remoteCandidateType = report.stat('googRemoteCandidateType');
// log pair as well so we can get nice pie charts
metadata.candidatePair = report.stat('googLocalCandidateType') + ';' + report.stat('googRemoteCandidateType');
if (report.stat('googRemoteAddress').indexOf('[') === 0) {
metadata.ipv6 = true;
}
}
});
trackUsage('iceConnected', metadata);
});
}
break;
}
});
$(document).bind('joined.muc', function (event, jid, info) { $(document).bind('joined.muc', function (event, jid, info) {
updateRoomUrl(window.location.href); updateRoomUrl(window.location.href);
document.getElementById('localNick').appendChild( document.getElementById('localNick').appendChild(

View File

@ -53,6 +53,7 @@
<script src="bottom_toolbar.js?v=2"></script><!-- media stream --> <script src="bottom_toolbar.js?v=2"></script><!-- media stream -->
<script src="roomname_generator.js?v=1"></script><!-- generator for random room names --> <script src="roomname_generator.js?v=1"></script><!-- generator for random room names -->
<script src="keyboard_shortcut.js?v=1"></script> <script src="keyboard_shortcut.js?v=1"></script>
<script src="tracking.js?v=1"></script><!-- tracking -->
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="css/font.css?v=4"/> <link rel="stylesheet" href="css/font.css?v=4"/>
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=23"/> <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=23"/>

View File

@ -126,6 +126,7 @@ ColibriFocus.prototype.makeConference = function (peers) {
window.setTimeout(function() { self.modifySources(); }, 1000); window.setTimeout(function() { self.modifySources(); }, 1000);
} }
*/ */
$(document).trigger('iceconnectionstatechange.jingle', [self.sid, self]);
}; };
this.peerconnection.onsignalingstatechange = function (event) { this.peerconnection.onsignalingstatechange = function (event) {
console.warn(self.peerconnection.signalingState); console.warn(self.peerconnection.signalingState);