(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
This commit is contained in:
Paul Fitzpatrick 2021-04-23 17:26:58 -04:00
parent 47ea00dea3
commit dcc4354da6

View File

@ -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.
};
}