feat(rtcstats): send dominant speaker stats (#9883)
* send dominant speaker stats * fix lint
This commit is contained in:
parent
56c0edc896
commit
f51e65d129
|
@ -85,6 +85,16 @@ class RTCStats {
|
|||
this.trace && this.trace.identity('identity', null, identityData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send dominant speaker data, the data will be processed by rtcstats-server and saved in the dump file.
|
||||
*
|
||||
* @param {Object} dominantSpeakerData - Dominant speaker data to be saved in the rtcstats dump.
|
||||
* @returns {void}
|
||||
*/
|
||||
sendDominantSpeakerData(dominantSpeakerData) {
|
||||
this.trace && this.trace.statsEntry('dominantSpeaker', null, dominantSpeakerData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the rtcstats server instance. Stats (data obtained from getstats) won't be send until the
|
||||
* connect successfully initializes, however calls to GUM are recorded in an internal buffer even if not
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
import { toState } from '../base/redux';
|
||||
|
||||
import RTCStats from './RTCStats';
|
||||
|
||||
/**
|
||||
* Checks whether rtcstats is enabled or not.
|
||||
*
|
||||
|
@ -19,3 +21,14 @@ export function isRtcstatsEnabled(stateful: Function | Object) {
|
|||
|
||||
return config?.analytics?.rtcstatsEnabled ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the rtcstats service send data.
|
||||
*
|
||||
* @param {Function|Object} stateful - The redux store or {@code getState} function.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function canSendRtcstatsData(stateful: Function | Object) {
|
||||
|
||||
return isRtcstatsEnabled(stateful) && RTCStats.isInitialized();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// @flow
|
||||
|
||||
import { getAmplitudeIdentity } from '../analytics';
|
||||
import { CONFERENCE_UNIQUE_ID_SET, getRoomName } from '../base/conference';
|
||||
import { CONFERENCE_UNIQUE_ID_SET, getConferenceOptions, getRoomName } from '../base/conference';
|
||||
import { LIB_WILL_INIT } from '../base/lib-jitsi-meet';
|
||||
import { getLocalParticipant } from '../base/participants';
|
||||
import { DOMINANT_SPEAKER_CHANGED, getLocalParticipant } from '../base/participants';
|
||||
import { MiddlewareRegistry } from '../base/redux';
|
||||
|
||||
import RTCStats from './RTCStats';
|
||||
import { isRtcstatsEnabled } from './functions';
|
||||
import { canSendRtcstatsData, isRtcstatsEnabled } from './functions';
|
||||
import logger from './logger';
|
||||
|
||||
/**
|
||||
|
@ -50,12 +50,15 @@ MiddlewareRegistry.register(store => next => action => {
|
|||
break;
|
||||
}
|
||||
case CONFERENCE_UNIQUE_ID_SET: {
|
||||
if (isRtcstatsEnabled(state) && RTCStats.isInitialized()) {
|
||||
if (canSendRtcstatsData(state)) {
|
||||
|
||||
// Once the conference started connect to the rtcstats server and send data.
|
||||
try {
|
||||
RTCStats.connect();
|
||||
|
||||
const localParticipant = getLocalParticipant(state);
|
||||
const options = getConferenceOptions(state);
|
||||
|
||||
|
||||
// Unique identifier for a conference session, not to be confused with meeting name
|
||||
// i.e. If all participants leave a meeting it will have a different value on the next join.
|
||||
|
@ -71,7 +74,8 @@ MiddlewareRegistry.register(store => next => action => {
|
|||
// conference with a specific version.
|
||||
RTCStats.sendIdentityData({
|
||||
...getAmplitudeIdentity(),
|
||||
...config,
|
||||
...options,
|
||||
endpointId: localParticipant?.id,
|
||||
confName: getRoomName(state),
|
||||
displayName: localParticipant?.name,
|
||||
meetingUniqueId
|
||||
|
@ -83,6 +87,15 @@ MiddlewareRegistry.register(store => next => action => {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case DOMINANT_SPEAKER_CHANGED: {
|
||||
if (canSendRtcstatsData(state)) {
|
||||
const { id, previousSpeakers } = action.participant;
|
||||
|
||||
RTCStats.sendDominantSpeakerData({ dominantSpeakerEndpoint: id,
|
||||
previousSpeakers });
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return next(action);
|
||||
|
|
Loading…
Reference in New Issue