瀏覽代碼

feat(meetingID): send analytics event.

dev1
Hristo Terezov 5 年之前
父節點
當前提交
4a87f34285
共有 3 個檔案被更改,包括 46 行新增19 行删除
  1. 3
    3
      JitsiConference.js
  2. 27
    16
      modules/xmpp/ChatRoom.js
  3. 16
    0
      service/statistics/AnalyticsEvents.js

+ 3
- 3
JitsiConference.js 查看文件

2123
 };
2123
 };
2124
 
2124
 
2125
 /**
2125
 /**
2126
- * Returns the meeting unique Id if any.
2126
+ * Returns the meeting unique ID if any.
2127
+ *
2128
+ * @returns {string|undefined}
2127
  */
2129
  */
2128
 JitsiConference.prototype.getMeetingUniqueId = function() {
2130
 JitsiConference.prototype.getMeetingUniqueId = function() {
2129
     if (this.room) {
2131
     if (this.room) {
2130
         return this.room.getMeetingId();
2132
         return this.room.getMeetingId();
2131
     }
2133
     }
2132
-
2133
-    return null;
2134
 };
2134
 };
2135
 
2135
 
2136
 /**
2136
 /**

+ 27
- 16
modules/xmpp/ChatRoom.js 查看文件

7
 import * as JitsiTranscriptionStatus from '../../JitsiTranscriptionStatus';
7
 import * as JitsiTranscriptionStatus from '../../JitsiTranscriptionStatus';
8
 import Listenable from '../util/Listenable';
8
 import Listenable from '../util/Listenable';
9
 import * as MediaType from '../../service/RTC/MediaType';
9
 import * as MediaType from '../../service/RTC/MediaType';
10
+import { createConferenceEvent } from '../../service/statistics/AnalyticsEvents';
10
 import XMPPEvents from '../../service/xmpp/XMPPEvents';
11
 import XMPPEvents from '../../service/xmpp/XMPPEvents';
12
+import Statistics from '../statistics/statistics';
11
 
13
 
12
 import Moderator from './moderator';
14
 import Moderator from './moderator';
13
 
15
 
127
 
129
 
128
         this.locked = false;
130
         this.locked = false;
129
         this.transcriptionStatus = JitsiTranscriptionStatus.OFF;
131
         this.transcriptionStatus = JitsiTranscriptionStatus.OFF;
130
-        this.meetingId = null;
131
     }
132
     }
132
 
133
 
133
     /* eslint-enable max-params */
134
     /* eslint-enable max-params */
283
                 = $(result).find('>query>x[type="result"]>field[var="muc#roominfo_meetingId"]>value');
284
                 = $(result).find('>query>x[type="result"]>field[var="muc#roominfo_meetingId"]>value');
284
 
285
 
285
             if (meetingIdValEl.length) {
286
             if (meetingIdValEl.length) {
286
-                const meetingId = meetingIdValEl.text();
287
-
288
-                if (this.meetingId !== meetingId) {
289
-                    if (this.meetingId) {
290
-                        logger.warn(`Meeting Id changed from:${this.meetingId} to:${meetingId}`);
291
-                    }
292
-                    this.meetingId = meetingId;
293
-                }
287
+                this.setMeetingId(meetingIdValEl.text());
294
             } else {
288
             } else {
295
-                logger.trace('No meeting id from backend');
289
+                logger.trace('No meeting ID from backend');
296
             }
290
             }
297
         }, error => {
291
         }, error => {
298
             GlobalOnErrorHandler.callErrorHandler(error);
292
             GlobalOnErrorHandler.callErrorHandler(error);
300
         });
294
         });
301
     }
295
     }
302
 
296
 
297
+    /**
298
+     * Sets the meeting unique Id (received from the backend).
299
+     *
300
+     * @param {string} meetingId - The new meetings id.
301
+     * @returns {void}
302
+     */
303
+    setMeetingId(meetingId) {
304
+        if (this.meetingId !== meetingId) {
305
+            if (this.meetingId) {
306
+                logger.warn(`Meeting Id changed from:${this.meetingId} to:${meetingId}`);
307
+            }
308
+            this.meetingId = meetingId;
309
+
310
+            // The name of the action is a little bit confusing but it seems this is the preferred name by the consumers
311
+            // of the analytics events.
312
+            Statistics.sendAnalytics(createConferenceEvent('joined', meetingId));
313
+        }
314
+    }
315
+
303
     /**
316
     /**
304
      *
317
      *
305
      */
318
      */
952
         }
965
         }
953
 
966
 
954
         if (from === this.roomjid
967
         if (from === this.roomjid
955
-                && $(msg)
956
-                    .find(
957
-                        '>x[xmlns="http://jabber.org/protocol/muc#user"]'
958
-                            + '>status[code="104"]')
959
-                    .length) {
968
+                && $(msg).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="104"]').length) {
960
             this.discoRoomInfo();
969
             this.discoRoomInfo();
961
         }
970
         }
962
         const jsonMessage = $(msg).find('>json-message').text();
971
         const jsonMessage = $(msg).find('>json-message').text();
1385
     }
1394
     }
1386
 
1395
 
1387
     /**
1396
     /**
1388
-     * Returns the meeting unique Id if any came from backend.
1397
+     * Returns the meeting unique ID if any came from backend.
1398
+     *
1399
+     * @returns {string} - The meeting ID.
1389
      */
1400
      */
1390
     getMeetingId() {
1401
     getMeetingId() {
1391
         return this.meetingId;
1402
         return this.meetingId;

+ 16
- 0
service/statistics/AnalyticsEvents.js 查看文件

264
         };
264
         };
265
     };
265
     };
266
 
266
 
267
+/**
268
+ * Creates a conference event.
269
+ *
270
+ * @param {string} action - The action of the event.
271
+ * @param {Object} attributes - The attributes to be added to the event.
272
+ * @returns {{type: string, source: string, action: string, attributes: object}}
273
+ */
274
+export function createConferenceEvent(action, attributes) {
275
+    return {
276
+        action,
277
+        attributes,
278
+        source: 'conference',
279
+        type: TYPE_OPERATIONAL
280
+    };
281
+}
282
+
267
 /**
283
 /**
268
  * Creates an operational event which indicates that a particular connection
284
  * Creates an operational event which indicates that a particular connection
269
  * stage was reached (i.e. the XMPP connection transitioned to the "connected"
285
  * stage was reached (i.e. the XMPP connection transitioned to the "connected"

Loading…
取消
儲存