소스 검색

fix(analytics): delay conference.join event (#1048)

Send conference.join event only after the peer connection is created.
This way we won't send events for lonely calls.
release-8443
Hristo Terezov 5 년 전
부모
커밋
5466c9d08a
No account linked to committer's email address
3개의 변경된 파일39개의 추가작업 그리고 10개의 파일을 삭제
  1. 33
    4
      JitsiConference.js
  2. 1
    6
      modules/xmpp/ChatRoom.js
  3. 5
    0
      service/xmpp/XMPPEvents.js

+ 33
- 4
JitsiConference.js 파일 보기

@@ -56,6 +56,7 @@ import {
56 56
     ACTION_P2P_FAILED,
57 57
     ACTION_P2P_SWITCH_TO_JVB,
58 58
     ICE_ESTABLISHMENT_DURATION_DIFF,
59
+    createConferenceEvent,
59 60
     createJingleEvent,
60 61
     createP2PEvent
61 62
 } from './service/statistics/AnalyticsEvents';
@@ -231,6 +232,7 @@ export default function JitsiConference(options) {
231 232
 
232 233
     this.videoSIPGWHandler = new VideoSIPGW(this.room);
233 234
     this.recordingManager = new RecordingManager(this.room);
235
+    this._conferenceJoinAnalyticsEventSent = false;
234 236
 }
235 237
 
236 238
 // FIXME convert JitsiConference to ES6 - ASAP !
@@ -290,12 +292,12 @@ JitsiConference.prototype._init = function(options = {}) {
290 292
     }
291 293
 
292 294
     const { config } = this.options;
293
-    const statsCurrentId = config.statisticsId ? config.statisticsId : Settings.callStatsUserName;
294 295
 
296
+    this._statsCurrentId = config.statisticsId ? config.statisticsId : Settings.callStatsUserName;
295 297
     this.room = this.xmpp.createRoom(
296 298
         this.options.name, {
297 299
             ...config,
298
-            statsId: statsCurrentId
300
+            statsId: this._statsCurrentId
299 301
         },
300 302
         JitsiConference.resourceCreator
301 303
     );
@@ -319,6 +321,9 @@ JitsiConference.prototype._init = function(options = {}) {
319 321
     this.room.addListener(XMPPEvents.CONFERENCE_PROPERTIES_CHANGED,
320 322
         this._updateProperties);
321 323
 
324
+    this._sendConferenceJoinAnalyticsEvent = this._sendConferenceJoinAnalyticsEvent.bind(this);
325
+    this.room.addListener(XMPPEvents.MEETING_ID_SET, this._sendConferenceJoinAnalyticsEvent);
326
+
322 327
     this.rttMonitor = new RttMonitor(config.rttMonitor || {});
323 328
 
324 329
     this.e2eping = new E2ePing(
@@ -354,7 +359,7 @@ JitsiConference.prototype._init = function(options = {}) {
354 359
 
355 360
     if (!this.statistics) {
356 361
         this.statistics = new Statistics(this.xmpp, {
357
-            aliasName: statsCurrentId,
362
+            aliasName: this._statsCurrentId,
358 363
             userName: config.statisticsDisplayName ? config.statisticsDisplayName : this.myUserId(),
359 364
             callStatsConfIDNamespace: this.connection.options.hosts.domain,
360 365
             confID: config.confID || `${this.connection.options.hosts.domain}/${this.options.name}`,
@@ -367,7 +372,7 @@ JitsiConference.prototype._init = function(options = {}) {
367 372
             getWiFiStatsMethod: config.getWiFiStatsMethod
368 373
         });
369 374
         Statistics.analytics.addPermanentProperties({
370
-            'callstats_name': statsCurrentId
375
+            'callstats_name': this._statsCurrentId
371 376
         });
372 377
     }
373 378
 
@@ -571,6 +576,8 @@ JitsiConference.prototype.leave = function() {
571 576
             XMPPEvents.CONFERENCE_PROPERTIES_CHANGED,
572 577
             this._updateProperties);
573 578
 
579
+        room.removeListener(XMPPEvents.MEETING_ID_SET, this._sendConferenceJoinAnalyticsEvent);
580
+
574 581
         this.eventManager.removeXMPPListeners();
575 582
 
576 583
         this.room = null;
@@ -1833,6 +1840,7 @@ JitsiConference.prototype._acceptJvbIncomingCall = function(
1833 1840
     // Accept incoming call
1834 1841
     this.jvbJingleSession = jingleSession;
1835 1842
     this.room.connectionTimes['session.initiate'] = now;
1843
+    this._sendConferenceJoinAnalyticsEvent();
1836 1844
 
1837 1845
     if (this.wasStopped) {
1838 1846
         Statistics.sendAnalyticsAndLog(
@@ -2609,6 +2617,7 @@ JitsiConference.prototype._acceptP2PIncomingCall = function(
2609 2617
 
2610 2618
     // Accept the offer
2611 2619
     this.p2pJingleSession = jingleSession;
2620
+    this._sendConferenceJoinAnalyticsEvent();
2612 2621
 
2613 2622
     this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
2614 2623
 
@@ -2957,6 +2966,7 @@ JitsiConference.prototype._startP2PSession = function(remoteJid) {
2957 2966
             remoteJid);
2958 2967
     logger.info(
2959 2968
         'Created new P2P JingleSession', this.room.myroomjid, remoteJid);
2969
+    this._sendConferenceJoinAnalyticsEvent();
2960 2970
 
2961 2971
     this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
2962 2972
 
@@ -3266,3 +3276,22 @@ JitsiConference.prototype.createVideoSIPGWSession
3266 3276
         return this.videoSIPGWHandler
3267 3277
             .createVideoSIPGWSession(sipAddress, displayName);
3268 3278
     };
3279
+
3280
+/**
3281
+ * Sends a conference.join analytics event.
3282
+ *
3283
+ * @returns {void}
3284
+ */
3285
+JitsiConference.prototype._sendConferenceJoinAnalyticsEvent = function() {
3286
+    const meetingId = this.getMeetingUniqueId();
3287
+
3288
+    if (this._conferenceJoinAnalyticsEventSent || !meetingId || this.getActivePeerConnection() === null) {
3289
+        return;
3290
+    }
3291
+
3292
+    Statistics.sendAnalytics(createConferenceEvent('joined', {
3293
+        meetingId,
3294
+        participantId: `${meetingId}.${this._statsCurrentId}`
3295
+    }));
3296
+    this._conferenceJoinAnalyticsEventSent = true;
3297
+};

+ 1
- 6
modules/xmpp/ChatRoom.js 파일 보기

@@ -7,9 +7,7 @@ import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
7 7
 import * as JitsiTranscriptionStatus from '../../JitsiTranscriptionStatus';
8 8
 import Listenable from '../util/Listenable';
9 9
 import * as MediaType from '../../service/RTC/MediaType';
10
-import { createConferenceEvent } from '../../service/statistics/AnalyticsEvents';
11 10
 import XMPPEvents from '../../service/xmpp/XMPPEvents';
12
-import Statistics from '../statistics/statistics';
13 11
 
14 12
 import Moderator from './moderator';
15 13
 import XmppConnection from './XmppConnection';
@@ -314,10 +312,7 @@ export default class ChatRoom extends Listenable {
314 312
                 logger.warn(`Meeting Id changed from:${this.meetingId} to:${meetingId}`);
315 313
             }
316 314
             this.meetingId = meetingId;
317
-
318
-            // The name of the action is a little bit confusing but it seems this is the preferred name by the consumers
319
-            // of the analytics events.
320
-            Statistics.sendAnalytics(createConferenceEvent('joined', { meetingId }));
315
+            this.eventEmitter.emit(XMPPEvents.MEETING_ID_SET, meetingId);
321 316
         }
322 317
     }
323 318
 

+ 5
- 0
service/xmpp/XMPPEvents.js 파일 보기

@@ -99,6 +99,11 @@ const XMPPEvents = {
99 99
     // Designates an event indicating that our role in the XMPP MUC has changed.
100 100
     LOCAL_ROLE_CHANGED: 'xmpp.localrole_changed',
101 101
 
102
+    /**
103
+     * Event fired when the unique meeting id is set.
104
+     */
105
+    MEETING_ID_SET: 'xmpp.meeting_id_set',
106
+
102 107
     // Designates an event indicating that an XMPP message in the MUC was
103 108
     // received.
104 109
     MESSAGE_RECEIVED: 'xmpp.message_received',

Loading…
취소
저장