Kaynağa Gözat

feat(analytics): available devices

tags/v0.0.2
hristoterezov 8 yıl önce
ebeveyn
işleme
a02a3ea072
1 değiştirilmiş dosya ile 32 ekleme ve 0 silme
  1. 32
    0
      modules/RTC/RTCUtils.js

+ 32
- 0
modules/RTC/RTCUtils.js Dosyayı Görüntüle

@@ -25,6 +25,7 @@ import RTCEvents from '../../service/RTC/RTCEvents';
25 25
 import ortcRTCPeerConnection from './ortc/RTCPeerConnection';
26 26
 import screenObtainer from './ScreenObtainer';
27 27
 import SDPUtil from '../xmpp/SDPUtil';
28
+import Statistics from '../statistics/statistics';
28 29
 import VideoType from '../../service/RTC/VideoType';
29 30
 
30 31
 const logger = getLogger(__filename);
@@ -425,6 +426,32 @@ function pollForAvailableMediaDevices() {
425 426
     }
426 427
 }
427 428
 
429
+/**
430
+ * Sends analytics event with the passed device list.
431
+ *
432
+ * @param {Array<MediaDeviceInfo>} deviceList - List with info about the
433
+ * available devices.
434
+ * @returns {void}
435
+ */
436
+function sendDeviceListToAnalytics(deviceList) {
437
+    const devicesPropsArray
438
+        = deviceList.map(
439
+            ({ deviceId, groupId, kind, label }) => {
440
+                // Filter the props of the device object.
441
+                return {
442
+                    deviceId,
443
+                    groupId,
444
+                    kind,
445
+                    label
446
+                };
447
+            });
448
+
449
+    Statistics.analytics.sendEvent(
450
+        'devices.deviceList', {
451
+            devices: devicesPropsArray
452
+        });
453
+}
454
+
428 455
 /**
429 456
  * Event handler for the 'devicechange' event.
430 457
  *
@@ -437,6 +464,8 @@ function onMediaDevicesListChanged(devicesReceived) {
437 464
         'list of media devices has changed:',
438 465
         currentlyAvailableMediaDevices);
439 466
 
467
+    sendDeviceListToAnalytics(currentlyAvailableMediaDevices);
468
+
440 469
     const videoInputDevices
441 470
         = currentlyAvailableMediaDevices.filter(d => d.kind === 'videoinput');
442 471
     const audioInputDevices
@@ -1460,6 +1489,9 @@ function onReady(options, GUM) {
1460 1489
         rawEnumerateDevicesWithCallback(ds => {
1461 1490
             currentlyAvailableMediaDevices = ds.splice(0);
1462 1491
 
1492
+            logger.info('Available devices: ', currentlyAvailableMediaDevices);
1493
+            sendDeviceListToAnalytics(currentlyAvailableMediaDevices);
1494
+
1463 1495
             eventEmitter.emit(RTCEvents.DEVICE_LIST_AVAILABLE,
1464 1496
                 currentlyAvailableMediaDevices);
1465 1497
 

Loading…
İptal
Kaydet