浏览代码

Add user id to analytics if provided in jwt

master
yanas 8 年前
父节点
当前提交
a9b8f49995
共有 2 个文件被更改,包括 10 次插入5 次删除
  1. 5
    4
      react/features/analytics/functions.js
  2. 5
    1
      react/features/base/jwt/middleware.js

+ 5
- 4
react/features/analytics/functions.js 查看文件

@@ -35,20 +35,21 @@ export function initAnalytics({ getState }: { getState: Function }) {
35 35
         return;
36 36
     }
37 37
 
38
-    const config = getState()['features/base/config'];
38
+    const state = getState();
39
+    const config = state['features/base/config'];
39 40
     const { analyticsScriptUrls } = config;
40 41
     const machineId = JitsiMeetJS.getMachineId();
42
+    const { user } = state['features/base/jwt'];
41 43
     const handlerConstructorOptions = {
42 44
         product: 'lib-jitsi-meet',
43 45
         version: JitsiMeetJS.version,
44 46
         session: machineId,
45
-        user: `uid-${machineId}`,
46
-        server: getState()['features/base/connection'].locationURL.host
47
+        user: user ? user.id : `uid-${machineId}`,
48
+        server: state['features/base/connection'].locationURL.host
47 49
     };
48 50
 
49 51
     _loadHandlers(analyticsScriptUrls, handlerConstructorOptions)
50 52
         .then(handlers => {
51
-            const state = getState();
52 53
             const permanentProperties: Object = {
53 54
                 roomName: state['features/base/conference'].room,
54 55
                 userAgent: navigator.userAgent

+ 5
- 1
react/features/base/jwt/middleware.js 查看文件

@@ -288,10 +288,11 @@ function _undoOverwriteLocalParticipant(
288 288
  * @returns {{
289 289
  *     avatarURL: ?string,
290 290
  *     email: ?string,
291
+ *     id: ?string,
291 292
  *     name: ?string
292 293
  * }}
293 294
  */
294
-function _user2participant({ avatar, avatarUrl, email, name }) {
295
+function _user2participant({ avatar, avatarUrl, email, id, name }) {
295 296
     const participant = {};
296 297
 
297 298
     if (typeof avatarUrl === 'string') {
@@ -302,6 +303,9 @@ function _user2participant({ avatar, avatarUrl, email, name }) {
302 303
     if (typeof email === 'string') {
303 304
         participant.email = email.trim();
304 305
     }
306
+    if (typeof id === 'string') {
307
+        participant.id = id.trim();
308
+    }
305 309
     if (typeof name === 'string') {
306 310
         participant.name = name.trim();
307 311
     }

正在加载...
取消
保存