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 }) {
|
export function initAnalytics({ getState }) {
|
||||||
getJitsiMeetGlobalNS().analyticsHandlers = [];
|
getJitsiMeetGlobalNS().analyticsHandlers = [];
|
||||||
|
window.analyticsHandlers = []; // Legacy support.
|
||||||
// legacy support for old analytics location
|
|
||||||
window.analyticsHandlers = [];
|
|
||||||
|
|
||||||
const { analytics } = JitsiMeetJS;
|
const { analytics } = JitsiMeetJS;
|
||||||
|
|
||||||
if (!isAnalyticsEnabled({ getState }) || !analytics) {
|
if (!analytics || !isAnalyticsEnabled(getState)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,11 +51,10 @@ export function initLib() {
|
||||||
dispatch({ type: LIB_WILL_INIT });
|
dispatch({ type: LIB_WILL_INIT });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
JitsiMeetJS.init(
|
JitsiMeetJS.init({
|
||||||
Object.assign({
|
enableAnalyticsLogging: isAnalyticsEnabled(getState),
|
||||||
enableAnalyticsLogging: isAnalyticsEnabled({ getState })
|
...config
|
||||||
},
|
})
|
||||||
config))
|
|
||||||
.then(() => dispatch({ type: LIB_DID_INIT }))
|
.then(() => dispatch({ type: LIB_DID_INIT }))
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
dispatch(libInitError(error));
|
dispatch(libInitError(error));
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import { setConfigFromURLParams } from '../../base/config';
|
import { setConfigFromURLParams } from '../../base/config';
|
||||||
|
import { toState } from '../../base/redux';
|
||||||
import { loadScript } from '../../base/util';
|
import { loadScript } from '../../base/util';
|
||||||
|
|
||||||
import JitsiMeetJS from './_';
|
import JitsiMeetJS from './_';
|
||||||
|
@ -31,6 +32,26 @@ export function createLocalTrack(type: string, deviceId: string) {
|
||||||
.then(([ jitsiLocalTrack ]) => jitsiLocalTrack));
|
.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
|
* Determines whether a specific JitsiConnectionErrors instance indicates a
|
||||||
* fatal JitsiConnection error.
|
* fatal JitsiConnection error.
|
||||||
|
@ -102,23 +123,3 @@ export function loadConfig(url: string) {
|
||||||
|
|
||||||
return promise;
|
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;
|
const { getState } = stateful;
|
||||||
|
|
||||||
if (typeof getState === 'function'
|
if (typeof getState === 'function') {
|
||||||
&& typeof stateful.dispatch === 'function') {
|
|
||||||
return getState();
|
return getState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue