2022-11-11 08:20:33 +00:00
|
|
|
import { createVpaasConferenceJoinedEvent } from '../analytics/AnalyticsEvents';
|
|
|
|
import { sendAnalytics } from '../analytics/functions';
|
|
|
|
import { IReduxState } from '../app/types';
|
2020-10-29 12:30:57 +00:00
|
|
|
import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
|
2022-11-11 08:20:33 +00:00
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
2020-08-25 11:57:35 +00:00
|
|
|
|
2022-09-27 07:10:28 +00:00
|
|
|
import { getVpaasTenant, isVpaasMeeting } from './functions';
|
2020-08-25 11:57:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux middleware for billing counter.
|
|
|
|
*
|
|
|
|
* @param {Store} store - The redux store.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2020-09-17 09:21:01 +00:00
|
|
|
|
2020-08-25 11:57:35 +00:00
|
|
|
MiddlewareRegistry.register(store => next => async action => {
|
|
|
|
switch (action.type) {
|
2020-10-29 12:30:57 +00:00
|
|
|
case CONFERENCE_JOINED: {
|
|
|
|
_maybeTrackVpaasConferenceJoin(store.getState());
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2020-08-25 11:57:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|
2020-10-29 12:30:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tracks the conference join event if the meeting is a vpaas one.
|
|
|
|
*
|
|
|
|
* @param {Store} state - The app state.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2022-11-11 08:20:33 +00:00
|
|
|
function _maybeTrackVpaasConferenceJoin(state: IReduxState) {
|
2020-10-29 12:30:57 +00:00
|
|
|
if (isVpaasMeeting(state)) {
|
|
|
|
sendAnalytics(createVpaasConferenceJoinedEvent(
|
2021-07-20 08:58:42 +00:00
|
|
|
getVpaasTenant(state)));
|
2020-10-29 12:30:57 +00:00
|
|
|
}
|
|
|
|
}
|