diff --git a/JitsiConference.js b/JitsiConference.js index 6ddd525e8e..a329fa443a 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -2123,14 +2123,14 @@ JitsiConference.prototype.getPhonePin = function() { }; /** - * Returns the meeting unique Id if any. + * Returns the meeting unique ID if any. + * + * @returns {string|undefined} */ JitsiConference.prototype.getMeetingUniqueId = function() { if (this.room) { return this.room.getMeetingId(); } - - return null; }; /** diff --git a/modules/xmpp/ChatRoom.js b/modules/xmpp/ChatRoom.js index 020440b593..5228d13875 100644 --- a/modules/xmpp/ChatRoom.js +++ b/modules/xmpp/ChatRoom.js @@ -7,7 +7,9 @@ import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler'; import * as JitsiTranscriptionStatus from '../../JitsiTranscriptionStatus'; import Listenable from '../util/Listenable'; import * as MediaType from '../../service/RTC/MediaType'; +import { createConferenceEvent } from '../../service/statistics/AnalyticsEvents'; import XMPPEvents from '../../service/xmpp/XMPPEvents'; +import Statistics from '../statistics/statistics'; import Moderator from './moderator'; @@ -127,7 +129,6 @@ export default class ChatRoom extends Listenable { this.locked = false; this.transcriptionStatus = JitsiTranscriptionStatus.OFF; - this.meetingId = null; } /* eslint-enable max-params */ @@ -283,16 +284,9 @@ export default class ChatRoom extends Listenable { = $(result).find('>query>x[type="result"]>field[var="muc#roominfo_meetingId"]>value'); if (meetingIdValEl.length) { - const meetingId = meetingIdValEl.text(); - - if (this.meetingId !== meetingId) { - if (this.meetingId) { - logger.warn(`Meeting Id changed from:${this.meetingId} to:${meetingId}`); - } - this.meetingId = meetingId; - } + this.setMeetingId(meetingIdValEl.text()); } else { - logger.trace('No meeting id from backend'); + logger.trace('No meeting ID from backend'); } }, error => { GlobalOnErrorHandler.callErrorHandler(error); @@ -300,6 +294,25 @@ export default class ChatRoom extends Listenable { }); } + /** + * Sets the meeting unique Id (received from the backend). + * + * @param {string} meetingId - The new meetings id. + * @returns {void} + */ + setMeetingId(meetingId) { + if (this.meetingId !== meetingId) { + if (this.meetingId) { + logger.warn(`Meeting Id changed from:${this.meetingId} to:${meetingId}`); + } + this.meetingId = meetingId; + + // The name of the action is a little bit confusing but it seems this is the preferred name by the consumers + // of the analytics events. + Statistics.sendAnalytics(createConferenceEvent('joined', meetingId)); + } + } + /** * */ @@ -952,11 +965,7 @@ export default class ChatRoom extends Listenable { } if (from === this.roomjid - && $(msg) - .find( - '>x[xmlns="http://jabber.org/protocol/muc#user"]' - + '>status[code="104"]') - .length) { + && $(msg).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="104"]').length) { this.discoRoomInfo(); } const jsonMessage = $(msg).find('>json-message').text(); @@ -1385,7 +1394,9 @@ export default class ChatRoom extends Listenable { } /** - * Returns the meeting unique Id if any came from backend. + * Returns the meeting unique ID if any came from backend. + * + * @returns {string} - The meeting ID. */ getMeetingId() { return this.meetingId; diff --git a/service/statistics/AnalyticsEvents.js b/service/statistics/AnalyticsEvents.js index cd56870d66..01d119dc5c 100644 --- a/service/statistics/AnalyticsEvents.js +++ b/service/statistics/AnalyticsEvents.js @@ -264,6 +264,22 @@ export const createConnectionFailedEvent }; }; +/** + * Creates a conference event. + * + * @param {string} action - The action of the event. + * @param {Object} attributes - The attributes to be added to the event. + * @returns {{type: string, source: string, action: string, attributes: object}} + */ +export function createConferenceEvent(action, attributes) { + return { + action, + attributes, + source: 'conference', + type: TYPE_OPERATIONAL + }; +} + /** * Creates an operational event which indicates that a particular connection * stage was reached (i.e. the XMPP connection transitioned to the "connected"