Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

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

Andrei Gavrilescu3a1fc363edfc
diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.ts
index 25c17968e7..dc8ef8cd8c 100644
--- a/react/features/base/config/configType.ts
+++ b/react/features/base/config/configType.ts
@@ -460,6 +460,7 @@ export interface IConfig {
inviteServiceCallFlowsUrl?: string;
inviteServiceUrl?: string;
jaasActuatorUrl?: string;
+ jaasConferenceCreatorUrl?: string;
jaasFeedbackMetadataURL?: string;
jaasTokenUrl?: string;
legalUrls?: {
diff --git a/react/features/jaas/functions.ts b/react/features/jaas/functions.ts
index 43e23ccfe8..89ac44a599 100644
--- a/react/features/jaas/functions.ts
+++ b/react/features/jaas/functions.ts
@@ -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';
@@ -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);
+ 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.
*
diff --git a/react/features/rtcstats/RTCStats.ts b/react/features/rtcstats/RTCStats.ts
index bff467d627..77002f9ea1 100644
--- a/react/features/rtcstats/RTCStats.ts
+++ b/react/features/rtcstats/RTCStats.ts
@@ -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.
diff --git a/react/features/rtcstats/middleware.ts b/react/features/rtcstats/middleware.ts
index 0953c046cc..46f838c290 100644
--- a/react/features/rtcstats/middleware.ts
+++ b/react/features/rtcstats/middleware.ts
@@ -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
@@ -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;
}