浏览代码

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
没有帐户链接到提交者的电子邮件
共有 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
     ACTION_P2P_FAILED,
56
     ACTION_P2P_FAILED,
57
     ACTION_P2P_SWITCH_TO_JVB,
57
     ACTION_P2P_SWITCH_TO_JVB,
58
     ICE_ESTABLISHMENT_DURATION_DIFF,
58
     ICE_ESTABLISHMENT_DURATION_DIFF,
59
+    createConferenceEvent,
59
     createJingleEvent,
60
     createJingleEvent,
60
     createP2PEvent
61
     createP2PEvent
61
 } from './service/statistics/AnalyticsEvents';
62
 } from './service/statistics/AnalyticsEvents';
231
 
232
 
232
     this.videoSIPGWHandler = new VideoSIPGW(this.room);
233
     this.videoSIPGWHandler = new VideoSIPGW(this.room);
233
     this.recordingManager = new RecordingManager(this.room);
234
     this.recordingManager = new RecordingManager(this.room);
235
+    this._conferenceJoinAnalyticsEventSent = false;
234
 }
236
 }
235
 
237
 
236
 // FIXME convert JitsiConference to ES6 - ASAP !
238
 // FIXME convert JitsiConference to ES6 - ASAP !
290
     }
292
     }
291
 
293
 
292
     const { config } = this.options;
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
     this.room = this.xmpp.createRoom(
297
     this.room = this.xmpp.createRoom(
296
         this.options.name, {
298
         this.options.name, {
297
             ...config,
299
             ...config,
298
-            statsId: statsCurrentId
300
+            statsId: this._statsCurrentId
299
         },
301
         },
300
         JitsiConference.resourceCreator
302
         JitsiConference.resourceCreator
301
     );
303
     );
319
     this.room.addListener(XMPPEvents.CONFERENCE_PROPERTIES_CHANGED,
321
     this.room.addListener(XMPPEvents.CONFERENCE_PROPERTIES_CHANGED,
320
         this._updateProperties);
322
         this._updateProperties);
321
 
323
 
324
+    this._sendConferenceJoinAnalyticsEvent = this._sendConferenceJoinAnalyticsEvent.bind(this);
325
+    this.room.addListener(XMPPEvents.MEETING_ID_SET, this._sendConferenceJoinAnalyticsEvent);
326
+
322
     this.rttMonitor = new RttMonitor(config.rttMonitor || {});
327
     this.rttMonitor = new RttMonitor(config.rttMonitor || {});
323
 
328
 
324
     this.e2eping = new E2ePing(
329
     this.e2eping = new E2ePing(
354
 
359
 
355
     if (!this.statistics) {
360
     if (!this.statistics) {
356
         this.statistics = new Statistics(this.xmpp, {
361
         this.statistics = new Statistics(this.xmpp, {
357
-            aliasName: statsCurrentId,
362
+            aliasName: this._statsCurrentId,
358
             userName: config.statisticsDisplayName ? config.statisticsDisplayName : this.myUserId(),
363
             userName: config.statisticsDisplayName ? config.statisticsDisplayName : this.myUserId(),
359
             callStatsConfIDNamespace: this.connection.options.hosts.domain,
364
             callStatsConfIDNamespace: this.connection.options.hosts.domain,
360
             confID: config.confID || `${this.connection.options.hosts.domain}/${this.options.name}`,
365
             confID: config.confID || `${this.connection.options.hosts.domain}/${this.options.name}`,
367
             getWiFiStatsMethod: config.getWiFiStatsMethod
372
             getWiFiStatsMethod: config.getWiFiStatsMethod
368
         });
373
         });
369
         Statistics.analytics.addPermanentProperties({
374
         Statistics.analytics.addPermanentProperties({
370
-            'callstats_name': statsCurrentId
375
+            'callstats_name': this._statsCurrentId
371
         });
376
         });
372
     }
377
     }
373
 
378
 
571
             XMPPEvents.CONFERENCE_PROPERTIES_CHANGED,
576
             XMPPEvents.CONFERENCE_PROPERTIES_CHANGED,
572
             this._updateProperties);
577
             this._updateProperties);
573
 
578
 
579
+        room.removeListener(XMPPEvents.MEETING_ID_SET, this._sendConferenceJoinAnalyticsEvent);
580
+
574
         this.eventManager.removeXMPPListeners();
581
         this.eventManager.removeXMPPListeners();
575
 
582
 
576
         this.room = null;
583
         this.room = null;
1833
     // Accept incoming call
1840
     // Accept incoming call
1834
     this.jvbJingleSession = jingleSession;
1841
     this.jvbJingleSession = jingleSession;
1835
     this.room.connectionTimes['session.initiate'] = now;
1842
     this.room.connectionTimes['session.initiate'] = now;
1843
+    this._sendConferenceJoinAnalyticsEvent();
1836
 
1844
 
1837
     if (this.wasStopped) {
1845
     if (this.wasStopped) {
1838
         Statistics.sendAnalyticsAndLog(
1846
         Statistics.sendAnalyticsAndLog(
2609
 
2617
 
2610
     // Accept the offer
2618
     // Accept the offer
2611
     this.p2pJingleSession = jingleSession;
2619
     this.p2pJingleSession = jingleSession;
2620
+    this._sendConferenceJoinAnalyticsEvent();
2612
 
2621
 
2613
     this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
2622
     this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
2614
 
2623
 
2957
             remoteJid);
2966
             remoteJid);
2958
     logger.info(
2967
     logger.info(
2959
         'Created new P2P JingleSession', this.room.myroomjid, remoteJid);
2968
         'Created new P2P JingleSession', this.room.myroomjid, remoteJid);
2969
+    this._sendConferenceJoinAnalyticsEvent();
2960
 
2970
 
2961
     this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
2971
     this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
2962
 
2972
 
3266
         return this.videoSIPGWHandler
3276
         return this.videoSIPGWHandler
3267
             .createVideoSIPGWSession(sipAddress, displayName);
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
 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';
11
 import XMPPEvents from '../../service/xmpp/XMPPEvents';
10
 import XMPPEvents from '../../service/xmpp/XMPPEvents';
12
-import Statistics from '../statistics/statistics';
13
 
11
 
14
 import Moderator from './moderator';
12
 import Moderator from './moderator';
15
 import XmppConnection from './XmppConnection';
13
 import XmppConnection from './XmppConnection';
314
                 logger.warn(`Meeting Id changed from:${this.meetingId} to:${meetingId}`);
312
                 logger.warn(`Meeting Id changed from:${this.meetingId} to:${meetingId}`);
315
             }
313
             }
316
             this.meetingId = meetingId;
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
     // Designates an event indicating that our role in the XMPP MUC has changed.
99
     // Designates an event indicating that our role in the XMPP MUC has changed.
100
     LOCAL_ROLE_CHANGED: 'xmpp.localrole_changed',
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
     // Designates an event indicating that an XMPP message in the MUC was
107
     // Designates an event indicating that an XMPP message in the MUC was
103
     // received.
108
     // received.
104
     MESSAGE_RECEIVED: 'xmpp.message_received',
109
     MESSAGE_RECEIVED: 'xmpp.message_received',

正在加载...
取消
保存