Sfoglia il codice sorgente

feat(Amplitude): Add a new event for sending the ICE candidate types

dev1
Jaya Allamsetty 5 anni fa
parent
commit
a6186063ea

+ 34
- 2
modules/statistics/AvgRTPStatsReporter.js Vedi File

@@ -1,6 +1,10 @@
1 1
 /* global __filename */
2
+import isEqual from 'lodash.isequal';
2 3
 
3
-import { createRtpStatsEvent } from '../../service/statistics/AnalyticsEvents';
4
+import {
5
+    createRtpStatsEvent,
6
+    createTransportStatsEvent
7
+} from '../../service/statistics/AnalyticsEvents';
4 8
 import { getLogger } from 'jitsi-meet-logger';
5 9
 import * as ConnectionQualityEvents
6 10
     from '../../service/connectivity/ConnectionQualityEvents';
@@ -523,7 +527,12 @@ export default class AvgRTPStatsReporter {
523 527
          */
524 528
         this._avgCQ = new AverageStatReport('connection_quality');
525 529
 
526
-        this._onLocalStatsUpdated = data => this._calculateAvgStats(data);
530
+        this._cachedTransportStats = undefined;
531
+
532
+        this._onLocalStatsUpdated = data => {
533
+            this._calculateAvgStats(data);
534
+            this._maybeSendTransportAnalyticsEvent(data);
535
+        };
527 536
         conference.on(
528 537
             ConnectionQualityEvents.LOCAL_STATS_UPDATED,
529 538
             this._onLocalStatsUpdated);
@@ -920,6 +929,29 @@ export default class AvgRTPStatsReporter {
920 929
         return peerFpsSum / peerSsrcCount;
921 930
     }
922 931
 
932
+    /**
933
+     * Sends the 'transport.stats' analytics event whenever we detect that
934
+     * there is a change in the local or remote candidate type on the transport
935
+     * that is currently selected.
936
+     * @param {*} data
937
+     * @private
938
+     */
939
+    _maybeSendTransportAnalyticsEvent(data) {
940
+        if (!data || !data.transport || !data.transport.length) {
941
+            return;
942
+        }
943
+        const transportStats = {
944
+            'local_candidate_type': data.transport[0].localCandidateType,
945
+            'remote_candidate_type': data.transport[0].remoteCandidateType,
946
+            'transport_type': data.transport[0].type
947
+        };
948
+
949
+        if (!this._cachedTransportStats || !isEqual(transportStats, this._cachedTransportStats)) {
950
+            this._cachedTransportStats = transportStats;
951
+            Statistics.sendAnalytics(createTransportStatsEvent(transportStats));
952
+        }
953
+    }
954
+
923 955
     /**
924 956
      * Resets the stats related to JVB connection. Must not be called when in
925 957
      * P2P mode, because then the {@link AverageStatReport} instances are

+ 15
- 0
service/statistics/AnalyticsEvents.js Vedi File

@@ -493,6 +493,21 @@ export const createRttByRegionEvent = function(attributes) {
493 493
     };
494 494
 };
495 495
 
496
+/**
497
+ * Creates an event which contains the local and remote ICE candidate types
498
+ * for the transport that is currently selected.
499
+ *
500
+ * @param attributes
501
+ * @returns {{type: string, action: string, attributes: *}}
502
+ */
503
+export const createTransportStatsEvent = function(attributes) {
504
+    return {
505
+        type: TYPE_OPERATIONAL,
506
+        action: 'transport.stats',
507
+        attributes
508
+    };
509
+};
510
+
496 511
 /**
497 512
  * Creates an event which contains information about the audio output problem (the user id of the affected participant,
498 513
  * the local audio levels and the remote audio levels that triggered the event).

Loading…
Annulla
Salva