Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(analytics): Add analytics permanent properties and use new paramenters format

hristoterezov6e4a710df629
diff --git a/analytics.js b/analytics.js
index ff25e85b56..7f270fd4ee 100644
--- a/analytics.js
+++ b/analytics.js
@@ -16,17 +16,15 @@
/* eslint-enable */
}
- Analytics.prototype.sendEvent = function (action, data, label, browserName) {
+ Analytics.prototype.sendEvent = function (action, data) {
// empty label if missing value for it and add the value,
// the value should be integer or null
- var value = Math.round(parseFloat(data));
+ var value = data.value;
+ value = value? Math.round(parseFloat(value)) : null;
+ var label = data.label || "";
ga('send', 'event', 'jit.si',
- action + '.' + browserName, label ? label : "", value ? value : null);
- };
-
- Analytics.prototype.sendFeedback = function (data, label, browserName) {
- this.sendEvent('feedback.rating', data.overall, label, browserName);
+ action + '.' + data.browserName, label, value);
};
ctx.Analytics = Analytics;
diff --git a/app.js b/app.js
index 5a06b4c8d8..49b4b1059f 100644
--- a/app.js
+++ b/app.js
@@ -110,11 +110,6 @@ function init() {
var isUIReady = APP.UI.start();
if (isUIReady) {
APP.conference.init({roomName: buildRoomName()}).then(function () {
- let server = APP.tokenData.server;
- if(server) {
- APP.conference.logEvent("server." + server, 1);
- }
-
APP.UI.initConference();
APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
diff --git a/conference.js b/conference.js
index 11b20cc970..3b14f5c646 100644
--- a/conference.js
+++ b/conference.js
@@ -485,6 +485,39 @@ class ConferenceConnector {
}
}
+/**
+ * Sends statistics from APP.tokenData
+ */
+function sendTokenDataStats() {
+ let {server, group} = APP.tokenData;
+ if(server) {
+ APP.conference.logEvent("server." + server, 1);
+ }
+ if(group) {
+ APP.conference.logEvent("group", group);
+ }
+}
+
+/**
+ * Set permanent ptoperties to analytics.
+ * NOTE: Has to be used after JitsiMeetJS.init. otherwise analytics will be
+ * null.
+ */
+function setAnalyticsPermanentProperties() {
+ let permanentProperties = {
+ userAgent: navigator.userAgent,
+ roomName: APP.conference.roomName
+ };
+ let {server, group} = APP.tokenData;
+ if(server) {
+ permanentProperties.server = server;
+ }
+ if(group) {
+ permanentProperties.group = group;
+ }
+ JitsiMeetJS.analytics.addPermanentProperties(permanentProperties);
+}
+
export default {
isModerator: false,
audioMuted: false,
@@ -532,8 +565,11 @@ export default {
}
return JitsiMeetJS.init(config)
- .then(() => createInitialLocalTracksAndConnect(options.roomName))
- .then(([tracks, con]) => {
+ .then(() => {
+ setAnalyticsPermanentProperties();
+ sendTokenDataStats();
+ return createInitialLocalTracksAndConnect(options.roomName);
+ }).then(([tracks, con]) => {
console.log('initialized with %s local tracks', tracks.length);
APP.connection = connection = con;
this._createRoom(tracks);
@@ -1452,7 +1488,8 @@ export default {
// Longer delays will be caused by something else and will just
// poison the data.
if (delay < 2000) {
- JitsiMeetJS.analytics.sendEvent('stream.switch.delay', delay);
+ JitsiMeetJS.analytics.sendEvent('stream.switch.delay',
+ {value: delay});
}
});
@@ -1764,7 +1801,7 @@ export default {
*/
logEvent(name, value) {
if(JitsiMeetJS.analytics) {
- JitsiMeetJS.analytics.sendEvent(name, value);
+ JitsiMeetJS.analytics.sendEvent(name, {value});
}
if(room) {
room.sendApplicationLog(JSON.stringify({name, value}));
diff --git a/modules/TokenData/TokenData.js b/modules/TokenData/TokenData.js
index 0ed76fe32d..624e0dcb9c 100644
--- a/modules/TokenData/TokenData.js
+++ b/modules/TokenData/TokenData.js
@@ -99,6 +99,7 @@ class TokenData{
if(!this.payload.context)
return;
this.server = this.payload.context.server;
+ this.group = this.payload.context.group;
let callerData = this.payload.context.user;
let calleeData = this.payload.context.callee;
if(callerData)