feat(billing-counter) Removed iframe billing-counter callbacks (#9537)
* Removed iframe billing-counter callbacks * Moved remaining items to jaas * Fixed import path * Removed billingCounter condition * Use getvpaasTenant in middleware * Removed billingId * Path fix * Removed jwt from isVpaasMeeting * Fix isVpaas
This commit is contained in:
parent
4c3aae1e28
commit
4276f82c03
|
@ -17,8 +17,7 @@ import {
|
|||
JitsiConnectionErrors,
|
||||
JitsiConnectionEvents
|
||||
} from './react/features/base/lib-jitsi-meet';
|
||||
import { isVpaasMeeting } from './react/features/billing-counter/functions';
|
||||
import { getJaasJWT } from './react/features/jaas/functions';
|
||||
import { isVpaasMeeting, getJaasJWT } from './react/features/jaas/functions';
|
||||
import { setPrejoinDisplayNameRequired } from './react/features/prejoin/actions';
|
||||
const logger = Logger.getLogger(__filename);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import {
|
|||
parseURIString,
|
||||
toURLString
|
||||
} from '../base/util';
|
||||
import { isVpaasMeeting } from '../billing-counter/functions';
|
||||
import { isVpaasMeeting } from '../jaas/functions';
|
||||
import { clearNotifications, showNotification } from '../notifications';
|
||||
import { setFatalError } from '../overlay';
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import '../base/sounds/middleware';
|
|||
import '../base/testing/middleware';
|
||||
import '../base/tracks/middleware';
|
||||
import '../base/user-interaction/middleware';
|
||||
import '../billing-counter/middleware';
|
||||
import '../calendar-sync/middleware';
|
||||
import '../chat/middleware';
|
||||
import '../conference/middleware';
|
||||
|
|
|
@ -25,7 +25,6 @@ import '../base/sounds/reducer';
|
|||
import '../base/testing/reducer';
|
||||
import '../base/tracks/reducer';
|
||||
import '../base/user-interaction/reducer';
|
||||
import '../billing-counter/reducer';
|
||||
import '../calendar-sync/reducer';
|
||||
import '../chat/reducer';
|
||||
import '../deep-linking/reducer';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import { isVpaasMeeting } from '../../../../billing-counter/functions';
|
||||
import { isVpaasMeeting } from '../../../../jaas/functions';
|
||||
import { translate } from '../../../i18n';
|
||||
import { connect } from '../../../redux';
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* Action used to store the flag signaling the endpoint has been counted.
|
||||
*/
|
||||
export const SET_ENDPOINT_COUNTED = 'SET_ENDPOINT_COUNTED';
|
|
@ -1,42 +0,0 @@
|
|||
// @flow
|
||||
|
||||
import { SET_ENDPOINT_COUNTED } from './actionTypes';
|
||||
import { extractVpaasTenantFromPath, getBillingId, sendCountRequest } from './functions';
|
||||
|
||||
/**
|
||||
* Sends a billing count request when needed.
|
||||
*
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function countEndpoint() {
|
||||
return function(dispatch: Function, getState: Function) {
|
||||
const state = getState();
|
||||
const baseUrl = state['features/base/config'].billingCounterUrl;
|
||||
const jwt = state['features/base/jwt'].jwt;
|
||||
const tenant = extractVpaasTenantFromPath(state['features/base/connection'].locationURL.pathname);
|
||||
const shouldSendRequest = Boolean(baseUrl && jwt && tenant);
|
||||
|
||||
if (shouldSendRequest) {
|
||||
const billingId = getBillingId();
|
||||
|
||||
sendCountRequest({
|
||||
baseUrl,
|
||||
billingId,
|
||||
jwt,
|
||||
tenant
|
||||
});
|
||||
dispatch(setEndpointCounted());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Action used to mark the endpoint as counted.
|
||||
*
|
||||
* @returns {Object}
|
||||
*/
|
||||
function setEndpointCounted() {
|
||||
return {
|
||||
type: SET_ENDPOINT_COUNTED
|
||||
};
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
/**
|
||||
* The key for the billing id stored in localStorage.
|
||||
*/
|
||||
export const BILLING_ID = 'jitsiMeetId';
|
||||
|
||||
/**
|
||||
* The prefix for the vpaas tenant.
|
||||
*/
|
||||
export const VPAAS_TENANT_PREFIX = 'vpaas-magic-cookie-';
|
|
@ -1,112 +0,0 @@
|
|||
// @flow
|
||||
|
||||
import { jitsiLocalStorage } from '@jitsi/js-utils';
|
||||
import uuid from 'uuid';
|
||||
|
||||
import { BILLING_ID, VPAAS_TENANT_PREFIX } from './constants';
|
||||
import logger from './logger';
|
||||
|
||||
/**
|
||||
* Returns the full vpaas tenant if available, given a path.
|
||||
*
|
||||
* @param {string} path - The meeting url path.
|
||||
* @returns {string}
|
||||
*/
|
||||
export function extractVpaasTenantFromPath(path: string) {
|
||||
const [ , tenant ] = path.split('/');
|
||||
|
||||
if (tenant.startsWith(VPAAS_TENANT_PREFIX)) {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the vpaas tenant.
|
||||
*
|
||||
* @param {Object} state - The global state.
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getVpaasTenant(state: Object) {
|
||||
return extractVpaasTenantFromPath(state['features/base/connection'].locationURL.pathname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current meeting is a vpaas one.
|
||||
*
|
||||
* @param {Object} state - The state of the app.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isVpaasMeeting(state: Object) {
|
||||
const { billingCounterUrl } = state['features/base/config'];
|
||||
|
||||
return Boolean(
|
||||
billingCounterUrl
|
||||
&& extractVpaasTenantFromPath(
|
||||
state['features/base/connection'].locationURL.pathname)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a billing counter request.
|
||||
*
|
||||
* @param {Object} reqData - The request info.
|
||||
* @param {string} reqData.baseUrl - The base url for the request.
|
||||
* @param {string} billingId - The unique id of the client.
|
||||
* @param {string} jwt - The JWT token.
|
||||
* @param {string} tenat - The client tenant.
|
||||
* @returns {void}
|
||||
*/
|
||||
export async function sendCountRequest({ baseUrl, billingId, jwt, tenant }: {
|
||||
baseUrl: string,
|
||||
billingId: string,
|
||||
jwt: string,
|
||||
tenant: string
|
||||
}) {
|
||||
const fullUrl = `${baseUrl}/${encodeURIComponent(tenant)}/${billingId}`;
|
||||
const headers = {
|
||||
'Authorization': `Bearer ${jwt}`
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await fetch(fullUrl, {
|
||||
method: 'GET',
|
||||
headers
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
logger.error('Status error:', res.status);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error('Could not send request', err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stored billing id (or generates a new one if none is present).
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getBillingId() {
|
||||
let billingId = jitsiLocalStorage.getItem(BILLING_ID);
|
||||
|
||||
if (!billingId) {
|
||||
billingId = uuid.v4();
|
||||
jitsiLocalStorage.setItem(BILLING_ID, billingId);
|
||||
}
|
||||
|
||||
return billingId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the billing id for vpaas meetings.
|
||||
*
|
||||
* @param {Object} state - The state of the app.
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
export function getVpaasBillingId(state: Object) {
|
||||
if (isVpaasMeeting(state)) {
|
||||
return getBillingId();
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// @flow
|
||||
|
||||
import { getLogger } from '../base/logging/functions';
|
||||
|
||||
export default getLogger('features/billing-counter');
|
|
@ -1,29 +0,0 @@
|
|||
import { ReducerRegistry } from '../base/redux';
|
||||
|
||||
import {
|
||||
SET_ENDPOINT_COUNTED
|
||||
} from './actionTypes';
|
||||
|
||||
const DEFAULT_STATE = {
|
||||
endpointCounted: false
|
||||
};
|
||||
|
||||
/**
|
||||
* Listen for actions that mutate the billing-counter state
|
||||
*/
|
||||
ReducerRegistry.register(
|
||||
'features/billing-counter', (state = DEFAULT_STATE, action) => {
|
||||
switch (action.type) {
|
||||
|
||||
case SET_ENDPOINT_COUNTED: {
|
||||
return {
|
||||
...state,
|
||||
endpointCounted: true
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
},
|
||||
);
|
|
@ -16,7 +16,7 @@ import { translate } from '../../base/i18n';
|
|||
import { Icon, IconClose } from '../../base/icons';
|
||||
import { browser } from '../../base/lib-jitsi-meet';
|
||||
import { connect } from '../../base/redux';
|
||||
import { isVpaasMeeting } from '../../billing-counter/functions';
|
||||
import { isVpaasMeeting } from '../../jaas/functions';
|
||||
import logger from '../logger';
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import { translateToHTML } from '../base/i18n';
|
|||
import { getLocalParticipant } from '../base/participants';
|
||||
import { toState } from '../base/redux';
|
||||
import { getBackendSafePath, getJitsiMeetGlobalNS } from '../base/util';
|
||||
import { getVpaasBillingId } from '../billing-counter/functions';
|
||||
import { showWarningNotification } from '../notifications';
|
||||
import { createRnnoiseProcessor } from '../stream-effects/rnnoise';
|
||||
|
||||
|
@ -85,7 +84,6 @@ export function getConferenceOptions(stateful) {
|
|||
options.applicationName = getName();
|
||||
options.getWiFiStatsMethod = getWiFiStatsMethod;
|
||||
options.createVADProcessor = createRnnoiseProcessor;
|
||||
options.billingId = getVpaasBillingId(state);
|
||||
|
||||
// Disable CallStats, if requessted.
|
||||
if (options.disableThirdPartyRequests) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import { isMobileBrowser } from '../base/environment/utils';
|
||||
import { Platform } from '../base/react';
|
||||
import { URI_PROTOCOL_PATTERN } from '../base/util';
|
||||
import { isVpaasMeeting } from '../billing-counter/functions';
|
||||
import { isVpaasMeeting } from '../jaas/functions';
|
||||
|
||||
import {
|
||||
DeepLinkingDesktopPage,
|
||||
|
|
|
@ -4,8 +4,8 @@ import type { Dispatch } from 'redux';
|
|||
|
||||
import { FEEDBACK_REQUEST_IN_PROGRESS } from '../../../modules/UI/UIErrors';
|
||||
import { openDialog } from '../base/dialog';
|
||||
import { isVpaasMeeting } from '../billing-counter/functions';
|
||||
import { extractFqnFromPath } from '../dynamic-branding/functions';
|
||||
import { isVpaasMeeting } from '../jaas/functions';
|
||||
|
||||
import {
|
||||
CANCEL_FEEDBACK,
|
||||
|
|
|
@ -8,9 +8,9 @@ import { Dialog } from '../../../../base/dialog';
|
|||
import { translate } from '../../../../base/i18n';
|
||||
import { JitsiRecordingConstants } from '../../../../base/lib-jitsi-meet';
|
||||
import { connect } from '../../../../base/redux';
|
||||
import { isVpaasMeeting } from '../../../../billing-counter/functions';
|
||||
import { isDynamicBrandingDataLoaded } from '../../../../dynamic-branding/functions';
|
||||
import EmbedMeetingTrigger from '../../../../embed-meeting/components/EmbedMeetingTrigger';
|
||||
import { isVpaasMeeting } from '../../../../jaas/functions';
|
||||
import { getActiveSession } from '../../../../recording';
|
||||
import { updateDialInNumbers } from '../../../actions';
|
||||
import {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Icon, IconPhone } from '../../../../base/icons';
|
|||
import { getLocalParticipant } from '../../../../base/participants';
|
||||
import { MultiSelectAutocomplete } from '../../../../base/react';
|
||||
import { connect } from '../../../../base/redux';
|
||||
import { isVpaasMeeting } from '../../../../billing-counter/functions';
|
||||
import { isVpaasMeeting } from '../../../../jaas/functions';
|
||||
import { hideAddPeopleDialog } from '../../../actions';
|
||||
import { INVITE_TYPES } from '../../../constants';
|
||||
import AbstractAddPeopleDialog, {
|
||||
|
|
|
@ -9,7 +9,7 @@ import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
|
|||
import { getLocalParticipant, isLocalParticipantModerator } from '../base/participants';
|
||||
import { toState } from '../base/redux';
|
||||
import { doGetJSON, parseURIString } from '../base/util';
|
||||
import { isVpaasMeeting } from '../billing-counter/functions';
|
||||
import { isVpaasMeeting } from '../jaas/functions';
|
||||
|
||||
import { INVITE_TYPES, SIP_ADDRESS_REGEX } from './constants';
|
||||
import logger from './logger';
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
// @flow
|
||||
|
||||
import { openDialog } from '../base/dialog';
|
||||
import { VPAAS_TENANT_PREFIX } from '../billing-counter/constants';
|
||||
import { getVpaasTenant } from '../billing-counter/functions';
|
||||
|
||||
import { SET_DETAILS } from './actionTypes';
|
||||
import { PremiumFeatureDialog } from './components';
|
||||
import { isFeatureDisabled, sendGetDetailsRequest } from './functions';
|
||||
import { VPAAS_TENANT_PREFIX } from './constants';
|
||||
import { getVpaasTenant, isFeatureDisabled, sendGetDetailsRequest } from './functions';
|
||||
import logger from './logger';
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,3 +23,8 @@ export const FEATURES = {
|
|||
* URL for displaying JaaS upgrade options
|
||||
*/
|
||||
export const JAAS_UPGRADE_URL = 'https://jaas.8x8.vc/#/plan/upgrade';
|
||||
|
||||
/**
|
||||
* The prefix for the vpaas tenant.
|
||||
*/
|
||||
export const VPAAS_TENANT_PREFIX = 'vpaas-magic-cookie-';
|
||||
|
|
|
@ -1,9 +1,53 @@
|
|||
// @flow
|
||||
|
||||
import { getVpaasTenant } from '../billing-counter/functions';
|
||||
|
||||
import { VPAAS_TENANT_PREFIX } from './constants';
|
||||
import logger from './logger';
|
||||
|
||||
/**
|
||||
* Returns the full vpaas tenant if available, given a path.
|
||||
*
|
||||
* @param {string} path - The meeting url path.
|
||||
* @returns {string}
|
||||
*/
|
||||
function extractVpaasTenantFromPath(path: string) {
|
||||
const [ , tenant ] = path.split('/');
|
||||
|
||||
if (tenant.startsWith(VPAAS_TENANT_PREFIX)) {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the vpaas tenant.
|
||||
*
|
||||
* @param {Object} state - The global state.
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getVpaasTenant(state: Object) {
|
||||
return extractVpaasTenantFromPath(state['features/base/connection'].locationURL.pathname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current meeting is a vpaas one.
|
||||
*
|
||||
* @param {Object} state - The state of the app.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isVpaasMeeting(state: Object) {
|
||||
const connection = state['features/base/connection'];
|
||||
|
||||
if (connection?.locationURL?.pathname) {
|
||||
return Boolean(
|
||||
extractVpaasTenantFromPath(connection?.locationURL?.pathname)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request for retrieving jaas customer details.
|
||||
*
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import { sendAnalytics, createVpaasConferenceJoinedEvent } from '../analytics';
|
||||
import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
|
||||
import { PARTICIPANT_JOINED } from '../base/participants/actionTypes';
|
||||
import { MiddlewareRegistry } from '../base/redux';
|
||||
|
||||
import { countEndpoint } from './actions';
|
||||
import { isVpaasMeeting, extractVpaasTenantFromPath } from './functions';
|
||||
import { isVpaasMeeting, getVpaasTenant } from './functions';
|
||||
|
||||
/**
|
||||
* The redux middleware for billing counter.
|
||||
|
@ -20,17 +18,6 @@ MiddlewareRegistry.register(store => next => async action => {
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
case PARTICIPANT_JOINED: {
|
||||
const shouldCount = !store.getState()['features/billing-counter'].endpointCounted
|
||||
&& !action.participant.local;
|
||||
|
||||
if (shouldCount) {
|
||||
store.dispatch(countEndpoint());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return next(action);
|
||||
|
@ -45,7 +32,6 @@ MiddlewareRegistry.register(store => next => async action => {
|
|||
function _maybeTrackVpaasConferenceJoin(state) {
|
||||
if (isVpaasMeeting(state)) {
|
||||
sendAnalytics(createVpaasConferenceJoinedEvent(
|
||||
extractVpaasTenantFromPath(
|
||||
state['features/base/connection'].locationURL.pathname)));
|
||||
getVpaasTenant(state)));
|
||||
}
|
||||
}
|
|
@ -3,11 +3,12 @@ import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
|
|||
import { CONNECTION_FAILED } from '../base/connection';
|
||||
import { JitsiConnectionErrors } from '../base/lib-jitsi-meet';
|
||||
import { MiddlewareRegistry } from '../base/redux';
|
||||
import { isVpaasMeeting } from '../billing-counter/functions';
|
||||
|
||||
|
||||
import { SET_DETAILS } from './actionTypes';
|
||||
import { getCustomerDetails } from './actions';
|
||||
import { STATUSES } from './constants';
|
||||
import { isVpaasMeeting } from './functions';
|
||||
|
||||
/**
|
||||
* The redux middleware for jaas.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { ENDPOINT_REACTION_NAME } from '../../../modules/API/constants';
|
||||
import { MiddlewareRegistry } from '../base/redux';
|
||||
import { isVpaasMeeting } from '../billing-counter/functions';
|
||||
import { isVpaasMeeting } from '../jaas/functions';
|
||||
|
||||
import {
|
||||
SET_REACTIONS_MESSAGE,
|
||||
|
|
|
@ -4,7 +4,7 @@ import { getMeetingRegion, getRecordingSharingUrl } from '../base/config';
|
|||
import JitsiMeetJS, { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
|
||||
import { getLocalParticipant, getParticipantDisplayName } from '../base/participants';
|
||||
import { copyText } from '../base/util/helpers';
|
||||
import { getVpaasTenant, isVpaasMeeting } from '../billing-counter/functions';
|
||||
import { getVpaasTenant, isVpaasMeeting } from '../jaas/functions';
|
||||
import {
|
||||
NOTIFICATION_TIMEOUT,
|
||||
hideNotification,
|
||||
|
|
|
@ -21,8 +21,8 @@ import {
|
|||
} from '../../../base/react';
|
||||
import { connect } from '../../../base/redux';
|
||||
import { ColorPalette, StyleType } from '../../../base/styles';
|
||||
import { isVpaasMeeting } from '../../../billing-counter/functions';
|
||||
import { authorizeDropbox, updateDropboxToken } from '../../../dropbox';
|
||||
import { isVpaasMeeting } from '../../../jaas/functions';
|
||||
import { RECORDING_TYPES } from '../../constants';
|
||||
import { getRecordingDurationEstimation } from '../../functions';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import { IconDownload } from '../../base/icons';
|
|||
import { connect } from '../../base/redux';
|
||||
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
||||
import { openURLInBrowser } from '../../base/util';
|
||||
import { isVpaasMeeting } from '../../billing-counter/functions';
|
||||
import { isVpaasMeeting } from '../../jaas/functions';
|
||||
|
||||
type Props = AbstractButtonProps & {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { IconHelp } from '../../base/icons';
|
|||
import { connect } from '../../base/redux';
|
||||
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
||||
import { openURLInBrowser } from '../../base/util';
|
||||
import { isVpaasMeeting } from '../../billing-counter/functions';
|
||||
import { isVpaasMeeting } from '../../jaas/functions';
|
||||
|
||||
type Props = AbstractButtonProps & {
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@ import {
|
|||
} from '../../../base/participants';
|
||||
import { connect } from '../../../base/redux';
|
||||
import { getLocalVideoTrack } from '../../../base/tracks';
|
||||
import { isVpaasMeeting } from '../../../billing-counter/functions';
|
||||
import { toggleChat } from '../../../chat';
|
||||
import { ChatButton } from '../../../chat/components';
|
||||
import { EmbedMeetingButton } from '../../../embed-meeting';
|
||||
import { SharedDocumentButton } from '../../../etherpad';
|
||||
import { FeedbackButton } from '../../../feedback';
|
||||
import { isVpaasMeeting } from '../../../jaas/functions';
|
||||
import { KeyboardShortcutsButton } from '../../../keyboard-shortcuts';
|
||||
import { LocalRecordingButton } from '../../../local-recording';
|
||||
import {
|
||||
|
|
Loading…
Reference in New Issue