diff --git a/react/features/analytics/AnalyticsEvents.js b/react/features/analytics/AnalyticsEvents.js index e84cd2b7a..4733e6e23 100644 --- a/react/features/analytics/AnalyticsEvents.js +++ b/react/features/analytics/AnalyticsEvents.js @@ -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. * diff --git a/react/features/billing-counter/middleware.js b/react/features/billing-counter/middleware.js index 7898c1dbb..7427efd67 100644 --- a/react/features/billing-counter/middleware.js +++ b/react/features/billing-counter/middleware.js @@ -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))); + } +}