Browse Source

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

dev1
Jaya Allamsetty 5 years ago
parent
commit
a6186063ea
2 changed files with 49 additions and 2 deletions
  1. 34
    2
      modules/statistics/AvgRTPStatsReporter.js
  2. 15
    0
      service/statistics/AnalyticsEvents.js

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

1
 /* global __filename */
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
 import { getLogger } from 'jitsi-meet-logger';
8
 import { getLogger } from 'jitsi-meet-logger';
5
 import * as ConnectionQualityEvents
9
 import * as ConnectionQualityEvents
6
     from '../../service/connectivity/ConnectionQualityEvents';
10
     from '../../service/connectivity/ConnectionQualityEvents';
523
          */
527
          */
524
         this._avgCQ = new AverageStatReport('connection_quality');
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
         conference.on(
536
         conference.on(
528
             ConnectionQualityEvents.LOCAL_STATS_UPDATED,
537
             ConnectionQualityEvents.LOCAL_STATS_UPDATED,
529
             this._onLocalStatsUpdated);
538
             this._onLocalStatsUpdated);
920
         return peerFpsSum / peerSsrcCount;
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
      * Resets the stats related to JVB connection. Must not be called when in
956
      * Resets the stats related to JVB connection. Must not be called when in
925
      * P2P mode, because then the {@link AverageStatReport} instances are
957
      * P2P mode, because then the {@link AverageStatReport} instances are

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

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
  * Creates an event which contains information about the audio output problem (the user id of the affected participant,
512
  * Creates an event which contains information about the audio output problem (the user id of the affected participant,
498
  * the local audio levels and the remote audio levels that triggered the event).
513
  * the local audio levels and the remote audio levels that triggered the event).

Loading…
Cancel
Save