Skip to content

Commit

Permalink
feat(meetingID): send analytics event.
Browse files Browse the repository at this point in the history
  • Loading branch information
hristoterezov committed Nov 29, 2019
1 parent 24a0598 commit 4a87f34
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
6 changes: 3 additions & 3 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down
43 changes: 27 additions & 16 deletions modules/xmpp/ChatRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -127,7 +129,6 @@ export default class ChatRoom extends Listenable {

this.locked = false;
this.transcriptionStatus = JitsiTranscriptionStatus.OFF;
this.meetingId = null;
}

/* eslint-enable max-params */
Expand Down Expand Up @@ -283,23 +284,35 @@ 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);
logger.error('Error getting room info: ', error);
});
}

/**
* 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));
}
}

/**
*
*/
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions service/statistics/AnalyticsEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4a87f34

Please sign in to comment.