From c1bd30aac824370e9c7699904f47e9294265c2f7 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 24 Sep 2021 19:14:00 -0700 Subject: [PATCH] Add user to collaboration logs --- server/collaboration/logger.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/server/collaboration/logger.js b/server/collaboration/logger.js index 214c9313..8f01002b 100644 --- a/server/collaboration/logger.js +++ b/server/collaboration/logger.js @@ -1,19 +1,26 @@ // @flow import Logger from "../logging/logger"; +import { User } from "../models"; + export default class CollaborationLogger { - async onCreateDocument(data: { documentName: string }) { - Logger.info("hocuspocus", `Created document "${data.documentName}"`); + async onCreateDocument(data: { + documentName: string, + context: { user: User }, + }) { + Logger.info("hocuspocus", `Created document "${data.documentName}"`, { + userId: data.context.user.id, + }); } - async onConnect(data: { documentName: string }) { - Logger.info("hocuspocus", `New connection to "${data.documentName}"`); + async onConnect(data: { documentName: string, context: { user: User } }) { + Logger.info("hocuspocus", `New connection to "${data.documentName}"`, { + userId: data.context.user.id, + }); } - async onDisconnect(data: { documentName: string }) { - Logger.info("hocuspocus", `Connection to "${data.documentName}" closed`); - } - - async onUpgrade() { - Logger.info("hocuspocus", "Upgrading connection"); + async onDisconnect(data: { documentName: string, context: { user: User } }) { + Logger.info("hocuspocus", `Connection to "${data.documentName}" closed `, { + userId: data.context.user.id, + }); } }