Coding style
This commit is contained in:
parent
cfd6209a20
commit
f9f194d6fe
|
@ -15,13 +15,11 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
|
|||
*/
|
||||
export function initAnalytics({ getState }) {
|
||||
getJitsiMeetGlobalNS().analyticsHandlers = [];
|
||||
|
||||
// legacy support for old analytics location
|
||||
window.analyticsHandlers = [];
|
||||
window.analyticsHandlers = []; // Legacy support.
|
||||
|
||||
const { analytics } = JitsiMeetJS;
|
||||
|
||||
if (!isAnalyticsEnabled({ getState }) || !analytics) {
|
||||
if (!analytics || !isAnalyticsEnabled(getState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,11 +51,10 @@ export function initLib() {
|
|||
dispatch({ type: LIB_WILL_INIT });
|
||||
|
||||
return (
|
||||
JitsiMeetJS.init(
|
||||
Object.assign({
|
||||
enableAnalyticsLogging: isAnalyticsEnabled({ getState })
|
||||
},
|
||||
config))
|
||||
JitsiMeetJS.init({
|
||||
enableAnalyticsLogging: isAnalyticsEnabled(getState),
|
||||
...config
|
||||
})
|
||||
.then(() => dispatch({ type: LIB_DID_INIT }))
|
||||
.catch(error => {
|
||||
dispatch(libInitError(error));
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* @flow */
|
||||
|
||||
import { setConfigFromURLParams } from '../../base/config';
|
||||
import { toState } from '../../base/redux';
|
||||
import { loadScript } from '../../base/util';
|
||||
|
||||
import JitsiMeetJS from './_';
|
||||
|
@ -31,6 +32,26 @@ export function createLocalTrack(type: string, deviceId: string) {
|
|||
.then(([ jitsiLocalTrack ]) => jitsiLocalTrack));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether analytics is enabled in a specific redux {@code store}.
|
||||
*
|
||||
* @param {Function|Object} stateful - The redux store, state, or
|
||||
* {@code getState} function.
|
||||
* @returns {boolean} If analytics is enabled, {@code true}; {@code false},
|
||||
* otherwise.
|
||||
*/
|
||||
export function isAnalyticsEnabled(stateful: Function | Object) {
|
||||
const {
|
||||
analyticsScriptUrls,
|
||||
disableThirdPartyRequests
|
||||
} = toState(stateful)['features/base/config'];
|
||||
|
||||
return (
|
||||
!disableThirdPartyRequests
|
||||
&& Array.isArray(analyticsScriptUrls)
|
||||
&& Boolean(analyticsScriptUrls.length));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a specific JitsiConnectionErrors instance indicates a
|
||||
* fatal JitsiConnection error.
|
||||
|
@ -102,23 +123,3 @@ export function loadConfig(url: string) {
|
|||
|
||||
return promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates whether analytics is enabled or not based on
|
||||
* the redux {@code store}.
|
||||
*
|
||||
* @param {Store} store - The redux store in which the specified {@code action}
|
||||
* is being dispatched.
|
||||
* @returns {boolean} True if analytics is enabled, false otherwise.
|
||||
*/
|
||||
export function isAnalyticsEnabled({ getState }: { getState: Function }) {
|
||||
const {
|
||||
analyticsScriptUrls,
|
||||
disableThirdPartyRequests
|
||||
} = getState()['features/base/config'];
|
||||
|
||||
const scriptURLs = Array.isArray(analyticsScriptUrls)
|
||||
? analyticsScriptUrls : [];
|
||||
|
||||
return Boolean(scriptURLs.length) && !disableThirdPartyRequests;
|
||||
}
|
||||
|
|
|
@ -129,8 +129,7 @@ export function toState(stateful: Function | Object) {
|
|||
|
||||
const { getState } = stateful;
|
||||
|
||||
if (typeof getState === 'function'
|
||||
&& typeof stateful.dispatch === 'function') {
|
||||
if (typeof getState === 'function') {
|
||||
return getState();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue