Add user id to analytics if provided in jwt

This commit is contained in:
yanas 2017-11-28 20:57:13 -06:00 committed by Дамян Минков
parent 2306e26287
commit a9b8f49995
2 changed files with 10 additions and 5 deletions

View File

@ -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

View File

@ -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();
}