Browse Source

Send peer connection status changes to the analytics backend.

dev1
George Politis 5 years ago
parent
commit
592f72a63c

+ 41
- 0
modules/connectivity/ParticipantConnectionStatus.js View File

6
 import browser from '../browser';
6
 import browser from '../browser';
7
 import RTCEvents from '../../service/RTC/RTCEvents';
7
 import RTCEvents from '../../service/RTC/RTCEvents';
8
 import Statistics from '../statistics/statistics';
8
 import Statistics from '../statistics/statistics';
9
+import { createParticipantConnectionStatusEvent } from '../../service/statistics/AnalyticsEvents';
9
 
10
 
10
 const logger = getLogger(__filename);
11
 const logger = getLogger(__filename);
11
 
12
 
264
          * @type {Map<string, number>}
265
          * @type {Map<string, number>}
265
          */
266
          */
266
         this.restoringTimers = new Map();
267
         this.restoringTimers = new Map();
268
+
269
+        /**
270
+         * A map that holds the current connection status (along with all the internal events that happen
271
+         * while in that state).
272
+         *
273
+         * The goal is to send this information to the analytics backend for post-mortem analysis.
274
+         */
275
+        this.peerConnStatusMap = new Map();
267
     }
276
     }
268
 
277
 
269
     /**
278
     /**
429
                     status: newStatus
438
                     status: newStatus
430
                 }));
439
                 }));
431
 
440
 
441
+
432
             this.conference.eventEmitter.emit(
442
             this.conference.eventEmitter.emit(
433
                 JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
443
                 JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
434
                 endpointId, newStatus);
444
                 endpointId, newStatus);
614
                 isInLastN} currentStatus => newStatus: ${
624
                 isInLastN} currentStatus => newStatus: ${
615
                 participant.getConnectionStatus()} => ${newState}`);
625
                 participant.getConnectionStatus()} => ${newState}`);
616
 
626
 
627
+        const nowMs = new Date().getTime();
628
+        const internalState = {
629
+            'instantMs': nowMs,
630
+            'isVideoMuted': isVideoMuted,
631
+            'isConnActiveByJvb': isConnActiveByJvb,
632
+            'isVideoTrackFrozen': isVideoTrackFrozen,
633
+            'inP2PMode': inP2PMode,
634
+            'inInLastN': isInLastN
635
+        };
636
+
637
+        if (!this.peerConnStatusMap[id] || this.peerConnStatusMap[id].state !== newState) {
638
+            // The peer connection status has changed. Compute the duration of the current
639
+            // connection status and send it as an analytics event.
640
+            if (this.peerConnStatusMap[id]) {
641
+                this.peerConnStatusMap[id].value = nowMs - this.peerConnStatusMap[id].startedMs;
642
+                Statistics.sendAnalytics(
643
+                    createParticipantConnectionStatusEvent(this.peerConnStatusMap[id]));
644
+            }
645
+
646
+            // And start a new status for the participant.
647
+            this.peerConnStatusMap[id] = {
648
+                'internalStates': [ internalState ],
649
+                'state': newState,
650
+                'startedMs': nowMs
651
+            };
652
+        } else {
653
+            // The connection status hasn't changed, but there was an internal state change.
654
+            // Register the internal state.
655
+            this.peerConnStatusMap[id].internalStates.push(internalState);
656
+        }
657
+
617
         this._changeConnectionStatus(participant, newState);
658
         this._changeConnectionStatus(participant, newState);
618
     }
659
     }
619
 
660
 

+ 17
- 0
service/statistics/AnalyticsEvents.js View File

331
     };
331
     };
332
 };
332
 };
333
 
333
 
334
+/**
335
+ * Creates an event related to remote participant connection status changes.
336
+ *
337
+ * @param attributes the attributes to attach to the event.
338
+ * @returns {{type: string, source: string, name: string}}
339
+ */
340
+export const createParticipantConnectionStatusEvent = function(attributes = {}) {
341
+    const action = 'duration';
342
+
343
+    return {
344
+        type: TYPE_OPERATIONAL,
345
+        source: 'peer.conn.status',
346
+        action,
347
+        attributes
348
+    };
349
+};
350
+
334
 /**
351
 /**
335
  * Creates an event for a Jingle-related event.
352
  * Creates an event for a Jingle-related event.
336
  * @param action the action of the event
353
  * @param action the action of the event

Loading…
Cancel
Save