From dcc4354da669f06e5333dee23edba34a9f4d5e08 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Fri, 23 Apr 2021 17:26:58 -0400 Subject: [PATCH] (core) log user attribution in absence of client Summary: attribute ActiveDoc log messages to users regardless of whether they were triggered via a client or directly via api Test Plan: log messages checked manually Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2786 --- app/server/lib/ActiveDoc.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/server/lib/ActiveDoc.ts b/app/server/lib/ActiveDoc.ts index d438e06c..9b7c7c08 100644 --- a/app/server/lib/ActiveDoc.ts +++ b/app/server/lib/ActiveDoc.ts @@ -180,11 +180,13 @@ export class ActiveDoc extends EventEmitter { public getLogMeta(docSession: OptDocSession, docMethod?: string): log.ILogMeta { const client = docSession.client; const access = getDocSessionAccess(docSession); + const user = getDocSessionUser(docSession); return { docId: this._docName, access, ...(docMethod ? {docMethod} : {}), - ...(client ? client.getLogMeta() : {}), + ...(user ? {userId: user.id, email: user.email} : {}), + ...(client ? client.getLogMeta() : {}), // Client if present will repeat and add to user info. }; }