feat(vpaas): Track vpaas conference join

This commit is contained in:
Vlad Piersec 2020-10-29 14:30:57 +02:00 committed by vp8x8
parent f45af351d8
commit 9fbb35b6e1
2 changed files with 38 additions and 1 deletions

View File

@ -772,6 +772,22 @@ export function createTrackMutedEvent(mediaType, reason, muted = true) {
};
}
/**
* Creates an event for joining a vpaas conference.
*
* @param {string} tenant - The conference tenant.
* @returns {Object} The event in a format suitable for sending via
* sendAnalytics.
*/
export function createVpaasConferenceJoinedEvent(tenant) {
return {
action: 'vpaas.conference.joined',
attributes: {
tenant
}
};
}
/**
* Creates an event for an action on the welcome page.
*

View File

@ -1,9 +1,11 @@
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 { SET_BILLING_ID } from './actionTypes';
import { countEndpoint } from './actions';
import { setBillingId } from './functions';
import { isVpaasMeeting, extractVpaasTenantFromPath, setBillingId } from './functions';
/**
* The redux middleware for billing counter.
@ -14,6 +16,11 @@ import { setBillingId } from './functions';
MiddlewareRegistry.register(store => next => async action => {
switch (action.type) {
case CONFERENCE_JOINED: {
_maybeTrackVpaasConferenceJoin(store.getState());
break;
}
case SET_BILLING_ID: {
setBillingId(action.value);
@ -34,3 +41,17 @@ MiddlewareRegistry.register(store => next => async action => {
return next(action);
});
/**
* Tracks the conference join event if the meeting is a vpaas one.
*
* @param {Store} state - The app state.
* @returns {Function}
*/
function _maybeTrackVpaasConferenceJoin(state) {
if (isVpaasMeeting(state)) {
sendAnalytics(createVpaasConferenceJoinedEvent(
extractVpaasTenantFromPath(
state['features/base/connection'].locationURL.pathname)));
}
}