Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rtcstats): fetch conference creator id and send to rtcstats #14060

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions react/features/base/config/configType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ export interface IConfig {
inviteServiceCallFlowsUrl?: string;
inviteServiceUrl?: string;
jaasActuatorUrl?: string;
jaasConferenceCreatorUrl?: string;
jaasFeedbackMetadataURL?: string;
jaasTokenUrl?: string;
legalUrls?: {
Expand Down
26 changes: 26 additions & 0 deletions react/features/jaas/functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IReduxState } from '../app/types';
import { IJitsiConference } from '../base/conference/reducer';

import { VPAAS_TENANT_PREFIX } from './constants';
import logger from './logger';
Expand Down Expand Up @@ -47,6 +48,31 @@ export function isVpaasMeeting(state: IReduxState) {
return false;
}

/**
* Sends a request for retrieving the conference creator's customer id.
*
* @param {IJitsiConference} conference - The conference state.
* @param {IReduxState} state - The state of the app.
* @returns {Object} - Object containing customerId field.
*/
export async function sendGetCustomerIdRequest(conference: IJitsiConference, state: IReduxState) {
const { jaasConferenceCreatorUrl } = state['features/base/config'];

const roomJid = conference?.room?.roomjid;

if (jaasConferenceCreatorUrl && roomJid) {
const fullUrl = `${jaasConferenceCreatorUrl}?conference=${encodeURIComponent(roomJid)}`;
const response = await fetch(fullUrl);
quitrk marked this conversation as resolved.
Show resolved Hide resolved
const responseBody = await response.json();

if (response.ok) {
return responseBody;
}

logger.error(`Failed to fetch ${fullUrl}. with: ${JSON.stringify(responseBody)}`);
}
}

/**
* Sends a request for retrieving jaas customer details.
*
Expand Down
10 changes: 10 additions & 0 deletions react/features/rtcstats/RTCStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ class RTCStats {
JitsiMeetJS.rtcstats.sendStatsEntry('e2eRtt', e2eRttData);
}

/**
* Send identity data, the data will be processed by rtcstats-server and saved in the dump file.
*
* @param {Object} identityData - The object that holds the identity data.
* @returns {void}
*/
sendIdentityData(identityData: Object) {
JitsiMeetJS.rtcstats.sendIdentityEntry(identityData);
}

/**
* Send the timestamp of the start of the conference, the data will be processed by the rtcstats-server
* and saved in the dump file.
Expand Down
12 changes: 12 additions & 0 deletions react/features/rtcstats/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { TRACK_ADDED, TRACK_UPDATED } from '../base/tracks/actionTypes';
import { ADD_FACE_LANDMARKS } from '../face-landmarks/actionTypes';
import { FaceLandmarks } from '../face-landmarks/types';
import { sendGetCustomerIdRequest } from '../jaas/functions';

import RTCStats from './RTCStats';
import {
canSendFaceLandmarksRTCStatsData,
isRTCStatsEnabled
} from './functions';
import logger from './logger';

/**
* Middleware which intercepts lib-jitsi-meet initialization and conference join in order init the
Expand All @@ -33,6 +35,16 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
case CONFERENCE_JOINED: {
if (isRTCStatsEnabled(state)) {
RTCStats.init();

sendGetCustomerIdRequest(action?.conference, state)
.then(customerData => {
const { customerId } = customerData ?? {};

customerId && RTCStats.sendIdentityData({ customerId });
})
.catch(error => {
logger.error('Error while getting customer id:', error);
});
}
break;
}
Expand Down