1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00

Merge pull request #11086 from Budibase/collab-tweaks

Update tracking of collaboration events to only count unique users
This commit is contained in:
Andrew Kingston 2023-06-30 19:17:14 +01:00 committed by GitHub
commit cb7fd8ab29

View file

@ -18,13 +18,19 @@ export default class BuilderSocket extends BaseSocket {
// Initial identification of selected app
socket?.on(BuilderSocketEvent.SelectApp, async ({ appId }, callback) => {
await this.joinRoom(socket, appId)
// Reply with all users in current room
const sessions = await this.getRoomSessions(appId)
callback({ users: sessions })
// Track usage
await events.user.dataCollaboration(sessions.length)
// Track collaboration usage by unique users
let userIdMap: any = {}
sessions?.forEach(session => {
if (session._id) {
userIdMap[session._id] = true
}
})
await events.user.dataCollaboration(Object.keys(userIdMap).length)
// Reply with all current sessions
callback({ users: sessions })
})
}