fix(conference) unify conference options

Some options were missing on the mobile side, notably calltsts
enableDisplayNameInStats and enableEmailInStats. Now the same logic will be used
in web and mobile.
This commit is contained in:
Saúl Ibarra Corretgé 2021-08-04 12:56:07 +02:00 committed by Saúl Ibarra Corretgé
parent 4e43a31ec9
commit 465e7f1458
5 changed files with 75 additions and 92 deletions

View File

@ -39,6 +39,7 @@ import {
conferenceWillJoin,
conferenceWillLeave,
dataChannelOpened,
getConferenceOptions,
kickedOut,
lockStateChanged,
onStartMutedPolicyChanged,
@ -111,7 +112,6 @@ import {
trackRemoved
} from './react/features/base/tracks';
import { downloadJSON } from './react/features/base/util/downloadJSON';
import { getConferenceOptions } from './react/features/conference/functions';
import { showDesktopPicker } from './react/features/desktop-picker';
import { appendSuffix } from './react/features/display-name';
import {
@ -132,6 +132,7 @@ import { setScreenAudioShareState, isScreenAudioShared } from './react/features/
import { toggleScreenshotCaptureEffect } from './react/features/screenshot-capture';
import { AudioMixerEffect } from './react/features/stream-effects/audio-mixer/AudioMixerEffect';
import { createPresenterEffect } from './react/features/stream-effects/presenter';
import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise';
import { endpointMessageReceived } from './react/features/subtitles';
import UIEvents from './service/UI/UIEvents';
@ -1357,7 +1358,11 @@ export default {
},
_getConferenceOptions() {
return getConferenceOptions(APP.store.getState());
const options = getConferenceOptions(APP.store.getState());
options.createVADProcessor = createRnnoiseProcessor;
return options;
},
/**

View File

@ -6,7 +6,6 @@ import {
createStartMutedConfigurationEvent,
sendAnalytics
} from '../../analytics';
import { getName } from '../../app/functions';
import { endpointMessageReceived } from '../../subtitles';
import { getReplaceParticipant } from '../config/functions';
import { JITSI_CONNECTION_CONFERENCE_KEY } from '../connection';
@ -14,7 +13,6 @@ import { JitsiConferenceEvents } from '../lib-jitsi-meet';
import { MEDIA_TYPE, setAudioMuted, setVideoMuted } from '../media';
import {
dominantSpeakerChanged,
getLocalParticipant,
getNormalizedDisplayName,
participantConnectionStatusChanged,
participantKicked,
@ -24,11 +22,7 @@ import {
participantUpdated
} from '../participants';
import { getLocalTracks, replaceLocalTrack, trackAdded, trackRemoved } from '../tracks';
import {
getBackendSafePath,
getBackendSafeRoomName,
getJitsiMeetGlobalNS
} from '../util';
import { getBackendSafeRoomName } from '../util';
import {
AUTH_STATUS_CHANGED,
@ -61,6 +55,7 @@ import {
_addLocalTracksToConference,
commonUserJoinedHandling,
commonUserLeftHandling,
getConferenceOptions,
getCurrentConference,
sendLocalParticipant
} from './functions';
@ -434,22 +429,7 @@ export function createConference() {
throw new Error('Cannot join a conference without a room name!');
}
const config = state['features/base/config'];
const { tenant } = state['features/base/jwt'];
const { email, name: nick } = getLocalParticipant(state);
const conference
= connection.initJitsiConference(
getBackendSafeRoomName(room), {
...config,
applicationName: getName(),
getWiFiStatsMethod: getJitsiMeetGlobalNS().getWiFiStats,
confID: `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`,
siteID: tenant,
statisticsDisplayName: config.enableDisplayNameInStats ? nick : undefined,
statisticsId: config.enableEmailInStats ? email : undefined
});
const conference = connection.initJitsiConference(getBackendSafeRoomName(room), getConferenceOptions(state));
connection[JITSI_CONNECTION_CONFERENCE_KEY] = conference;

View File

@ -2,6 +2,7 @@
import _ from 'lodash';
import { getName } from '../../app/functions';
import { JitsiTrackErrors } from '../lib-jitsi-meet';
import {
getLocalParticipant,
@ -11,7 +12,7 @@ import {
participantLeft
} from '../participants';
import { toState } from '../redux';
import { safeDecodeURIComponent } from '../util';
import { getBackendSafePath, getJitsiMeetGlobalNS, safeDecodeURIComponent } from '../util';
import {
AVATAR_URL_COMMAND,
@ -198,6 +199,53 @@ export function getConferenceNameForTitle(stateful: Function | Object) {
return safeStartCase(safeDecodeURIComponent(getConferenceState(toState(stateful)).room));
}
/**
* Returns an object aggregating the conference options.
*
* @param {Object|Function} stateful - The redux store state.
* @returns {Object} - Options object.
*/
export function getConferenceOptions(stateful: Function | Object) {
const state = toState(stateful);
const config = state['features/base/config'];
const { locationURL } = state['features/base/connection'];
const { tenant } = state['features/base/jwt'];
const { email, name: nick } = getLocalParticipant(state);
const options = { ...config };
if (tenant) {
options.siteID = tenant;
}
if (options.enableDisplayNameInStats && nick) {
options.statisticsDisplayName = nick;
}
if (options.enableEmailInStats && email) {
options.statisticsId = email;
}
if (locationURL) {
options.confID = `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`;
}
options.applicationName = getName();
// Disable analytics, if requessted.
if (options.disableThirdPartyRequests) {
delete config.analytics.scriptURLs;
delete config.analytics.amplitudeAPPKey;
delete config.analytics.googleAnalyticsTrackingId;
delete options.callStatsID;
delete options.callStatsSecret;
} else {
options.getWiFiStatsMethod = getWiFiStatsMethod;
}
return options;
}
/**
* Returns the UTC timestamp when the first participant joined the conference.
*
@ -244,6 +292,21 @@ export function getRoomName(state: Object): string {
return getConferenceState(state).room;
}
/**
* Returns the result of getWiFiStats from the global NS or does nothing
* (returns empty result).
* Fixes a concurrency problem where we need to pass a function when creating
* a JitsiConference, but that method is added to the context later.
*
* @returns {Promise}
* @private
*/
function getWiFiStatsMethod() {
const gloabalNS = getJitsiMeetGlobalNS();
return gloabalNS.getWiFiStats ? gloabalNS.getWiFiStats() : Promise.resolve('{}');
}
/**
* Handle an error thrown by the backend (i.e. {@code lib-jitsi-meet}) while
* manipulating a conference participant (e.g. Pin or select participant).

View File

@ -1,29 +1,9 @@
import { getName } from '../app/functions.web';
import { isSuboptimalBrowser } from '../base/environment';
import { translateToHTML } from '../base/i18n';
import { getLocalParticipant } from '../base/participants';
import { toState } from '../base/redux';
import { getBackendSafePath, getJitsiMeetGlobalNS } from '../base/util';
import { showWarningNotification } from '../notifications';
import { createRnnoiseProcessor } from '../stream-effects/rnnoise';
export * from './functions.any';
/**
* Returns the result of getWiFiStats from the global NS or does nothing
(returns empty result).
* Fixes a concurrency problem where we need to pass a function when creating
* a JitsiConference, but that method is added to the context later.
*
* @returns {Promise}
* @private
*/
const getWiFiStatsMethod = () => {
const gloabalNS = getJitsiMeetGlobalNS();
return gloabalNS.getWiFiStats ? gloabalNS.getWiFiStats() : Promise.resolve('{}');
};
/**
* Shows the suboptimal experience notification if needed.
*
@ -49,48 +29,3 @@ export function maybeShowSuboptimalExperienceNotification(dispatch, t) {
);
}
}
/**
* Returns an object aggregating the conference options.
*
* @param {Object|Function} stateful - The redux store state.
* @returns {Object} - Options object.
*/
export function getConferenceOptions(stateful) {
const state = toState(stateful);
const options = state['features/base/config'];
const { locationURL } = state['features/base/connection'];
const { tenant } = state['features/base/jwt'];
const { email, name: nick } = getLocalParticipant(state);
if (tenant) {
options.siteID = tenant;
}
if (options.enableDisplayNameInStats && nick) {
options.statisticsDisplayName = nick;
}
if (options.enableEmailInStats && email) {
options.statisticsId = email;
}
if (locationURL) {
options.confID = `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`;
}
options.applicationName = getName();
options.getWiFiStatsMethod = getWiFiStatsMethod;
options.createVADProcessor = createRnnoiseProcessor;
// Disable CallStats, if requessted.
if (options.disableThirdPartyRequests) {
delete options.callStatsID;
delete options.callStatsSecret;
delete options.getWiFiStatsMethod;
}
return options;
}

View File

@ -5,10 +5,10 @@ import React from 'react';
import { batch } from 'react-redux';
import { BaseApp } from '../../../features/base/app';
import { getConferenceOptions } from '../../base/conference/functions';
import { setConfig } from '../../base/config';
import { DialogContainer } from '../../base/dialog';
import { createPrejoinTracks } from '../../base/tracks';
import { getConferenceOptions } from '../../conference/functions';
import { initPrejoin, makePrecallTest } from '../actions';
import Prejoin from './Prejoin';