Skip to content

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

Add user id to analytics if provided in jwt

yanasa9b8f4999569
diff --git a/react/features/analytics/functions.js b/react/features/analytics/functions.js
index 75f68a8665..55a38b41ac 100644
--- a/react/features/analytics/functions.js
+++ b/react/features/analytics/functions.js
@@ -35,20 +35,21 @@ export function initAnalytics({ getState }: { getState: Function }) {
return;
}
- const config = getState()['features/base/config'];
+ const state = getState();
+ const config = state['features/base/config'];
const { analyticsScriptUrls } = config;
const machineId = JitsiMeetJS.getMachineId();
+ const { user } = state['features/base/jwt'];
const handlerConstructorOptions = {
product: 'lib-jitsi-meet',
version: JitsiMeetJS.version,
session: machineId,
- user: `uid-${machineId}`,
- server: getState()['features/base/connection'].locationURL.host
+ user: user ? user.id : `uid-${machineId}`,
+ server: state['features/base/connection'].locationURL.host
};
_loadHandlers(analyticsScriptUrls, handlerConstructorOptions)
.then(handlers => {
- const state = getState();
const permanentProperties: Object = {
roomName: state['features/base/conference'].room,
userAgent: navigator.userAgent
diff --git a/react/features/base/jwt/middleware.js b/react/features/base/jwt/middleware.js
index 7b0738e121..8edc089e15 100644
--- a/react/features/base/jwt/middleware.js
+++ b/react/features/base/jwt/middleware.js
@@ -288,10 +288,11 @@ function _undoOverwriteLocalParticipant(
* @returns {{
* avatarURL: ?string,
* email: ?string,
+ * id: ?string,
* name: ?string
* }}
*/
-function _user2participant({ avatar, avatarUrl, email, name }) {
+function _user2participant({ avatar, avatarUrl, email, id, name }) {
const participant = {};
if (typeof avatarUrl === 'string') {
@@ -302,6 +303,9 @@ function _user2participant({ avatar, avatarUrl, email, name }) {
if (typeof email === 'string') {
participant.email = email.trim();
}
+ if (typeof id === 'string') {
+ participant.id = id.trim();
+ }
if (typeof name === 'string') {
participant.name = name.trim();
}