Просмотр исходного кода

Formats callstats application logs as JSON.

dev1
Boris Grozev 9 лет назад
Родитель
Сommit
961870f55c
4 измененных файлов: 47 добавлений и 16 удалений
  1. 5
    1
      JitsiConference.js
  2. 12
    4
      JitsiConferenceEventManager.js
  3. 24
    7
      JitsiMeetJS.js
  4. 6
    4
      modules/version/ComponentsVersions.js

+ 5
- 1
JitsiConference.js Просмотреть файл

@@ -1212,7 +1212,11 @@ JitsiConference.prototype._reportAudioProblem = function (ssrc) {
1212 1212
 };
1213 1213
 
1214 1214
 /**
1215
- * Logs an "application log" message
1215
+ * Logs an "application log" message.
1216
+ * @param message {string} The message to log. Note that while this can be a
1217
+ * generic string, the convention used by lib-jitsi-meet and jitsi-meet is to
1218
+ * log valid JSON strings, with an "id" field used for distinguishing between
1219
+ * message types. E.g.: {id: "recorder_status", status: "off"}
1216 1220
  */
1217 1221
 JitsiConference.prototype.sendApplicationLog = function(message) {
1218 1222
     Statistics.sendLog(message);

+ 12
- 4
JitsiConferenceEventManager.js Просмотреть файл

@@ -215,8 +215,14 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
215 215
         if (conference.statistics && conference.isModerator()) {
216 216
             conference.on(JitsiConferenceEvents.RECORDER_STATE_CHANGED,
217 217
                 function (status, error) {
218
-                    Statistics.sendLog("[Recorder] status: " + status
219
-                        + (error? " error: " + error : ""));
218
+                    var logObject = {
219
+                        id: "recorder_status",
220
+                        status: status
221
+                    };
222
+                    if (error) {
223
+                        logObject.error = error;
224
+                    }
225
+                    Statistics.sendLog(JSON.stringify(logObject));
220 226
                 });
221 227
         }
222 228
     });
@@ -254,11 +260,13 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
254 260
 
255 261
     conference.room.addListener(XMPPEvents.LOCAL_UFRAG_CHANGED,
256 262
         function (ufrag) {
257
-            Statistics.sendLog("Local ufrag: " + ufrag);
263
+            Statistics.sendLog(
264
+                JSON.stringify({id: "local_ufrag", value: ufrag}));
258 265
         });
259 266
     conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED,
260 267
         function (ufrag) {
261
-            Statistics.sendLog("Remote ufrag: " + ufrag);
268
+            Statistics.sendLog(
269
+                JSON.stringify({id: "remote_ufrag", value: ufrag}));
262 270
         });
263 271
 
264 272
     chatRoom.addPresenceListener("startmuted", function (data, from) {

+ 24
- 7
JitsiMeetJS.js Просмотреть файл

@@ -67,6 +67,7 @@ var LibJitsiMeet = {
67 67
     logLevels: Logger.levels,
68 68
     mediaDevices: JitsiMediaDevices,
69 69
     init: function (options) {
70
+        var logObject, attr;
70 71
         Statistics.audioLevelsEnabled = !options.disableAudioLevels;
71 72
 
72 73
         if(typeof options.audioLevelsInterval === 'number') {
@@ -78,16 +79,28 @@ var LibJitsiMeet = {
78 79
                 this.getGlobalOnErrorHandler.bind(this));
79 80
         }
80 81
 
81
-        // Lets send some general stats useful for debugging problems
82
+        // Log deployment-specific information, if available.
82 83
         if (window.jitsiRegionInfo
83 84
             && Object.keys(window.jitsiRegionInfo).length > 0) {
84
-            // remove quotes to make it prettier
85
-            Statistics.sendLog(
86
-                JSON.stringify(window.jitsiRegionInfo).replace(/\"/g, ""));
85
+            logObject = {};
86
+            for (attr in window.jitsiRegionInfo) {
87
+                if (window.jitsiRegionInfo.hasOwnProperty(attr)) {
88
+                    logObject[attr] = window.jitsiRegionInfo[attr];
89
+                }
90
+            }
91
+
92
+            logObject.id = "deployment_info";
93
+            Statistics.sendLog(JSON.stringify(logObject));
87 94
         }
88 95
 
89
-        if(this.version)
90
-            Statistics.sendLog("LibJitsiMeet:" + this.version);
96
+        if(this.version) {
97
+            logObject = {
98
+                id: "component_version",
99
+                component: "lib-jitsi-meet",
100
+                version: this.version
101
+            }
102
+            Statistics.sendLog(JSON.stringify(logObject));
103
+        }
91 104
 
92 105
         return RTC.init(options || {});
93 106
     },
@@ -180,7 +193,11 @@ var LibJitsiMeet = {
180 193
                     // User cancelled action is not really an error, so only
181 194
                     // log it as an event to avoid having conference classified
182 195
                     // as partially failed
183
-                    Statistics.sendLog(error.message);
196
+                    var logObject = {
197
+                        id: "chrome_extension_user_canceled",
198
+                        message: error.message
199
+                    };
200
+                    Statistics.sendLog(JSON.stringify(logObject));
184 201
                 } else {
185 202
                     // Report gUM failed to the stats
186 203
                     Statistics.sendGetUserMediaFailed(error);

+ 6
- 4
modules/version/ComponentsVersions.js Просмотреть файл

@@ -48,7 +48,7 @@ ComponentsVersions.prototype.processPresence =
48 48
         return;
49 49
     }
50 50
 
51
-    var log = "";
51
+    var log = [];
52 52
     node.children.forEach(function(item){
53 53
 
54 54
         var componentName = item.attributes.name;
@@ -66,14 +66,16 @@ ComponentsVersions.prototype.processPresence =
66 66
             this.versions[componentName] = version;
67 67
             logger.info("Got " + componentName + " version: " + version);
68 68
 
69
-            log += (log.length > 0? ", " : "")
70
-                + componentName + ": " + version;
69
+            log.push({
70
+                id: "component_version",
71
+                component: componentName,
72
+                version: version});
71 73
         }
72 74
     }.bind(this));
73 75
 
74 76
     // logs versions to stats
75 77
     if (log.length > 0)
76
-        Statistics.sendLog(log);
78
+        Statistics.sendLog(JSON.stringify(log));
77 79
 };
78 80
 
79 81
 /**

Загрузка…
Отмена
Сохранить