From a9b8f499956991670369731843697fa933700ae8 Mon Sep 17 00:00:00 2001 From: yanas Date: Tue, 28 Nov 2017 20:57:13 -0600 Subject: [PATCH] Add user id to analytics if provided in jwt --- react/features/analytics/functions.js | 9 +++++---- react/features/base/jwt/middleware.js | 6 +++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/react/features/analytics/functions.js b/react/features/analytics/functions.js index 75f68a866..55a38b41a 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 7b0738e12..8edc089e1 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(); }